Analisi di un semplice programma Assembly

;—————————————————————–

; Analysis and tracing of a simple assembly program

;—————————————————————–

;

;

        ORG 0000h

        JP   0500h    ;jump to 0500h address

        ORG 0500h    ;the program starts to 0500h address of ROM

;

BEGIN :   LD   HL,0CD00h     ;load the address 0CD00h in the HL register

        LD   B,12h         ;12h = 18d

        LD   A,00h         ;load the value 00H in the accumulator A

;

LOOPUP : LD   (HL),A        ;here starts a loop (LOOPup) that load for 18d times the value in A (00h)   

        INC HL            ;till the value in the register B is 0, that is the addresses from

        DEC B             ;0CD000h to 0CD11h will have the 0 value.

        JP   NZ,LOOPUP

        LD   B,012h        ;now the value 012h will reloaded in the register B

        LD   A,0FFh        ; load the value 0FFh in A

;

LOOPDOWN :    DEC         HL             ;here starts another loop (LOOPdown) that load for 18d times the value in A (0FFh)

        LD   (HL),A         ;till the value in the register B is 0, that is the addresses from

        DEC B              ;0CD11h to 0CD000h will have the 0FFh value.

        JP   NZ,LOOPDOWN

;

     JP    BEGIN           ;with this instruction the program will never have an end.

Lascia un commento