; SPEAKER TEST PROGRAM ; ==================== ; Rapidly toggles the speaker pin with a decreasing frequency, to create ; a test sound that should drop in pitch over a few seconds. LD A, 0b00000010 ; A stores what we write out to port 0x00 LD DE, 0xFFFF ; DE is what we reset the counter (HL) to LD BC, 0x0008 ; BC is what we add to HL in the delay loop start: XOR A, 0b01000000 ; flip the speaker bit OUT (0x00), A ; update port 0x00 LD HL, DE ; reset the counter (HL) delay: ADD HL, BC ; increment the counter (HL) by the value in BC JP NC, delay ; if the counter hasn't overflowed, loop again DEC DE ; decrement DE to increase the period of the counter JP start ; start another click/delay cycle ; HAND-ASSEMBLED MACHINE CODE ; =========================== ; The following machine code is the above program, hand-assembled using ; the Z80 documentation and lot of patience. ; ADDR CODE OCTAL ; ================================== ; 0000 LD A, 0x02 076 002 ; 0002 LD DE, 0xFFFF 021 377 377 ; 0005 LD BC, 0x0008 001 010 000 ; 0008 XOR A, 0x40 356 100 ; 000A OUT (0x00), A 323 000 ; 000C LD H, D 142 ; 000D LD L, E 153 ; 000E ADD HL, BC 011 ; 000F JP NC, 0x000E 322 016 000 ; 0012 DEC DE 033 ; 0013 JP 0x0008 303 010 000