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:


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?

             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

             mov al, 2
             mov bl, 1
             imul bl   ;stores 2 in AX?

Recommended Answers

All 2 Replies

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
    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
mov ecx, 18 ;specify the number of timer the loop will loop.
;Now you put your code                 

LOOP multiply_nums ;start the loop
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.