1) Convert the following pseudo-code to assembly language using em8086:
a = 0 b=2
for (i=0, i<=9 , i+2)
{
a=a+b
cout<<"number="<
a++
}
The program must be compatible with emu8086.
DATA SEGMENT
DATA ENDS
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
MOV ES,AX
mov al, 0 ; a = 0
mov bl, 2 ; b = 2
mov cl, 0 ; i = 0;
forI:
add al, bl ; a=a+b
push ax
cmp al,9
jle l1
push ax
xor ah,ah
mov bh, 10
div bh
add al, '0'
mov ah, 0eh
int 10h
pop ax
sub al,10
l1: add al, '0'
mov ah, 0eh
int 10h
mov al, ' '
mov ah, 0eh
int 10h
pop ax
inc al ;a++
add cl,2 ; i+2
cmp cl, 9
jle forI
MOV AH,1 ; Waiting for a key press
INT 16H
mov ah, 4ch
int 21h ; exit
end start
Comments
Leave a comment