SECTION "a",HOME
main:
- ld c, $51 ; Note that we are alive.
ld a, $FF
- ld [c],a
+ ld [$FF51],a
ld sp, $DFF0
- ld c, $07
ld a, $04 ;start timer, 4.096KHz
- ld [c], a
+ ld [$FF07], a
ld hl, $DF81
xor a
- ld [hl], a
+ ld [hli], a
+ ld [hli], a
ld hl, signon
call puts
PUSH HL
xor a
- ld c, $0F ; ack the irq
- ld [c], a
+ ld [$FF0F], a
+ ld hl, $DF82
+ ld a, [hld]
+ cp 0
+ jr z, .noprint
ld a, $41 ; print A
call putc
-
- ld hl, $DF81
+.noprint:
+ inc [hl]
ld a, [hl]
- ld b, 1
- add b
- ld c, $51
- ld [c], a
- ld [hl], a
-
+ ld [$FF51], a
POP HL
POP DE
POP BC
POP AF
RETI
- db $18,$FE,$18,$FE,$18,$FE,$18,$FE,$18,$FE,$18,$FE,$18,$FE,$18,$FE
- db $18,$FE,$18,$FE,$18,$FE,$18,$FE,$18,$FE,$18,$FE,$18,$FE,$18,$FE
- db $18,$FE,$18,$FE,$18,$FE,$18,$FE,$18,$FE,$18,$FE,$18,$FE,$18,$FE
; Memory tester: writes h ^ l to all addresses from C000 to DF80.
memtest:
ld a,h
xor l
ld [hli],a
- ld a, $DF
- cp h
+ ld a, h
+ cp $DF
jr nz, .wr
- ld a, $80
- cp l
+ ld a, l
+ cp $80
jr nz, .wr
ld hl, $C001 ; Read loop
cp b
jr nz, .memfail
- ld a, $DF
- cp h
+ ld a, h
+ cp $DF
jr nz, .rd
- ld a, $80
- cp l
+ ld a, l
+ cp $80
jr nz, .rd
ld hl, testokstr ; Say we're OK
rra
rra
rra
- ld b,$0F
- and b
- ld b,$30
- add b
+ and $0F
+ add $30
call putc
pop af
- ld b,$0F
- and b
- ld b,$30
- add b
+ and $0F
+ add $30
call putc
ret
waitsw:
ld hl,waitswstr
call puts
+
+ ld hl,$DF82
+ ld a, 1
+ ld [hl], a
ld c, $51
xor a
ld [c],a
- ld b, $0
.loop1:
ld a,[c]
- cp b
+ cp $0
jr z,.loop1
.loop2:
ld a,[c]
- cp b
+ cp $0
jr nz,.loop2
ret
; Test JR
ld a, $FF
- ld b, $00
- cp b
+ cp $0
jr nz,.jr
ld hl, .jrfail
jr .fail
; Test CP.
ld hl, .cpfail
ld a, $10
- ld b, $20
- cp b
+ cp $20
jr nc,.fail
ld a, $20
- ld b, $10
- cp b
+ cp $10
jr c,.fail
; Test CPL
ld hl, .cplfail
ld a, $55
- ld b, $AA
cpl
- cp b
+ cp $AA
jr nz,.fail
+
+ ; Test DI/EI delay
+ di
+ ld hl, .difail
+ ld c, $0F ; First, wait until an interrupt happens...
+.wait: ld a, [c]
+ cp 0
+ jr z, .wait
+ ei ; Now make sure that an IRQ didn't happen on EI/DI
+ di
+ ld a, [c]
+ cp 0
+ jr z, .fail
+ ei ; Make sure that an IRQ does happen on EI/NOP/DI
+ nop
+ di
+ ld a, [c]
+ cp 0
+ jr nz, .fail
+ ei
ld hl, .ok
call puts
ret
.fail:
+ ei
call puts
ld hl, .testfailed
call puts
db "CPL",0
.inc16fail:
db "INC16",0
+.difail:
+ db "DI/EI delay",0
.testfailed:
db " test failed.",$0D,$0A,0
.ok:
; Serial port manipulation functions.
putc:
- ld b, 0
ld c, $50
push af
.waitport:
ld a,[c]
- cp b
+ cp $00
jr nz,.waitport
pop af
ld [c],a
puts:
ld a, [hli]
- ld b, $00
- cp b
+ cp $00
ret z
call putc
jr puts