Answer to Question #285105 in Assembler for Ahmed Ali

Question #285105

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.


1
Expert's answer
2022-01-06T08:51:59-0500
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


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS