Addition of Two Numbers - Assembly Language - MASM


SUM OF TWO NUMBERS

Program:
.model small
.stack 200H
.data
   msg1 DB 10,13,'Enter the first no: $'
   msg2 DB 10,13,'Enter the second no: $'
   msg3 DB 10,13,'sum = $'
   newline DB 10,13, ' $'
.code
   print MACRO msg ;macro definition
   PUSH AX
   PUSH DX
   MOV AH,09H
   MOV DX,offset msg
   INT 21H
   POP DX
   POP AX
   ENDM
.startup
   print msg1
   CALL readnumtoAX
   MOV CX,AX
   print newline
   print msg2
   CALL readnumtoAX
   print newline
   print msg3
   ADD ax,cX
   CALL displayAX
.exit
readnumtoAX PROC NEAR
   PUSH BX
   PUSH CX
   MOV CX,10
   MOV BX,00
back:
   MOV AH,01H
   INT 21H
   CMP AL,'0'
   JB skip
   CMP AL,'9'
   JA skip
   SUB AL,'0'
   PUSH AX
   MOV AX,BX
   MUL CX
   MOV BX,AX
   POP AX
   MOV AH,00
   ADD BX,AX
   JMP back
skip:
   MOV AX,BX
   POP CX
   POP BX
   RET
readnumtoAX ENDP
displayAX PROC NEAR
   PUSH DX
   PUSH CX
   PUSH BX
   PUSH AX
   MOV CX,0
   MOV BX,10
back1:
   MOV DX,0
   DIV BX
   PUSH DX
   INC CX
   OR AX,AX
   JNZ back1
back2:
   POP DX
   ADD DL,30H
   MOV AH,02H
   INT 21H
   LOOP back2
   POP AX
   POP BX
   POP CX
   POP DX
   RET
  displayAX ENDP
end

Output:
F:\>adn1
Enter the first no: 27
Enter the second no: 32
sum = 59

6 comments:

  1. This post is an excellent, TI keep returning to read the content that is always updated.hanks!I am interested in reading more of your stuff translation service

    ReplyDelete
  2. Yo Yo honey Singh cmon girls put ur put ur hands up
    In the air in the air gela udat to(Flying high high and high)

    ReplyDelete
  3. subha hone na de shaam hone na de
    baki sab kuch hone deeeeee
    oye oye oye baby baby sing with me right now

    ReplyDelete
  4. hahahahahahahahaha SPAM

    ReplyDelete
  5. Please give some more security bro!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    humma humma hummahummahummahummahummahummahummahummahummahummahummahumm

    ReplyDelete
  6. Tnx...bro Very helpfull for me.....

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...