Machine Code of different instructions and labels in emu8086

1.4k views Asked by At

I would like convey my gratitude in advance. I'd like to ask about the machine code regarding a program in emu8086 as below:

ORG 100H

MOV AX,01H      
MOV CX,03H  

loop1:  NOP

        LOOP loop1  
        DEC AX
        JZ loop2    
        ADD AX,AX   

loop2:  DEC AX      
        HLT

By referring to the program above, I can see that the equivalent machine code for JZ loop2 is 74 02 as seen in the emu8086, in which JZ is 74, loop2 is 02.

I looked up on my appendix reference which shows me the number of bytes of each different mnemonics, it seemed that ADD corresponds to 2 bytes. I've tried a few different mnemonics to replace the code "ADD AX,AX" and the machine code for loop2 changes as well. For example, if I change "ADD AX,AX" to "DEC [500H]", the machine code for loop2 changes to 04, and my reference shows DEC [memory] corresponds to 4 bytes.

What could be the explanation on how does loop2 be equivalent to 02? And what does the 02 indicates? I'm confused.

Please help me on this. I'd love any helpful explanation or information. Any effort and replies are greatly appreciated.

0

There are 0 answers