English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

my question is how to write and execute an asembly lang prg to add two 16 bit numbers and store the res in sum
in 8086 programming.......

2007-01-24 18:25:52 · 1 answers · asked by kewl l 1 in Computers & Internet Programming & Design

1 answers

DOSSEG
.MODEL SMALL
.STACK
.DATA

.CODE

MAIN PROC
mov ax,dgroup
mov ds,ax

mov bx,1234h
mov cx,5678h
add bx,ax

call Binout

mov ax,4c00h ;exit (no error)
int 21h
MAIN ENDP

;-----------------------------------------------------------------------------
BINOUT PROC
; In : BX
; Out: none
; Uses: None
; Converts a number in BX to binary format and outputs it to the screen
;-----------------------------------------------------------------------------
push ax
push bx
push cx
push dx
mov ah,02
mov cx,16

binloop:
shr bx,1
jc put1
mov dl,"0"
int 21h
jmp proceed
put1:
mov dl,"1"
inat 21h
proceed:
dec cx
jnz binloop

mov dl,"b"
int 21h
pop dx
pop cx
pop bx
pop ax
ret
BINOUT ENDP

END MAIN

2007-01-25 19:55:55 · answer #1 · answered by Anonymous · 0 0

fedest.com, questions and answers