Home » Codes » Assembly » 8086 » Number to Binary Sum and Value Transformation in Assembly 8086

Number to Binary Sum and Value Transformation in Assembly 8086

Mar 17, 2013 by     0    Placed under: 8086, Assembly
1
SHARES

a2 Number to Binary Sum and Value Transformation in Assembly 8086 fb share Number to Binary Sum and Value Transformation in Assembly 8086 tweet Number to Binary Sum and Value Transformation in Assembly 8086

8086 Number to Binary Sum and Value Transformation in Assembly 8086

Number to Binary Sum and Value Transformation in Assembly 8086. The Following assembly language code provides Number to Binary Sum and Value Transformation for Intel 8086 Microprocessor.

[asm]org 100h

.data

info1 db "Enter 2 Digits Number For Binary Sum : $"
info2 db 0dh,0ah, "2 Digits Number Binary Sum : $"
info3 db 0dh,0ah, "2 Digits Number Binary value : $"
binary_in db 5 dup(0)
binary_out db 12 dup(0)

.code

lea dx,info1
mov ah,09h
int 21h

lea dx,binary_in
mov ah,0ah
mov binary_in, 3
int 21h

mov cx,3
mov di,2

l1:

mov bl,binary_in[di]
sub bl,30h
mov binary_in[di],bl
inc di
loop l1

mov cx,3
mov bx,0
mov si,2

mask:

mov al,binary_in[si]
and al,00001000b
shr al,3
mov binary_out[bx],al
inc bx

mov al,binary_in[si]
and al,00000100b
shr al,2
mov binary_out[bx],al
inc bx

mov al,binary_in[si]
and al,00000010b
shr al,1
mov binary_out[bx],al
inc bx

mov al,binary_in[si]
and al,00000001b
mov binary_out[bx],al
inc bx
inc si
loop mask

mov si,0
mov cx,12
mov bh,0

binary_sum:

mov bl,binary_out[si]
add bh,bl
inc si
loop binary_sum

lea dx,info2
mov ah,09h
int 21h
mov dl,bh
add dl,30h
mov ah,02h
int 21h

lea dx,info3
mov ah,09h
int 21h
mov cx,12
mov di,0

l2:

mov dl,binary_out[di]
add dl,30h
mov ah,02h
int 21h
inc di
loop l2

ret[/asm]

Loading Disqus Comments ...
Loading Facebook Comments ...

Subscribe to our Newsletter

To subscribe to our newsletter simply add your email below. A confirmation email will be sent to you!