First let's look at the source for that test:
Code: Select all
LD BC,$1200 ;start with BC=$1200
- PUSH BC ; save bc on the stack
POP AF ; pop the stack into af (effectively AF = BC)
PUSH AF ; push AF onto the stack
POP DE ; pop the stack into DE (effectively DE = AF (= BC))
LD A,C ; load C into A
AND $FO ; only keep the high 4 bits of A
CP E ; compare E to A
JP NZ,test_failed ; if they're not equal, the test is failed
INC B ; otherwise, increment B
INC C ; and C
JR NZ,- ; and do it again until C = $00
Code: Select all
LD A,C ; load $01 to A
AND $F0 ; keep only high bits ($01 -> $00)
CP E ; compare A ($00) with E ($01) -> not same, test failed