Assembly Language Code For 32-Bit Addition

Assembly Language Code For 32-Bit Addition














.model small
.386p

.data
msg1 db,0ah,"Enter the first no. : $"
msg2 db,0ah,"Enter the second no. : $"
msg db,0ah,"Addition is : $"
emsg db,0ah,"Wrong input : $"
no1 dd ?
no2 dd ?
res dd ?


.code
byte_in  PROC NEAR
    mov ah,01h
        int 21h
    cmp al,30h
        jc wrong
        cmp al,40h
        jc calc1
        cmp al,41h
        jc wrong
        cmp al,47h
        jc calc2
  calc1:sub al,30h
        jmp exit1
  calc2:sub al,31h
        jmp exit1
  wrong:LEA dx,emsg
        mov ah,09h
        int 21h
exit1:  ret
byte_in endp

byte_out PROC NEAR
         add dl,30h
        cmp dl,3Ah
        jb disp
       add dl,07h
 disp: mov ah,02h
        int 21h   
ret
byte_out endp  


.startup
        mov ax,@data
        mov ds,ax
        LEA dx,msg1
        mov ah,09h
        int 21h
    call byte_in
        mov ch,al
    call byte_in
        mov cl,al
        SHL ecx,10h
    call byte_in
        mov ch,al
    call byte_in
        mov cl,al
        mov ebx,ecx
        LEA dx,msg2
        mov ah,09h
        int 21h

    call byte_in
        mov ch,al
    call byte_in
        mov cl,al
        SHL ecx,10h
    call byte_in
        mov ch,al
    call byte_in
        mov cl,al
        add ebx,ecx

        LEA dx,msg
        mov ah,09h
        int 21h

    mov ecx,ebx
    SHR ecx,10h
    SHR ecx,08h
    mov dl,cl
    Call byte_out
    mov ecx,ebx
    SHR ecx,10h
    mov dl,cl
    Call byte_out
    mov ecx,ebx
    SHR ecx,08h
    mov dl,cl
    Call byte_out
        mov ecx,ebx
    mov dl,cl
    Call byte_out

   exit:mov ah,4ch
        int 21h
.exit
end


0 comments :