-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathversion.z80
65 lines (55 loc) · 1.39 KB
/
version.z80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
;; version.z80 - Show the version of the emulator we're running on.
;;
;; This uses the custom BIOS function we've added to the BIOS, which was never
;; present in real CP/M. Consider it a hook into the emulator.
;;
FCB1: EQU 0x5C
BDOS_ENTRY_POINT: EQU 5
BDOS_OUTPUT_STRING: EQU 9
;;
;; CP/M programs start at 0x100.
;;
ORG 100H
;; Test that we're running under cpmulator by calling the
;; "is cpmulator" function.
ld HL, 0x0000
ld a, 31
out (0xff), a
;; We expect SKX to appear in registers HLA
CP 'X'
jr nz, not_cpmulator
LD A, H
CP 'S'
jr nz, not_cpmulator
LD A, L
CP 'K'
jr nz, not_cpmulator
;; Okay then the version will be stored in the DMA area.
;; unknown value
LD HL, 0x0080
print_loop:
LD A, (HL)
CP 0
JR Z, exit
LD E, A
INC HL
PUSH HL
LD C, 0x02
CALL 0x0005
POP HL
JR print_loop
;; Exit
exit:
LD C,0x00
CALL BDOS_ENTRY_POINT
not_cpmulator:
LD DE, WRONG_EMULATOR
LD C, BDOS_OUTPUT_STRING
call BDOS_ENTRY_POINT
jr exit
;;
;; Text output strings.
;;
WRONG_EMULATOR:
db "This binary is not running under cpmulator, aborting.", 0x0a, 0x0d, "$"
END