; ; Testing RRD instruction ; Also see: ; https://retrocomputing.stackexchange.com/questions/6551/why-does-the-z80-include-the-rld-and-rrd-instructions ; HL_CONTENT .DB 00H LD A, 00H OUT (00H), A OUT (01H), A OUT (02H), A OUT (03H), A ; Initialize A and (HL) LD A, 10000100B LD HL, HL_CONTENT LD (HL), 00100000B ; Display A before operation OUT (00H), A ; Display (HL) before operation PUSH AF LD A, (HL_CONTENT) OUT (01H), A POP AF ; ; Performs a 4-bit rightward rotation of the 12-bit number whose 4 most signigifcant bits ; are the 4 least significant ; bits of A, and its 8 least significant bits are in (HL) ; RRD ; After execution, expect: A = 10000000, (HL) = 01000010 ; Display A after operation OUT (02H), A ; Display (HL) after operation PUSH AF LD A, (HL_CONTENT) OUT (03H), A POP AF HALT ;-------------------------------------------------------------------------------------- ; ; Routine to add a delay ; DELAY: PUSH BC LD C, 0FFH DELAY1: LD B, 0FFH DELAY2: NOP DJNZ DELAY2 DEC C JR NZ, DELAY1 POP BC RET ;-------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------