Вопрос

//comment or description about function of this assembly code

    MOV A,#15    /* comment about this here */
    MOV B,#23    /*comment about this here */

//add a comment here about function of next block of code

    Loop CMP A,B    /*comment here */  
    JAE LpDone    /*comment here */
    ADD A,#101    /*comment here */
    JMP Loop    /*comment here */
    LpDone NOP    /*comment here */

Can anyone explain the steps of this program and what they do? I tried to see it using Visual studio debugging mode through step over function but did not quite get the idea of what they do?

Your help will be much appreciated,

Это было полезно?

Решение

This looks like 8080 or Z80 assembly. It has been a while since I have done anything related to that processor so I might be wrong. Here is my interpretation:

MOV A,#15    /* Move number 15 to register A */
MOV B,#23    /* Move number 23 to register B */

Loop CMP A,B /* Compare A with B. Loop is a label used later */  
JAE LpDone   /* If above or equal, jump to label LpDone */
ADD A,#101   /* Add number 101 to register A */
JMP Loop     /* Jump to label Loop */
LpDone NOP   /* LpDone is label. NOP is no-operation so it does nothing. */

Другие советы

I think that the first two instructions are moving an immediate vallue into a register. And the next intruction compare the values in the register and set or clear some flags of the flagregister. The next instruction is a conditional jump that jumps if the result is above or equal. If it does not jump to the address outside of the loop, then the following addition instruction will be execute. At last the unconditional jump instrucction let us jump back to the compare instruction.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top