Search code examples
assemblyx86-16cpu-registersemu8086

How to print the contents of a register in emu8086?


include 'emu8086.inc'
#make_com#

org 100h

s1 dw 50,60,70,80,90,100,120,130,140,160,170,190,190,220,250,270,300

    MOV SI,0
    MOV CX,16

s2:
    MOV AX,s1[SI]

s3:
    INC SI
    CMP AX,100
    JBE s4
    JA s5

s4:
    PRINTf AX
    JMP s3

s5:
    CMP AX,200
    JB s6
    JA s7

s6:
    PRINTf AX
    JMP s3

s7:
    PRINTf AX
    JMP s3

    END
    ;printf AX doesn't work and i want to print the contents of AX

Solution

  • ;printf AX doesn't work and i want to print the contents of AX

    You haven't shown us what PRINTf is supposed to do. So all of your PRINTf AX macro calls could be OK.

    But your program does have 2 errors that prevent it from executing correctly.

    1. A .COM program starts executing from the top but that's where you have placed your data. This must not be executed! So either place the data below the code or jump over the data.
    2. The data you use is word sized and thus you need to add 2 to the SI register when iterating over the data.