0

Hello, I am just starting and introductory course in Assembly. We are using 8086, and I am having trouble with the assignment.

We are to start with the number 1, and then double that number 18 times, and print out each number in hex. For example, output should look like:


0001
0002
0004
0008
....

I have the convert to hex function already, i just dont understand how to loop 18 times to multiply by the constant (2) in assembly.


Maybe create a function and call it like this?

loop:
         
             call multiply_nums   ;Multiply by 2
             
             call display_hex   ;Convert and display in hex
             
             cmp Ax, 18 ; loop 18 times?

             jnz loop ;start loop again



     multiply_nums:
     
             
             mov al, 2
             mov bl, 1
             imul bl   ;stores 2 in AX?
             ret
3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by AceStryker
0

First off, you can only multiply 14 or 15 times then the result is too big for a word register

mov     ecx, 18
    mov     eax, 1
    
Mult:
    mov     edx, 2
    mul     edx
    push    eax
    push    ecx
    push    edx
    ; Print your hex numbers here
    pop     edx
    pop     ecx
    pop     eax
    dec     ecx
    jnz     Mult

Edited by GunnerInc: n/a

0
mov ecx, 18 ;specify the number of timer the loop will loop.
;Now you put your code                 

LOOP multiply_nums ;start the loop
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.