Files
Z8C-Homebrew-Computer/OperatingSystem/monitor_v2/zout/main.lst
Dennis Gunia d18e8e9e69 pushed updates
2024-06-24 09:21:16 +02:00

5838 lines
249 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
1: ;----------------------------------------------------------------
2: ;Z8C Homebrew Computer Monitor
3: ;by Dennis Gunia (01/2023)
4: ;----------------------------------------------------------------
5:
6: ;================================================================
7: ; Memory areas
8: ;================================================================
9: - 4000 SYS_RAM_START equ 0x4000
10: - 4010 SYS_BUF_START equ 0x4010
11: - 4110 PRG_RAM_START equ 0x4110
12: - FF00 PRG_RAM_TOP equ 0xFF00
13: - FFFF STACK_RAM_TOP equ 0xFFFF
14:
15: ;================================================================
16: ; Terminal configuration
17: ;================================================================
18: - 000F VAR_CONSOLE_CONF equ 0x0F ;CPU/16 Clock @ 230402.5625/s
19: - 0018 VAR_CONSOLE_BAUD equ 24 ;BAUD timer constant
20: ;CLK/TRG Clock @ 1843220.5/s
21: ; -> 0x16 : 14400
22: ;CPU/16 Clock @ 230402.5625/s
23: ; -> 12 : 19200
24: ; -> 24 : 9600
25:
26: ;================================================================
27: ; Includes (1/2)
28: ;================================================================
29: ; include IO device addresses
30: .include "addresses.s"
**** include/addresses.s ****
1: - 0000 CS_BANK equ 0000000b
2: - 0001 CS_DIP equ 0000001b
3: - 0004 CS_CTC_0 equ 0000100b
4: - 0005 CS_CTC_1 equ 0000101b
5: - 0006 CS_CTC_2 equ 0000110b
6: - 0007 CS_CTC_3 equ 0000111b
7: - 0008 CS_SIO_A_D equ 0001000b
8: - 0009 CS_SIO_A_C equ 0001001b
9: - 000A CS_SIO_B_D equ 0001010b
10: - 000B CS_SIO_B_C equ 0001011b
11:
12: - 0020 IO_RTC_SEC0 equ 00100000b
13: - 0021 IO_RTC_SEC1 equ 00100001b
14: - 0022 IO_RTC_MIN0 equ 00100010b
15: - 0023 IO_RTC_MIN1 equ 00100011b
16: - 0024 IO_RTC_HOUR equ 00100100b
17: - 0025 IO_RTC_AMPM equ 00100101b
18: - 0026 IO_RTC_DAY0 equ 00100110b
19: - 0027 IO_RTC_DAY1 equ 00100111b
20: - 0028 IO_RTC_MON0 equ 00101000b
21: - 0029 IO_RTC_MON1 equ 00101001b
22: - 002A IO_RTC_YERR0 equ 00101010b
23: - 002B IO_RTC_YEAR1 equ 00101011b
24: - 002C IO_RTC_WEEK equ 00101100b
25: - 002D IO_RTC_CTR_D equ 00101101b
26: - 002E IO_RTC_CTR_E equ 00101110b
27: - 002F IO_RTC_CTR_F equ 00101111b
28:
29: - 0040 IO_AY0_ADDR equ 01000000b ;64
30: - 0041 IO_AY0_DATA equ 01000001b ;65
31: - 0042 IO_AY1_ADDR equ 01000010b ;66
32: - 0043 IO_AY1_DATA equ 01000011b ;67
33:
34: - 0000 START_ROM equ 0x0000
35: - 0020 IO_REG0 equ 0x20
36:
37: - 0081 VDP_REG equ 0x81
38: - 0080 VDP_MEM equ 0x80
39:
40: - 0100 PROG_ROM_START equ 0x0100
41: - 4000 PROG_MEM_START equ 04000h
42:
43:
44: - 00F5 CS_PIO_BD .EQU 0xF5
45: - 00F7 CS_PIO_BC .EQU 0xF7
46: - 00F4 CS_PIO_AD .EQU 0xF4
47: - 00F6 CS_PIO_AC .EQU 0xF6
48:
49: - 00F8 CS_APU_DATA .EQU 0xF8
**** main.asm ****
31: - 00F9 CS_APU_CTRL .EQU 0xF9
32:
33: ;================================================================
34: ; RST Vectors for BASIC
35: ;================================================================
36: - 0000 org 0x0000
37: - 0000 RST_00: ;Hardware Restart
38: 0+10 0000 C38300 jp BOOT_PHASE0
39:
40: - 0008 org 0x0008
41: - 0008 RST_08 ;Print Char
42: 10+10 0008 C3D50D jp EXEC_RST_08
43:
44: - 0010 org 0x0010
45: - 0010 RST_10 ;receive char
46: 20+10 0010 C3D90D jp EXEC_RST_10
47:
48: - 0018 org 0x0018
49: - 0018 RST_18 ;Buffer length
50: 30+10 0018 C3E50D jp EXEC_RST_18
51:
52: ;================================================================
53: ; Default interrupt vectors
54: ;================================================================
55: - 001B INT_VEC:
56: - 0044 org 0x0044
57: ;DEFW EXEC_INT_VDP
58:
59: ;================================================================
60: ; Memory layout
61: ;================================================================
62: - 0044 mon_var_template:
63: - 4000 phase SYS_RAM_START
64: - 4000 interrupt_vectors:
65: - 4000 ..40FF 00 defs 256
66: - 4100 var_buffer_len:
67: - 4100 00 defb 0
68: - 4101 var_last_char:
69: - 4101 00 defb 0
70: - 4102 var_curserx:
71: - 4102 00 defb 0
72: - 4103 var_cursery:
73: - 4103 00 defb 0
74: - 4104 var_curserstate:
75: - 4104 00 defb 0
76: - 4105 var_curseron:
77: - 4105 00 defb 0
78: - 4106 var_curserchar:
79: - 4106 00 defb 0
80: - 4107 var_curserlastaddr:
81: - 4107 0000 defw 0
82: - 4109 var_pio_present:
83: - 4109 00 defb 0
84: - 410A var_apu_present:
85: - 410A 00 defb 0
86: - 410B var_scratch:
87: - 410B ..411A 00 defs 16 ;16 bytes space for scratch vars
88: - 411B var_ps2mem:
89: - 411B ..412A 00 defs 16 ;16 bytes space for scratch vars
90: - 412B var_dir:
91: - 412B ..417A 00 defs 80
92: - 417B var_input:
93: - 417B ..41CA 00 defs 80
94: - 41CB var_idebuffer:
95: - 41CB ..44CA 00 defs 768
96:
97: - 050F dephase
98: - 050F mon_var_template_end:
99: 40+4 050F 00 nop
100:
101: ;================================================================
102: ; Start of monitor
103: ;================================================================
104: - 0050 org 0x0050
105: .include "ref.s" ;static bios calls for programs
**** include/ref.s ****
1: ;-------------------------------------
2: ; BIOS Routines entry points
3: ; Do not move in memory!!!!
4: ;-------------------------------------
5: - 0050 B_BEEP:
6: 44+10 0050 C3E80D jp beep
7:
8: - 0053 B_IICSEND:
9: 54+10 0053 C3C316 jp iic_send_buffer
10:
11: - 0056 B_IICRECV:
12: 64+10 0056 C3ED16 jp iic_receive_buffer
13:
14: - 0059 B_PRINTCHAR:
15: 74+10 0059 C31501 jp print_char
16:
17: - 005C B_PRINTSTR:
18: 84+10 005C C31D01 jp print_str
19:
20: - 005F B_PRINTINLINE:
21: 94+10 005F C3D001 jp PRINTINLINE
22:
23: - 0062 B_PRINTAHEX:
24: 104+10 0062 C34301 jp print_a_hex
25:
26: - 0065 B_PRINTLN:
27: 114+10 0065 C32D01 jp print_newLine
28:
29: - 0068 B_READCHAR:
30: 124+10 0068 C35B01 jp read_char
31:
32: - 006B B_KEYREAD:
33: 134+10 006B C9 ret ;placeholder -> not implemented
34: - 006C 0000 db 0x00, 0x00
35:
36: - 006E B_KEYSEND:
37: 144+10 006E C9 ret ;placeholder -> not implemented
38: - 006F 0000 db 0x00, 0x00
39:
40: - 0071 B_DSKSEL:
41: 154+10 0071 C39A15 jp ideif_drv_sel
42:
43: - 0074 B_FATOPEN:
44: 164+10 0074 C31722 jp fat_openfile
45:
46: - 0077 B_FATREAD:
47: 174+10 0077 C3EA21 jp fat_readfilesec
48:
49: - 007A B_FATCD:
50: 184+10 007A C39B24 jp fat_cd_single
51:
52: - 007D B_FATCREATE:
53: 194+10 007D C9 ret ;placeholder -> not implemented
54: - 007E 0000 db 0x00, 0x00
55:
56: - 0080 B_FATWRITE:
57: 204+10 0080 C9 ret ;placeholder -> not implemented
**** main.asm ****
106: - 0081 0000 db 0x00, 0x00
107:
108: - 0083 BOOT_PHASE0: ;Setup Hardware
109: ;Setup Stack-Pointer
110: 214+10 0083 31FFFF ld sp, STACK_RAM_TOP
111: ;Disable Interrupts
112: 224+4 0086 F3 di
113: ;Setup PIO on MIO Board
114: 228+7 0087 3ECF LD A,0xCF
115: 235+11 0089 D3F6 OUT (CS_PIO_AC), A
116: 246+7 008B 3EF7 LD A,11110111b ;All pins inputs except speaker
117: 253+11 008D D3F6 OUT (CS_PIO_AC), A
118: 264+7 008F 3E03 LD A,00000011B ;Preset I2C pins to high
119: 271+11 0091 D3F6 OUT (CS_PIO_AC), A
120:
121: ;Set variables
122: 282+13 0093 320441 ld (var_curserstate),a
123: 295+13 0096 320541 ld (var_curseron),a
124: 308+7 0099 3E20 ld a, " "
125: 315+13 009B 320641 ld (var_curserchar),a
126:
127: ;setup interrupt table
128: 328+7 009E 3E40 ld a,[interrupt_vectors]>>8
129: 335+9 00A0 ED47 ld i,a
130:
131: ;Initialize Console (Serial-Port)
132: 344+17 00A2 CDDC00 call CONSOLE_INIT
133:
134: - 00A5 BOOT_PHASE1: ;Copy default values to RAM
135: 361+10 00A5 214400 ld hl,mon_var_template
136: 371+10 00A8 110F05 ld de,mon_var_template_end
137: 381+10 00AB 010040 ld bc,SYS_RAM_START
138: - 00AE BOOT_PHASE1_LOOP:
139: 391+7 00AE 7E ld a,(hl) ;copy values
140: 398+7 00AF 02 ld (bc),a
141: 405+6 00B0 23 inc hl
142: 411+6 00B1 03 inc bc
143: 417+11 00B2 E5 push hl ;check if end is reached
144: 428+15 00B3 ED52 sbc hl,de
145: 443+10 00B5 E1 pop hl
146: 453+10 00B6 C2AE00 jp nz, BOOT_PHASE1_LOOP
147: ;template copy done
148:
149:
150: - 00B9 BOOT_PHASE2: ;Hardware initialized.
151: ; Print banner
152: 463+17 00B9 CD2601 call print_clear
153: 480+10 00BC 218926 ld hl, [STR_Banner_Start]
154: 490+17 00BF CD1D01 call print_str
155:
156: ; Power-On Self Tests
157: 507+17 00C2 CD481E call POST_START
158:
159: ; Detect IDE drives
160: 524+17 00C5 CD4E15 call ideif_init_all
161:
162: ; Beep after start
163: 541+10 00C8 114000 LD DE,0x40
164: 551+10 00CB 014800 LD BC,0x48
165: 561+17 00CE CDE80D CALL beep
166:
167: 578+4 00D1 AF xor a ;set dir to empty
168: 582+13 00D2 322B41 ld (var_dir),a
169: 595+13 00D5 322C41 ld (var_dir+1),a
170: ; Start commandline
171: 608+10 00D8 C34419 jp COMMAND
172:
173: ; This instruction should never be reached
174: 618+4 00DB 76 halt
175:
176: ;================================================================
177: ; Includes (2/2)
178: ;================================================================
179: .include "console.s"
**** include/console.s ****
1: ;DIP SWICTHES
2: ;1843200 CLK / x16 SIO CLOCK MODE = 115200
3: ;MAX BAUD RATE = 115200
4: ;DIP VALUE = 115200/<BAUD>
5: ;
6: ;9600 -> 12 / 00110000
7: ;
8:
9: - 00DC CONSOLE_INIT:
10: - 00DC CONSOLE_INIT_CTC:
11: ;LD A,00001111b ; Set /16 Divider, CPU Trigger, Time COnstant Follows
12: 622+7 00DC 3E4F LD A,01001111b ; External Trigger, Time COnstant Follows
13: 629+11 00DE D304 OUT (CS_CTC_0),A
14: 640+11 00E0 DB01 IN A,(CS_DIP) ; Read BAUD from DIP-Switches
15: ;LD A,39
16: 651+11 00E2 D304 OUT (CS_CTC_0),A
17: - 00E4 CONSOLE_INIT_SIO:
18: 662+7 00E4 3E30 LD A,00110000b ;write into WR0: error reset, select WR0
19: 669+11 00E6 D309 OUT (CS_SIO_A_C),A
20: 680+7 00E8 3E18 LD a,018h ;write into WR0: channel reset
21: 687+11 00EA D309 OUT (CS_SIO_A_C),A
22: 698+7 00EC 3E04 LD a,004h ;write into WR0: select WR4
23: 705+11 00EE D309 OUT (CS_SIO_A_C),A
24: 716+7 00F0 3E44 LD a,01000100b ;write into WR4: clkx16,1 stop bit, no parity
25: 723+11 00F2 D309 OUT (CS_SIO_A_C),A
26: 734+7 00F4 3E05 LD a,005h ;write into WR0: select WR5
27: 741+11 00F6 D309 OUT (CS_SIO_A_C),A
28: 752+7 00F8 3EE8 LD a,11101000b ;DTR inactive, TX 8bit, BREAK off, TX on, RTS inactive
29: 759+11 00FA D309 OUT (CS_SIO_A_C),A
30: 770+7 00FC 3E01 LD a,01h ;write into WR0: select WR1
31: 777+11 00FE D309 OUT (CS_SIO_A_C),A
32: 788+7 0100 3E04 LD a,00000100b ;no interrupt in CH B, special RX condition affects vect
33: 795+11 0102 D309 OUT (CS_SIO_A_C),A
34: 806+7 0104 3E02 LD a,02h ;write into WR0: select WR2
35: 813+11 0106 D309 OUT (CS_SIO_A_C),A
36: 824+7 0108 3E00 LD a,0h ;write into WR2: cmd line int vect (see int vec table)
37: ;bits D3,D2,D1 are changed according to RX condition
38: 831+11 010A D309 OUT (CS_SIO_A_C),A
39: 842+7 010C 3E03 LD a,003h ;write into WR0: select WR3
40: 849+11 010E D309 OUT (CS_SIO_A_C),A
41: 860+7 0110 3EC1 LD a,0C1h ;RX 8bit, auto enable off, RX on
42: 867+11 0112 D309 OUT (CS_SIO_A_C),A
43: ;Channel A RX active
44: 878+10 0114 C9 RET
45:
46: ; A contains char
47: ; Destroys A
48: - 0115 print_char:
49: 888+11 0115 F5 push af
50: 899+11 0116 D308 out (CS_SIO_A_D),a
51: 910+17 0118 CD3801 call print_wait_out
52: 927+10 011B F1 pop af
53: ;call print_char
54: 937+10 011C C9 ret
55: ; HL contains pointer to string
56: ; Destroy A, HL
57:
58: - 011D print_str:
59: 947+7 011D 7E ld a, (hl)
60: 954+4 011E B7 or a
61: 958+5+6 011F C8 ret z
62: 963+17 0120 CD1501 call print_char
63: 980+6 0123 23 inc hl
64: 986+12 0124 18F7 jr print_str
65:
66:
67: - 0126 print_clear:
68: 998+10 0126 21B601 ld hl, [MSG_CLEAR]
69: 1008+17 0129 CD1D01 call print_str
70: 1025+10 012C C9 ret
71:
72: - 012D print_newLine:
73: 1035+7 012D 3E0A ld a,10
74: 1042+17 012F CD1501 call print_char
75: 1059+7 0132 3E0D ld a,13
76: 1066+17 0134 CD1501 call print_char
77: 1083+10 0137 C9 ret
78: ; destroys a
79: - 0138 print_wait_out:
80: ; check for TX buffer empty
81: 1093+4 0138 97 sub a ;clear a, write into WR0: select RR0
82: 1097+4 0139 3C inc a ;select RR1
83: 1101+11 013A D309 out (CS_SIO_A_C),A
84: 1112+11 013C DB09 in A,(CS_SIO_A_C) ;read RRx
85: 1123+8 013E CB47 bit 0,A
86: 1131+7+5 0140 28F6 jr z,print_wait_out
87: 1138+10 0142 C9 ret
88:
89: - 0143 print_a_hex:
90: 1148+11 0143 F5 push af
91: 1159+11 0144 C5 push bc
92: 1170+11 0145 D5 push de
93: 1181+17 0146 CD6C02 call STRCONV_BYTES_TO_HEX
94: 1198+4 0149 78 ld a,b
95: 1202+17 014A CD1501 call print_char
96: 1219+4 014D 79 ld a,c
97: 1223+17 014E CD1501 call print_char
98: 1240+10 0151 D1 pop de
99: 1250+10 0152 C1 pop bc
100: 1260+10 0153 F1 pop af
101: 1270+10 0154 C9 ret
102:
103: - 0155 print_bcd:
104: 1280+7 0155 C630 ADD 48 ;offset for ascii number
105: 1287+17 0157 CD1501 call print_char
106: 1304+10 015A C9 ret
107:
108: - 015B read_char:
109: 1314+17 015B CDC701 call A_RTS_ON
110: 1331+4 015E 00 nop
111: 1335+4 015F AF xor a ; a = 0
112: 1339+11 0160 D309 out (CS_SIO_A_C), a ; select reg 0
113: 1350+11 0162 DB09 in a, (CS_SIO_A_C) ; read reg 0
114: 1361+7 0164 E601 and 1 ; mask D0 (recieve char available)
115: 1368+17 0166 CDBE01 call A_RTS_OFF
116: 1385+5+6 0169 C8 ret Z ; return 0 if no char
117: 1390+11 016A DB08 in a, (CS_SIO_A_D) ; read char if avail
118: 1401+10 016C C9 ret ; return
119:
120:
121: - 016D read_in_sts:
122: 1411+11 016D D309 out (CS_SIO_A_C), a ; select reg 0
123: 1422+11 016F DB09 in a, (CS_SIO_A_C) ; read reg 0
124: 1433+7 0171 E601 and 1 ; mask D0 (recieve char available)
125: 1440+5+6 0173 C8 ret z
126: 1445+7 0174 3EFF ld a, 0xFF
127: 1452+10 0176 C9 ret
128:
129: - 0177 read_bcd;
130: 1462+17 0177 CD5B01 call read_char
131: 1479+10 017A CA7701 jp z, read_bcd
132: 1489+17 017D CD1501 call print_char
133: 1506+7 0180 DE30 sbc 48 ;remove ascii offset
134: 1513+10 0182 DA8D01 jp c, _read_bcd_invalid ;if carry, wrong input
135: 1523+7 0185 FE0A cp 10
136: 1530+10 0187 CA8D01 jp z, _read_bcd_invalid ;if equal or greater than 10, also error
137: 1540+7 018A E60F and 0x0F ;mask unused bits
138: 1547+10 018C C9 ret
139: - 018D _read_bcd_invalid
140: 1557+7 018D 3EFF ld a, 0xFF
141: 1564+10 018F C9 ret
142:
143: - 0190 print_32_hex:
144: 1574+19 0190 DD7E03 ld a,(ix+3)
145: 1593+17 0193 CD4301 call print_a_hex
146: 1610+19 0196 DD7E02 ld a,(ix+2)
147: 1629+17 0199 CD4301 call print_a_hex
148: 1646+19 019C DD7E01 ld a,(ix+1)
149: 1665+17 019F CD4301 call print_a_hex
150: 1682+19 01A2 DD7E00 ld a,(ix+0)
151: 1701+17 01A5 CD4301 call print_a_hex
152: 1718+10 01A8 C9 ret
153:
154: - 01A9 print_16_hex:
155: 1728+19 01A9 DD7E01 ld a,(ix+1)
156: 1747+17 01AC CD4301 call print_a_hex
157: 1764+19 01AF DD7E00 ld a,(ix+0)
158: 1783+17 01B2 CD4301 call print_a_hex
159: 1800+10 01B5 C9 ret
160:
161:
162: ;MSG_CRSR_0:
163: ; db 0x1B, "[?25h",0
164: ;MSG_CRSR_1:
165: ; db 0x1B, "[?25l",0
166: - 01B6 MSG_CLEAR:
167: - 01B6 1B5B324A db 27, '[2J', 27, '[H',0
1B5B4800
168:
169:
170:
171: ; Serial Util Functions
172: - 01BE A_RTS_OFF:
173: 1810+7 01BE 3E05 ld a,005h ;write into WR0: select WR5
174: 1817+11 01C0 D309 out (CS_SIO_A_C),A
175: 1828+7 01C2 3E68 ld a,068h ;DTR inactive, TX 8bit, BREAK off, TX on, RTS inactive
176: 1835+11 01C4 D309 out (CS_SIO_A_C),A
177: 1846+10 01C6 C9 ret
178: - 01C7 A_RTS_ON:
179: 1856+7 01C7 3E05 ld a,005h ;write into WR0: select WR5
180: 1863+11 01C9 D309 out (CS_SIO_A_C),A
181: 1874+7 01CB 3EEA ld a,0EAh ;DTR active, TX 8bit, BREAK off, TX on, RTS active
182: 1881+11 01CD D309 out (CS_SIO_A_C),A
183: 1892+10 01CF C9 ret
184:
185: ;------------------------------------------------------------------------------
186: ; PRINTINLINE
187: ;
188: ; String output function
189: ;
190: ; Prints in-line data (bytes immediately following the PRINTINLINE call)
191: ; until a string terminator is encountered (0 - null char).
192: ;------------------------------------------------------------------------------
193: - 01D0 PRINTINLINE:
194: 1902+19 01D0 E3 EX (SP),HL ; PUSH HL and put RET ADDress into HL
195: 1921+11 01D1 F5 PUSH AF
196: 1932+11 01D2 C5 PUSH BC
197: - 01D3 nxtILC:
198: 1943+7 01D3 7E LD A,(HL)
199: 1950+7 01D4 FE00 CP 0
200: 1957+7+5 01D6 2806 JR Z,endPrint
201: 1964+17 01D8 CD1501 CALL print_char
202: 1981+6 01DB 23 INC HL
203: 1987+12 01DC 18F5 JR nxtILC
204: - 01DE endPrint:
205: 1999+6 01DE 23 INC HL ; Get past "null" terminator
206: 2005+10 01DF C1 POP BC
207: 2015+10 01E0 F1 POP AF
208: 2025+19 01E1 E3 EX (SP),HL ; PUSH new RET ADDress on stack and restore HL
209: 2044+10 01E2 C9 RET
210:
211: - 01E3 print_reg:
212: 2054+11 01E3 F5 push af
213: 2065+11 01E4 D5 push de
214: 2076+11 01E5 C5 push bc
215: 2087+11 01E6 E5 push hl
216: 2098+11 01E7 F5 push af
217: 2109+17 01E8 CDD001 call PRINTINLINE
218: - 01EB 0A0D413A db 10,13,"A: ",0
202000
219: 2126+10 01F2 F1 pop af
220: 2136+17 01F3 CD4301 call print_a_hex
221: 2153+17 01F6 CDD001 call PRINTINLINE
222: - 01F9 0A0D4243 db 10,13,"BC: ",0
3A2000
223: 2170+4 0200 78 ld a,b
224: 2174+17 0201 CD4301 call print_a_hex
225: 2191+4 0204 79 ld a,c
226: 2195+17 0205 CD4301 call print_a_hex
227: 2212+17 0208 CDD001 call PRINTINLINE
228: - 020B 0A0D4445 db 10,13,"DE: ",0
3A2000
229: 2229+4 0212 7A ld a,d
230: 2233+17 0213 CD4301 call print_a_hex
231: 2250+4 0216 7B ld a,e
232: 2254+17 0217 CD4301 call print_a_hex
233: 2271+10 021A F1 pop af
234: 2281+17 021B CDD001 call PRINTINLINE
235: - 021E 0A0D484C db 10,13,"HL: ",0
3A2000
236: 2298+4 0225 7C ld a,h
237: 2302+17 0226 CD4301 call print_a_hex
238: 2319+4 0229 7D ld a,l
239: 2323+17 022A CD4301 call print_a_hex
240: 2340+17 022D CD2D01 call print_newLine
241: 2357+10 0230 E1 pop hl
242: 2367+10 0231 C1 pop bc
243: 2377+10 0232 D1 pop de
244: 2387+10 0233 F1 pop af
**** main.asm ****
180: 2397+10 0234 C9 ret
181: .include "conversions.s"
**** include/conversions.s ****
1: ; HL Contains Address to string
2: ; E is 0xFF if error
3: ; E is 0x00 if okay
4: ; A returns byte
5: ; A,DE are destroyed
6: - 0235 DHEX_TO_BYTE:
7: 2407+11 0235 E5 PUSH HL ;Backup pointer
8: ; Load First Byte
9: 2418+7 0236 7E LD A,(HL) ;Load first char (high)
10: 2425+17 0237 CD5502 CALL HEX_TO_BIN ;Conv chart to 4bit
11: 2442+7+5 023A 3815 jr C, DHEX_TO_BYTE_FAILED ;If error jmp to DHEX_TO_BYTE_FAILED
12: 2449+8 023C CB27 SLA A ;shift result to upper 4 bits
13: 2457+8 023E CB27 SLA A
14: 2465+8 0240 CB27 SLA A
15: 2473+8 0242 CB27 SLA A
16: 2481+4 0244 57 LD D,A ;store result in D
17:
18: 2485+6 0245 23 INC HL ;next byte
19: 2491+7 0246 7E LD A,(HL) ;load 2nd char (lower)
20: 2498+17 0247 CD5502 CALL HEX_TO_BIN ;Conv chart to 4bit
21: 2515+7+5 024A 3805 jr C, DHEX_TO_BYTE_FAILED ;If error jmp to DHEX_TO_BYTE_FAILED
22: 2522+4 024C B2 OR D ;merge D with accumulator
23:
24: 2526+10 024D E1 POP HL ;restor original pointer
25: 2536+7 024E 1E00 LD E,0x00 ;set error to 0x00 = no error
26: 2543+10 0250 C9 RET
27: - 0251 DHEX_TO_BYTE_FAILED:
28: 2553+7 0251 1EFF LD E,0xFF ;set error to oxFF
29: ;LD A,0x00
30: 2560+10 0253 E1 POP HL
31: 2570+10 0254 C9 RET
32:
33: ; REG A Contains CHAR-Low
34: ; If failed, Carry is set
35: - 0255 HEX_TO_BIN:
36: 2580+7 0255 D630 SUB 48 ; 0 is 0
37: 2587+10 0257 EA6A02 jp PE, HEX_TO_INVALID_2; to low (SUB overflow)
38: 2597+7 025A FE0A CP 10 ; Value is between 0 and 9
39: 2604+7+5 025C 3805 JR C, HEX_TO_BIN_2
40: 2611+7 025E D607 SUB 7
41: 2618+10 0260 EA6A02 jp PE, HEX_TO_INVALID_2; to low (SUB overflow)
42: - 0263 HEX_TO_BIN_2:
43: 2628+7 0263 FE10 CP 16
44: 2635+7+5 0265 3003 JR NC, HEX_TO_INVALID_2; if bigger than 15-> fail
45: 2642+7 0267 E60F AND 0x0F
46: 2649+10 0269 C9 RET
47: - 026A HEX_TO_INVALID_2:
48: 2659+4 026A 37 SCF ;set carry flag
49: 2663+10 026B C9 RET
50:
51:
52: ;*****************
53: ; Convert Byte to Hex Char (ASCII)
54: ;*****************
55: ;Description: the StrLength function inline
56: ;
57: ;Inputs: A contains input byte
58: ;
59: ;Outputs: BC contains 2 Bytes of ASCII (HEX)
60: ;
61: ;Destroys: A, BC,
62: - 026C STRCONV_BYTES_TO_HEX:
63: 2673+11 026C F5 PUSH AF;Backup A Register
64: 2684+4 026D 1F RRA
65: 2688+4 026E 1F RRA
66: 2692+4 026F 1F RRA
67: 2696+4 0270 1F RRA
68: 2700+17 0271 CD7B02 CALL STRCONV_BYTES_TO_HEX_1
69: ;LD A,D
70: 2717+4 0274 47 LD B,A
71: 2721+10 0275 F1 POP AF ; Reload first Byte
72: 2731+17 0276 CD7B02 CALL STRCONV_BYTES_TO_HEX_1
73: ;LD A,D
74: 2748+4 0279 4F LD C,A
75: 2752+10 027A C9 RET
76:
77: - 027B STRCONV_BYTES_TO_HEX_1:
78: 2762+7 027B E60F AND 0x0F
79: 2769+7 027D C630 ADD 48
80: 2776+7 027F FE3A CP 58 ; Check if less than 58 (less than ASCII 9)
81: ;JR C, STRCONV_BYTES_TO_HEX_2
82: 2783+5+6 0281 D8 RET C
83: 2788+7 0282 C607 ADD 7 ; A-F
84: 2795+10 0284 C9 RET
85: - 0285 STRCONV_BYTES_TO_HEX_2:
86: ;LD D,A
87: 2805+10 0285 C9 RET
88:
89:
**** main.asm ****
182: .include "disassembler.s"
**** include/disassembler.s ****
1: - 4110 var_opcode_start equ PRG_RAM_START ;16 bit pointer to opcode in mem
2: - 4112 var_opcode_table equ PRG_RAM_START+2 ;16 bit pointer to opcode in table
3: - 4114 var_opcode equ PRG_RAM_START+4 ;8 bit opcode value
4: - 4115 var_opcode_x equ PRG_RAM_START+5 ;8 bit opcode extension value
5: - 4116 var_opcode_length equ PRG_RAM_START+6 ;8 bit opcode length (in bytes)
6: - 4117 var_opcode_string equ PRG_RAM_START+7 ;16 bit pointer to opcode string
7: - 4119 var_opcode_pcount equ PRG_RAM_START+9 ;8 bit opcode param count
8: - 411A var_bytes_count equ PRG_RAM_START+10 ;bytes to examine
9: ; HL contains start address
10: ; B contains length
11: - 0286 disassemble:
12: 2815+4 0286 78 ld a,b
13: 2819+13 0287 321A41 ld (var_bytes_count),a
14: - 028A disassemble_next:
15:
16:
17: 2832+16 028A 221041 ld (var_opcode_start), hl ;16 bit pointer to opcode in mem
18: 2848+7 028D 7E ld a,(hl) ;load opcode to find in A
19: 2855+13 028E 321441 ld (var_opcode), a ;8 bit opcode value
20: 2868+6 0291 23 inc hl
21: 2874+7 0292 7E ld a,(hl) ;load opcode to find in A
22: 2881+13 0293 321541 ld (var_opcode_x), a ;8 bit opcode extended value
23: 2894+6 0296 2B dec hl
24: 2900+17 0297 CD7A03 call disassemble_table_seek
25: 2917+4 029A 78 ld a,b
26: 2921+4 029B B1 or c
27: 2925+10 029C CA5C03 jp z, disassemble_err ;if bc==0000h
28:
29: 2935+20 029F ED431241 ld (var_opcode_table), bc ;16 bit pointer to opcode in table
30:
31: ;load params
32: 2955+6 02A3 03 inc bc
33: 2961+6 02A4 03 inc bc
34: 2967+6 02A5 03 inc bc
35: 2973+6 02A6 03 inc bc
36: 2979+7 02A7 0A ld a,(bc)
37: 2986+13 02A8 321641 ld (var_opcode_length),A ;8 bit opcode length (in bytes)
38: 2999+6 02AB 03 inc bc
39: 3005+7 02AC 0A ld a, (bc)
40: 3012+4 02AD 5F ld e,a
41: 3016+6 02AE 03 inc bc
42: 3022+7 02AF 0A ld a, (bc)
43: 3029+4 02B0 57 ld d,a
44: 3033+20 02B1 ED531741 ld (var_opcode_string),de ;16 bit pointer to opcode string
45: 3053+6 02B5 03 inc bc
46: 3059+7 02B6 0A ld a,(bc)
47: 3066+13 02B7 321941 ld (var_opcode_pcount),A ;8 bit opcode param count
48:
49: ;values are prepared. Continue with print
50:
51: 3079+16 02BA 2A1041 ld hl,(var_opcode_start) ;print address
52: 3095+17 02BD CDC203 call dasm_print16hex_addr
53:
54: 3112+13 02C0 3A1641 ld a,(var_opcode_length)
55: 3125+4 02C3 47 ld b, a
56:
57: ;print up to 4 opcode bytes
58: 3129+16 02C4 2A1041 ld hl,(var_opcode_start)
59:
60: - 02C7 disassemble_print_opcode_raw
61: 3145+7 02C7 7E ld a,(hl) ;load first byte
62: 3152+17 02C8 CD4301 call print_a_hex
63: 3169+6 02CB 23 inc hl
64: 3175+8+5 02CC 10F9 djnz disassemble_print_opcode_raw
65:
66: 3183+7 02CE 3E68 ld a,"h"
67: 3190+17 02D0 CD1501 call print_char
68: ;fill empty spots
69: 3207+13 02D3 3A1641 ld a,(var_opcode_length)
70: 3220+4 02D6 47 ld b,a
71: 3224+7 02D7 3E06 ld a,6
72: 3231+4 02D9 90 sub b
73: 3235+4 02DA 47 ld b,a
74:
75: - 02DB disassemble_print_opcode_raw_fill:
76: 3239+7 02DB 3E20 ld a," "
77: 3246+17 02DD CD1501 call print_char
78: 3263+7 02E0 3E20 ld a," "
79: 3270+17 02E2 CD1501 call print_char
80: 3287+8+5 02E5 10F4 djnz disassemble_print_opcode_raw_fill
81: 3295+7 02E7 3E20 ld a," "
82: 3302+17 02E9 CD1501 call print_char
83:
84: 3319+11 02EC E5 push hl
85: ;print opcode
86: 3330+16 02ED 2A1741 ld hl,(var_opcode_string)
87: 3346+17 02F0 CD1D01 call print_str
88:
89:
90: ;print params
91: 3363+13 02F3 3A1941 ld a,(var_opcode_pcount)
92: 3376+4 02F6 B7 or a
93: 3380+10 02F7 CA5903 jp z, disassemble_print_opcode_params_end ;skip if no params
94:
95: 3390+16 02FA 2A1241 ld hl,(var_opcode_table)
96: 3406+10 02FD 010800 ld bc, 8
97: 3416+11 0300 09 add hl,bc ;hl now has address of first param
98: 3427+13 0301 3A1941 ld a,(var_opcode_pcount)
99: 3440+4 0304 47 ld b,a
100: - 0305 disassemble_print_opcode_params_loop:
101: ;ld a,(hl) ;load param
102: ;call print_a_hex
103: 3444+7 0305 7E ld a,(hl) ;load param
104:
105: 3451+7 0306 FE01 cp 0x01
106: 3458+10+7 0308 CCE803 call z, param_01
107: 3468+7 030B FE02 cp 0x02
108: 3475+10+7 030D CC0F04 call z, param_02
109: 3485+7 0310 FE03 cp 0x03
110: 3492+10+7 0312 CC2C04 call z, param_03
111: 3502+7 0315 FE04 cp 0x04
112: 3509+10+7 0317 CC6804 call z, param_04
113: 3519+7 031A FE05 cp 0x05
114: 3526+10+7 031C CC7E04 call z, param_05
115: 3536+7 031F FE06 cp 0x06
116: 3543+10+7 0321 CC8B04 call z, param_06
117: 3553+7 0324 FE07 cp 0x07
118: 3560+10+7 0326 CCA504 call z, param_07
119: 3570+7 0329 FE08 cp 0x08
120: 3577+10+7 032B CCB204 call z, param_08
121: 3587+7 032E FE09 cp 0x09
122: 3594+10+7 0330 CCC704 call z, param_09
123: 3604+7 0333 FE10 cp 0x10
124: 3611+10+7 0335 CCDC04 call z, param_10
125: 3621+7 0338 FE11 cp 0x11
126: 3628+10+7 033A CCEC04 call z, param_11
127: 3638+7 033D FE12 cp 0x12
128: 3645+10+7 033F CCF404 call z, param_12
129: 3655+7 0342 FE13 cp 0x13
130: 3662+10+7 0344 CC2C05 call z, param_13
131: 3672+7 0347 FE0A cp 0x0A
132: 3679+10+7 0349 CCBE04 call z, param_0A
133: ;strings
134: 3689+7 034C FE80 cp 0x80
135: 3696+10+7 034E CC4B05 call z, param_80
136: 3706+7 0351 FE81 cp 0x81
137: 3713+10+7 0353 CC4205 call z, param_81
138: 3723+6 0356 23 inc hl
139: 3729+8+5 0357 10AC djnz disassemble_print_opcode_params_loop
140: - 0359 disassemble_print_opcode_params_end:
141: 3737+10 0359 E1 pop hl
142: 3747+12 035A 1810 jr disassemble_continue
143:
144:
145: - 035C disassemble_err:
146: 3759+17 035C CDC203 call dasm_print16hex_addr
147: 3776+7 035F 7E ld a,(hl)
148: 3783+17 0360 CDDA03 call dasm_print8hex ;print value
149: 3800+6 0363 23 inc hl
150: 3806+11 0364 E5 push hl
151: 3817+10 0365 21970D ld hl, [dasm_UU]
152: 3827+17 0368 CD1D01 call print_str
153: 3844+10 036B E1 pop hl
154:
155: - 036C disassemble_continue:
156:
157: 3854+17 036C CD2D01 call print_newLine
158: ;inc hl
159: 3871+13 036F 3A1A41 ld a,(var_bytes_count)
160: 3884+4 0372 3D dec a
161: 3888+13 0373 321A41 ld (var_bytes_count),a
162: 3901+10 0376 C28A02 jp nz, disassemble_next
163: 3911+10 0379 C9 ret
164:
165:
166:
167: ;A contains opcode
168: ;BC contains returned position
169: - 037A disassemble_table_seek:
170: 3921+11 037A E5 push hl
171: 3932+10 037B 219505 ld hl, [dasm_opcode_table]
172: - 037E disassemble_table_seek_loop:
173: 3942+13 037E 3A1441 ld a,(var_opcode)
174: 3955+4 0381 4F ld c,a
175: 3959+7 0382 7E ld a,(hl)
176: 3966+7 0383 FEFF cp 0xFF ; if null
177: 3973+10 0385 CABC03 jp z, disassemble_table_notfound
178:
179: ;apply mask
180: 3983+11 0388 F5 push af
181: 3994+6 0389 23 inc hl
182: 4000+7 038A 46 ld b,(hl) ;load mask
183: 4007+6 038B 2B dec hl
184: 4013+4 038C 79 ld a,c
185: 4017+4 038D A0 and b ;apply mask
186: 4021+4 038E 4F ld c,a
187: 4025+10 038F F1 pop af
188:
189: 4035+4 0390 B9 cp c ; if match
190: 4039+7+5 0391 280B jr z, disassemble_table_first_match
191: 4046+7 0393 0600 ld b,0
192: 4053+7 0395 0E07 ld c,7
193: 4060+11 0397 09 add hl,bc
194: 4071+7 0398 7E ld a,(hl)
195: 4078+4 0399 4F ld c,a
196: 4082+11 039A 09 add hl,bc
197: 4093+6 039B 23 inc hl
198: 4099+12 039C 18E0 jr disassemble_table_seek_loop
199:
200: - 039E disassemble_table_first_match
201: 4111+6 039E 23 inc hl
202: 4117+6 039F 23 inc hl
203: 4123+7 03A0 4E ld c,(hl) ;load opcode x from table
204: 4130+6 03A1 23 inc hl
205: 4136+13 03A2 3A1541 ld a,(var_opcode_x) ;load current opcode x
206: 4149+7 03A5 46 ld b,(hl) ;load mask
207: 4156+4 03A6 A0 and b ;apply mask
208: 4160+4 03A7 B9 cp c ;compare to table
209: 4164+6 03A8 2B dec hl
210: 4170+6 03A9 2B dec hl
211: 4176+6 03AA 2B dec hl
212: 4182+7+5 03AB 280B jr z, disassemble_table_found ;IF FOUND
213: 4189+7 03AD 0600 ld b,0 ;else continue with next
214:
215: 4196+7 03AF 0E07 ld c,7
216: 4203+11 03B1 09 add hl,bc
217: 4214+7 03B2 7E ld a,(hl)
218: 4221+4 03B3 4F ld c,a
219: 4225+11 03B4 09 add hl,bc
220: 4236+6 03B5 23 inc hl
221: 4242+12 03B6 18C6 jr disassemble_table_seek_loop
222:
223: - 03B8 disassemble_table_found
224: 4254+4 03B8 44 ld b,H
225: 4258+4 03B9 4D ld c,l
226: 4262+10 03BA E1 pop hl
227: 4272+10 03BB C9 ret
228:
229: - 03BC disassemble_table_notfound
230: 4282+7 03BC 0600 ld b,0
231: 4289+7 03BE 0E00 ld c,0
232: 4296+10 03C0 E1 pop hl
233: 4306+10 03C1 C9 ret
234:
235:
236:
237:
238: - 03C2 dasm_print16hex_addr:
239: 4316+7 03C2 3E24 ld a,"$"
240: 4323+17 03C4 CD1501 call print_char
241: 4340+4 03C7 7C ld a,h
242: 4344+17 03C8 CD4301 call print_a_hex
243: 4361+4 03CB 7D ld a,l
244: 4365+17 03CC CD4301 call print_a_hex
245: 4382+7 03CF 3E68 ld a,"h"
246: 4389+17 03D1 CD1501 call print_char
247: 4406+7 03D4 3E20 ld a," "
248: 4413+17 03D6 CD1501 call print_char
249: 4430+10 03D9 C9 ret
250:
251: - 03DA dasm_print8hex:
252: 4440+17 03DA CD4301 call print_a_hex
253: 4457+7 03DD 3E68 ld a,"h"
254: 4464+17 03DF CD1501 call print_char
255: 4481+7 03E2 3E20 ld a," "
256: 4488+17 03E4 CD1501 call print_char
257: 4505+10 03E7 C9 ret
258:
259:
260:
261:
262:
263:
264:
265: - 03E8 param_01: ; 0x01 16bit address pointer
266: 4515+11 03E8 E5 push hl
267: 4526+20 03E9 ED5B1041 ld de,(var_opcode_start)
268: 4546+6 03ED 13 inc de
269: 4552+7 03EE 1A ld a,(de)
270: 4559+4 03EF 6F ld l,a
271: 4563+6 03F0 13 inc de
272: 4569+7 03F1 1A ld a,(de)
273: 4576+4 03F2 67 ld h,a
274:
275: 4580+7 03F3 3E24 ld a,"$"
276: 4587+17 03F5 CD1501 call print_char
277: 4604+4 03F8 7C ld a,h
278: 4608+17 03F9 CD4301 call print_a_hex
279: 4625+4 03FC 7D ld a,l
280: 4629+17 03FD CD4301 call print_a_hex
281: 4646+7 0400 3E68 ld a,"h"
282: 4653+17 0402 CD1501 call print_char
283: 4670+7 0405 3E20 ld a," "
284: 4677+17 0407 CD1501 call print_char
285: 4694+17 040A CD8605 call param_comma
286: 4711+10 040D E1 pop hl
287: 4721+10 040E C9 ret
288:
289: - 040F param_02:
290: 4731+11 040F C5 push bc
291: 4742+20 0410 ED5B1041 ld de,(var_opcode_start)
292: 4762+7 0414 1A ld a,(de)
293: 4769+4 0415 1F rra
294: 4773+4 0416 1F rra
295: 4777+7 0417 E60E and 0x0E
296:
297: 4784+11 0419 E5 push hl
298: 4795+10 041A 21A00D ld hl, [dasm_printFlags_table]
299: 4805+7 041D 0600 ld b,0
300: 4812+4 041F 4F ld c,a
301: 4816+11 0420 09 add hl,bc
302: 4827+17 0421 CD1D01 call print_str
303: 4844+7 0424 3E20 ld a, " "
304: 4851+17 0426 CD1501 call print_char
305: 4868+10 0429 E1 pop hl
306: 4878+10 042A C1 pop bc
307: 4888+10 042B C9 ret
308:
309:
310: - 042C param_03:
311: 4898+20 042C ED5B1041 ld de,(var_opcode_start)
312: 4918+6 0430 13 inc de
313: 4924+7 0431 1A ld a,(de)
314:
315: 4931+11 0432 F5 push af
316: 4942+7 0433 E680 and 0x80
317: 4949+10 0435 C24D04 jp nz, param_03_neg
318: 4959+7 0438 3E24 ld a,"$"
319: 4966+17 043A CD1501 call print_char
320: 4983+7 043D 3E2B ld a,"+"
321: 4990+17 043F CD1501 call print_char
322: 5007+10 0442 F1 pop af
323: 5017+17 0443 CD4301 call print_a_hex
324: 5034+7 0446 3E68 ld a,"h"
325: 5041+17 0448 CD1501 call print_char
326: 5058+12 044B 1817 jr param_03_done
327:
328: - 044D param_03_neg:
329: 5070+7 044D 3E24 ld a,"$"
330: 5077+17 044F CD1501 call print_char
331: 5094+7 0452 3E2D ld a,"-"
332: 5101+17 0454 CD1501 call print_char
333: 5118+10 0457 F1 pop af
334: 5128+8 0458 ED44 neg
335: 5136+17 045A CD4301 call print_a_hex
336: 5153+7 045D 3E68 ld a,"h"
337: 5160+17 045F CD1501 call print_char
338: 5177+12 0462 1800 jr param_03_done
339:
340: - 0464 param_03_done:
341: 5189+17 0464 CD8605 call param_comma
342: 5206+10 0467 C9 ret
343:
344:
345: - 0468 param_04:
346: 5216+20 0468 ED5B1041 ld de,(var_opcode_start)
347: 5236+6 046C 13 inc de
348: 5242+7 046D 1A ld a,(de)
349: 5249+7 046E FE4D cp 0x4D
350: 5256+7+5 0470 2806 jr z,param_04_i
351: 5263+7 0472 3E4E ld a,"N"
352: 5270+17 0474 CD1501 call print_char
353: 5287+10 0477 C9 ret
354: - 0478 param_04_i:
355: 5297+7 0478 3E49 ld a,"I"
356: 5304+17 047A CD1501 call print_char
357: 5321+10 047D C9 ret
358:
359: - 047E param_05:
360: 5331+11 047E C5 push bc
361: 5342+20 047F ED5B1041 ld de,(var_opcode_start)
362: 5362+7 0483 1A ld a,(de)
363: 5369+7 0484 E638 and 0x38
364: ; print hex char
365: 5376+17 0486 CDDA03 call dasm_print8hex
366: 5393+10 0489 C1 pop bc
367: 5403+10 048A C9 ret
368:
369:
370: - 048B param_06:
371: 5413+11 048B C5 push bc
372: 5424+20 048C ED5B1041 ld de,(var_opcode_start)
373: 5444+7 0490 1A ld a,(de)
374: 5451+4 0491 1F rra
375: 5455+4 0492 1F rra
376: 5459+4 0493 1F rra
377: 5463+7 0494 E607 and 0x07
378: 5470+17 0496 CD6105 call param_printRegister
379: 5487+7 0499 3E20 ld a," "
380: 5494+17 049B CD1501 call print_char
381: 5511+7 049E 3E2C ld a,","
382: 5518+17 04A0 CD1501 call print_char
383: 5535+10 04A3 C1 pop bc
384: 5545+10 04A4 C9 ret
385:
386: - 04A5 param_07:
387: 5555+11 04A5 C5 push bc
388: 5566+20 04A6 ED5B1041 ld de,(var_opcode_start)
389: 5586+7 04AA 1A ld a,(de)
390: 5593+7 04AB E607 and 0x07
391:
392: 5600+17 04AD CD6105 call param_printRegister
393: 5617+10 04B0 C1 pop bc
394: 5627+10 04B1 C9 ret
395:
396: - 04B2 param_08:
397: 5637+11 04B2 C5 push bc
398: 5648+20 04B3 ED5B1041 ld de,(var_opcode_start)
399: 5668+6 04B7 13 inc de
400: 5674+7 04B8 1A ld a,(de)
401: 5681+17 04B9 CDDA03 call dasm_print8hex
402: 5698+10 04BC C1 pop bc
403: 5708+10 04BD C9 ret
404:
405:
406: - 04BE param_0A:
407: 5718+11 04BE E5 push hl
408: 5729+20 04BF ED5B1041 ld de,(var_opcode_start)
409: 5749+6 04C3 13 inc de
410: 5755+6 04C4 13 inc de
411: 5761+12 04C5 1806 jr param_09_0A
412: - 04C7 param_09:
413: 5773+11 04C7 E5 push hl
414: 5784+20 04C8 ED5B1041 ld de,(var_opcode_start)
415: 5804+6 04CC 13 inc de
416: - 04CD param_09_0A:
417: 5810+7 04CD 1A ld a,(de)
418: 5817+4 04CE 6F ld l,a
419: 5821+6 04CF 13 inc de
420: 5827+7 04D0 1A ld a,(de)
421: 5834+4 04D1 67 ld h,a
422: 5838+4 04D2 7C ld a,h
423: 5842+17 04D3 CD4301 call print_a_hex
424: 5859+4 04D6 7D ld a,l
425: 5863+17 04D7 CD4301 call print_a_hex
426: 5880+10 04DA E1 pop hl
427: 5890+10 04DB C9 ret
428:
429: - 04DC param_10:
430: 5900+11 04DC C5 push bc
431: 5911+20 04DD ED5B1041 ld de,(var_opcode_start)
432: 5931+7 04E1 1A ld a,(de)
433: 5938+4 04E2 1F rra
434: 5942+4 04E3 1F rra
435: 5946+4 04E4 1F rra
436: 5950+7 04E5 E607 and 0x07
437: 5957+17 04E7 CD6105 call param_printRegister
438: 5974+10 04EA C1 pop bc
439: 5984+10 04EB C9 ret
440:
441:
442: - 04EC param_11:
443: 5994+11 04EC E5 push hl
444: 6005+11 04ED C5 push bc
445: 6016+20 04EE ED5B1041 ld de,(var_opcode_start)
446: 6036+12 04F2 1807 jr param_11_12
447: - 04F4 param_12:
448: 6048+11 04F4 E5 push hl
449: 6059+11 04F5 C5 push bc
450: 6070+20 04F6 ED5B1041 ld de,(var_opcode_start)
451: 6090+6 04FA 13 inc de
452:
453: - 04FB param_11_12:
454: 6096+7 04FB 1A ld a,(de)
455: 6103+4 04FC 1F rra
456: 6107+4 04FD 1F rra
457: 6111+4 04FE 1F rra
458: 6115+7 04FF E606 and 0x06
459: 6122+11 0501 F5 push af
460: ;check which table to use
461: 6133+16 0502 2A1041 ld hl, (var_opcode_start)
462: 6149+7 0505 7E ld a,(hl)
463: 6156+7 0506 FEDD cp 0xDD
464: 6163+7+5 0508 2809 jr z,param_11_12_ix
465: 6170+7 050A FEFD cp 0xFD
466: 6177+7+5 050C 280A jr z,param_11_12_iy
467: - 050E param_11_12_def:
468: 6184+10 050E 21B00D ld hl, [dasm_printRegister8_table]
469: 6194+12 0511 1808 jr param_11_12_all
470: - 0513 param_11_12_ix:
471: 6206+10 0513 21B80D ld hl, [dasm_printRegisterIX_table]
472: 6216+12 0516 1803 jr param_11_12_all
473: - 0518 param_11_12_iy:
474: 6228+10 0518 21C00D ld hl, [dasm_printRegisterIY_table]
475: - 051B param_11_12_all:
476: 6238+10 051B F1 pop af
477: 6248+7 051C 0600 ld b,0
478: 6255+4 051E 4F ld c,a
479: 6259+11 051F 09 add hl, bc
480: 6270+7 0520 7E ld a,(hl)
481: 6277+17 0521 CD1501 call print_char
482: 6294+6 0524 23 inc hl
483: 6300+7 0525 7E ld a,(hl)
484: 6307+17 0526 CD1501 call print_char
485: 6324+10 0529 C1 pop bc
486: 6334+10 052A E1 pop hl
487: 6344+10 052B C9 ret
488:
489: - 052C param_13:
490: 6354+11 052C E5 push hl
491: 6365+11 052D C5 push bc
492: 6376+20 052E ED5B1041 ld de,(var_opcode_start)
493: 6396+7 0532 1A ld a,(de)
494: 6403+4 0533 1F rra
495: 6407+4 0534 1F rra
496: 6411+4 0535 1F rra
497: 6415+7 0536 E606 and 0x06
498: 6422+11 0538 F5 push af
499: ;check which table to use
500: 6433+16 0539 2A1041 ld hl, (var_opcode_start)
501: 6449+7 053C 7E ld a,(hl)
502: 6456+10 053D 21C80D ld hl, [dasm_printRegisterSP_table]
503: 6466+12 0540 18D9 jr param_11_12_all ;reuse code from 11_12
504:
505:
506: - 0542 param_81:
507: 6478+11 0542 E5 push hl
508: 6489+11 0543 C5 push bc
509: 6500+16 0544 2A1741 ld hl, (var_opcode_string)
510: 6516+7 0547 0602 ld b,2
511: 6523+12 0549 1807 jr param_80_seek
512: - 054B param_80:
513: 6535+11 054B E5 push hl
514: 6546+11 054C C5 push bc
515: 6557+16 054D 2A1741 ld hl, (var_opcode_string)
516: 6573+7 0550 0601 ld b,1
517: - 0552 param_80_seek:
518: 6580+7 0552 7E ld a,(hl)
519: 6587+6 0553 23 inc hl
520: 6593+4 0554 A7 and a
521: 6597+7+5 0555 20FB jr nz, param_80_seek
522: ;found
523: 6604+4 0557 05 dec b ;found but counter too high
524: 6608+10 0558 C25205 jp nz, param_80_seek
525:
526: 6618+17 055B CD1D01 call print_str
527: 6635+10 055E C1 pop bc
528: 6645+10 055F E1 pop hl
529: 6655+10 0560 C9 ret
530:
531:
532:
533: - 0561 param_printRegister:
534: 6665+11 0561 E5 push hl
535: 6676+7 0562 FE06 cp 0x06
536: 6683+7+5 0564 2811 jr z, param_printRegisterHL
537: 6690+7 0566 FE07 cp 0x07
538: 6697+7+5 0568 2815 jr z, param_printRegisterA
539: 6704+10 056A 21B00D ld hl, [dasm_printRegister8_table]
540: 6714+7 056D 0600 ld b,0
541: 6721+4 056F 4F ld c,a
542: 6725+11 0570 09 add hl,bc
543: 6736+7 0571 7E ld a, (hl)
544: 6743+17 0572 CD1501 call print_char
545: 6760+10 0575 E1 pop hl
546: 6770+10 0576 C9 ret
547:
548: - 0577 param_printRegisterHL:
549: 6780+10 0577 21D00D ld hl, [dasm_printRegister8_table_HL]
550: 6790+17 057A CD1D01 call print_str
551: 6807+10 057D E1 pop hl
552: 6817+10 057E C9 ret
553:
554: - 057F param_printRegisterA:
555: 6827+7 057F 3E41 ld a,"A"
556: 6834+17 0581 CD1501 call print_char
557: 6851+10 0584 E1 pop hl
558: 6861+10 0585 C9 ret
559:
560:
561: - 0586 param_comma:
562: 6871+4 0586 78 ld a,b
563: 6875+7 0587 FE01 cp 1
564: 6882+5+6 0589 C8 ret z
565: 6887+7 058A 3E20 ld a," "
566: 6894+17 058C CD1501 call print_char
567: 6911+7 058F 3E2C ld a,","
568: 6918+17 0591 CD1501 call print_char
**** main.asm ****
183: 6935+10 0594 C9 ret
184: .include "disassembler_table.s"
**** include/disassembler_table.s ****
1: ;disassembler tables
2:
3: - 0595 dasm_opcode_table:
4: ;byte 0 = opcode
5: ;byte 1 = opcode mask
6: ;byte 2 = opcode extended
7: ;byte 3 = opcode extended mask
8: ;byte 4 = length
9: ;byte 5+6 = pointer to string
10: ;byte 7 = params = count of paramters
11: ;byte 8+ = paramters
12: ; 0x01 16bit address pointer
13: ; 0x02 flag bit 3-5
14: ; 0x03 relative jmp address
15: ; 0x04 RETI/RETN
16: ; 0x05 RST Vector
17: ; 0x06 register (r)
18: ; 0x07 register (r')
19: ; 0x08 8-Bit value
20: ; 0x09 16-Bit value
21: ; 0x0A 16-bit value with offset +1
22: ; 0x10 same as 0x06 without ","
23: ; 0x11 print 16 bit register from 1st byte
24: ; 0x12 print 16 bit register from 2nd byte
25: ; 0x13 push/pop register lookup
26: ; 0x80 print string suffix
27: ; 0x81 print string suffix 2
28: - 0595 00FF0000 defb 0x00, 0xFF, 0x00, 0x00, 1, [dasm_00], [dasm_00]>>8,0 ;NOP
01ED0900
29: ;General-Purpose Arithmetic and CPU Control Groups
30: - 059D 27FF0000 defb 0x27, 0xFF, 0x00, 0x00, 1, [dasm_27], [dasm_27]>>8, 0 ;DAA
01B80A00
31: - 05A5 2FFF0000 defb 0x2F, 0xFF, 0x00, 0x00, 1, [dasm_2F], [dasm_2F]>>8, 0 ;CPL
01BC0A00
32: - 05AD EDFF44FF defb 0xED, 0xFF, 0x44, 0xFF, 2, [dasm_ED_44], [dasm_ED_44]>>8, 0 ;NEG
02C00A00
33: - 05B5 3FFF0000 defb 0x3f, 0xFF, 0x00, 0x00, 1, [dasm_3F], [dasm_3F]>>8, 0 ;CCF
01C40A00
34: - 05BD 37FF0000 defb 0x37, 0xFF, 0x00, 0x00, 1, [dasm_37], [dasm_37]>>8, 0 ;SCF
01C80A00
35: ;defb 0x00, 0xFF, 0x00, 0x00, 1, [dasm_00], [dasm_00]>>8,0 ;NOP -> already at top for performance reasons
36: - 05C5 76FF0000 defb 0x76, 0xFF, 0x00, 0x00, 1, [dasm_76], [dasm_76]>>8, 0 ;HALT
01CC0A00
37: - 05CD F3FF0000 defb 0xF3, 0xFF, 0x00, 0x00, 1, [dasm_F3], [dasm_F3]>>8, 0 ;DI
01D10A00
38: - 05D5 FBFF0000 defb 0xFB, 0xFF, 0x00, 0x00, 1, [dasm_FB], [dasm_FB]>>8, 0 ;EI
01D40A00
39: - 05DD EDFF46FF defb 0xED, 0xFF, 0x46, 0xFF, 2, [dasm_ED_46], [dasm_ED_46]>>8, 0 ;IM 0
02D70A00
40: - 05E5 EDFF56FF defb 0xED, 0xFF, 0x56, 0xFF, 2, [dasm_ED_56], [dasm_ED_56]>>8, 0 ;IM 1
02DC0A00
41: - 05ED EDFF5EFF defb 0xED, 0xFF, 0x5E, 0xFF, 2, [dasm_ED_5E], [dasm_ED_5E]>>8, 0 ;IM 2
02E10A00
42:
43: ;Exchange, Block Transfer, and Search Group
44: - 05F5 EBFF0000 defb 0xEB, 0xFF, 0x00, 0x00, 1, [dasm_BE], [dasm_BE]>>8, 0 ;EX DE, HL
01E60A00
45: - 05FD 08FF0000 defb 0x08, 0xFF, 0x00, 0x00, 1, [dasm_08], [dasm_08]>>8, 0 ;EX AF, AF
01F00A00
46: - 0605 D9FF0000 defb 0xD9, 0xFF, 0x00, 0x00, 1, [dasm_D9], [dasm_D9]>>8, 0 ;EXX
01FD0A00
47: - 060D E3FF0000 defb 0xE3, 0xFF, 0x00, 0x00, 1, [dasm_E3], [dasm_E3]>>8, 0 ;EX (SP), HL
01010B00
48: - 0615 DDFFE3FF defb 0xDD, 0xFF, 0xE3, 0xFF, 2, [dasm_DD_E3], [dasm_DD_E3]>>8, 0 ;EX (SP), IX
020D0B00
49: - 061D FDFFE3FF defb 0xFD, 0xFF, 0xE3, 0xFF, 2, [dasm_FD_E3], [dasm_FD_E3]>>8, 0 ;EX (SP), IY
02190B00
50: - 0625 EDFFA0FF defb 0xED, 0xFF, 0xA0, 0xFF, 2, [dasm_ED_A0], [dasm_ED_A0]>>8, 0 ;LDI
02250B00
51: - 062D EDFFB0FF defb 0xED, 0xFF, 0xB0, 0xFF, 2, [dasm_ED_B0], [dasm_ED_B0]>>8, 0 ;LDIR
02290B00
52: - 0635 EDFFA8FF defb 0xED, 0xFF, 0xA8, 0xFF, 2, [dasm_ED_A8], [dasm_ED_A8]>>8, 0 ;LDD
022E0B00
53: - 063D EDFFB8FF defb 0xED, 0xFF, 0xB8, 0xFF, 2, [dasm_ED_B8], [dasm_ED_B8]>>8, 0 ;LDDR
02320B00
54: - 0645 EDFFA1FF defb 0xED, 0xFF, 0xA1, 0xFF, 2, [dasm_ED_A1], [dasm_ED_A1]>>8, 0 ;CPI
02370B00
55: - 064D EDFFB1FF defb 0xED, 0xFF, 0xB1, 0xFF, 2, [dasm_ED_B1], [dasm_ED_B1]>>8, 0 ;CPIR
023B0B00
56: - 0655 EDFFA9FF defb 0xED, 0xFF, 0xA9, 0xFF, 2, [dasm_ED_A9], [dasm_ED_A9]>>8, 0 ;CPD
02400B00
57: - 065D EDFFB9FF defb 0xED, 0xFF, 0xB9, 0xFF, 2, [dasm_ED_B9], [dasm_ED_B9]>>8, 0 ;CPDR
02440B00
58:
59: ;JUMP Group
60: - 0665 C3FF0000 defb 0xC3, 0xFF, 0x00, 0x00, 3, [dasm_C3], [dasm_C3]>>8,1, 0x01 ;JP nn
03F10901
01
61: - 066E C2C70000 defb 0xC2, 0xC7, 0x00, 0x00, 3, [dasm_C3], [dasm_C3]>>8,3, 0x02, 0x80, 0x01 ;JP cc,nn
03F10903
028001
62: - 0679 18FF0000 defb 0x18, 0xFF, 0x00, 0x00, 2, [dasm_18], [dasm_18]>>8,1, 0x03 ;JR e
02F80901
03
63: - 0682 38FF0000 defb 0x38, 0xFF, 0x00, 0x00, 2, [dasm_38], [dasm_38]>>8,1, 0x03 ;JR C,e
02FC0901
03
64: - 068B 30FF0000 defb 0x30, 0xFF, 0x00, 0x00, 2, [dasm_30], [dasm_30]>>8,1, 0x03 ;JR NC,e
02030A01
03
65: - 0694 28FF0000 defb 0x28, 0xFF, 0x00, 0x00, 2, [dasm_28], [dasm_28]>>8,1, 0x03 ;JR Z,e
020B0A01
03
66: - 069D 20FF0000 defb 0x20, 0xFF, 0x00, 0x00, 2, [dasm_20], [dasm_20]>>8,1, 0x03 ;JR NZ,e
02120A01
03
67: - 06A6 E9FF0000 defb 0xE9, 0xFF, 0x00, 0x00, 2, [dasm_E9], [dasm_E9]>>8,0 ;JP (HL)
021A0A00
68: - 06AE DDFFE9FF defb 0xDD, 0xFF, 0xE9, 0xFF, 2, [dasm_DD], [dasm_DD]>>8,0 ;JP (IX)
02230A00
69: - 06B6 FDFFE9FF defb 0xFD, 0xFF, 0xE9, 0xFF, 2, [dasm_FD], [dasm_FD]>>8,0 ;JP (IY)
022C0A00
70: - 06BE 10FF0000 defb 0x10, 0xFF, 0x00, 0x00, 2, [dasm_10], [dasm_10]>>8,1, 0x03 ;DJNZ, e
02350A01
03
71: ;Call and Return Group
72: - 06C7 CDFF0000 defb 0xCD, 0xFF, 0x00, 0x00, 3, [dasm_CD], [dasm_CD]>>8,1, 0x01 ;CALL nn
033B0A01
01
73: - 06D0 C4C70000 defb 0xC4, 0xC7, 0x00, 0x00, 3, [dasm_CD], [dasm_CD]>>8,2, 0x02, 0x01 ;CALL cc,nn
033B0A02
0201
74: - 06DA C9FF0000 defb 0xC9, 0xFF, 0x00, 0x00, 1, [dasm_C9], [dasm_C9]>>8,0 ;RET
01410A00
75: - 06E2 C0C70000 defb 0xC0, 0xC7, 0x00, 0x00, 1, [dasm_C9], [dasm_C9]>>8,1, 0x02 ;RET cc
01410A01
02
76: - 06EB EDFF4DFF defb 0xED, 0xFF, 0x4D, 0xFF, 2, [dasm_ED_4D], [dasm_ED_4D]>>8,0 ;RETI
02460A00
77: - 06F3 EDFF45FF defb 0xED, 0xFF, 0x45, 0xFF, 2, [dasm_ED_45], [dasm_ED_45]>>8,0 ;RETN
024B0A00
78:
79: - 06FB C7C70000 defb 0xC7, 0xC7, 0x00, 0x00, 1, [dasm_FF], [dasm_FF]>>8,1, 0x05 ;RST
01500A01
05
80: ;8-Bit load group
81: - 0704 0AFF0000 defb 0x0A, 0xFF, 0x00, 0x00, 1, [dasm_0A], [dasm_0A]>>8, 0 ;LD A, (BC)
01550A00
82: - 070C 1AFF0000 defb 0x1A, 0xFF, 0x00, 0x00, 1, [dasm_1A], [dasm_1A]>>8, 0 ;LD A, (DE)
015F0A00
83: - 0714 3AFF0000 defb 0x3A, 0xFF, 0x00, 0x00, 3, [dasm_3A], [dasm_3A]>>8, 2, 0x09, 0x80 ;LD A, (nn)
03690A02
0980
84: - 071E 02FF0000 defb 0x02, 0xFF, 0x00, 0x00, 1, [dasm_02], [dasm_02]>>8, 0 ;LD (BC), A
01730A00
85: - 0726 12FF0000 defb 0x12, 0xFF, 0x00, 0x00, 1, [dasm_12], [dasm_12]>>8, 0 ;LD (DE), A
017E0A00
86: - 072E 32FF0000 defb 0x32, 0xFF, 0x00, 0x00, 3, [dasm_32], [dasm_32]>>8, 2, 0x09, 0x80 ;LD (nn), A
03890A02
0980
87: - 0738 EDFF57FF defb 0xED, 0xFF, 0x57, 0xFF, 2, [dasm__ED_57], [dasm__ED_57]>>8, 0 ;LD A, I
02980A00
88: - 0740 EDFF5FFF defb 0xED, 0xFF, 0x5F, 0xFF, 2, [dasm__ED_5F], [dasm__ED_5F]>>8, 0 ;LD A, R
02A00A00
89: - 0748 EDFF47FF defb 0xED, 0xFF, 0x47, 0xFF, 2, [dasm__ED_47], [dasm__ED_47]>>8, 0 ;LD I, A
02A80A00
90: - 0750 EDFF4FFF defb 0xED, 0xFF, 0x4F, 0xFF, 2, [dasm__ED_4F], [dasm__ED_4F]>>8, 0 ;LD R, A
02B00A00
91:
92: - 0758 06C70000 defb 0x06, 0xC7, 0x00, 0x00, 2, [dasm__LD], [dasm__LD]>>8, 2, 0x06, 0x08 ;LD r, n
02940A02
0608
93: - 0762 40C00000 defb 0x40, 0xC0, 0x00, 0x00, 1, [dasm__LD], [dasm__LD]>>8, 2, 0x06, 0x07 ;LD r, r' / LD r, (HL) / LD (HL), r
01940A02
0607
94:
95: ;8-Bit Arithmetic Group
96: - 076C 80F80000 defb 0x80, 0xF8, 0x00, 0x00, 1, [dasm_80C6], [dasm_80C6]>>8, 1, 0x07 ;ADD A, r / ADD A, (HL)
01490B01
07
97: - 0775 C6FF0000 defb 0xC6, 0xFF, 0x00, 0x00, 2, [dasm_80C6], [dasm_80C6]>>8, 1, 0x08 ;ADD A, n
02490B01
08
98: - 077E DDFF86FF defb 0xDD, 0xFF, 0x86, 0xFF, 3, [dasm_DD_86], [dasm_DD_86]>>8, 2, 0x08, 0x80 ;ADD A, (IX + d)
03510B02
0880
99: - 0788 FDFF86FF defb 0xFD, 0xFF, 0x86, 0xFF, 3, [dasm_FD_86], [dasm_FD_86]>>8, 2, 0x08, 0x80 ;ADD A, (IY + d)
03600B02
0880
100: - 0792 C8F80000 defb 0xC8, 0xF8, 0x00, 0x00, 1, [dasm_C88E], [dasm_C88E]>>8, 1, 0x07 ;ADC A, r / ADC A, (HL)
016F0B01
07
101: - 079B 8EF80000 defb 0x8E, 0xF8, 0x00, 0x00, 2, [dasm_C88E], [dasm_C88E]>>8, 1, 0x08 ;ADC A, n
026F0B01
08
102: - 07A4 DDFF8EFF defb 0xDD, 0xFF, 0x8E, 0xFF, 3, [dasm_DD_8E], [dasm_DD_8E]>>8, 2, 0x08, 0x80 ;ADC A, (IX + d)
03770B02
0880
103: - 07AE FDFF8EFF defb 0xFD, 0xFF, 0x8E, 0xFF, 3, [dasm_FD_8E], [dasm_FD_8E]>>8, 2, 0x08, 0x80 ;ADC A, (IY + d)
03860B02
0880
104: - 07B8 90F80000 defb 0x90, 0xF8, 0x00, 0x00, 1, [dasm__SUB], [dasm__SUB]>>8, 1, 0x07 ;SUB r / SUB A, (HL)
01950B01
07
105: - 07C1 D6FF0000 defb 0xD6, 0xFF, 0x00, 0x00, 2, [dasm__SUB], [dasm__SUB]>>8, 1, 0x08 ;SUB n
02950B01
08
106: - 07CA DDFF96FF defb 0xDD, 0xFF, 0x96, 0xFF, 3, [dasm_DD_96], [dasm_DD_96]>>8, 2, 0x08, 0x80 ;SUB (IX + d)
039A0B02
0880
107: - 07D4 FDFF96FF defb 0xFD, 0xFF, 0x96, 0xFF, 3, [dasm_FD_96], [dasm_FD_96]>>8, 2, 0x08, 0x80 ;SUB (IY + d)
03A60B02
0880
108: - 07DE 94F80000 defb 0x94, 0xF8, 0x00, 0x00, 1, [dasm__SBC], [dasm__SBC]>>8, 1, 0x07 ;SBC A,r / SBC A, (HL)
01B20B01
07
109: - 07E7 DEFF0000 defb 0xDE, 0xFF, 0x00, 0x00, 2, [dasm__SBC], [dasm__SBC]>>8, 1, 0x08 ;SBC A,n
02B20B01
08
110: - 07F0 DDFF9EFF defb 0xDD, 0xFF, 0x9E, 0xFF, 3, [dasm_DD_9E], [dasm_DD_9E]>>8, 2, 0x08, 0x80 ;SBC A,(IX + d)
03BA0B02
0880
111: - 07FA FDFF9EFF defb 0xFD, 0xFF, 0x9E, 0xFF, 3, [dasm_FD_9E], [dasm_FD_9E]>>8, 2, 0x08, 0x80 ;SBC A,(IY + d)
03C80B02
0880
112: - 0804 A0F80000 defb 0xA0, 0xF8, 0x00, 0x00, 1, [dasm__AND], [dasm__AND]>>8, 1, 0x07 ;AND A,r / AND A, (HL)
01D60B01
07
113: - 080D E6FF0000 defb 0xE6, 0xFF, 0x00, 0x00, 2, [dasm__AND], [dasm__AND]>>8, 1, 0x08 ;AND A,n
02D60B01
08
114: - 0816 DDFFA6FF defb 0xDD, 0xFF, 0xA6, 0xFF, 3, [dasm_DD_A6], [dasm_DD_A6]>>8, 2, 0x08, 0x80 ;AND A,(IX + d)
03DB0B02
0880
115: - 0820 FDFFA6FF defb 0xFD, 0xFF, 0xA6, 0xFF, 3, [dasm_FD_A6], [dasm_FD_A6]>>8, 2, 0x08, 0x80 ;AND A,(IY + d)
03E70B02
0880
116: - 082A B0F80000 defb 0xB0, 0xF8, 0x00, 0x00, 1, [dasm__OR], [dasm__OR]>>8, 1, 0x07 ;OR A,r / OR A, (HL)
01F30B01
07
117: - 0833 F6FF0000 defb 0xF6, 0xFF, 0x00, 0x00, 2, [dasm__OR], [dasm__OR]>>8, 1, 0x08 ;OR A,n
02F30B01
08
118: - 083C DDFFB6FF defb 0xDD, 0xFF, 0xB6, 0xFF, 3, [dasm_DD_B6], [dasm_DD_B6]>>8, 2, 0x08, 0x80 ;OR A,(IX + d)
03F70B02
0880
119: - 0846 FDFFB6FF defb 0xFD, 0xFF, 0xB6, 0xFF, 3, [dasm_FD_B6], [dasm_FD_B6]>>8, 2, 0x08, 0x80 ;OR A,(IY + d)
03020C02
0880
120: - 0850 A8F80000 defb 0xA8, 0xF8, 0x00, 0x00, 1, [dasm__XOR], [dasm__XOR]>>8, 1, 0x07 ;XOR A,r / XOR A, (HL)
010D0C01
07
121: - 0859 EEFF0000 defb 0xEE, 0xFF, 0x00, 0x00, 2, [dasm__XOR], [dasm__XOR]>>8, 1, 0x08 ;XOR A,n
020D0C01
08
122: - 0862 DDFFAEFF defb 0xDD, 0xFF, 0xAE, 0xFF, 3, [dasm_DD_AE], [dasm_DD_AE]>>8, 2, 0x08, 0x80 ;XOR A,(IX + d)
03120C02
0880
123: - 086C FDFFAEFF defb 0xFD, 0xFF, 0xAE, 0xFF, 3, [dasm_FD_AE], [dasm_FD_AE]>>8, 2, 0x08, 0x80 ;XOR A,(IY + d)
031E0C02
0880
124: - 0876 B8F80000 defb 0xB8, 0xF8, 0x00, 0x00, 1, [dasm__CP], [dasm__CP]>>8, 1, 0x07 ;CP A,r / CP A, (HL)
012A0C01
07
125: - 087F FEFF0000 defb 0xFE, 0xFF, 0x00, 0x00, 2, [dasm__CP], [dasm__CP]>>8, 1, 0x08 ;CP A,n
022A0C01
08
126: - 0888 DDFFBEFF defb 0xDD, 0xFF, 0xBE, 0xFF, 3, [dasm_DD_BE], [dasm_DD_BE]>>8, 2, 0x08, 0x80 ;CP A,(IX + d)
032E0C02
0880
127: - 0892 FDFFBEFF defb 0xFD, 0xFF, 0xBE, 0xFF, 3, [dasm_FD_BE], [dasm_FD_BE]>>8, 2, 0x08, 0x80 ;CP A,(IY + d)
03390C02
0880
128: - 089C 04C70000 defb 0x04, 0xC7, 0x00, 0x00, 1, [dasm__INC], [dasm__INC]>>8, 1, 0x10 ;INC r / INC (HL)
01440C01
10
129: - 08A5 DDFF34FF defb 0xDD, 0xFF, 0x34, 0xFF, 3, [dasm_DD_34], [dasm_DD_34]>>8, 2, 0x08, 0x80 ;INC (IX + d)
03490C02
0880
130: - 08AF FDFF34FF defb 0xFD, 0xFF, 0x34, 0xFF, 3, [dasm_FD_34], [dasm_FD_34]>>8, 2, 0x08, 0x80 ;INC (IY + d)
03550C02
0880
131: - 08B9 05C70000 defb 0x05, 0xC7, 0x00, 0x00, 1, [dasm__DEC], [dasm__DEC]>>8, 1, 0x10 ;DEC r / DEC (HL)
01610C01
10
132: - 08C2 DDFF35FF defb 0xDD, 0xFF, 0x35, 0xFF, 3, [dasm_DD_35], [dasm_DD_35]>>8, 2, 0x08, 0x80 ;DEC (IX + d)
03660C02
0880
133: - 08CC FDFF35FF defb 0xFD, 0xFF, 0x35, 0xFF, 3, [dasm_FD_35], [dasm_FD_35]>>8, 2, 0x08, 0x80 ;DEC (IY + d)
03720C02
0880
134: ;16-Bit Arithmetic Group
135: - 08D6 09CF0000 defb 0x09, 0xCF, 0x00, 0x00, 1, [dasm_09], [dasm_09]>>8, 1, 0x11 ;ADD HL, ss
017E0C01
11
136: - 08DF EDFF4ACF defb 0xED, 0xFF, 0x4A, 0xCF, 2, [dasm_ED_4A], [dasm_ED_4A]>>8, 1, 0x12 ;ADC HL, ss
02870C01
12
137: - 08E8 EDFF42CF defb 0xED, 0xFF, 0x42, 0xCF, 2, [dasm_ED_42], [dasm_ED_42]>>8, 1, 0x12 ;SBC HL, ss
02900C01
12
138: - 08F1 DDFF09CF defb 0xDD, 0xFF, 0x09, 0xCF, 2, [dasm_DD_09], [dasm_DD_09]>>8, 1, 0x12 ;ADD IX, ss
02990C01
12
139: - 08FA FDFF09CF defb 0xFD, 0xFF, 0x09, 0xCF, 2, [dasm_FD_09], [dasm_FD_09]>>8, 1, 0x12 ;ADD IY, ss
02A20C01
12
140: - 0903 03CF0000 defb 0x03, 0xCF, 0x00, 0x00, 1, [dasm_03], [dasm_03]>>8, 1, 0x11 ;INC ss
01AB0C01
11
141: - 090C DDFF23FF defb 0xDD, 0xFF, 0x23, 0xFF, 2, [dasm_DD_23], [dasm_DD_23]>>8, 0 ;INC IX
02B00C00
142: - 0914 FDFF23FF defb 0xFD, 0xFF, 0x23, 0xFF, 2, [dasm_FD_23], [dasm_FD_23]>>8, 0 ;INC IY
02B90C00
143: - 091C 0BCF0000 defb 0x0B, 0xCF, 0x00, 0x00, 1, [dasm_0B], [dasm_0B]>>8, 1, 0x11 ;DEC ss
01C20C01
11
144: - 0925 DDFF2BFF defb 0xDD, 0xFF, 0x2B, 0xFF, 2, [dasm_DD_2B], [dasm_DD_2B]>>8, 0 ;DEC IX
02C70C00
145: - 092D FDFF2BFF defb 0xFD, 0xFF, 0x2B, 0xFF, 2, [dasm_FD_2B], [dasm_FD_2B]>>8, 0 ;DEC IY
02D00C00
146: ;16-Bit Load Group
147: - 0935 01CF0000 defb 0x01, 0xCF, 0x00, 0x00, 3, [dasm_01], [dasm_01]>>8, 3, 0x11, 0x80, 0x09 ;LD dd, nn
03D90C03
118009
148: - 0940 DDFF21FF defb 0xDD, 0xFF, 0x21, 0xFF, 4, [dasm_DD_01], [dasm_DD_01]>>8, 1, 0x0A ;LD IX, nn
04E00C01
0A
149: - 0949 FDFF21FF defb 0xFD, 0xFF, 0x21, 0xFF, 4, [dasm_FD_01], [dasm_FD_01]>>8, 1, 0x0A ;LD IY, nn
04E80C01
0A
150: - 0952 2AFF0000 defb 0x2A, 0xFF, 0x00, 0x00, 3, [dasm_2A], [dasm_2A]>>8, 2, 0x09, 0x80 ;LD HL, (nn)
03F00C02
0980
151: - 095C EDFF4BCF defb 0xED, 0xFF, 0x4B, 0xCF, 4, [dasm_ED_4B], [dasm_ED_4B]>>8, 4, 0x12, 0x80, 0x0A, 0x81 ;LD dd, (nn)
04FC0C04
12800A81
152: - 0968 DDFF2AFF defb 0xDD, 0xFF, 0x2A, 0xFF, 4, [dasm_DD_2A], [dasm_DD_2A]>>8, 1, 0x0A ;LD IX, (nn)
04070D01
0A
153: - 0971 FDFF2AFF defb 0xFD, 0xFF, 0x2A, 0xFF, 4, [dasm_FD_2A], [dasm_FD_2A]>>8, 1, 0x0A ;LD IY, (nn)
04130D01
0A
154: - 097A 22FF0000 defb 0x22, 0xFF, 0x00, 0x00, 3, [dasm_22], [dasm_22]>>8, 2, 0x0A, 0x80 ;LD (nn), HL
031F0D02
0A80
155: - 0984 EDFF43CF defb 0xED, 0xFF, 0x43, 0xCF, 4, [dasm_ED_43], [dasm_ED_43]>>8, 3, 0x0A, 0x80, 0x12 ;LD (nn), dd
042B0D03
0A8012
156: - 098F DDFF22CF defb 0xDD, 0xFF, 0x22, 0xCF, 4, [dasm_DD_22], [dasm_DD_22]>>8, 2, 0x0A, 0x80 ;LD (nn), IX
04350D02
0A80
157: - 0999 FDFF22CF defb 0xFD, 0xFF, 0x22, 0xCF, 4, [dasm_FD_22], [dasm_FD_22]>>8, 2, 0x0A, 0x80 ;LD (nn), IY
04410D02
0A80
158: - 09A3 F9FF0000 defb 0xF9, 0xFF, 0x00, 0x00, 1, [dasm_F9], [dasm_F9]>>8, 0 ;LD SP, HL
014D0D00
159: - 09AB DDFFF9FF defb 0xDD, 0xFF, 0xF9, 0xFF, 2, [dasm_DD_F9], [dasm_DD_F9]>>8, 0 ;LD SP, IX
02570D00
160: - 09B3 FDFFF9FF defb 0xFD, 0xFF, 0xF9, 0xFF, 2, [dasm_FD_F9], [dasm_FD_F9]>>8, 0 ;LD SP, IY
02610D00
161: - 09BB C5CF0000 defb 0xC5, 0xCF, 0x00, 0x00, 1, [dasm_E5], [dasm_E5]>>8, 1, 0x13 ;PUSH qq
016B0D01
13
162: - 09C4 DDFFE5FF defb 0xDD, 0xFF, 0xE5, 0xFF, 2, [dasm_DD_E5], [dasm_DD_E5]>>8, 0 ;PUSH IX
02710D00
163: - 09CC FDFFE5FF defb 0xFD, 0xFF, 0xE5, 0xFF, 2, [dasm_FD_E5], [dasm_FD_E5]>>8, 0 ;PUSH IY
02790D00
164: - 09D4 C1CF0000 defb 0xC1, 0xCF, 0x00, 0x00, 1, [dasm_E1], [dasm_E1]>>8, 1, 0x13 ;POP qq
01810D01
13
165: - 09DD DDFFE1FF defb 0xDD, 0xFF, 0xE1, 0xFF, 2, [dasm_DD_E1], [dasm_DD_E1]>>8, 0 ;POP IX
02870D00
166: - 09E5 FDFFE1FF defb 0xFD, 0xFF, 0xE1, 0xFF, 2, [dasm_FD_E1], [dasm_FD_E1]>>8, 0 ;POP IY
028F0D00
167:
168:
169: - 09ED 4E4F5000 dasm_00: db "NOP",0x00
170: ;JUMP Group
171: - 09F1 4A502000 dasm_C3: db "JP ",0x00,", ",0x00
2C2000
172: - 09F8 4A522000 dasm_18: db "JR ",0x00
173: - 09FC 4A522043 dasm_38: db "JR C, ",0x00
2C2000
174: - 0A03 4A52204E dasm_30: db "JR NC, ",0x00
432C2000
175: - 0A0B 4A52205A dasm_28: db "JR Z, ",0x00
2C2000
176: - 0A12 4A52204E dasm_20: db "JR NZ, ",0x00
5A2C2000
177: - 0A1A 4A502028 dasm_E9: db "JP (HL) ",0x00
484C2920
00
178: - 0A23 4A502028 dasm_DD: db "JP (IX) ",0x00
49582920
00
179: - 0A2C 4A502028 dasm_FD: db "JP (IY) ",0x00
49592920
00
180: - 0A35 444A4E5A dasm_10: db "DJNZ ",0x00
2000
181: ;Call and Return Group
182: - 0A3B 43414C4C dasm_CD: db "CALL ",0x00
2000
183: - 0A41 52455420 dasm_C9: db "RET ",0x00
00
184: - 0A46 52455449 dasm_ED_4D: db "RETI",0x00
00
185: - 0A4B 5245544E dasm_ED_45: db "RETN",0x00
00
186: - 0A50 52535420 dasm_FF: db "RST ",0x00
00
187: ;8-Bit load group
188: - 0A55 4C442041 dasm_0A: db "LD A,(BC)",0x00
2C284243
2900
189: - 0A5F 4C442041 dasm_1A: db "LD A,(DE)",0x00
2C284445
2900
190: - 0A69 4C442041 dasm_3A: db "LD A,(",0x00, "h)",0x00
2C280068
2900
191: - 0A73 4C442028 dasm_02: db "LD (BC), A",0x00
4243292C
204100
192: - 0A7E 4C442028 dasm_12: db "LD (DE), A",0x00
4445292C
204100
193: - 0A89 4C442028 dasm_32: db "LD (",0x00, "h), A",0x00
0068292C
204100
194: - 0A94 4C442000 dasm__LD: db "LD ",0x00
195: - 0A98 4C442041 dasm__ED_57: db "LD A, I",0x00
2C204900
196: - 0AA0 4C442041 dasm__ED_5F: db "LD A, R",0x00
2C205200
197: - 0AA8 4C442049 dasm__ED_47: db "LD I, A",0x00
2C204100
198: - 0AB0 4C442052 dasm__ED_4F: db "LD R, A",0x00
2C204100
199: ;General-Purpose Arithmetic and CPU Control Groups
200: - 0AB8 44414100 dasm_27: db "DAA",0x00
201: - 0ABC 43504C00 dasm_2F: db "CPL",0x00
202: - 0AC0 4E454700 dasm_ED_44: db "NEG",0x00
203: - 0AC4 43434600 dasm_3F: db "CCF",0x00
204: - 0AC8 53434600 dasm_37: db "SCF",0x00
205: - 0ACC 48414C54 dasm_76: db "HALT",0x00
00
206: - 0AD1 444900 dasm_F3: db "DI",0x00
207: - 0AD4 454900 dasm_FB: db "EI",0x00
208: - 0AD7 494D2030 dasm_ED_46: db "IM 0",0x00
00
209: - 0ADC 494D2031 dasm_ED_56: db "IM 1",0x00
00
210: - 0AE1 494D2032 dasm_ED_5E: db "IM 2",0x00
00
211: ;Exchange, Block Transfer, and Search Group
212: - 0AE6 45582044 dasm_BE: db "EX DE, HL",0x00
452C2048
4C00
213: - 0AF0 45582041 dasm_08: db "EX AF, AF",0x00
462C2041
46E280B2
00
214: - 0AFD 45585800 dasm_D9: db "EXX",0x00
215: - 0B01 45582028 dasm_E3: db "EX (SP), HL",0x00
5350292C
20484C00
216: - 0B0D 45582028 dasm_DD_E3: db "EX (SP), IX",0x00
5350292C
20495800
217: - 0B19 45582028 dasm_FD_E3: db "EX (SP), IY",0x00
5350292C
20495900
218: - 0B25 4C444900 dasm_ED_A0: db "LDI",0x00
219: - 0B29 4C444952 dasm_ED_B0: db "LDIR",0x00
00
220: - 0B2E 4C444400 dasm_ED_A8: db "LDD",0x00
221: - 0B32 4C444452 dasm_ED_B8: db "LDDR",0x00
00
222: - 0B37 43504900 dasm_ED_A1: db "CPI",0x00
223: - 0B3B 43504952 dasm_ED_B1: db "CPIR",0x00
00
224: - 0B40 43504400 dasm_ED_A9: db "CPD",0x00
225: - 0B44 43504452 dasm_ED_B9: db "CPDR",0x00
00
226: ;8-Bit Arithmetic Group
227: - 0B49 41444420 dasm_80C6: db "ADD A, ", 0x00
412C2000
228: - 0B51 41444420 dasm_DD_86: db "ADD A, (IX+", 0x00, "h)",0x00
412C2028
49582B00
682900
229: - 0B60 41444420 dasm_FD_86: db "ADD A, (IY+", 0x00, "h)",0x00
412C2028
49592B00
682900
230: - 0B6F 41444320 dasm_C88E: db "ADC A, ", 0x00
412C2000
231: - 0B77 41444320 dasm_DD_8E: db "ADC A, (IX+", 0x00, "h)",0x00
412C2028
49582B00
682900
232: - 0B86 41444320 dasm_FD_8E: db "ADC A, (IY+", 0x00, "h)",0x00
412C2028
49592B00
682900
233: - 0B95 53554220 dasm__SUB: db "SUB ", 0x00
00
234: - 0B9A 53554220 dasm_DD_96: db "SUB (IX+", 0x00, "h)",0x00
2849582B
00682900
235: - 0BA6 53554220 dasm_FD_96: db "SUB (IY+", 0x00, "h)",0x00
2849592B
00682900
236: - 0BB2 53424320 dasm__SBC: db "SBC A, ", 0x00
412C2000
237: - 0BBA 53424320 dasm_DD_9E: db "SBC A,(IX+", 0x00, "h)",0x00
412C2849
582B0068
2900
238: - 0BC8 53424320 dasm_FD_9E: db "SBC A,(IY+", 0x00, "h)",0x00
412C2849
592B0068
2900
239: - 0BD6 414E4420 dasm__AND: db "AND ", 0x00
00
240: - 0BDB 414E4420 dasm_DD_A6: db "AND (IX+", 0x00, "h)",0x00
2849582B
00682900
241: - 0BE7 414E4420 dasm_FD_A6: db "AND (IY+", 0x00, "h)",0x00
2849592B
00682900
242: - 0BF3 4F522000 dasm__OR: db "OR ", 0x00
243: - 0BF7 4F522028 dasm_DD_B6: db "OR (IX+", 0x00, "h)",0x00
49582B00
682900
244: - 0C02 4F522028 dasm_FD_B6: db "OR (IY+", 0x00, "h)",0x00
49592B00
682900
245: - 0C0D 584F5220 dasm__XOR: db "XOR ", 0x00
00
246: - 0C12 584F5220 dasm_DD_AE: db "XOR (IX+", 0x00, "h)",0x00
2849582B
00682900
247: - 0C1E 584F5220 dasm_FD_AE: db "XOR (IY+", 0x00, "h)",0x00
2849592B
00682900
248: - 0C2A 43502000 dasm__CP: db "CP ", 0x00
249: - 0C2E 43502028 dasm_DD_BE: db "CP (IX+", 0x00, "h)",0x00
49582B00
682900
250: - 0C39 43502028 dasm_FD_BE: db "CP (IY+", 0x00, "h)",0x00
49592B00
682900
251: - 0C44 494E4320 dasm__INC: db "INC ", 0x00
00
252: - 0C49 494E4320 dasm_DD_34: db "INC (IX+", 0x00, "h)",0x00
2849582B
00682900
253: - 0C55 494E4320 dasm_FD_34: db "INC (IY+", 0x00, "h)",0x00
2849592B
00682900
254: - 0C61 44454320 dasm__DEC: db "DEC ", 0x00
00
255: - 0C66 44454320 dasm_DD_35: db "DEC (IX+", 0x00, "h)",0x00
2849582B
00682900
256: - 0C72 44454320 dasm_FD_35: db "DEC (IY+", 0x00, "h)",0x00
2849592B
00682900
257: ;16-Bit Arithmetic Group
258: - 0C7E 41444420 dasm_09: db "ADD HL, ",0x00
484C2C20
00
259: - 0C87 41444320 dasm_ED_4A: db "ADC HL, ",0x00
484C2C20
00
260: - 0C90 53424320 dasm_ED_42: db "SBC HL, ",0x00
484C2C20
00
261: - 0C99 41444420 dasm_DD_09: db "ADD IX, ",0x00
49582C20
00
262: - 0CA2 41444420 dasm_FD_09: db "ADD IY, ",0x00
49592C20
00
263: - 0CAB 494E4320 dasm_03: db "INC ",0x00
00
264: - 0CB0 494E4320 dasm_DD_23: db "INC IX, ",0x00
49582C20
00
265: - 0CB9 494E4320 dasm_FD_23: db "INC IY, ",0x00
49592C20
00
266: - 0CC2 44454320 dasm_0B: db "DEC ",0x00
00
267: - 0CC7 44454320 dasm_DD_2B: db "DEC IX, ",0x00
49582C20
00
268: - 0CD0 44454320 dasm_FD_2B: db "DEC IY, ",0x00
49592C20
00
269: ;16-Bit Load Group
270: - 0CD9 4C442000 dasm_01: db "LD ",0x00, ", ",0x00
2C2000
271: - 0CE0 4C442049 dasm_DD_01: db "LD IX, ",0x00
582C2000
272: - 0CE8 4C442049 dasm_FD_01: db "LD IY, ",0x00
592C2000
273: - 0CF0 4C442048 dasm_2A: db "LD HL, (",0x00,"h)",0x00
4C2C2028
00682900
274: - 0CFC 4C442000 dasm_ED_4B: db "LD ",0x00,", (",0x00,"h)",0x00
2C202800
682900
275: - 0D07 4C442049 dasm_DD_2A: db "LD IX, (",0x00,"h)",0x00
582C2028
00682900
276: - 0D13 4C442049 dasm_FD_2A: db "LD IY, (",0x00,"h)",0x00
592C2028
00682900
277: - 0D1F 4C442028 dasm_22: db "LD (",0x00,"h), HL",0x00
0068292C
20484C00
278: - 0D2B 4C442028 dasm_ED_43: db "LD (",0x00,"h), ",0x00
0068292C
2000
279: - 0D35 4C442028 dasm_DD_22: db "LD (",0x00,"h), IX",0x00
0068292C
20495800
280: - 0D41 4C442028 dasm_FD_22: db "LD (",0x00,"h), IY",0x00
0068292C
20495900
281: - 0D4D 4C442053 dasm_F9: db "LD SP, HL",0x00
502C2048
4C00
282: - 0D57 4C442053 dasm_DD_F9: db "LD SP, IX",0x00
502C2049
5800
283: - 0D61 4C442053 dasm_FD_F9: db "LD SP, IY",0x00
502C2049
5900
284: - 0D6B 50555348 dasm_E5: db "PUSH ",0x00
2000
285: - 0D71 50555348 dasm_DD_E5: db "PUSH IX",0x00
20495800
286: - 0D79 50555348 dasm_FD_E5: db "PUSH IY",0x00
20495900
287: - 0D81 50555348 dasm_E1: db "PUSH ",0x00
2000
288: - 0D87 50555348 dasm_DD_E1: db "PUSH IX",0x00
20495800
289: - 0D8F 50555348 dasm_FD_E1: db "PUSH IY",0x00
20495900
290:
291: ;Misc
292: - 0D97 2E3F2E00 dasm_UU: db ".?.",0x00
293: - 0D9B 20202020 dasm_UW: db " ",0x00
00
294:
295: - 0DA0 dasm_printFlags_table:
296: - 0DA0 4E5A db "NZ"
297: - 0DA2 5A00 db "Z",0
298: - 0DA4 4E43 db "NC"
299: - 0DA6 4300 db "C",0
300: - 0DA8 504F db "PO"
301: - 0DAA 5045 db "PE"
302: - 0DAC 5000 db "P",0
303: - 0DAE 4D00 db "M",0
304:
305: - 0DB0 dasm_printRegister8_table:
306: - 0DB0 42 db "B"
307: - 0DB1 43 db "C"
308: - 0DB2 44 db "D"
309: - 0DB3 45 db "E"
310: - 0DB4 48 db "H"
311: - 0DB5 4C db "L"
312: - 0DB6 53 db "S" ;only 18 bit (SP)
313: - 0DB7 50 db "P" ;only 18 bit (SP)
314:
315: - 0DB8 dasm_printRegisterIX_table:
316: - 0DB8 4243 db "BC"
317: - 0DBA 4445 db "DE"
318: - 0DBC 4958 db "IX"
319: - 0DBE 5350 db "SP"
320: - 0DC0 dasm_printRegisterIY_table:
321: - 0DC0 4243 db "BC"
322: - 0DC2 4445 db "DE"
323: - 0DC4 4959 db "IY"
324: - 0DC6 5350 db "SP"
325:
326: - 0DC8 dasm_printRegisterSP_table:
327: - 0DC8 4243 db "BC"
328: - 0DCA 4445 db "DE"
329: - 0DCC 484C db "HL"
330: - 0DCE 4146 db "AF"
331:
332: - 0DD0 dasm_printRegister8_table_HL:
**** main.asm ****
185: - 0DD0 28484C29 db "(HL)", 0
00
186: .include "rst.s"
**** include/rst.s ****
1: - 0DD5 EXEC_RST_08:
2: 6945+17 0DD5 CD1501 call print_char
3: 6962+10 0DD8 C9 ret
4:
5:
6: - 0DD9 EXEC_RST_10:
7: 6972+11 0DD9 C5 push bc
8: 6983+11 0DDA D5 push de
9: 6994+11 0DDB E5 push hl
10: ;call vdp_cursor_on
11: 7005+17 0DDC CD5B01 call read_char
12: 7022+11 0DDF F5 push af
13: ;call vdp_cursor_off
14: 7033+10 0DE0 F1 pop af
15: 7043+10 0DE1 E1 pop hl
16: 7053+10 0DE2 D1 pop de
17: 7063+10 0DE3 C1 pop bc
18: 7073+10 0DE4 C9 ret
19:
20: - 0DE5 EXEC_RST_18:
21: 7083+7 0DE5 3E00 ld a,0
22: 7090+10 0DE7 C9 ret
**** main.asm ****
187: .include "beep.s"
**** include/beep.s ****
1: ;------------------------------------------------------------------------------
2: ; beep
3: ;
4: ; Beeps the speaker
5: ; DE sets duration
6: ;------------------------------------------------------------------------------
7: - 0DE8 beep:
8: 7100+11 0DE8 F5 push AF
9: 7111+11 0DE9 D5 push DE
10: - 0DEA beep_loop:
11: 7122+7 0DEA 3E08 LD A,0x08
12: 7129+11 0DEC D3F4 OUT (CS_PIO_AD), A
13: 7140+17 0DEE CD000E CALL beep_pause
14: 7157+7 0DF1 3E00 LD A,0x00
15: 7164+11 0DF3 D3F4 OUT (CS_PIO_AD), A
16: 7175+17 0DF5 CD000E CALL beep_pause
17: 7192+6 0DF8 1B DEC DE
18: 7198+4 0DF9 7A ld A,D
19: 7202+4 0DFA B3 or E
20: 7206+7+5 0DFB 20ED jr NZ, beep_loop
21: 7213+10 0DFD D1 pop de
22: 7223+10 0DFE F1 pop af
23: 7233+10 0DFF C9 ret
24:
25: - 0E00 beep_pause:
26: 7243+11 0E00 C5 PUSH BC
27: - 0E01 _beep_pause_l1:
28: ;NEG ; 8 T-states
29: ;NEG ; 8 T-states
30: 7254+8 0E01 ED44 NEG ; 8 T-states
31: 7262+8 0E03 ED44 NEG ; 8 T-states
32: 7270+6 0E05 0B DEC BC ; 6 T-states
33: 7276+4 0E06 79 LD A,C ; 9 T-states
34: 7280+4 0E07 B0 OR B ; 4 T-states
35: 7284+10 0E08 C2010E JP NZ,_beep_pause_l1 ; 10 T-states
36: 7294+10 0E0B C1 POP BC
**** main.asm ****
188: 7304+10 0E0C C9 RET ; Pause complete, RETurn
189: .include "kdrv_ide8255.s" ;include ide interface driver.
**** include/kdrv_ide8255.s ****
1: ;----------------------------------------------------------------
2: ;BIOS Driver for IDE Interface 82C55
3: ;by Dennis Gunia (01/2023)
4: ;----------------------------------------------------------------
5:
6: ;================================================================
7: ; I/O registers
8: ;================================================================
9: - 0030 CS_PIA_PA .EQU 0x30 ; D0-7
10: - 0031 CS_PIA_PB .EQU 0x31 ; D8-15
11: - 0032 CS_PIA_PC .EQU 0x32 ; Controll Lines
12: - 0033 CS_PIA_CR .EQU 0x33
13:
14: ;================================================================
15: ; I/O pins
16: ;================================================================
17: - 0020 IDE_WR .EQU 00100000b
18: - 0040 IDE_RD .EQU 01000000b
19: - 0080 IDE_RST .EQU 10000000b
20:
21: ;================================================================
22: ; IDE registers
23: ;================================================================
24: - 0008 IDE_REG_DATA .EQU 01000b ;data I/O register (16-bits)
25: - 0009 IDE_REG_ERROR .EQU 01001b ;error information register when read; write precompensation register when written.
26: - 000A IDE_REG_SECTOR .EQU 01010b ;Sector counter register
27: - 000B IDE_REG_SSECTOR .EQU 01011b ;Start sector register
28: - 000C IDE_REG_LCYL .EQU 01100b ;Low byte of the cylinder number
29: - 000D IDE_REG_HCYL .EQU 01101b ;High two bits of the cylinder number
30: - 000E IDE_REG_HEAD .EQU 01110b ;Head and device select register
31: - 000F IDE_REG_CMDSTS .EQU 01111b ;command/status register
32: - 0016 IDE_REG_ALTSTS .EQU 10110b ;Alternate Status/Digital Output
33: - 0017 IDE_REG_DRVADDR .EQU 10111b ;Drive Address
34:
35: - 000B IDE_REG_LBA0 .EQU 01011b ;Start sector register
36: - 000C IDE_REG_LBA1 .EQU 01100b ;Low byte of the cylinder number
37: - 000D IDE_REG_LBA2 .EQU 01101b ;High two bits of the cylinder number
38: - 000E IDE_REG_LBA3 .EQU 01110b ;Head and device select register
39:
40: ide_wait_rdy macro
41: local wait
42: wait:
43: ld b, IDE_REG_CMDSTS
44: call ide_regread_8
45: rla
46: jr c, wait
47: endm
48:
49: ide_wait_drq macro
50: local wait
51: wait:
52: ld b, IDE_REG_CMDSTS
53: call ide_regread_8
54: bit 0,a ;Error Bit set.
55: jp nz, ide_printerror
56: bit 3,a
57: jr z,wait
58: endm
59:
60:
61: ;================================================================
62: ; I/O access functions
63: ;================================================================
64:
65: ;------------------------------------------------------------------------------
66: ; ide_reset
67: ;
68: ; resets drives on bus
69: ;------------------------------------------------------------------------------
70: - 0E0D ide_reset:
71:
72: 7314+7 0E0D 3E80 LD A, 10000000b ;CommandByte-A, Mode 0, PA Out, PC Out, PB Out
73: 7321+11 0E0F D333 OUT (CS_PIA_CR), A ;Set Data direction to out
74: 7332+7 0E11 3E80 LD A, IDE_RST
75: 7339+11 0E13 D332 OUT (CS_PIA_PC), A ;Reset IDE Device
76: 7350+4 0E15 AF XOR A
77: 7354+11 0E16 D332 OUT (CS_PIA_PC), A ;end device reset
78: 7365+10 0E18 C9 RET
79:
80:
81: ;------------------------------------------------------------------------------
82: ; ide_regwrite_8
83: ;
84: ; Sends data to the IDE device
85: ; A contains DATA
86: ; B contains register number
87: ;------------------------------------------------------------------------------
88: - 0E19 ide_regwrite_8:
89: 7375+11 0E19 F5 PUSH AF ;store date to stack
90: ; Prepare PIA Data Direction
91: 7386+7 0E1A 3E80 LD A, 10000000b ;CommandByte-A, Mode 0, PA Out, PC Out, PB Out
92: 7393+11 0E1C D333 OUT (CS_PIA_CR), A ;Set Data direction to out
93: ; Write Data out
94: 7404+10 0E1E F1 POP AF
95: 7414+11 0E1F D330 OUT (CS_PIA_PA), A ;Write Data to bit 0-7
96: ;Prepare Address
97: 7425+4 0E21 78 LD A, B ;Load register address
98: 7429+7 0E22 E61F AND 00011111b ;Mask unused bits
99: 7436+11 0E24 D332 OUT (CS_PIA_PC), A ;Write Data to bit controll lines
100: 7447+7 0E26 F620 OR IDE_WR ;Set Write bit
101: 7454+11 0E28 D332 OUT (CS_PIA_PC), A ;Set write signal
102: ;NOP ;delay to wait for processing
103: 7465+4 0E2A 78 LD A, B ;Load register address
104: 7469+7 0E2B E61F AND 00011111b ;Mask unused bits
105: 7476+11 0E2D D332 OUT (CS_PIA_PC), A ;disable write signal
106: ;NOP
107: 7487+4 0E2F AF XOR A ;clear register A
108: 7491+11 0E30 D332 OUT (CS_PIA_PC), A ;clear controll lines
109: 7502+10 0E32 C9 RET
110:
111:
112: ;------------------------------------------------------------------------------
113: ; ide_regread_8
114: ;
115: ; Sends data to the IDE device
116: ; B contains register number
117: ; A returns data
118: ;------------------------------------------------------------------------------
119: - 0E33 ide_regread_8:
120: 7512+7 0E33 3E92 LD A, 10010010b ;CommandByte-A, Mode 0, PA IN, PC Out, PB IN
121: 7519+11 0E35 D333 OUT (CS_PIA_CR), A ;Set Data direction to in
122: ;Prepare Address
123: 7530+4 0E37 78 LD A, B ;Load register address
124: 7534+7 0E38 E61F AND 00011111b ;Mask unused bits
125: 7541+11 0E3A D332 OUT (CS_PIA_PC), A ;Write Data to bit controll lines
126: 7552+7 0E3C F640 OR IDE_RD ;Set Write bit
127: 7559+11 0E3E D332 OUT (CS_PIA_PC), A ;Write Data to bit controll lines
128: 7570+4 0E40 00 NOP
129: 7574+11 0E41 DB30 IN A,(CS_PIA_PA) ;read data from ide device to b (because a is used later)
130: 7585+11 0E43 F5 PUSH AF
131: 7596+4 0E44 AF XOR A ;clear register A
132: 7600+11 0E45 D332 OUT (CS_PIA_PC), A ;clear controll lines
133: 7611+10 0E47 F1 POP AF ;put data in accumulator
134: 7621+10 0E48 C9 RET
135:
136: ;------------------------------------------------------------------------------
137: ; ide_readsector_512_fast
138: ;
139: ; Reads IDE Data until no more data is available (multiple sectors)
140: ; HL contains destination address
141: ; A returns 0 on success, 1 on error
142: ;------------------------------------------------------------------------------
143: - 0E49 ide_readsector_512_fast:
144: 7631+7 0E49 060F ld b, IDE_REG_CMDSTS ;check status
145: 7638+17 0E4B CD330E call ide_regread_8
146: 7655+8 0E4E CB47 bit 0,a ;Error Bit set
147: 7663+10 0E50 C2940E jp nz, ide_printerror ;then abort
148: 7673+8 0E53 CB5F bit 3,a ;wait for drq
149: 7681+7+5 0E55 28F2 jr z,ide_readsector_512_fast
150: 7688+7 0E57 0600 ld b,0 ;256x
151: 7695+7 0E59 3E92 ld a, 10010010b ;CommandByte-A, Mode 0, PA IN, PC Out, PB IN
152: 7702+11 0E5B D333 out (CS_PIA_CR), a ;Set Data direction to IN
153: - 0E5D _ide_readsector_512_floop:
154: 7713+7 0E5D 3E08 ld a, IDE_REG_DATA ;CS0 and A=0 -> I/O register
155: 7720+11 0E5F D332 out (CS_PIA_PC), a ;set register
156: 7731+7 0E61 F640 or IDE_RD ;Set Read bit
157: 7738+11 0E63 D332 out (CS_PIA_PC), a ;Write Read to bit controll lines
158: 7749+11 0E65 DB30 in a,(CS_PIA_PA) ;load first byte
159: 7760+7 0E67 77 ld (hl), a
160: 7767+6 0E68 23 inc hl
161: 7773+11 0E69 DB31 in a,(CS_PIA_PB) ;load second byte
162: 7784+7 0E6B 77 ld (hl), a
163: 7791+6 0E6C 23 inc hl
164: 7797+8+5 0E6D 10EE djnz _ide_readsector_512_floop ;loop 256 times (256words = 512 bytes)
165: 7805+7 0E6F 060F ld b, IDE_REG_CMDSTS;check drive status
166: 7812+17 0E71 CD330E call ide_regread_8 ;
167: 7829+7 0E74 E689 and 10001001b ;busy, DRQ, or error?
168: 7836+5+6 0E76 C8 ret z ;no more data or errors -> exit
169: 7841+8 0E77 CB5F bit 3,a ;test if more data available
170: 7849+7+5 0E79 20CE jr nz,ide_readsector_512_fast ;if true, repeat read function
171: 7856+10 0E7B C3940E jp ide_printerror ;else exit function
172:
173: - 0E7E ide_readsector_timeout:
174: 7866+10 0E7E 21F80E LD HL, [str_error_time]
175: 7876+17 0E81 CD1D01 CALL print_str
176: 7893+4 0E84 79 LD A, C
177: 7897+17 0E85 CD4301 CALL print_a_hex
178: 7914+7 0E88 3E0A LD A,10
179: 7921+17 0E8A CD1501 CALL print_char
180: 7938+7 0E8D 3E0D LD A,13
181: 7945+17 0E8F CD1501 CALL print_char
182: 7962+10 0E92 C9 RET
183:
184: ;------------------------------------------------------------------------------
185: ; ide_writesector_256
186: ;
187: ; Writes 512 bytes (256 words) of IDE Data
188: ; HL contains data start address
189: ;------------------------------------------------------------------------------
190: - 0E93 ide_writesector_256:
191: 7972+10 0E93 C9 RET ;NOT IMPLEMENTED
192:
193:
194: ;================================================================
195: ; utility functions
196: ;================================================================
197:
198: ;------------------------------------------------------------------------------
199: ; ide_printerror
200: ;
201: ; prints IDE error to console
202: ;------------------------------------------------------------------------------
203: - 0E94 ide_printerror:
204: 7982+10 0E94 21C90E LD HL, [str_error_start]
205: 7992+17 0E97 CD1D01 CALL print_str
206: 8009+7 0E9A 060F LD B, IDE_REG_CMDSTS
207: 8016+17 0E9C CD330E CALL ide_regread_8
208: 8033+17 0E9F CD4301 CALL print_a_hex
209: 8050+10 0EA2 21E60E LD HL, [str_error_start1]
210: 8060+17 0EA5 CD1D01 CALL print_str
211: 8077+13 0EA8 3ACB41 LD A,(MEM_IDE_DEVICE)
212: 8090+17 0EAB CD4301 CALL print_a_hex
213: 8107+10 0EAE 21EF0E LD HL, [str_error_start2]
214: 8117+17 0EB1 CD1D01 CALL print_str
215: 8134+7 0EB4 0609 LD B, IDE_REG_ERROR
216: 8141+17 0EB6 CD330E CALL ide_regread_8
217: 8158+17 0EB9 CD4301 CALL print_a_hex
218: 8175+7 0EBC 3E0A LD A,10
219: 8182+17 0EBE CD1501 CALL print_char
220: 8199+7 0EC1 3E0D LD A,13
221: 8206+17 0EC3 CD1501 CALL print_char
222: 8223+7 0EC6 3E01 LD A,1
223: 8230+10 0EC8 C9 RET
224:
225: - 0EC9 str_error_start:
226: - 0EC9 0D0A4469 db 13,10,"Disk I/O error. Status: 0x",0
736B2049
2F4F2065
72726F72
2E205374
61747573
3A203078
00
227: - 0EE6 str_error_start1:
228: - 0EE6 20446576 db " Dev: 0x",0
3A203078
00
229: - 0EEF str_error_start2:
230: - 0EEF 20457272 db " Err: 0x",0
3A203078
00
231:
232: - 0EF8 str_error_time:
233: - 0EF8 0D0A4469 db 13,10,"Disk I/O error. Data timeout @ 0x",0
736B2049
2F4F2065
72726F72
2E204461
74612074
696D656F
75742040
20307800
**** main.asm ****
190: .include "kdrv_ideif.s" ;include ide driver.
**** include/kdrv_ideif.s ****
1: ;----------------------------------------------------------------
2: ;BIOS Driver for IDE Access
3: ;by Dennis Gunia (01/2023)
4: ;----------------------------------------------------------------
5:
6: ;================================================================
7: ; IDE commands
8: ;================================================================
9: - 00EC IDE_CMD_IDENT .EQU 0xEC ;Identify drive.
10: - 0020 IDE_CMD_READSEC .EQU 0x20 ;Read sectors.
11:
12: ;================================================================
13: ; IDE Variables
14: ;================================================================
15: - 41CB phase var_idebuffer
16: - 41CB MEM_IDE_DEVICE:
17: - 41CB ..41CB 00 defs 1
18: - 41CC MEM_IDE_STATUS:
19: - 41CC ..41CC 00 defs 1 ;1Byte: 0x00 if status is okay
20: - 41CD MEM_IDE_PARTITION:
21: - 41CD ..41D0 00 defs 4 ;4*16Bytes: LBA first sector
22: - 41D1 MEM_IDE_POINTER:
23: - 41D1 ..41D4 00 defs 4 ;4*16Bytes: LBA first sector
24: - 41D5 MEM_IDE_DEV_TABLE:
25: - 41D5 ..4214 00 defs 16*4
26: - 4215 MEM_IDE_SELECTED:
27: - 4215 ..4215 00 defs 1
28: - 4216 MEM_IDE_STRING_0:
29: - 4216 ..423D 00 defs 40
30: - 423E MEM_IDE_STRING_1:
31: - 423E ..4265 00 defs 40
32: - 4266 MEM_IDE_STRING_2:
33: - 4266 ..428D 00 defs 40
34: - 428E MEM_IDE_STRING_3:
35: - 428E ..42B5 00 defs 40
36: - 42B6 MEM_IDE_BUFFER:
37: - 42B6 ..44B5 00 defs 512
38: - 44B6 MEM_IDE_FSBUFFER:
39: - 44B6 ..45B5 00 defs 256
40: - 1307 dephase
41: ;DEV-Table layout
42: ;<STATUS> <TYPE> <FIRST-SECTOR (4-byte)> <Length (4-byte)> <I/O Addr> <Master/Slave> 0x00 0x00
43: ;Status: 0x00 -> Ready
44: ; 0x01 -> Not found
45: ; 0x02 -> No supported filesystem
46: ;I/O Addr: Base addr of 82C55
47: ;Type: File system type
48:
49:
50: - 1307 IDE_DEV_TABLE:
51: - 1307 FF000000 db 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, [MEM_IDE_STRING_0], [MEM_IDE_STRING_0]>>8, 0x00, 0x00
00000000
00003000
16420000
52: - 1317 FF000000 db 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x01, [MEM_IDE_STRING_1], [MEM_IDE_STRING_1]>>8, 0x00, 0x00
00000000
00003001
3E420000
53: - 1327 FF000000 db 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, [MEM_IDE_STRING_2], [MEM_IDE_STRING_2]>>8, 0x00, 0x00
00000000
00004000
66420000
54: - 1337 FF000000 db 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, [MEM_IDE_STRING_3], [MEM_IDE_STRING_3]>>8, 0x00, 0x00
00000000
00004001
8E420000
55:
56: ;================================================================
57: ; IDE funtions
58: ;================================================================
59:
60: ;------------------------------------------------------------------------------
61: ; ideif_init_table
62: ;
63: ; initializes drive table
64: ;------------------------------------------------------------------------------
65: - 1347 ideif_init_devtable:
66: ;copy default values to ram
67: 8240+10 1347 210713 ld hl,[IDE_DEV_TABLE]
68: 8250+10 134A 11D541 ld de,[MEM_IDE_DEV_TABLE]
69: 8260+10 134D 014000 ld bc,16*4
70: 8270+16+5 1350 EDB0 ldir
71: ;set selected device
72: 8286+7 1352 3E00 ld a,0
73: 8293+13 1354 321542 ld (MEM_IDE_SELECTED),a
74: ;set empty names
75: 8306+4 1357 AF xor a
76: 8310+13 1358 321642 ld (MEM_IDE_STRING_0),a
77: 8323+13 135B 323E42 ld (MEM_IDE_STRING_1),a
78: 8336+13 135E 326642 ld (MEM_IDE_STRING_2),a
79: 8349+13 1361 328E42 ld (MEM_IDE_STRING_3),a
80: 8362+10 1364 C9 ret
81:
82: ;------------------------------------------------------------------------------
83: ; ideif_prnt_devtable
84: ;
85: ; prints drive table
86: ;------------------------------------------------------------------------------
87: - 1365 ideif_prnt_devtable:
88: 8372+17 1365 CD2D01 call print_newLine
89: 8389+10 1368 211216 ld hl,[_ideif_prnt_devtable_hdr]
90: 8399+17 136B CD1D01 call print_str
91: 8416+10 136E 21D541 ld hl,[MEM_IDE_DEV_TABLE]
92: 8426+7 1371 0600 ld b,0 ;device number
93: - 1373 _ideif_prnt_devtable_l1: ;loop 1 -> for each device
94: ;print if selected
95: 8433+13 1373 3A1542 ld a,(MEM_IDE_SELECTED)
96: 8446+4 1376 B8 cp b
97: 8450+10 1377 CA7E13 jp z,_ideif_prnt_devtable_l1_sel
98: 8460+7 137A 3E20 ld a, ' '
99: 8467+12 137C 1802 jr _ideif_prnt_devtable_l1_nxt
100: - 137E _ideif_prnt_devtable_l1_sel:
101: 8479+7 137E 3E2A ld a, '*'
102: - 1380 _ideif_prnt_devtable_l1_nxt:
103: 8486+17 1380 CD1501 call print_char
104: ;print drive letter
105: 8503+4 1383 78 ld a,b
106: 8507+7 1384 C645 add 69 ;offset letter to D
107: 8514+17 1386 CD1501 call print_char
108: 8531+7 1389 3E3A ld a, ':'
109: 8538+17 138B CD1501 call print_char
110: 8555+7 138E 3E20 ld a, ' '
111: 8562+17 1390 CD1501 call print_char
112: ;print status
113: 8579+11 1393 E5 push hl
114: 8590+7 1394 7E ld a,(HL)
115: 8597+4 1395 B7 or a
116: 8601+7+5 1396 280E jr z, _ideif_prnt_devtable_l1_s00
117: 8608+7 1398 FE01 cp 0x01
118: 8615+7+5 139A 280F jr z, _ideif_prnt_devtable_l1_s01
119: 8622+7 139C FE02 cp 0x02
120: 8629+7+5 139E 2810 jr z, _ideif_prnt_devtable_l1_s02
121: 8636+7 13A0 FEFF cp 0xFF
122: 8643+7+5 13A2 2811 jr z, _ideif_prnt_devtable_l1_sFF
123: 8650+12 13A4 180F jr _ideif_prnt_devtable_l1_sFF
124: - 13A6 _ideif_prnt_devtable_l1_s00
125: 8662+10 13A6 214A16 ld hl,[_ideif_prnt_devtable_s00]
126: 8672+12 13A9 180D jr _ideif_prnt_devtable_l1_es
127: - 13AB _ideif_prnt_devtable_l1_s01
128: 8684+10 13AB 215516 ld hl,[_ideif_prnt_devtable_s01]
129: 8694+12 13AE 1808 jr _ideif_prnt_devtable_l1_es
130: - 13B0 _ideif_prnt_devtable_l1_s02
131: 8706+10 13B0 216016 ld hl,[_ideif_prnt_devtable_s02]
132: 8716+12 13B3 1803 jr _ideif_prnt_devtable_l1_es
133: - 13B5 _ideif_prnt_devtable_l1_sFF
134: 8728+10 13B5 216B16 ld hl,[_ideif_prnt_devtable_sFF]
135: - 13B8 _ideif_prnt_devtable_l1_es
136: 8738+17 13B8 CD1D01 call print_str
137: 8755+10 13BB E1 pop hl
138: 8765+6 13BC 23 inc hl
139: ;print FS-Type
140: 8771+7 13BD 3E30 ld a,'0'
141: 8778+17 13BF CD1501 call print_char
142: 8795+7 13C2 3E78 ld a,'x'
143: 8802+17 13C4 CD1501 call print_char
144: 8819+7 13C7 7E ld a,(HL)
145: 8826+17 13C8 CD4301 call print_a_hex
146: 8843+7 13CB 3E20 ld a,' '
147: 8850+17 13CD CD1501 call print_char
148: 8867+6 13D0 23 inc hl
149: ;print first sector
150: 8873+11 13D1 E5 push hl
151: 8884+14 13D2 DDE1 pop ix
152:
153: 8898+6 13D4 23 inc hl
154: 8904+6 13D5 23 inc hl
155: 8910+6 13D6 23 inc hl
156: 8916+6 13D7 23 inc hl
157: 8922+6 13D8 23 inc hl
158: 8928+6 13D9 23 inc hl
159: 8934+6 13DA 23 inc hl
160: 8940+6 13DB 23 inc hl
161:
162: 8946+19 13DC DD7E03 ld a,(ix+3)
163: 8965+17 13DF CD4301 call print_a_hex
164: 8982+19 13E2 DD7E02 ld a,(ix+2)
165: 9001+17 13E5 CD4301 call print_a_hex
166: 9018+19 13E8 DD7E01 ld a,(ix+1)
167: 9037+17 13EB CD4301 call print_a_hex
168: 9054+19 13EE DD7E00 ld a,(ix+0)
169: 9073+17 13F1 CD4301 call print_a_hex
170: 9090+7 13F4 3E20 ld a,' '
171: 9097+17 13F6 CD1501 call print_char
172: ;print length
173: 9114+19 13F9 DD7E07 ld a,(ix+7)
174: 9133+17 13FC CD4301 call print_a_hex
175: 9150+19 13FF DD7E06 ld a,(ix+6)
176: 9169+17 1402 CD4301 call print_a_hex
177: 9186+19 1405 DD7E05 ld a,(ix+5)
178: 9205+17 1408 CD4301 call print_a_hex
179: 9222+19 140B DD7E04 ld a,(ix+4)
180: 9241+17 140E CD4301 call print_a_hex
181: 9258+7 1411 3E20 ld a,' '
182: 9265+17 1413 CD1501 call print_char
183: ;print Port
184: 9282+7 1416 3E30 ld a,'0'
185: 9289+17 1418 CD1501 call print_char
186: 9306+7 141B 3E78 ld a,'x'
187: 9313+17 141D CD1501 call print_char
188: 9330+7 1420 7E ld a,(HL)
189: 9337+17 1421 CD4301 call print_a_hex
190: 9354+7 1424 3E20 ld a,' '
191: 9361+17 1426 CD1501 call print_char
192: 9378+6 1429 23 inc hl
193: ;print M/S
194: 9384+7 142A 7E ld a,(HL)
195: 9391+11 142B E5 push hl
196: 9402+4 142C B7 or a
197: 9406+10 142D CA3614 jp z,_ideif_prnt_devtable_l1_ms
198: 9416+10 1430 217E16 ld hl,[_ideif_prnt_devtable_slave]
199: 9426+10 1433 C33914 jp _ideif_prnt_devtable_l1_e2
200: - 1436 _ideif_prnt_devtable_l1_ms
201: 9436+10 1436 217616 ld hl,[_ideif_prnt_devtable_master]
202: - 1439 _ideif_prnt_devtable_l1_e2
203: 9446+17 1439 CD1D01 call print_str
204: 9463+10 143C E1 pop hl
205: 9473+6 143D 23 inc hl
206: ;print str
207: 9479+11 143E C5 push bc
208: 9490+7 143F 7E ld a,(hl)
209: 9497+4 1440 4F ld c,a
210: 9501+6 1441 23 inc hl
211: 9507+7 1442 7E ld a,(hl)
212: 9514+4 1443 47 ld b,a
213: 9518+6 1444 23 inc hl
214: 9524+11 1445 E5 push hl
215: 9535+4 1446 60 ld h,b
216: 9539+4 1447 69 ld l,c
217: 9543+17 1448 CD1D01 call print_str
218: 9560+17 144B CD2D01 call print_newLine
219: 9577+10 144E E1 pop hl
220: 9587+10 144F C1 pop bc
221: ;next
222: 9597+6 1450 23 inc hl
223: 9603+6 1451 23 inc hl
224: 9609+4 1452 04 inc b
225: 9613+4 1453 78 ld a,b
226: 9617+7 1454 FE04 cp 4
227: 9624+5+6 1456 C8 ret z
228: 9629+10 1457 C37313 jp _ideif_prnt_devtable_l1
229: ;------------------------------------------------------------------------------
230: ; ideif_init_drive
231: ;
232: ; initializes selected drive in table
233: ;------------------------------------------------------------------------------
234: - 145A ideif_init_drive:
235: 9639+17 145A CD3A15 call ideif_get_drv_pointer
236: ; load addresses. not used atm
237: ;ld a,(IX+6) ;load IO Addr
238: ;ld d,a
239: ;ld a,(IX+7) ;load Master/Slave bit
240: ;ld e,a
241: 9656+17 145D CD0D0E call ide_reset
242:
243: 9673+10 1460 11FFAF ld de, 0xAFFF ;preload timeout counter
244: - 1463 _ideif_init_drive_loop:
245: 9683+7 1463 060F ld b, IDE_REG_CMDSTS
246: 9690+17 1465 CD330E call ide_regread_8 ;read drive status register
247: 9707+4 1468 B7 or a
248: 9711+7+5 1469 280B jr z,_ideif_init_drive_nodrv ;no drive found
249: 9718+8 146B CB77 bit 6,a
250: 9726+7+5 146D 200C jr nz, _ideif_init_drive_found
251: 9733+6 146F 1B dec de
252: 9739+4 1470 7A ld a,d
253: 9743+4 1471 B3 or e
254: 9747+7+5 1472 2802 jr z, _ideif_init_drive_nodrv
255: 9754+12 1474 18ED jr _ideif_init_drive_loop
256:
257: - 1476 _ideif_init_drive_nodrv:
258: 9766+19 1476 DD360001 ld(ix+0),0x01
259: 9785+10 147A C9 ret
260:
261: - 147B _ideif_init_drive_found:
262: 9795+19 147B DD360002 ld (ix+0),0x02
263: ;get drive name
264: 9814+7 147F 060F ld b, IDE_REG_CMDSTS ;Get drive identification
265: 9821+7 1481 3EEC ld a, IDE_CMD_IDENT
266: 9828+17 1483 CD190E call ide_regwrite_8 ;Write command to drive
267: 9845+10 1486 21B642 ld hl, MEM_IDE_BUFFER ;set read/write buffer start address
268: 9855+17 1489 CD490E call ide_readsector_512_fast ;read 256 words from device
269: 9872+10 148C 21EC42 ld hl,MEM_IDE_BUFFER + 54 ;print device serial
270: 9882+19 148F DD7E0C ld a,(ix+12) ;load str pointer into de
271: 9901+4 1492 5F ld e,a
272: 9905+19 1493 DD7E0D ld a,(ix+13)
273: 9924+4 1496 57 ld d,a
274: 9928+7 1497 0614 ld b,20
275: - 1499 _ideif_init_drive_charloop:
276: 9935+7 1499 7E ld a,(hl) ;load data from HL (buffer)
277: 9942+6 149A 23 inc hl
278: 9948+4 149B 08 ex af,af'
279: 9952+7 149C 7E ld a,(hl)
280: 9959+6 149D 23 inc hl
281: 9965+7 149E 12 ld (de),a
282: 9972+6 149F 13 inc de
283: 9978+4 14A0 08 ex af,af'
284: 9982+7 14A1 12 ld (de),a
285: 9989+6 14A2 13 inc de
286: 9995+8+5 14A3 10F4 djnz _ideif_init_drive_charloop
287: ;get partition table
288: ;read bootsector
289: - 14A5 ?a0000:
289:10003+7 14A5 060F ld b, IDE_REG_CMDSTS
289:10010+17 14A7 CD330E call ide_regread_8
289:10027+4 14AA 17 rla
289:10031+7+5 14AB 38F8 jr c, ?a0000
289: - 14AD endm
289:10003+35 14A5 060FCD33 ide_wait_rdy
0E1738F8
290:10038+7 14AD 3E01 ld a,1 ;read 1 sector
291:10045+7 14AF 060A ld B,IDE_REG_SECTOR
292:10052+17 14B1 CD190E call ide_regwrite_8
293:10069+7 14B4 3E00 ld a,0 ;read sector 0
294:10076+7 14B6 060B ld b,IDE_REG_LBA0
295:10083+17 14B8 CD190E call ide_regwrite_8
296:10100+7 14BB 3E00 ld a,0 ;read cylinder 0
297:10107+7 14BD 060C ld b,IDE_REG_LBA1
298:10114+17 14BF CD190E call ide_regwrite_8
299:10131+7 14C2 3E00 ld a,0
300:10138+7 14C4 060D ld b,IDE_REG_LBA2
301:10145+17 14C6 CD190E call ide_regwrite_8
302:10162+7 14C9 3EE0 ld a,11100000b ;read head 0
303:10169+7 14CB 060E ld b,IDE_REG_LBA3
304:10176+17 14CD CD190E call ide_regwrite_8
305:
306:10193+7 14D0 3E20 ld a,IDE_CMD_READSEC ;send read command
307:10200+7 14D2 060F ld b,IDE_REG_CMDSTS
308:10207+17 14D4 CD190E call ide_regwrite_8
309:
310:10224+10 14D7 21B642 ld hl, MEM_IDE_BUFFER ;set read/write buffer start address
311:10234+17 14DA CD490E call ide_readsector_512_fast ;read 256 words from device
312: ;prepare partitions
313:10251+7 14DD 0604 ld b,4 ;Partition table length
314:10258+7 14DF 0E00 ld c,0 ;Partition ID counter
315:10265+14 14E1 FD217444 ld iy,MEM_IDE_BUFFER+446 ;Load offest of first partition table entry
316: - 14E5 _ideif_init_drive_prt_l1:
317:10279+19 14E5 FD7E04 ld a,(iy+4) ;load status byte
318:10298+4 14E8 B7 or a
319:10302+10 14E9 C2F714 jp NZ, _ideif_init_drive_prt_fnd ;If not zero, jump to print function
320:10312+10 14EC C3EF14 jp _ideif_init_drive_prt_ln
321: - 14EF _ideif_init_drive_prt_ln:
322:10322+10 14EF 111000 ld de,16
323:10332+15 14F2 FD19 add iy,de
324:10347+8+5 14F4 10EF djnz _ideif_init_drive_prt_l1
325:10355+10 14F6 C9 ret
326: - 14F7 _ideif_init_drive_prt_fnd;
327:10365+19 14F7 FD7E04 ld a,(iy+4)
328:10384+19 14FA DD7701 ld (ix+1),a ;store partition type
329:10403+7 14FD FE0E cp 0x0E ;if not 0xE0, continue with next entry
330:10410+7+5 14FF 20EE jr nz, _ideif_init_drive_prt_ln
331: ;get start LBA
332:10417+19 1501 FD7E08 ld a,(iy+0x08)
333:10436+19 1504 DD7702 ld (ix+0x02),a
334:10455+19 1507 FD7E09 ld a,(iy+0x09)
335:10474+19 150A DD7703 ld (ix+0x03),a
336:10493+19 150D FD7E0A ld a,(iy+0x0A)
337:10512+19 1510 DD7704 ld (ix+0x04),a
338:10531+19 1513 FD7E0B ld a,(iy+0x0B)
339:10550+19 1516 DD7705 ld (ix+0x05),a
340:10569+19 1519 DD360000 ld (ix+0),0x00
341: ;get count LBA
342:10588+19 151D FD7E0C ld a,(iy+0x0C)
343:10607+19 1520 DD7706 ld (ix+0x06),a
344:10626+19 1523 FD7E0D ld a,(iy+0x0D)
345:10645+19 1526 DD7707 ld (ix+0x07),a
346:10664+19 1529 FD7E0E ld a,(iy+0x0E)
347:10683+19 152C DD7708 ld (ix+0x08),a
348:10702+19 152F FD7E0F ld a,(iy+0x0F)
349:10721+19 1532 DD7709 ld (ix+0x09),a
350:10740+19 1535 DD360000 ld (ix+0),0x00
351:10759+10 1539 C9 ret
352:
353: ;------------------------------------------------------------------------------
354: ; ideif_get_drv_pointer
355: ;
356: ; gets pointer to selected drive in table in IX
357: ;------------------------------------------------------------------------------
358: - 153A ideif_get_drv_pointer:
359:10769+11 153A F5 push af
360:10780+11 153B C5 push bc
361: ;get selected drive
362:10791+13 153C 3A1542 ld a,(MEM_IDE_SELECTED)
363: ;multiply a *8
364:10804+4 153F 07 rlca ;*2
365:10808+4 1540 07 rlca ;*4
366:10812+4 1541 07 rlca ;*8
367:10816+7 1542 0600 ld b,0
368:10823+4 1544 4F ld c,a
369:10827+14 1545 DD21D541 ld ix,[MEM_IDE_DEV_TABLE]
370:10841+15 1549 DD09 add ix,bc
371:10856+10 154B C1 pop bc
372:10866+10 154C F1 pop af
373:10876+10 154D C9 ret
374:
375: ;------------------------------------------------------------------------------
376: ; ideif_init_all
377: ;
378: ; initializes interface
379: ;------------------------------------------------------------------------------
380: - 154E ideif_init_all:
381:10886+10 154E 21F215 ld hl, [str_dev_waitready]
382:10896+17 1551 CD1D01 call print_str ;print waiting message
383:
384:10913+17 1554 CD4713 call ideif_init_devtable
385:10930+17 1557 CD5A14 call ideif_init_drive
386:
387:10947+10 155A 210A16 ld hl, [str_dev_done]
388:10957+17 155D CD1D01 call print_str
389:10974+10 1560 C9 RET
390:
391:
392: ;------------------------------------------------------------------------------
393: ; ideif_drv_sel
394: ;
395: ; Selects drive from table and initializes the fat16 file system
396: ; A contains drive id
397: ;------------------------------------------------------------------------------
398:
399:
400:
401: ;------------------------------------------------------------------------------
402: ; read_lba_sector
403: ;
404: ; Reads A*512 byte sector into memory
405: ; HL contains pointer to LBA address
406: ; DE contains destination location
407: ; A contains sector count
408: ;------------------------------------------------------------------------------
409: - 1561 read_lba_sector:
410:10984+11 1561 F5 push af
411: - 1562 ?a0001:
411:10995+7 1562 060F ld b, IDE_REG_CMDSTS
411:11002+17 1564 CD330E call ide_regread_8
411:11019+4 1567 17 rla
411:11023+7+5 1568 38F8 jr c, ?a0001
411: - 156A endm
411:10995+35 1562 060FCD33 ide_wait_rdy
0E1738F8
412:11030+10 156A F1 pop af
413:11040+7 156B 060A LD B,IDE_REG_SECTOR ;amount of sectores
414:11047+17 156D CD190E CALL ide_regwrite_8
415:
416:11064+7 1570 7E LD A,(HL)
417:11071+7 1571 060B LD B,IDE_REG_LBA0
418:11078+17 1573 CD190E CALL ide_regwrite_8
419:11095+6 1576 23 INC HL
420:11101+7 1577 7E LD A,(HL)
421:11108+7 1578 060C LD B,IDE_REG_LBA1
422:11115+17 157A CD190E CALL ide_regwrite_8
423:11132+6 157D 23 INC HL
424:11138+7 157E 7E LD A,(HL)
425:11145+7 157F 060D LD B,IDE_REG_LBA2
426:11152+17 1581 CD190E CALL ide_regwrite_8
427:11169+6 1584 23 INC HL
428:11175+7 1585 7E LD A,(HL)
429:11182+7 1586 E60F AND 00001111b
430:11189+7 1588 F6E0 OR 11100000b
431:11196+7 158A 060E LD B,IDE_REG_LBA3
432:11203+17 158C CD190E CALL ide_regwrite_8
433:
434:11220+7 158F 3E20 LD A,IDE_CMD_READSEC ;send read command
435:11227+7 1591 060F LD B,IDE_REG_CMDSTS
436:11234+17 1593 CD190E CALL ide_regwrite_8
437:
438: ;LD HL,MEM_IDE_BUFFER ;set read/write buffer start address
439:11251+4 1596 EB EX DE,HL ;transfer destination in DE to HL
440:11255+10 1597 C3490E jp ide_readsector_512_fast ;read 256 words from device
441:
442: ;------------------------------------------------------------------------------
443: ; ideif_drv_sel
444: ;
445: ; Select drive from table
446: ; Prepare variables
447: ;
448: ; A contains drive number
449: ;------------------------------------------------------------------------------
450: - 159A ideif_drv_sel:
451:11265+13 159A 321542 ld (MEM_IDE_SELECTED),a
452:11278+11 159D F5 push af
453:11289+17 159E CD3A15 call ideif_get_drv_pointer ;test if drive is marked as available
454:11306+19 15A1 DD7E00 ld a,(ix+0)
455:11325+4 15A4 B7 or a
456:11329+10 15A5 C2D215 jp nz, _ideif_drv_sel_fail ;if not-> fail
457:
458:11339+17 15A8 CD6D20 call fat_get_root_table ;else get root table
459:
460:11356+10 15AB 218616 ld hl,[_ideif_drv_sel_pstr] ;print success message
461:11366+17 15AE CD1D01 call print_str
462:11383+10 15B1 F1 pop af
463:11393+7 15B2 C645 add 69
464:11400+13 15B4 322B41 ld (var_dir),a ;store drive letter
465:11413+17 15B7 CD1501 call print_char
466:11430+7 15BA 3E3A ld a, ':'
467:11437+13 15BC 322C41 ld (var_dir+1),a
468:11450+7 15BF 3E5C ld a, '\'
469:11457+13 15C1 322D41 ld (var_dir+2),a
470:11470+4 15C4 AF xor a ;set dir to empty
471:11474+13 15C5 322E41 ld (var_dir+3),a
472:11487+13 15C8 327A41 ld (var_dir+79),a ;set depth counter
473:11500+10 15CB 219D16 ld hl,[_ideif_drv_sel_sstr0]
474:11510+17 15CE CD1D01 call print_str
475:11527+10 15D1 C9 ret
476: - 15D2 _ideif_drv_sel_fail:
477:11537+10 15D2 218616 ld hl,[_ideif_drv_sel_pstr]
478:11547+17 15D5 CD1D01 call print_str
479:11564+10 15D8 F1 pop af
480:11574+7 15D9 C645 add 69
481:11581+17 15DB CD1501 call print_char
482:11598+10 15DE 218F16 ld hl,[_ideif_drv_sel_fstr0]
483:11608+17 15E1 CD1D01 call print_str
484:11625+4 15E4 AF xor a ;set dir to empty
485:11629+13 15E5 322B41 ld (var_dir),a
486:11642+10 15E8 112000 LD DE,0x20
487:11652+10 15EB 017000 LD BC,0x70
488:11662+17 15EE CDE80D CALL beep
489:11679+10 15F1 C9 ret
490:
491:
492:
493:
494: ;================================================================
495: ; IDE strings
496: ;===============================================================
497:
498: - 15F2 str_dev_waitready:
499: - 15F2 0D0A4465 db 13,10,"Detecting drives ... ",0
74656374
696E6720
64726976
6573202E
2E2E2000
500: - 160A str_dev_done:
501: - 160A 646F6E65 db "done!",13,10,0
210D0A00
502:
503: - 1612 _ideif_prnt_devtable_hdr:
504: - 1612 44525620 db "DRV Status Type LBA Length Port M/S Name",10,13,0
53746174
75732020
20205479
7065204C
42412020
20202020
4C656E67
74682020
20506F72
74204D2F
53202020
204E616D
650A0D00
505: - 164A _ideif_prnt_devtable_s00:
506: - 164A 41766169 db "Avail ",0
6C202020
202000
507: - 1655 _ideif_prnt_devtable_s01:
508: - 1655 4E6F7420 db "Not Found ",0
466F756E
642000
509: - 1660 _ideif_prnt_devtable_s02:
510: - 1660 556E6B6F db "Unkown FS ",0
776E2046
532000
511: - 166B _ideif_prnt_devtable_sFF:
512: - 166B 4374726C db "Ctrl. Err ",0
2E204572
722000
513: - 1676 _ideif_prnt_devtable_master:
514: - 1676 4D617374 db "Master ",0
65722000
515: - 167E _ideif_prnt_devtable_slave:
516: - 167E 536C6176 db "Slave ",0
65202000
517: - 1686 _ideif_drv_sel_pstr:
518: - 1686 0A0D4472 db 10,13,"Drive ",0
69766520
00
519: - 168F _ideif_drv_sel_fstr0:
520: - 168F 3A206E6F db ": not ready",10,13,0
74207265
6164790A
0D00
521: - 169D _ideif_drv_sel_sstr0:
522: - 169D 3A207365 db ": selected",10,13,0
6C656374
65640A0D
00
523: - 16AA _ideif_drv_sel_syn:
524: - 16AA 0A0D496E db 10,13,"Invalid drive letter",10,13,0
76616C69
64206472
69766520
6C657474
65720A0D
00
**** main.asm ****
191: .include "kdrv_siic.s"
**** include/kdrv_siic.s ****
1: ;----------------------------------------------------------------
2: ;BIOS Driver for I2C Protocol (Software)
3: ;by Dennis Gunia (01/2024)
4: ;
5: ; SCL is connected to PA1 of PIO (U6) with pull-up
6: ; SDA is connected to PA0 of PIO (U6) with pull-up
7: ;----------------------------------------------------------------
8:
9:
10: ;================================================================
11: ; I/O registers
12: ;================================================================
13:
14:
15: ;================================================================
16: ; I/O pins
17: ;================================================================
18: - 0001 IIC_CLK .EQU 00000001b
19: - 0002 IIC_DATA .EQU 00000010b
20:
21: ;================================================================
22: ; basic access functions
23: ;================================================================
24: ;HL contains buffer location
25: ;B defines amount of bytes to send
26: ;C contains device address
27: - 16C3 iic_send_buffer:
28:11689+17 16C3 CD2917 CALL iic_send_sbit ;Send startbit
29:11706+4 16C6 79 LD A,C
30:11710+7 16C7 E6FE AND 0xFE ;Mask R/W bit (must be 0 for write)
31:11717+17 16C9 CDC317 CALL iic_send_byte ;Send Address
32:11734+17 16CC CD6317 CALL iic_read_ack
33:11751+4 16CF B7 OR A ; if no ack, error
34:11755+10 16D0 C2E716 JP NZ, iic_send_buffer_err
35: - 16D3 iic_send_buffer_loop;
36:11765+7 16D3 7E LD A,(HL)
37:11772+6 16D4 23 INC HL
38:11778+17 16D5 CDC317 CALL iic_send_byte
39:11795+17 16D8 CD6317 CALL iic_read_ack
40:11812+4 16DB B7 OR A ; if no ack, error
41:11816+10 16DC C2E716 JP NZ, iic_send_buffer_err
42:11826+8+5 16DF 10F2 DJNZ iic_send_buffer_loop ;loop for remaining bytes
43: - 16E1 iic_send_buffer_done:
44:11834+17 16E1 CD4217 CALL iic_send_ebit
45:11851+7 16E4 3E00 LD A,0
46:11858+10 16E6 C9 RET
47: - 16E7 iic_send_buffer_err:
48:11868+17 16E7 CD4217 CALL iic_send_ebit
49:11885+7 16EA 3E01 LD A,1
50:11892+10 16EC C9 RET
51:
52: ;HL contains buffer location
53: ;B defines amount of bytes to send
54: ;C contains device address
55: - 16ED iic_receive_buffer:
56:11902+4 16ED 05 DEC B
57:11906+17 16EE CD2917 CALL iic_send_sbit ;Send startbit
58:11923+4 16F1 79 LD A,C
59:11927+7 16F2 F601 OR 0x01 ;set R/W bit (must be 1 for read)
60:11934+17 16F4 CDC317 CALL iic_send_byte ;Send Address
61:11951+17 16F7 CD6317 CALL iic_read_ack
62:11968+4 16FA B7 OR A ; if no ack, error
63:11972+10 16FB C21617 JP NZ, iic_receive_buffer_err
64: - 16FE iic_receive_buffer_loop:
65:11982+17 16FE CDE917 CALL iic_receive_byte
66:11999+7 1701 77 LD (HL),A
67:12006+6 1702 23 INC HL
68:12012+17 1703 CD8917 CALL iic_send_ack
69:12029+8+5 1706 10F6 DJNZ iic_receive_buffer_loop
70: ; last time:
71:12037+17 1708 CDE917 CALL iic_receive_byte
72:12054+7 170B 77 LD (HL),A
73:12061+6 170C 23 INC HL
74:12067+17 170D CDA617 CALL iic_send_nack
75:
76: - 1710 iic_receive_buffer_done:
77:12084+17 1710 CD4217 CALL iic_send_ebit
78:12101+7 1713 3E00 LD A,0
79:12108+10 1715 C9 RET
80: - 1716 iic_receive_buffer_err:
81:12118+17 1716 CD4217 CALL iic_send_ebit
82:12135+7 1719 3E01 LD A,1
83:12142+10 171B C9 RET
84:
85:
86:
87: ;================================================================
88: ; I/O access functions
89: ;================================================================
90:
91: ;Reset PIO configuration
92: - 171C iic_init:
93: ;SCL HIGH, SDA HIGH
94:12152+7 171C 3E03 LD A,0x03
95:12159+11 171E D3F4 OUT (CS_PIO_AD), A
96: ;Set port to controll mode (MODE3)
97:12170+7 1720 3ECF LD A,0xCF
98:12177+11 1722 D3F6 OUT (CS_PIO_AC), A
99: ;Set inputs/outputs
100:12188+7 1724 3EF0 LD A,0xF0
101:12195+11 1726 D3F6 OUT (CS_PIO_AC), A
102:12206+10 1728 C9 RET
103:
104: ; send start bit
105: - 1729 iic_send_sbit:
106: ;SCL HIGH, SDA HIGH
107:12216+7 1729 3E03 LD A,0x03
108:12223+11 172B D3F4 OUT (CS_PIO_AD), A
109: ;Set port to controll mode (MODE3)
110:12234+7 172D 3ECF LD A,0xCF
111:12241+11 172F D3F6 OUT (CS_PIO_AC), A
112: ;Set inputs/outputs (SDA and SCL is now output)
113:12252+7 1731 3EFC LD A,0xFC
114:12259+11 1733 D3F6 OUT (CS_PIO_AC), A
115: ;SCL HIGH, SDA LOW
116:12270+7 1735 3E02 LD A,0x02
117:12277+11 1737 D3F4 OUT (CS_PIO_AD), A
118:12288+4 1739 00 NOP
119:12292+4 173A 00 NOP
120:12296+7 173B 3E00 LD A,0x00
121:12303+11 173D D3F4 OUT (CS_PIO_AD), A
122:12314+4 173F 00 NOP
123:12318+4 1740 00 NOP
124:12322+10 1741 C9 RET
125:
126: ; send end/stop bit
127: - 1742 iic_send_ebit:
128: ;Set port to controll mode (MODE3)
129:12332+7 1742 3ECF LD A,0xCF
130:12339+11 1744 D3F6 OUT (CS_PIO_AC), A
131:
132: ;Set inputs/outputs (SDA and SCL is now output)
133:12350+7 1746 3EFC LD A,0xFC
134:12357+11 1748 D3F6 OUT (CS_PIO_AC), A
135: ;SCL HIGH, SDA LOW
136:12368+7 174A 3E02 LD A,0x02
137:12375+11 174C D3F4 OUT (CS_PIO_AD), A
138:12386+4 174E 00 NOP
139:12390+4 174F 00 NOP
140:12394+7 1750 3E03 LD A,0x03 ; both high
141:12401+11 1752 D3F4 OUT (CS_PIO_AD), A
142:12412+4 1754 00 NOP
143:12416+4 1755 00 NOP
144: ;release bus
145: ;Set port to controll mode (MODE3)
146:12420+7 1756 3ECF LD A,0xCF
147:12427+11 1758 D3F6 OUT (CS_PIO_AC), A
148:12438+4 175A 00 NOP
149:12442+4 175B 00 NOP
150: ;Set inputs/outputs (SDA and SCL is now input, sound enabled)
151:12446+7 175C 3EF7 LD A,11110111b
152:12453+11 175E D3F6 OUT (CS_PIO_AC), A
153:12464+4 1760 00 NOP
154:12468+4 1761 00 NOP
155:12472+10 1762 C9 RET
156:
157:
158: - 1763 iic_read_ack:
159:12482+7 1763 3ECF LD A,0xCF
160:12489+11 1765 D3F6 OUT (CS_PIO_AC), A
161: ;Set inputs/outputs (SCL is now output, SDA input)
162:12500+7 1767 3EFD LD A,0xFD
163:12507+11 1769 D3F6 OUT (CS_PIO_AC), A
164:12518+4 176B 00 NOP
165:12522+4 176C 00 NOP
166:12526+7 176D 3E00 LD A,0x00 ;set SCL LOW
167:12533+11 176F D3F4 OUT (CS_PIO_AD), A
168:12544+4 1771 00 NOP
169:12548+4 1772 00 NOP
170:12552+7 1773 EE02 XOR 0x02 ;set SCL HIGH
171:12559+11 1775 D3F4 OUT (CS_PIO_AD), A
172:12570+4 1777 00 NOP
173:12574+11 1778 DBF4 IN A,(CS_PIO_AD) ; Read SDA
174:12585+4 177A 00 NOP
175:12589+4 177B 00 NOP
176:12593+11 177C F5 PUSH AF
177:12604+7 177D E6FE AND 0xFE ; Filter input
178:12611+7 177F EE02 XOR 0x02 ;set SCL LOW
179:12618+11 1781 D3F4 OUT (CS_PIO_AD), A
180:12629+4 1783 00 NOP
181:12633+4 1784 00 NOP
182:12637+10 1785 F1 POP AF
183:12647+7 1786 E601 AND 1
184:12654+10 1788 C9 RET
185:
186: - 1789 iic_send_ack:
187: ;Set port to controll mode (MODE3)
188:12664+7 1789 3ECF LD A,0xCF
189:12671+11 178B D3F6 OUT (CS_PIO_AC), A
190: ;Set inputs/outputs (SDA and SCL is now output)
191:12682+7 178D 3EFC LD A,0xFC
192:12689+11 178F D3F6 OUT (CS_PIO_AC), A
193:12700+4 1791 00 NOP
194:12704+4 1792 00 NOP
195:12708+7 1793 3E00 LD A,0x00 ; SCL LOW, SDA LOW
196:12715+11 1795 D3F4 OUT (CS_PIO_AD), A
197:12726+4 1797 00 NOP
198:12730+4 1798 00 NOP
199:12734+7 1799 3E02 LD A,0x02 ; SCL HIGH, SDA LOW
200:12741+11 179B D3F4 OUT (CS_PIO_AD), A
201:12752+4 179D 00 NOP
202:12756+4 179E 00 NOP
203:12760+7 179F 3E00 LD A,0x00 ; SCL LOW, SDA LOW
204:12767+11 17A1 D3F4 OUT (CS_PIO_AD), A
205:12778+4 17A3 00 NOP
206:12782+4 17A4 00 NOP
207:12786+10 17A5 C9 RET
208:
209: - 17A6 iic_send_nack:
210: ;Set port to controll mode (MODE3)
211:12796+7 17A6 3ECF LD A,0xCF
212:12803+11 17A8 D3F6 OUT (CS_PIO_AC), A
213: ;Set inputs/outputs (SDA and SCL is now output)
214:12814+7 17AA 3EFC LD A,0xFC
215:12821+11 17AC D3F6 OUT (CS_PIO_AC), A
216:12832+4 17AE 00 NOP
217:12836+4 17AF 00 NOP
218:12840+7 17B0 3E02 LD A,0x02 ; SCL LOW, SDA HIGH
219:12847+11 17B2 D3F4 OUT (CS_PIO_AD), A
220:12858+4 17B4 00 NOP
221:12862+4 17B5 00 NOP
222:12866+7 17B6 3E03 LD A,0x03 ; both high
223:12873+11 17B8 D3F4 OUT (CS_PIO_AD), A
224:12884+4 17BA 00 NOP
225:12888+4 17BB 00 NOP
226:12892+7 17BC 3E02 LD A,0x02 ; SCL LOW, SDA HIGH
227:12899+11 17BE D3F4 OUT (CS_PIO_AD), A
228:12910+4 17C0 00 NOP
229:12914+4 17C1 00 NOP
230:12918+10 17C2 C9 RET
231:
232: ;A contains byte
233: - 17C3 iic_send_byte:
234:12928+11 17C3 C5 PUSH BC
235:12939+4 17C4 4F LD C,A ;buffer
236: ;Set port to controll mode (MODE3)
237:12943+7 17C5 3ECF LD A,0xCF
238:12950+11 17C7 D3F6 OUT (CS_PIO_AC), A
239: ;Set inputs/outputs (SDA and SCL is now output)
240:12961+7 17C9 3EFC LD A,0xFC
241:12968+11 17CB D3F6 OUT (CS_PIO_AC), A
242:12979+7 17CD 0608 LD B,8 ;bit counter
243:
244: - 17CF iic_send_byte_loop:
245: ;prepare data
246:12986+8 17CF CB11 RL C
247:12994+7 17D1 3E00 LD A,0
248:13001+4 17D3 17 RLA ; set SCA bit from carry, SCL LOW
249:13005+11 17D4 D3F4 OUT (CS_PIO_AD), A
250:13016+4 17D6 00 NOP
251:13020+4 17D7 00 NOP
252:13024+7 17D8 EE02 XOR 0x02 ;set SCL HIGH
253:13031+11 17DA D3F4 OUT (CS_PIO_AD), A
254:13042+4 17DC 00 NOP
255:13046+4 17DD 00 NOP
256:13050+7 17DE EE02 XOR 0x02 ;set SCL LOW
257:13057+11 17E0 D3F4 OUT (CS_PIO_AD), A
258:13068+4 17E2 00 NOP
259:13072+4 17E3 00 NOP
260:13076+8+5 17E4 10E9 DJNZ iic_send_byte_loop ;loop until counter is 0
261: ;transmittion end / end loop
262:13084+4 17E6 79 LD A,C
263:13088+10 17E7 C1 POP BC
264:13098+10 17E8 C9 RET
265:
266: - 17E9 iic_receive_byte:
267:13108+11 17E9 C5 PUSH BC
268: ;Set port to controll mode (MODE3)
269:13119+7 17EA 3ECF LD A,0xCF
270:13126+11 17EC D3F6 OUT (CS_PIO_AC), A
271: ;Set inputs/outputs (SCL is now output, SDA input)
272:13137+7 17EE 3EFD LD A,0xFD
273:13144+11 17F0 D3F6 OUT (CS_PIO_AC), A
274:13155+7 17F2 0608 LD B,8 ;bit counter
275:13162+7 17F4 0E00 LD C,0
276: - 17F6 iic_receive_byte_loop:
277:13169+4 17F6 AF XOR A ;set SCL LOW
278:13173+11 17F7 D3F4 OUT (CS_PIO_AD), A
279:13184+4 17F9 00 NOP
280:13188+4 17FA 00 NOP
281:13192+7 17FB 3E02 LD A,2 ;set SCL HIGH
282:13199+11 17FD D3F4 OUT (CS_PIO_AD), A
283:13210+4 17FF 00 NOP
284:13214+11 1800 DBF4 IN A, (CS_PIO_AD)
285:13225+4 1802 00 NOP
286:13229+4 1803 1F RRA ;read SDA bit
287:13233+8 1804 CB11 RL C ;store bit
288:13241+4 1806 AF XOR A ;set SCL LOW again
289:13245+11 1807 D3F4 OUT (CS_PIO_AD), A
290:13256+4 1809 00 NOP
291:13260+4 180A 00 NOP
292:13264+8+5 180B 10E9 DJNZ iic_receive_byte_loop
293:13272+4 180D 79 LD A,C
294:13276+10 180E C1 POP BC
**** main.asm ****
192:13286+10 180F C9 RET
193: .include "prettydump.s"
**** include/prettydump.s ****
1: ;----------------------------------------------------------------
2: ;HEX and ASCII dump function
3: ;by Dennis Gunia (01/2023)
4: ;----------------------------------------------------------------
5:
6: ;------------------------------------------------------------------------------
7: ; dump_pretty
8: ;
9: ; Dumps memory content
10: ; B contains amount of rows
11: ; HL contains start address
12: ; Destroys BC, HL
13: ;------------------------------------------------------------------------------
14: - 1810 dump_pretty:
15:13296+11 1810 E5 PUSH HL
16:13307+10 1811 216B18 LD HL,[STR_PD_HEADER] ;Print header
17:13317+17 1814 CD1D01 CALL print_str
18:13334+10 1817 E1 POP HL
19: - 1818 dump_pretty_row:
20:13344+4 1818 78 LD A,B ;Check row counter
21:13348+4 1819 B7 OR A
22:13352+10 181A CA6A18 JP Z, dump_pretty_end ;If counter is 0, exit
23:13362+4 181D 05 DEC B ;Decrement row counter by 1
24:13366+7 181E 0E10 LD C, 16 ;Load column counter
25:13373+4 1820 7C LD A, H ;Print base address
26:13377+17 1821 CD4301 CALL print_a_hex
27:13394+4 1824 7D LD A, L
28:13398+17 1825 CD4301 CALL print_a_hex
29:13415+7 1828 3E20 LD A, ' '
30:13422+17 182A CD1501 CALL print_char
31: - 182D dump_pretty_col: ;Loop for column
32:13439+7 182D 7E LD A,(HL) ;Load byte to disply
33:13446+17 182E CD4301 CALL print_a_hex
34:13463+7 1831 3E20 LD A, ' '
35:13470+17 1833 CD1501 CALL print_char
36:13487+6 1836 23 INC HL
37:13493+4 1837 0D DEC C ;Decrement column counter
38:13497+7+5 1838 20F3 JR NZ, dump_pretty_col ;Loop if not 0
39: - 183A dump_pretty_ascii:
40:13504+11 183A C5 PUSH BC
41:13515+11 183B E5 PUSH HL
42:13526+7 183C 0600 LD B,0
43:13533+7 183E 0E10 LD C,16
44:13540+15 1840 ED42 SBC HL,BC ;Reset HL by column count
45: - 1842 dump_pretty_ascii_loop:
46:13555+7 1842 7E LD A,(HL)
47:13562+6 1843 23 INC HL
48:13568+7 1844 FE20 CP 32
49:13575+10 1846 DA5318 JP C, dump_pretty_ascii_none ;if less than 32, it is not a char
50:13585+7 1849 FE7F CP 127
51:13592+10 184B D25318 JP NC, dump_pretty_ascii_none ;if greater or equal than 128, it is not a char
52:13602+17 184E CD1501 call print_char
53:13619+12 1851 1805 jr dump_pretty_ascii_cont
54: - 1853 dump_pretty_ascii_none:
55:13631+7 1853 3E2E LD A,'.'
56:13638+17 1855 CD1501 call print_char
57: - 1858 dump_pretty_ascii_cont:
58:13655+4 1858 0D DEC C
59:13659+10 1859 C24218 JP NZ, dump_pretty_ascii_loop
60:
61:
62:13669+10 185C E1 POP HL
63:13679+10 185D C1 POP BC
64: - 185E dump_pretty_nextrow:
65:13689+7 185E 3E0A LD A,10 ;New line
66:13696+17 1860 CD1501 CALL print_char
67:13713+7 1863 3E0D LD A,13
68:13720+17 1865 CD1501 CALL print_char
69:13737+12 1868 18AE JR dump_pretty_row ;Else next line
70: - 186A dump_pretty_end:
71:13749+10 186A C9 RET
72:
73: - 186B STR_PD_HEADER:
74: - 186B 0D0A4241 db 13,10,'BASE 0 1 2 3 4 5 6 7 8 9 A B C D E F ASCII',13,10,0
53452030
20203120
20322020
33202034
20203520
20362020
37202038
20203920
20412020
42202043
20204420
20452020
46202041
53434949
0D0A00
75:
76:
77: ;------------------------------------------------------------------------------
78: ; print_str_fixed
79: ;
80: ; Prints string with fixed length
81: ; B contains length
82: ; HL contains start address
83: ;------------------------------------------------------------------------------
84: - 18AA print_str_fixed:
85:13759+7 18AA 7E LD A,(HL)
86:13766+6 18AB 23 INC HL
87:13772+17 18AC CD1501 CALL print_char
88:13789+8+5 18AF 10F9 DJNZ print_str_fixed
89:13797+10 18B1 C9 RET
90:
**** main.asm ****
194: .include "command.s"
**** include/command.s ****
1: - 18B2 COMMAND_LUT:
2: - 18B2 64617465 db "date", 0 , [OP_RTIME], [OP_RTIME]>>8 ;Read time
00EF1B
3: - 18B9 73657464 db "setdate", 0 , [OP_STIME], [OP_STIME]>>8 ;Read time
61746500
871D
4: - 18C3 70696E20 db "pin ", 0 , [OP_IO_IN], [OP_IO_IN]>>8 ;Read port
00081B
5: - 18CA 64756D70 db "dump ",0, [OP_DUMP], [OP_DUMP]>>8 ;print pretty hexdump
2000771A
6: - 18D2 706F7574 db "pout ", 0 , [OP_IO_OUT], [OP_IO_OUT]>>8 ;Write port
20001E1B
7: - 18DA 69696E20 db "iin ", 0, [OP_IIC_IN], [OP_IIC_IN]>>8 ;Read IIC
009F1B
8: - 18E1 696F7574 db "iout ", 0, [OP_IIC_OUT], [OP_IIC_OUT]>>8 ;Write IIC
20003F1B
9: - 18E9 63616C6C db "call ", 0, [OP_CALL], [OP_CALL]>>8 ;Call to addr
2000571A
10: - 18F1 636C7200 db "clr", 0, [OP_CLR], [OP_CLR]>>8 ;Call to addr
EB1B
11: - 18F7 6461736D db "dasm ", 0, [OP_DASM], [OP_DASM]>>8 ;Call to addr
2000D81A
12: - 18FF 6A702000 db "jp ", 0,[OP_EXEC], [OP_EXEC]>>8 ;jump to addr
3E1A
13: - 1905 72737400 db "rst", 0,0x00,0x00 ;soft reset
0000
14: - 190B 6C736473 db "lsdsk", 0,[OP_LSDSK], [OP_LSDSK]>>8 ;list disks
6B00001E
15: - 1913 73656C64 db "seldsk ", 0,[OP_SELDSK], [OP_SELDSK]>>8 ;select disk
736B2000
041E
16: - 191D 63642000 db "cd ", 0 , [OP_CD], [OP_CD]>>8 ;Read time
271E
17: - 1923 6C730023 db "ls", 0 , [OP_DIR], [OP_DIR]>>8 ;Read time
1E
18: - 1928 72756E20 db "run ", 0 , [OP_FSEXEC], [OP_FSEXEC]>>8 ;Read time
00441E
19: - 192F 24003E1A db "$", 0, [OP_EXEC], [OP_EXEC]>>8 ;jump to addr
20: - 1933 6900081B db "i", 0, [OP_IO_IN], [OP_IO_IN]>>8 ;Read port
21: - 1937 6F001E1B db "o", 0, [OP_IO_OUT], [OP_IO_OUT]>>8 ;Write port
22: - 193B 2100A71A db "!", 0, [OP_SET], [OP_SET]>>8 ;Write memory
23: - 193F 3F00771A db "?", 0, [OP_DUMP], [OP_DUMP]>>8 ;Print memory
24: - 1943 FF db 0xFF ;End of Table
25:
26: - 1944 COMMAND:
27:13807+17 1944 CD2D01 call print_newLine
28:13824+10 1947 212B41 ld hl,[var_dir]
29:13834+17 194A CD1D01 call print_str
30:13851+7 194D 3E3E ld a,'>'
31:13858+17 194F CD1501 call print_char
32:13875+4 1952 AF xor a ;reset buffer len
33:13879+13 1953 320041 ld (var_buffer_len),a ;set buffer len to 0
34: - 1956 COMMAND_READ:
35:13892+17 1956 CD5B01 call read_char
36:13909+10 1959 CA5619 jp z, COMMAND_READ ;wait for input
37:13919+7 195C FE0D cp 13 ; enter
38:13926+10 195E CAAB19 jp z,COMMAND_PROCESS
39:13936+7 1961 FE0A cp 10
40:13943+10 1963 CA5619 jp z, COMMAND_READ; skip LF for file load
41:13953+7 1966 FE08 cp 0x08 ; backspace 0x08 VT102 0x7f Putty
42:13960+10 1968 CA8519 jp z,COMMAND_BACKSPACE
43:
44:13970+11 196B F5 push af
45: ; a contains latest char
46:13981+10 196C 217B41 ld hl,[var_input]
47:13991+7 196F 1600 ld d,0
48:13998+13 1971 3A0041 ld a,(var_buffer_len)
49:14011+4 1974 5F ld e,a
50:14015+11 1975 19 add hl,de ;hl now contains pointer to last position in buffer
51:14026+4 1976 3C inc a
52:14030+13 1977 320041 ld (var_buffer_len),a ;store incremented buffer length
53:
54:14043+10 197A F1 pop af
55:14053+7 197B 77 ld (hl),a
56:14060+17 197C CD1501 call print_char
57:14077+6 197F 23 inc hl
58:14083+4 1980 AF xor a ;a = 0
59:14087+7 1981 77 ld (hl),a ;always add null termination after last char
60:14094+10 1982 C35619 jp COMMAND_READ
61:
62:
63: - 1985 COMMAND_BACKSPACE:
64:14104+13 1985 3A0041 ld a,(var_buffer_len)
65:14117+4 1988 A7 and a
66:14121+10 1989 CA5619 jp z, COMMAND_READ ; do not continue if already at char 0
67:14131+4 198C 3D dec a ;decrement length
68:14135+13 198D 320041 ld (var_buffer_len),a ;and store it
69:14148+4 1990 5F ld e,a ;load de with decremented value
70:14152+7 1991 1600 ld d,0
71:14159+10 1993 217B41 ld hl,[var_input]
72:14169+11 1996 19 add hl,de ;hl now contains pointer to last position in buffer
73:14180+4 1997 AF xor a ; store null byte to current location
74:14184+7 1998 77 ld (hl),a
75: ;call print_delete
76:14191+7 1999 3E08 ld a, 0x08
77:14198+17 199B CD1501 call print_char
78:14215+7 199E 3E20 ld a, 0x20
79:14222+17 19A0 CD1501 call print_char
80:14239+7 19A3 3E08 ld a, 0x08
81:14246+17 19A5 CD1501 call print_char
82:14263+10 19A8 C35619 jp COMMAND_READ
83: - 19AB COMMAND_PROCESS:
84: ;compare
85:14273+10 19AB 21B218 LD HL,[COMMAND_LUT] ;Lookup table
86: - 19AE COMMAND_PROCESS_LOOP:
87:14283+10 19AE 117B41 LD DE,[var_input] ;Buffer
88:14293+7 19B1 7E LD A,(HL) ;Load first byte of entry
89:14300+7 19B2 FEFF CP 0xFF
90:14307+10 19B4 CADD19 JP Z,COMMAND_PROCESS_NOT_FOUND ;if first byte is 0xFF, End is reached
91: ; compare string loop
92: - 19B7 COMMAND_PROCESS_LOOP_STR1:
93:14317+7 19B7 1A LD A,(DE)
94:14324+4 19B8 47 LD B,A
95:14328+7 19B9 7E LD A,(HL)
96:14335+4 19BA B0 OR B ;not 0 -> match
97:14339+10 19BB CAE619 JP Z, COMMAND_PROCESS_FOUND ;match
98:
99:14349+7 19BE 1A LD A,(DE)
100:14356+4 19BF 47 LD B,A
101: ;LD A,(HL) ;Load first byte of entry
102: ;call print_a_hex
103:14360+7 19C0 7E LD A,(HL)
104: ;compare byte
105:14367+4 19C1 A8 XOR B
106:14371+4 19C2 B7 OR A ;if identical = resoult shopuld be zero
107:14375+10 19C3 CACD19 JP Z, COMMAND_PROCESS_LOOP_STR2 ;then continue
108: ; if not identical
109:14385+7 19C6 7E LD A,(HL)
110:14392+4 19C7 B7 OR A ;if reached end of compare string
111:14396+10 19C8 CAE619 JP Z, COMMAND_PROCESS_FOUND ;match
112:14406+12 19CB 1805 JR COMMAND_PROCESS_NEXT_ENTRY ;next entry on no match
113:
114: - 19CD COMMAND_PROCESS_LOOP_STR2: ;continue with next char
115:14418+6 19CD 23 INC HL
116:14424+6 19CE 13 INC DE
117:14430+12 19CF 18E6 JR COMMAND_PROCESS_LOOP_STR1
118:
119: - 19D1 COMMAND_PROCESS_NEXT_ENTRYI: ;do not jump here
120:14442+6 19D1 23 INC HL
121: - 19D2 COMMAND_PROCESS_NEXT_ENTRY: ;jump here
122:14448+7 19D2 7E LD A,(HL)
123:14455+4 19D3 B7 OR A
124:14459+10 19D4 C2D119 JP NZ,COMMAND_PROCESS_NEXT_ENTRYI ;loop until end of string
125:14469+6 19D7 23 INC HL ;skip pointer
126:14475+6 19D8 23 INC HL
127:14481+6 19D9 23 INC HL
128:14487+10 19DA C3AE19 JP COMMAND_PROCESS_LOOP
129: - 19DD COMMAND_PROCESS_NOT_FOUND:
130:14497+10 19DD 21171A LD HL,[_STR_NOT_FOUND]
131:14507+17 19E0 CD1D01 CALL print_str
132:14524+10 19E3 C34419 JP COMMAND
133:
134: - 19E6 COMMAND_PROCESS_FOUND:
135:14534+11 19E6 E5 PUSH HL
136:14545+10 19E7 C1 POP BC
137:14555+6 19E8 03 INC BC
138:14561+7 19E9 0A LD A,(BC)
139:14568+4 19EA 6F LD L,A
140:14572+6 19EB 03 INC BC
141:14578+7 19EC 0A LD A,(BC)
142:14585+4 19ED 67 LD H,A
143:
144: ;HL: pointer to start of routine
145: ;DE: buffer start of arguments
146:14589+17 19EE CDF419 CALL _COMMAND_PROCESS_FOUND
147:14606+10 19F1 C34419 JP COMMAND
148: - 19F4 _COMMAND_PROCESS_FOUND
149:14616+4 19F4 E9 JP (HL)
150:
151: - 19F5 NOT_IMPLEMENTED:
152:14620+10 19F5 21031A LD HL,[_STR_NOT_IMPLEMENTED]
153:14630+17 19F8 CD1D01 CALL print_str
154:14647+10 19FB C9 RET
155:
156: - 19FC ERR_SYNTAX:
157:14657+10 19FC 212B1A LD HL,[_STR_SYNTAX]
158:14667+17 19FF CD1D01 CALL print_str
159:14684+10 1A02 C9 RET
160:
161: - 1A03 _STR_NOT_IMPLEMENTED:
162: - 1A03 0A0D6E6F db 10,13,"not implemented",10,13,0
7420696D
706C656D
656E7465
640A0D00
163:
164: - 1A17 _STR_NOT_FOUND:
165: - 1A17 0A0D696E db 10,13,"invalid command",10,13,0
76616C69
6420636F
6D6D616E
640A0D00
166:
167: - 1A2B _STR_SYNTAX:
**** main.asm ****
195: - 1A2B 0A0D696E db 10,13,"invalid syntax",10,13,0
76616C69
64207379
6E746178
0A0D00
196: .include "cmd_mem.s"
**** include/cmd_mem.s ****
1: - 1A3E OP_EXEC:
2: ;DE contains pointer
3:14694+11 1A3E D5 push DE
4:14705+10 1A3F E1 pop HL
5:14715+17 1A40 CD3502 call DHEX_TO_BYTE
6:14732+4 1A43 47 ld b,a ;store result in b
7:14736+4 1A44 7B ld a,e ;check for error
8:14740+4 1A45 A7 and a
9:14744+10 1A46 C2FC19 jp nz, ERR_SYNTAX
10:14754+6 1A49 23 inc HL
11:14760+6 1A4A 23 inc HL
12:14766+17 1A4B CD3502 call DHEX_TO_BYTE
13:14783+4 1A4E 4F ld c,a
14:14787+4 1A4F 7B ld a,e ;check for error
15:14791+4 1A50 A7 and a
16:14795+10 1A51 C2FC19 jp nz, ERR_SYNTAX
17:14805+4 1A54 60 ld h,b
18:14809+4 1A55 69 ld l,c
19:14813+4 1A56 E9 jp (hl)
20: - 1A57 OP_CALL:
21: ;DE contains pointer
22:14817+11 1A57 D5 push DE
23:14828+10 1A58 E1 pop HL
24:14838+17 1A59 CD3502 call DHEX_TO_BYTE
25:14855+4 1A5C 47 ld b,a ;store result in b
26:14859+4 1A5D 7B ld a,e ;check for error
27:14863+4 1A5E A7 and a
28:14867+10 1A5F C2FC19 jp nz, ERR_SYNTAX
29:14877+6 1A62 23 inc HL
30:14883+6 1A63 23 inc HL
31:14889+17 1A64 CD3502 call DHEX_TO_BYTE
32:14906+4 1A67 4F ld c,a
33:14910+4 1A68 7B ld a,e ;check for error
34:14914+4 1A69 A7 and a
35:14918+10 1A6A C2FC19 jp nz, ERR_SYNTAX
36:14928+4 1A6D 60 ld h,b
37:14932+4 1A6E 69 ld l,c
38:14936+17 1A6F CD761A call _OP_CALL
39:14953+17 1A72 CD2D01 call print_newLine
40:14970+10 1A75 C9 ret
41: - 1A76 _OP_CALL
42:14980+4 1A76 E9 jp (hl)
43:
44: - 1A77 OP_DUMP:
45: ;DE contains pointer
46:14984+11 1A77 D5 push DE
47:14995+10 1A78 E1 pop HL
48:15005+17 1A79 CD3502 call DHEX_TO_BYTE ;parse start address
49:15022+4 1A7C 47 ld b,a ;store result in b
50:15026+4 1A7D 7B ld a,e ;check for error
51:15030+4 1A7E A7 and a
52:15034+10 1A7F C2FC19 jp nz, ERR_SYNTAX
53:15044+6 1A82 23 inc HL
54:15050+6 1A83 23 inc HL
55:15056+17 1A84 CD3502 call DHEX_TO_BYTE
56:15073+4 1A87 4F ld c,a
57:15077+4 1A88 7B ld a,e ;check for error
58:15081+4 1A89 A7 and a
59:15085+10 1A8A C2FC19 jp nz, ERR_SYNTAX
60:15095+6 1A8D 23 inc HL
61:15101+6 1A8E 23 inc HL
62:15107+7 1A8F 7E ld a,(HL)
63:15114+7 1A90 FE20 cp ' '
64:15121+10 1A92 C2FC19 jp nz, ERR_SYNTAX
65:15131+6 1A95 23 inc HL
66:15137+17 1A96 CD3502 call DHEX_TO_BYTE
67:15154+11 1A99 F5 push af
68:15165+4 1A9A 7B ld a,e ;check for error
69:15169+4 1A9B A7 and a
70:15173+10 1A9C C2FC19 jp nz, ERR_SYNTAX
71:15183+10 1A9F F1 pop af
72:
73:15193+4 1AA0 60 ld h,b
74:15197+4 1AA1 69 ld l,c
75:15201+4 1AA2 47 ld b,a
76:
77:15205+17 1AA3 CD1018 call dump_pretty
78:15222+10 1AA6 C9 ret
79:
80: - 1AA7 OP_SET:
81: ;DE contains pointer
82:15232+11 1AA7 D5 push DE
83:15243+10 1AA8 E1 pop HL
84:15253+17 1AA9 CD3502 call DHEX_TO_BYTE ;parse start address
85:15270+4 1AAC 47 ld b,a ;store result in b
86:15274+4 1AAD 7B ld a,e ;check for error
87:15278+4 1AAE A7 and a
88:15282+10 1AAF C2FC19 jp nz, ERR_SYNTAX
89:15292+6 1AB2 23 inc HL
90:15298+6 1AB3 23 inc HL
91:15304+17 1AB4 CD3502 call DHEX_TO_BYTE
92:15321+4 1AB7 4F ld c,a
93:15325+4 1AB8 7B ld a,e ;check for error
94:15329+4 1AB9 A7 and a
95:15333+10 1ABA C2FC19 jp nz, ERR_SYNTAX
96: ;bc now contains the start address
97:15343+6 1ABD 23 INC HL
98:15349+6 1ABE 23 INC HL
99: ;hl now cointains start addr of data bytes
100: - 1ABF _OP_SET_LOOP:
101:15355+7 1ABF 7E ld a,(hl)
102:15362+7 1AC0 FE00 cp 0 ;if 0 then end
103:15369+5+6 1AC2 C8 RET Z
104:15374+7 1AC3 FE20 cp ' '
105:15381+10 1AC5 C2FC19 jp nz, ERR_SYNTAX
106:15391+6 1AC8 23 inc hl ;next byte
107:15397+17 1AC9 CD3502 call DHEX_TO_BYTE
108:15414+7 1ACC 02 ld (bc),a ;load byte to
109:15421+4 1ACD 7B ld a,e
110:15425+4 1ACE A7 and a
111:15429+10 1ACF C2FC19 jp nz, ERR_SYNTAX
112:15439+6 1AD2 03 inc bc
113:15445+6 1AD3 23 inc hl
114:15451+6 1AD4 23 inc hl
115:15457+10 1AD5 C3BF1A jp _OP_SET_LOOP
116:
117: - 1AD8 OP_DASM:
118:15467+11 1AD8 D5 push DE
119:15478+10 1AD9 E1 pop HL
120:15488+17 1ADA CD3502 call DHEX_TO_BYTE
121:15505+4 1ADD 47 ld b,a ;store result in b
122:15509+4 1ADE 7B ld a,e ;check for error
123:15513+4 1ADF A7 and a
124:15517+10 1AE0 C2FC19 jp nz, ERR_SYNTAX
125:15527+6 1AE3 23 inc hl
126:15533+6 1AE4 23 inc hl
127:15539+17 1AE5 CD3502 call DHEX_TO_BYTE
128:15556+4 1AE8 4F ld c,a
129:15560+4 1AE9 7B ld a,e ;check for error
130:15564+4 1AEA A7 and a
131:15568+10 1AEB C2FC19 jp nz, ERR_SYNTAX
132:15578+6 1AEE 23 inc hl
133:15584+6 1AEF 23 inc hl
134:15590+7 1AF0 7E ld a,(HL)
135:15597+7 1AF1 FE20 cp ' '
136:15604+10 1AF3 C2FC19 jp nz, ERR_SYNTAX
137:15614+6 1AF6 23 inc hl
138:15620+17 1AF7 CD3502 call DHEX_TO_BYTE
139:15637+11 1AFA F5 push af
140:15648+4 1AFB 7B ld a,e ;check for error
141:15652+4 1AFC A7 and a
142:15656+10 1AFD C2FC19 jp nz, ERR_SYNTAX
143:15666+4 1B00 60 ld h,b
144:15670+4 1B01 69 ld l,c
145:15674+10 1B02 F1 pop af ;restore af
146:15684+4 1B03 47 ld b,a
147:15688+17 1B04 CD8602 call disassemble
**** main.asm ****
197:15705+10 1B07 C9 ret
198: .include "cmd_io.s"
**** include/cmd_io.s ****
1: - 1B08 OP_IO_IN:
2:15715+11 1B08 D5 push DE
3:15726+10 1B09 E1 pop HL
4:15736+17 1B0A CD3502 call DHEX_TO_BYTE
5:15753+4 1B0D 4F ld c,a ;store result in b
6:15757+4 1B0E 7B ld a,e ;check for error
7:15761+4 1B0F A7 and a
8:15765+10 1B10 C2FC19 jp nz, ERR_SYNTAX
9:15775+12 1B13 ED78 in a,(c)
10:15787+11 1B15 F5 push af
11:15798+17 1B16 CD2D01 call print_newLine
12:15815+10 1B19 F1 pop af
13:15825+17 1B1A CD4301 call print_a_hex
14:15842+10 1B1D C9 ret
15:
16: - 1B1E OP_IO_OUT:
17:15852+11 1B1E D5 push DE
18:15863+10 1B1F E1 pop HL
19:15873+17 1B20 CD3502 call DHEX_TO_BYTE
20:15890+4 1B23 4F ld c,a ;store result in b
21:15894+4 1B24 7B ld a,e ;check for error
22:15898+4 1B25 A7 and a
23:15902+10 1B26 C2FC19 jp nz, ERR_SYNTAX
24:15912+6 1B29 23 inc hl
25:15918+6 1B2A 23 inc hl
26:15924+7 1B2B 7E ld a,(hl)
27:15931+7 1B2C FE20 cp ' '
28:15938+10 1B2E C2FC19 jp nz, ERR_SYNTAX
29:15948+6 1B31 23 inc hl
30:15954+17 1B32 CD3502 call DHEX_TO_BYTE
31:15971+11 1B35 F5 push af
32:15982+4 1B36 7B ld a,e ;check for error
33:15986+4 1B37 A7 and a
34:15990+10 1B38 C2FC19 jp nz, ERR_SYNTAX
35:16000+10 1B3B F1 pop af
36:16010+12 1B3C ED79 out (c),a
37:16022+10 1B3E C9 ret
38:
39: - 1B3F OP_IIC_OUT:
40:16032+11 1B3F D5 push DE
41:16043+10 1B40 E1 pop HL
42:16053+17 1B41 CD3502 call DHEX_TO_BYTE ;load start addr
43:16070+13 1B44 320C41 ld (var_scratch+1),A ;store result in ram
44:16083+4 1B47 7B ld a,e ;check for error
45:16087+4 1B48 A7 and a
46:16091+10 1B49 C2FC19 jp nz, ERR_SYNTAX
47:16101+6 1B4C 23 inc hl
48:16107+6 1B4D 23 inc hl
49:16113+10 1B4E 010D41 LD BC,[var_scratch + 2]
50:16123+4 1B51 AF XOR A
51:16127+13 1B52 320B41 LD (var_scratch),A
52: - 1B55 _OP_IIC_OUT_LOOP:
53:16140+7 1B55 7E ld a,(hl)
54:16147+7 1B56 FE00 cp 0 ;if 0 then end
55:16154+10 1B58 CA711B jp z,_OP_IIC_OUT_SEND
56:16164+7 1B5B FE20 cp ' '
57:16171+10 1B5D C2FC19 jp nz, ERR_SYNTAX
58:16181+6 1B60 23 inc hl ;next byte
59:
60:16187+17 1B61 CD3502 call DHEX_TO_BYTE
61:16204+7 1B64 02 ld (bc),a
62:16211+6 1B65 03 inc bc ;incerement pointer
63:16217+13 1B66 3A0B41 ld a,(var_scratch)
64:16230+4 1B69 3C inc a ;increment counter
65:16234+13 1B6A 320B41 ld (var_scratch),a
66:16247+6 1B6D 23 inc HL
67:16253+6 1B6E 23 inc HL
68:16259+12 1B6F 18E4 jr _OP_IIC_OUT_LOOP
69: - 1B71 _OP_IIC_OUT_SEND:
70:16271+10 1B71 210D41 ld hl,[var_scratch + 2]
71:16281+13 1B74 3A0B41 ld a,(var_scratch) ;load amount of bytes
72:16294+4 1B77 47 ld b,a
73:16298+13 1B78 3A0C41 ld a,(var_scratch+1) ;load start addr
74:16311+4 1B7B 4F ld c,a
75:16315+17 1B7C CDC316 call iic_send_buffer
76:16332+4 1B7F B7 or a
77:16336+10 1B80 C2841B jp nz, _OP_IIC_ACK_ERR
78:16346+10 1B83 C9 ret
79:
80: - 1B84 _OP_IIC_ACK_ERR:
81:16356+10 1B84 218B1B LD HL,[_OP_IIC_ACK_ERR_str]
82:16366+17 1B87 CD1D01 call print_str
83:16383+10 1B8A C9 ret
84: - 1B8B _OP_IIC_ACK_ERR_str:
85: - 1B8B 0A0D6275 db 10,13,"bus-error: no ACK",0
732D6572
726F723A
206E6F20
41434B00
86:
87: - 1B9F OP_IIC_IN:
88:16393+11 1B9F D5 push DE
89:16404+10 1BA0 E1 pop HL
90:16414+17 1BA1 CD3502 call DHEX_TO_BYTE ;load start addr
91:16431+4 1BA4 4F ld C,a ;store start addr to B
92:16435+4 1BA5 7B ld a,e ;check for error
93:16439+4 1BA6 A7 and a
94:16443+10 1BA7 C2FC19 jp nz, ERR_SYNTAX
95:16453+6 1BAA 23 inc hl
96:16459+6 1BAB 23 inc hl
97:16465+7 1BAC 7E ld a,(hl)
98:16472+7 1BAD FE20 cp ' '
99:16479+10 1BAF C2FC19 jp nz, ERR_SYNTAX
100:16489+6 1BB2 23 inc hl
101:16495+17 1BB3 CD3502 call DHEX_TO_BYTE ;read length
102:16512+4 1BB6 47 ld b,a ;store length in B
103:16516+11 1BB7 C5 push bc
104:16527+4 1BB8 7B ld a,e ;check for error
105:16531+4 1BB9 A7 and a
106:16535+10 1BBA C2FC19 jp nz, ERR_SYNTAX
107:16545+10 1BBD 210B41 ld hl,[var_scratch]
108:16555+17 1BC0 CDED16 call iic_receive_buffer
109:16572+10 1BC3 C1 pop bc
110:16582+4 1BC4 B7 or a
111:16586+10 1BC5 C2841B jp nz, _OP_IIC_ACK_ERR
112:16596+10 1BC8 21DE1B ld hl,[_OP_IIC_IN_LOOP_TEXT]
113:16606+17 1BCB CD1D01 call print_str
114:16623+10 1BCE 210B41 ld hl,[var_scratch]
115: ;print data
116: - 1BD1 _OP_IIC_IN_LOOP:
117:16633+7 1BD1 7E ld a,(hl)
118:16640+17 1BD2 CD4301 call print_a_hex
119:16657+7 1BD5 3E20 ld a, ' '
120:16664+17 1BD7 CD1501 call print_char
121:16681+6 1BDA 23 inc hl
122:16687+8+5 1BDB 10F4 djnz _OP_IIC_IN_LOOP
123:16695+10 1BDD C9 ret
124:
125: - 1BDE _OP_IIC_IN_LOOP_TEXT:
126: - 1BDE 0A0D7265 db 10,13,"rec-buff: ",0
632D6275
66663A20
00
127:
128: - 1BEB OP_CLR:
129:16705+17 1BEB CD2601 call print_clear
**** main.asm ****
199:16722+10 1BEE C9 ret
200: .include "cmd_date.s"
**** include/cmd_date.s ****
1: - 00D0 ADDR_RTC .equ 0xD0
2:
3: - 1BEF OP_RTIME:
4:16732+17 1BEF CD2D01 call print_newLine
5: - 1BF2 _OP_RTIME_NN:
6: ;set pointer
7:16749+10 1BF2 21AA1C ld hl,[_OP_RTIME_RD_CMD]
8:16759+7 1BF5 0601 ld b, 1
9:16766+7 1BF7 0ED0 ld c, ADDR_RTC
10:16773+17 1BF9 CDC316 call iic_send_buffer
11:16790+4 1BFC B7 or a
12:16794+10 1BFD C2841B jp nz, _OP_IIC_ACK_ERR
13: ;read RTC data
14:16804+10 1C00 210B41 ld hl,[var_scratch]
15:16814+7 1C03 0608 ld b,8
16:16821+7 1C05 0ED0 ld c, ADDR_RTC
17:16828+17 1C07 CDED16 call iic_receive_buffer
18:16845+4 1C0A B7 or a
19:16849+10 1C0B C2841B jp nz, _OP_IIC_ACK_ERR
20: ;process display hours
21:16859+13 1C0E 3A0D41 ld a,(var_scratch+2)
22:16872+7 1C11 E630 and 00110000b
23:16879+4 1C13 1F RRA
24:16883+4 1C14 1F RRA
25:16887+4 1C15 1F RRA
26:16891+4 1C16 1F RRA
27:16895+17 1C17 CD5501 call print_bcd
28:16912+13 1C1A 3A0D41 ld a,(var_scratch+2)
29:16925+7 1C1D E60F and 00001111b
30:16932+17 1C1F CD5501 call print_bcd
31:16949+7 1C22 3E3A ld a,':'
32:16956+17 1C24 CD1501 call print_char
33: ;display minutes
34:16973+13 1C27 3A0C41 ld a,(var_scratch+1)
35:16986+7 1C2A E670 and 01110000b
36:16993+4 1C2C 1F RRA
37:16997+4 1C2D 1F RRA
38:17001+4 1C2E 1F RRA
39:17005+4 1C2F 1F RRA
40:17009+17 1C30 CD5501 call print_bcd
41:17026+13 1C33 3A0C41 ld a,(var_scratch+1)
42:17039+7 1C36 E60F and 00001111b
43:17046+17 1C38 CD5501 call print_bcd
44:17063+7 1C3B 3E3A ld a,':'
45:17070+17 1C3D CD1501 call print_char
46: ;display seconds
47:17087+13 1C40 3A0B41 ld a,(var_scratch+0)
48:17100+7 1C43 E670 and 01110000b
49:17107+4 1C45 1F RRA
50:17111+4 1C46 1F RRA
51:17115+4 1C47 1F RRA
52:17119+4 1C48 1F RRA
53:17123+17 1C49 CD5501 call print_bcd
54:17140+13 1C4C 3A0B41 ld a,(var_scratch+0)
55:17153+7 1C4F E60F and 00001111b
56:17160+17 1C51 CD5501 call print_bcd
57:17177+7 1C54 3E20 ld a,' '
58:17184+17 1C56 CD1501 call print_char
59: ;display date
60:17201+13 1C59 3A0F41 ld a,(var_scratch+4)
61:17214+7 1C5C E630 and 00110000b
62:17221+4 1C5E 1F RRA
63:17225+4 1C5F 1F RRA
64:17229+4 1C60 1F RRA
65:17233+4 1C61 1F RRA
66:17237+17 1C62 CD5501 call print_bcd
67:17254+13 1C65 3A0F41 ld a,(var_scratch+4)
68:17267+7 1C68 E60F and 00001111b
69:17274+17 1C6A CD5501 call print_bcd
70:17291+7 1C6D 3E2E ld a,'.'
71:17298+17 1C6F CD1501 call print_char
72:17315+13 1C72 3A1041 ld a,(var_scratch+5)
73:17328+7 1C75 E610 and 00010000b
74:17335+4 1C77 1F RRA
75:17339+4 1C78 1F RRA
76:17343+4 1C79 1F RRA
77:17347+4 1C7A 1F RRA
78:17351+17 1C7B CD5501 call print_bcd
79:17368+13 1C7E 3A1041 ld a,(var_scratch+5)
80:17381+7 1C81 E60F and 00001111b
81:17388+17 1C83 CD5501 call print_bcd
82:17405+7 1C86 3E2E ld a,'.'
83:17412+17 1C88 CD1501 call print_char
84:17429+7 1C8B 3E32 ld a,'2'
85:17436+17 1C8D CD1501 call print_char
86:17453+7 1C90 3E30 ld a,'0'
87:17460+17 1C92 CD1501 call print_char
88:17477+13 1C95 3A1141 ld a,(var_scratch+6)
89:17490+7 1C98 E6F0 and 11110000b
90:17497+4 1C9A 1F RRA
91:17501+4 1C9B 1F RRA
92:17505+4 1C9C 1F RRA
93:17509+4 1C9D 1F RRA
94:17513+17 1C9E CD5501 call print_bcd
95:17530+13 1CA1 3A1141 ld a,(var_scratch+6)
96:17543+7 1CA4 E60F and 00001111b
97:17550+17 1CA6 CD5501 call print_bcd
98:
99:17567+10 1CA9 C9 RET
100: - 1CAA _OP_RTIME_RD_CMD:
101: - 1CAA 00 db 0x00
102:
103: - 1CAB 0A0D456E _OP_STIME_STR_DAY: db 10,13,"Enter Date (00-31) : ",0
74657220
44617465
20202020
2830302D
33312920
3A2000
104: - 1CC6 0A0D456E _OP_STIME_STR_MON: db 10,13,"Enter Month (00-12) : ",0
74657220
4D6F6E74
68202020
2830302D
31322920
3A2000
105: - 1CE1 0A0D456E _OP_STIME_STR_YEAR: db 10,13,"Enter Year (00-99) : ",0
74657220
59656172
20202020
2830302D
39392920
3A2000
106: - 1CFC 0A0D456E _OP_STIME_STR_HOUR: db 10,13,"Enter Hours (00-23) : ",0
74657220
486F7572
73202020
2830302D
32332920
3A2000
107: - 1D17 0A0D456E _OP_STIME_STR_MIN: db 10,13,"Enter Minutes (00-59) : ",0
74657220
4D696E75
74657320
2830302D
35392920
3A2000
108: - 1D32 0A0D456E _OP_STIME_STR_SEC: db 10,13,"Enter Seconds (00-59) : ",0
74657220
5365636F
6E647320
2830302D
35392920
3A2000
109: - 1D4D 20696E76 _OP_STIME_INVALID: db " invaild input. Retry!",0
61696C64
20696E70
75742E20
52657472
792100
110: ;HL contains pointer to stack
111: ;BC returns value (BCD)
112: - 1D64 _OP_STIME_PROMPT:
113:17577+11 1D64 E5 push hl
114:17588+17 1D65 CD1D01 call print_str
115:17605+10 1D68 E1 pop hl
116:17615+17 1D69 CD7701 call read_bcd
117:17632+7 1D6C FEFF cp 0xFF ;if failed
118:17639+10 1D6E CA7C1D jp Z, _OP_STIME_PROMPT_ERR
119:17649+4 1D71 47 ld b,a
120:17653+17 1D72 CD7701 call read_bcd
121:17670+7 1D75 FEFF cp 0xFF ;if failed
122:17677+10 1D77 CA7C1D jp Z, _OP_STIME_PROMPT_ERR
123:17687+4 1D7A 4F ld c,a
124:17691+10 1D7B C9 ret
125: - 1D7C _OP_STIME_PROMPT_ERR:
126:17701+11 1D7C E5 push HL
127:17712+10 1D7D 214D1D ld hl, [_OP_STIME_INVALID]
128:17722+17 1D80 CD1D01 call print_str
129:17739+10 1D83 E1 pop hl
130:17749+10 1D84 C3641D jp _OP_STIME_PROMPT
131:
132:
133:
134: - 1D87 OP_STIME:
135:17759+4 1D87 AF xor a
136:17763+13 1D88 320B41 ld (var_scratch),a ;set pointer
137: ;date
138:17776+10 1D8B 21AB1C ld hl, [_OP_STIME_STR_DAY]
139:17786+17 1D8E CD641D call _OP_STIME_PROMPT
140:17803+4 1D91 78 ld a,b
141:17807+17 1D92 CDFB1D call _shift4
142:17824+7 1D95 E630 and 00110000b ;mask bits; bit6 low -> 24h mode
143:17831+4 1D97 B1 or c ;add second digit
144:17835+13 1D98 321041 ld (var_scratch+5),a
145: ;month
146:17848+10 1D9B 21C61C ld hl, [_OP_STIME_STR_MON]
147:17858+17 1D9E CD641D call _OP_STIME_PROMPT
148:17875+4 1DA1 78 ld a,b
149:17879+17 1DA2 CDFB1D call _shift4
150:17896+7 1DA5 E610 and 00010000b ;mask bits; bit6 low -> 24h mode
151:17903+4 1DA7 B1 or c ;add second digit
152:17907+13 1DA8 321141 ld (var_scratch+6),a
153: ;year
154:17920+10 1DAB 21E11C ld hl, [_OP_STIME_STR_YEAR]
155:17930+17 1DAE CD641D call _OP_STIME_PROMPT
156:17947+4 1DB1 78 ld a,b
157:17951+17 1DB2 CDFB1D call _shift4
158:17968+7 1DB5 E6F0 and 11110000b ;mask bits; bit6 low -> 24h mode
159:17975+4 1DB7 B1 or c ;add second digit
160:17979+13 1DB8 321241 ld (var_scratch+7),a
161: ;hours
162:17992+10 1DBB 21FC1C ld hl, [_OP_STIME_STR_HOUR]
163:18002+17 1DBE CD641D call _OP_STIME_PROMPT
164:18019+4 1DC1 78 ld a,b
165:18023+17 1DC2 CDFB1D call _shift4
166:18040+7 1DC5 E630 and 00110000b ;mask bits; bit6 low -> 24h mode
167:18047+4 1DC7 B1 or c ;add second digit
168:18051+13 1DC8 320E41 ld (var_scratch+3),a
169: ; minutes
170:18064+10 1DCB 21171D ld hl, [_OP_STIME_STR_MIN]
171:18074+17 1DCE CD641D call _OP_STIME_PROMPT
172:18091+4 1DD1 78 ld a,b
173:18095+17 1DD2 CDFB1D call _shift4
174:18112+7 1DD5 E670 and 01110000b ;mask bits
175:18119+4 1DD7 B1 or c ;add second digit
176:18123+13 1DD8 320D41 ld (var_scratch+2),a
177: ; seconds
178:18136+10 1DDB 21321D ld hl, [_OP_STIME_STR_SEC]
179:18146+17 1DDE CD641D call _OP_STIME_PROMPT
180:18163+4 1DE1 78 ld a,b
181:18167+17 1DE2 CDFB1D call _shift4
182:18184+7 1DE5 E670 and 01110000b ;mask bits / bit6 low -> 24h mode (enable clock)
183:18191+4 1DE7 B1 or c ;add second digit
184:18195+13 1DE8 320C41 ld (var_scratch+1),a
185:18208+6 1DEB 13 inc de ;next
186:
187:18214+7 1DEC 0ED0 ld c, ADDR_RTC
188:18221+7 1DEE 0608 ld b, 8
189:18228+10 1DF0 210B41 ld hl,[var_scratch]
190:18238+17 1DF3 CDC316 call iic_send_buffer
191:18255+4 1DF6 B7 or a
192:18259+10 1DF7 C2841B jp nz, _OP_IIC_ACK_ERR
193:
194:18269+10 1DFA C9 ret
195:
196: - 1DFB _shift4:
197:18279+4 1DFB 07 RLCA
198:18283+4 1DFC 07 RLCA
199:18287+4 1DFD 07 RLCA
200:18291+4 1DFE 07 RLCA
**** main.asm ****
201:18295+10 1DFF C9 ret
202: .include "cmd_disk.s"
**** include/cmd_disk.s ****
1: - 1E00 OP_LSDSK:
2:18305+17 1E00 CD6513 call ideif_prnt_devtable
3:18322+10 1E03 C9 ret
4:
5: - 1E04 OP_SELDSK:
6: ;DE contains pointer
7:18332+11 1E04 D5 push de
8:18343+10 1E05 E1 pop hl
9:18353+7 1E06 7E ld a,(hl)
10:18360+7 1E07 DE45 sbc 69
11:18367+7+5 1E09 3808 jr c,_OP_SELDSK_INVALID
12:18374+7 1E0B FE04 cp 4
13:18381+7+5 1E0D 3004 jr nc, _OP_SELDSK_INVALID
14:18388+17 1E0F CD9A15 call ideif_drv_sel
15:18405+10 1E12 C9 ret
16:
17: - 1E13 _OP_SELDSK_INVALID:
18:18415+10 1E13 212B1E ld hl,[_OP_SELDSK_INVALID_STR]
19:18425+17 1E16 CD1D01 call print_str
20:18442+10 1E19 112000 LD DE,0x20
21:18452+10 1E1C 017000 LD BC,0x70
22:18462+17 1E1F CDE80D CALL beep
23:18479+10 1E22 C9 ret
24:
25: - 1E23 OP_DIR:
26:18489+17 1E23 CD8223 CALL fat_print_directory
27:18506+10 1E26 C9 ret
28:
29: - 1E27 OP_CD:
30:18516+17 1E27 CD9B24 call fat_cd_single
31:18533+10 1E2A C9 ret
32:
33: - 1E2B _OP_SELDSK_INVALID_STR:
34: - 1E2B 0A0D496E db 10,13,"Invalid drive letter",10,13,0
76616C69
64206472
69766520
6C657474
65720A0D
00
35:
36: - 1E44 OP_FSEXEC:
37:18543+17 1E44 CDB625 call fat_exec
**** main.asm ****
203:18560+10 1E47 C9 ret
204: .include "post.s"
**** include/post.s ****
1: ;Power-On self test
2: - 1E48 POST_START:
3:18570+17 1E48 CD581E call POST_CHECK_PIO
4:18587+17 1E4B CD7D1E call POST_CHECK_APU
5:18604+17 1E4E CDD51E call POST_TEST_RTC
6:18621+17 1E51 CDA81E call POST_CHECK_IDE_30
7:18638+17 1E54 CDBB1E call POST_CHECK_IDE_40
8:18655+10 1E57 C9 ret
9:
10: - 1E58 POST_CHECK_PIO:
11:18665+10 1E58 214C1F ld hl,[str_post_pio]
12:18675+17 1E5B CD1D01 call print_str
13:18692+11 1E5E DBF6 in a,(CS_PIO_AC) ;test read from pio
14:18703+7 1E60 FE00 cp 0x00 ;0x78 when not installed
15:18710+10 1E62 C2711E jp nz, _POST_CHECK_PIO_FAILED
16:18720+7 1E65 3E00 ld a, 0x00 ;set present flag
17:18727+13 1E67 320941 ld (var_pio_present),a
18:18740+10 1E6A 21D51F ld hl,[str_post_ok]
19:18750+17 1E6D CD1D01 call print_str
20:18767+10 1E70 C9 ret
21: - 1E71 _POST_CHECK_PIO_FAILED:
22:18777+7 1E71 3EFF ld a, 0xFF
23:18784+13 1E73 320941 ld (var_pio_present),a
24:18797+10 1E76 219D1F ld hl,[str_post_nd]
25:18807+17 1E79 CD1D01 call print_str
26:18824+10 1E7C C9 ret
27:
28: - 1E7D POST_CHECK_APU:
29:18834+10 1E7D 21671F ld hl,[str_post_apu]
30:18844+17 1E80 CD1D01 call print_str
31:
32:18861+7 1E83 3EFF ld a, 0xFF
33:18868+11 1E85 D3F8 out (CS_APU_DATA),a
34:18879+4 1E87 00 nop
35:18883+4 1E88 00 nop
36:18887+11 1E89 DBF8 in a,(CS_APU_DATA)
37:18898+7 1E8B FEFF cp 0xFF
38:18905+10 1E8D C29C1E jp nz, _POST_CHECK_APU_FAILED
39:18915+7 1E90 3E00 ld a, 0x00 ;set present flag
40:18922+13 1E92 320A41 ld (var_apu_present),a
41:18935+10 1E95 21D51F ld hl,[str_post_ok]
42:18945+17 1E98 CD1D01 call print_str
43:18962+10 1E9B C9 ret
44: - 1E9C _POST_CHECK_APU_FAILED:
45:18972+7 1E9C 3EFF ld a, 0xFF
46:18979+13 1E9E 320A41 ld (var_apu_present),a
47:18992+10 1EA1 219D1F ld hl,[str_post_nd]
48:19002+17 1EA4 CD1D01 call print_str
49:19019+10 1EA7 C9 ret
50:
51: - 1EA8 POST_CHECK_IDE_30:
52:19029+10 1EA8 21161F ld hl,[str_post_ide_30]
53:19039+17 1EAB CD1D01 call print_str
54:19056+11 1EAE DB30 in a,(0x30)
55:19067+4 1EB0 B7 or a
56:19071+10 1EB1 C2CE1E jp nz, _POST_CHECK_IDE_FAILED
57:19081+10 1EB4 21D51F ld hl,[str_post_ok]
58:19091+17 1EB7 CD1D01 call print_str
59:19108+10 1EBA C9 ret
60: - 1EBB POST_CHECK_IDE_40:
61:19118+10 1EBB 21311F ld hl,[str_post_ide_40]
62:19128+17 1EBE CD1D01 call print_str
63:19145+11 1EC1 DB40 in a,(0x40)
64:19156+4 1EC3 B7 or a
65:19160+10 1EC4 C2CE1E jp nz, _POST_CHECK_IDE_FAILED
66:19170+10 1EC7 21D51F ld hl,[str_post_ok]
67:19180+17 1ECA CD1D01 call print_str
68:19197+10 1ECD C9 ret
69:
70: - 1ECE _POST_CHECK_IDE_FAILED
71:19207+10 1ECE 219D1F ld hl,[str_post_nd]
72:19217+17 1ED1 CD1D01 call print_str
73:19234+10 1ED4 C9 ret
74:
75: - 1ED5 POST_TEST_RTC:
76:19244+7 1ED5 3E06 ld a, 0x06
77:19251+13 1ED7 320B41 ld (var_scratch),a
78:19264+10 1EDA 21821F ld hl,[str_post_rtc]
79:19274+17 1EDD CD1D01 call print_str
80:19291+10 1EE0 210B41 ld hl,[var_scratch]
81:19301+7 1EE3 0601 ld b, 1
82:19308+7 1EE5 0ED0 ld c, ADDR_RTC
83:19315+17 1EE7 CDC316 call iic_send_buffer
84:19332+4 1EEA B7 or a
85:19336+10 1EEB C2081F jp nz, _POST_TEST_RTC_NOTFOUND
86:19346+10 1EEE 210B41 ld hl,[var_scratch]
87:19356+7 1EF1 0601 ld b, 1
88:19363+7 1EF3 0ED0 ld c, ADDR_RTC
89:19370+17 1EF5 CDED16 call iic_receive_buffer
90:19387+13 1EF8 3A0B41 ld a, (var_scratch)
91:19400+4 1EFB B7 or a
92:19404+10 1EFC CA0F1F jp z, _POST_TEST_RTC_INVALID
93:19414+10 1EFF 21D51F ld hl,[str_post_ok]
94:19424+17 1F02 CD1D01 call print_str
95:19441+10 1F05 C3F21B jp _OP_RTIME_NN
96: - 1F08 _POST_TEST_RTC_NOTFOUND:
97:19451+10 1F08 219D1F ld hl,[str_post_nd]
98:19461+17 1F0B CD1D01 call print_str
99:19478+10 1F0E C9 ret
100: - 1F0F _POST_TEST_RTC_INVALID:
101:19488+10 1F0F 21AB1F ld hl,[str_post_rtc_iv]
102:19498+17 1F12 CD1D01 call print_str
103:19515+10 1F15 C9 ret
104:
105: - 1F16 str_post_ide_30:
106: - 1F16 0D0A4368 db 13,10,"Check Diskctrl.@030h... ",0
65636B20
4469736B
6374726C
2E403033
30682E2E
2E2000
107: - 1F31 str_post_ide_40:
108: - 1F31 0D0A4368 db 13,10,"Check Diskctrl.@040h... ",0
65636B20
4469736B
6374726C
2E403034
30682E2E
2E2000
109: - 1F4C str_post_pio:
110: - 1F4C 0D0A4368 db 13,10,"Check IO-Controller ... ",0
65636B20
494F2D43
6F6E7472
6F6C6C65
72202E2E
2E2000
111: - 1F67 str_post_apu:
112: - 1F67 0D0A4368 db 13,10,"Check AMD8911 APU ... ",0
65636B20
414D4438
39313120
41505520
20202E2E
2E2000
113: - 1F82 str_post_rtc:
114: - 1F82 0D0A4368 db 13,10,"Check DS1307 RTC ... ",0
65636B20
44533133
30372052
54432020
20202E2E
2E2000
115: - 1F9D str_post_nd:
116: - 1F9D 6E6F7420 db "not detected!",0
64657465
63746564
2100
117: - 1FAB str_post_rtc_iv:
118: - 1FAB 6E6F7420 db "not set. Check battery and run 'setdate'!",0
7365742E
20436865
636B2062
61747465
72792061
6E642072
756E2027
73657464
61746527
2100
119: - 1FD5 str_post_ok:
**** main.asm ****
205: - 1FD5 6F6B2120 db "ok! ",0
00
206: .include "fat16.s"
**** include/fat16.s ****
1: ; VARS
2:
3: - 44B6 phase MEM_IDE_FSBUFFER
4: - 44B6 MEM_FAT_RESERVED: ; Reserved sectors (2byte)
5: - 44B6 ..44B7 00 defs 2
6: - 44B8 MEM_FAT_AMOUNT: ; Amount of FATs (1byte)
7: - 44B8 ..44B8 00 defs 1
8: - 44B9 MEM_FAT_SECTORS: ; Length of FAT (2byte)
9: - 44B9 ..44BA 00 defs 2
10: - 44BB MEM_FAT_CLUSTERLEN: ; Length of Cluster (1byte)
11: - 44BB ..44BB 00 defs 1
12: - 44BC MEM_FAT_COUNT1: ; Counter Var for reading FAT (2byte)
13: - 44BC ..44BC 00 defs 1
14: - 44BD MEM_FAT_TMPPOINTER: ; Temporary working pointer
15: - 44BD ..44C0 00 defs 4
16: - 44C1 MEM_FAT_DATASTART: ; Start of data area
17: - 44C1 ..44C4 00 defs 4
18: - 44C5 MEM_FAT_ROOTSTART: ; Start of Root directory
19: - 44C5 ..44C8 00 defs 4
20: - 44C9 MEM_FAT_FILEREMAIN: ; Remaining sectors in file
21: - 44C9 ..44CC 00 defs 4
22: - 44CD MEM_FAT_DIRSEC: ; Sectors per directory
23: - 44CD ..44CE 00 defs 2
24: - 44CF MEM_FAT_TMPFNAME: ; Temporary filename
25: - 44CF ..44DE 00 defs 16
26: - 44DF MEM_FAT_CURDIR: ; Current Directory
27: - 44DF ..452E 00 defs 80
28: - 452F MEM_FAT_OF0_ATTRIBUTE: ;Current file attribute
29: - 452F 0000 defw 0
30: - 4531 MEM_FAT_OF0_CCLUST: ;Current cluster of file
31: - 4531 0000 defw 0
32: - 4533 MEM_FAT_OF0_FATSEC: ;Current sector in FAT
33: - 4533 ..4536 00 defs 4
34: - 4537 MEM_FAT_OF0_DATSEC: ;Current sector in Data
35: - 4537 ..453A 00 defs 4
36: - 453B MEM_FAT_OF0_DATREM: ;Remaining bytes in Data
37: - 453B ..453E 00 defs 4
38: - 453F MEM_FAT_CURRDIR: ;Current directory
39: - 453F ..4542 00 defs 4
40: - 4543 MEM_FAT_EXEC_CURR:
41: - 4543 0000 defw 0
42: - 4545 MEM_FAT_EXEC_COUNT:
43: - 4545 0000 defw 0
44: - 4547 MEM_FAT_EXEC_START:
45: - 4547 0000 defw 0
46:
47: - 206D dephase
48:
49:
50:
51: ;-------------------------------------
52: ; Get FAT Root-Table position
53: ;-------------------------------------
54: - 206D fat_get_root_table:
55:19525+17 206D CD2E23 call fat_reset_pointer ;reset fat pointer
56:
57: ; Load first sector on active partition
58:19542+10 2070 21D141 LD HL, MEM_IDE_POINTER ; pointer to LBA address
59:19552+7 2073 3E01 LD A,1 ;read 1 sector
60:19559+10 2075 11B642 LD DE, MEM_IDE_BUFFER ;where to store data?
61:19569+17 2078 CD6115 call read_lba_sector
62:
63: ; check for valid Boot sector
64:19586+13 207B 3AB642 ld a,(MEM_IDE_BUFFER)
65:19599+7 207E FEEB cp 0xEB ;first byte should be 0xEB
66:19606+10 2080 C23A21 jp nz, _fat_get_root_table_invalid
67:
68: ; Read and store FS Properties
69:19616+14 2083 DD21B642 LD IX,MEM_IDE_BUFFER
70:19630+19 2087 DD7E0D LD A,(IX+0x0D)
71:19649+13 208A 32BB44 LD (MEM_FAT_CLUSTERLEN),A
72:19662+19 208D DD7E0E LD A,(IX+0x0E)
73:19681+13 2090 32B644 LD (MEM_FAT_RESERVED),A
74:19694+19 2093 DD7E0F LD A,(IX+0x0F)
75:19713+13 2096 32B744 LD (MEM_FAT_RESERVED+1),A
76:19726+19 2099 DD7E10 LD A,(IX+0x10)
77:19745+13 209C 32B844 LD (MEM_FAT_AMOUNT),A
78:19758+19 209F DD7E16 LD A,(IX+0x16)
79:19777+13 20A2 32B944 LD (MEM_FAT_SECTORS),A
80:19790+19 20A5 DD7E17 LD A,(IX+0x17)
81:19809+13 20A8 32BA44 LD (MEM_FAT_SECTORS+1),A
82:
83: ;Get Data Start Sector
84: ;calculate fat length
85:19822+20 20AB ED4BB944 ld bc,(MEM_FAT_SECTORS)
86:19842+13 20AF 3AB844 ld a,(MEM_FAT_AMOUNT) ;add fat to cluster number
87:19855+7 20B2 1600 ld d,0
88:19862+4 20B4 5F ld e,a
89:19866+17 20B5 CD1523 call _fat_math_mul32
90: ; BCHL contains result -> store to PTR.MEM_FAT_ROOTSTART
91:19883+16 20B8 22C544 ld (MEM_FAT_ROOTSTART+0),hl
92:19899+20 20BB ED43C744 ld (MEM_FAT_ROOTSTART+2),bc
93:
94: ;add offset (reserved sectors)
95:19919+16 20BF 2AC442 ld hl,(MEM_IDE_BUFFER +0x0E) ; load sectors into hl
96:19935+16 20C2 22BD44 ld (MEM_FAT_TMPPOINTER), hl
97:19951+4 20C5 AF xor a
98:19955+13 20C6 32BF44 ld (MEM_FAT_TMPPOINTER+2),a
99:19968+13 20C9 32C044 ld (MEM_FAT_TMPPOINTER+3),a
100:
101:19981+10 20CC 01C544 ld bc,[MEM_FAT_ROOTSTART]
102:19991+10 20CF 11BD44 ld de,[MEM_FAT_TMPPOINTER]
103:20001+17 20D2 CDE422 call _fat_math_add32 ;MEM_FAT_ROOTSTART now contains the first sector
104: ;of the Root directory
105:
106: ;add offset (partition location)
107:20018+17 20D5 CD3A15 call ideif_get_drv_pointer
108:20035+10 20D8 DD23 inc ix
109:20045+10 20DA DD23 inc ix
110:20055+15 20DC DDE5 push ix
111:20070+10 20DE D1 pop de ;copy poiter to hl
112:20080+10 20DF 01C544 ld bc,[MEM_FAT_ROOTSTART]
113:20090+17 20E2 CDE422 call _fat_math_add32 ;MEM_FAT_OF0_DATSEC now contains the first sector
114: ;of the cluster
115: ;copy value from MEM_FAT_ROOTSTART to MEM_IDE_POINTER
116:20107+10 20E5 21C544 ld hl,MEM_FAT_ROOTSTART
117:20117+10 20E8 11D141 ld de,MEM_IDE_POINTER
118:20127+16 20EB EDA0 ldi
119:20143+16 20ED EDA0 ldi
120:20159+16 20EF EDA0 ldi
121:20175+16 20F1 EDA0 ldi
122:
123: ;copy value from MEM_FAT_ROOTSTART to MEM_IDE_POINTER
124:20191+10 20F3 21C544 ld hl,MEM_FAT_ROOTSTART
125:20201+10 20F6 11C144 ld de,MEM_FAT_DATASTART
126:20211+16 20F9 EDA0 ldi
127:20227+16 20FB EDA0 ldi
128:20243+16 20FD EDA0 ldi
129:20259+16 20FF EDA0 ldi
130:
131:20275+10 2101 21C544 ld hl,MEM_FAT_ROOTSTART
132:20285+10 2104 113F45 ld de,MEM_FAT_CURRDIR
133:20295+16 2107 EDA0 ldi
134:20311+16 2109 EDA0 ldi
135:20327+16 210B EDA0 ldi
136:20343+16 210D EDA0 ldi
137:
138: ;add offset to data area
139: ;multiply cluster by length of cluster
140:
141: ;calculate sectors for root dir
142:20359+16 210F 2AC742 ld hl,(MEM_IDE_BUFFER+0x11) ;load Maximum root directory entries
143:20375+4 2112 7C ld a,h
144:20379+4 2113 6F ld l,a
145:20383+4 2114 AF xor a ;set a 0, clear carry flag
146:20387+4 2115 67 ld h,a ;shift right by 8 bit = /512
147:
148: ;last step: multiply by 16
149:20391+4 2116 EB ex de,hl
150:20395+10 2117 011000 ld bc,16
151:20405+17 211A CD1523 call _fat_math_mul32
152: ; BCHL contains result -> store to PTR.MEM_FAT_TMPPOINTER
153:20422+16 211D 22BD44 ld (MEM_FAT_TMPPOINTER+0),hl
154:20438+20 2120 ED43BF44 ld (MEM_FAT_TMPPOINTER+2),bc
155:
156:20458+16 2124 22CD44 ld (MEM_FAT_DIRSEC),hl
157: ; add offset to MEM_FAT_DATASTART
158:20474+10 2127 11BD44 ld de,[MEM_FAT_TMPPOINTER]
159:20484+10 212A 01C144 ld bc,[MEM_FAT_DATASTART]
160:20494+17 212D CDE422 call _fat_math_add32 ;MEM_FAT_DATASTART now contains the correct sector
161: ;at teh beginnig of the data area
162:
163:
164: ;done all FS vars populated
165:
166: ;navigate to root directory
167:20511+7 2130 3E5C ld a,'\'
168:20518+13 2132 32DF44 ld(MEM_FAT_CURDIR),a
169:20531+4 2135 AF xor a
170:20535+13 2136 32E044 ld(MEM_FAT_CURDIR+1),a
171:
172:20548+10 2139 C9 ret
173:
174: - 213A _fat_get_root_table_invalid:
175:20558+17 213A CDD001 call PRINTINLINE
176: - 213D 0A0D4361 db 10,13,"Cannot find boot sector.",10,13,0
6E6E6F74
2066696E
6420626F
6F742073
6563746F
722E0A0D
00
177:20575+17 215A CD3A15 call ideif_get_drv_pointer
178:20592+19 215D DD360002 ld (ix+0),0x02
179:20611+10 2161 C9 ret
180:
181: ;-------------------------------------
182: ; fat_getfatsec
183: ;
184: ; gets sector in FAT table for the cluster stored in MEM_FAT_OF0_CCLUST
185: ;
186: ; store result in MEM_FAT_OF0_FATSEC
187: ; stores next cluster in MEM_FAT_OF0_CCLUST
188: ;-------------------------------------
189: - 2162 fat_getfatsec:
190:20621+16 2162 2A3145 ld HL,(MEM_FAT_OF0_CCLUST) ;load cluster
191:20637+4 2165 7C ld a,h ;if not 0x0000
192:20641+4 2166 B5 or l
193:20645+10 2167 C27921 jp nz, _fat_getfatsec_notroot
194: ;if 0x0000, goto root directory
195:20655+10 216A 21C544 ld hl,MEM_FAT_ROOTSTART
196:20665+10 216D 113745 ld de,MEM_FAT_OF0_DATSEC
197:20675+16 2170 EDA0 ldi ;quick and dirty hack to go back to root directory
198:20691+16 2172 EDA0 ldi
199:20707+16 2174 EDA0 ldi
200:20723+16 2176 EDA0 ldi
201:20739+10 2178 C9 ret
202:
203: - 2179 _fat_getfatsec_notroot:
204:20749+16 2179 2A3145 ld HL,(MEM_FAT_OF0_CCLUST) ;load cluster
205: ;each sector contains 256 clusters
206: ;first 8bits are not needed (/256)
207:20765+4 217C 7C ld a,h ;divide by 256
208:20769+4 217D 6F ld l,a
209:20773+4 217E AF xor a
210:20777+4 217F 67 ld h,a
211:
212:20781+20 2180 ED4BB644 ld bc,(MEM_FAT_RESERVED) ;add reserved sectors
213:20801+11 2184 09 add hl,bc
214:20812+16 2185 223345 ld(MEM_FAT_OF0_FATSEC+0),hl;store sector
215:20828+4 2188 AF xor a
216:20832+13 2189 323545 ld(MEM_FAT_OF0_FATSEC+2),a
217:20845+13 218C 323645 ld(MEM_FAT_OF0_FATSEC+3),a
218:
219:20858+17 218F CD3A15 call ideif_get_drv_pointer
220:20875+10 2192 DD23 inc ix
221:20885+10 2194 DD23 inc ix
222:20895+15 2196 DDE5 push ix
223:20910+10 2198 D1 pop de ;copy poiter to hl
224:20920+10 2199 013345 ld bc,[MEM_FAT_OF0_FATSEC]
225:20930+17 219C CDE422 call _fat_math_add32 ;MEM_FAT_OF0_FATSEC now contains the correct sector
226: ;in the FAT
227:
228: ;read FAT sector
229:20947+10 219F 213345 ld hl,MEM_FAT_OF0_FATSEC ;read next sector
230:20957+7 21A2 0601 ld b,1
231:20964+7 21A4 3E01 ld a,1
232:20971+10 21A6 11B642 LD DE, MEM_IDE_BUFFER ;where to store data?
233:20981+17 21A9 CD6115 call read_lba_sector
234:
235: ;calculate data sector
236: ;multiply cluster by length of cluster
237:20998+4 21AC AF xor a ;clear carry
238:21002+13 21AD 3ABB44 ld a,(MEM_FAT_CLUSTERLEN)
239:21015+7 21B0 0600 ld b,0
240:21022+4 21B2 4F ld c,a
241:21026+20 21B3 ED5B3145 ld de,(MEM_FAT_OF0_CCLUST) ;load cluster number
242:21046+6 21B7 1B dec de ; sub 2 becaus fat starts at 3
243:21052+6 21B8 1B dec de
244:21058+17 21B9 CD1523 call _fat_math_mul32
245: ; BCHL contains result -> store to PTR.MEM_FAT_OF0_DATSEC
246:21075+16 21BC 223745 ld (MEM_FAT_OF0_DATSEC+0),hl
247:21091+20 21BF ED433945 ld (MEM_FAT_OF0_DATSEC+2),bc
248:
249: ; add start of data region to addr
250:21111+10 21C3 013745 ld bc,[MEM_FAT_OF0_DATSEC]
251:21121+10 21C6 11C144 ld de,[MEM_FAT_DATASTART]
252:21131+17 21C9 CDE422 call _fat_math_add32 ;MEM_FAT_OF0_FATSEC now contains the correct sector
253: ;in the FAT
254: ;MEM_FAT_OF0_DATSEC now has the first sector of the selected cluster
255:
256: ;reset MEM_FAT_OF0_DATREM to default cluster length
257:21148+13 21CC 3ABB44 ld a,(MEM_FAT_CLUSTERLEN)
258:21161+4 21CF 6F ld l,a
259:21165+7 21D0 2600 ld h,0
260:21172+16 21D2 223B45 ld (MEM_FAT_OF0_DATREM), hl
261:
262: ;get next cluster
263: ;calculate offset address
264:21188+13 21D5 3A3145 ld a,(MEM_FAT_OF0_CCLUST)
265:21201+4 21D8 17 RLA ;shift to left (x2)
266:21205+4 21D9 6F ld l, a
267:21209+7 21DA 3E00 ld a,0
268:21216+4 21DC 17 RLA ;shift in carry flag
269:21220+4 21DD 67 ld h,a
270:21224+10 21DE 11B642 ld de,MEM_IDE_BUFFER
271:21234+11 21E1 19 add hl,de
272: ;copy pointer (hl to de)
273:21245+10 21E2 113145 ld de,MEM_FAT_OF0_CCLUST
274:21255+16 21E5 EDA0 ldi ;copy byte for next cluster from FAT
275:21271+16 21E7 EDA0 ldi
276:21287+10 21E9 C9 ret
277: ;store data
278:
279: ;-------------------------------------
280: ; fat_readfilesec
281: ;
282: ; reads single sector of file
283: ; must run fat_readfilesec before to initialize
284: ; if a ix 0x00, success
285: ; if a is 0xFF, end reached
286: ;
287: ; DE contains destination address
288: ;-------------------------------------
289: - 21EA fat_readfilesec:
290: ;call fat_print_dbg
291:21297+10 21EA 213745 ld hl,[MEM_FAT_OF0_DATSEC]
292:21307+7 21ED 0601 ld b,1
293:21314+7 21EF 3E01 ld a,1
294: ;LD DE, MEM_IDE_BUFFER ;where to store data?
295:21321+17 21F1 CD6115 call read_lba_sector ;read sectore
296:21338+10 21F4 213745 ld hl,[MEM_FAT_OF0_DATSEC] ;increment pointer to next sector
297:21348+17 21F7 CDD022 call _fat_increment_32 ;***
298:21365+16 21FA 2A3B45 ld hl,(MEM_FAT_OF0_DATREM) ;reduce counter
299:21381+4 21FD AF xor a
300:21385+10 21FE 110100 ld de,1
301:21395+15 2201 ED52 sbc hl,de ;decrement counter
302:21410+16 2203 223B45 ld (MEM_FAT_OF0_DATREM),hl ;store decremented counter
303:21426+5+6 2206 C0 ret nz ;when not zero, exit function
304: ;if zero:
305:21431+7 2207 3EFF ld a, 0xFF ;preload error code
306:21438+16 2209 2A3145 ld hl,(MEM_FAT_OF0_CCLUST) ;check next chunk
307:21454+10 220C 11FFFF ld de,0xFFFF ;end mark
308:21464+15 220F ED52 sbc hl,de ;if Z match
309:21479+5+6 2211 C8 ret z ;If 0xFFFF, end is reched. Return
310: ;if next cluster available:
311:21484+4 2212 AF xor a
312:21488+17 2213 CD6221 call fat_getfatsec ; read next cluster information
313:21505+10 2216 C9 ret
314:
315:
316: ;-------------------------------------
317: ; fat_openfile
318: ; search for entry in current directory
319: ;
320: ; DE pointer to file name
321: ; sets:
322: ; - MEM_FAT_OF0_CCLUST
323: ; - MEM_FAT_OF0_ATTRIBUTE
324: ; - MEM_FAT_FILEREMAIN
325: ; if a is 0x00, success
326: ; if a is 0xFF, end reached
327: ;-------------------------------------
328: - 2217 fat_openfile:
329:21515+11 2217 D5 PUSH DE
330: ;MEM_FAT_TMPFNAME now has valid text to compare
331:21526+10 2218 21CF44 LD HL,[MEM_FAT_TMPFNAME]
332:21536+17 221B CD5C23 call format_filename_fat16
333:21553+10 221E D1 POP DE
334: - 221F fat_openfile_noprepare:
335:21563+11 221F D5 PUSH DE
336: ;prepare pointer
337:21574+10 2220 213F45 ld hl,MEM_FAT_CURRDIR
338:21584+10 2223 11D141 ld de,MEM_IDE_POINTER
339:21594+16 2226 EDA0 ldi
340:21610+16 2228 EDA0 ldi
341:21626+16 222A EDA0 ldi
342:21642+16 222C EDA0 ldi
343:
344:21658+13 222E 3ACD44 LD A,(MEM_FAT_DIRSEC) ;init counter for FAT sectors
345:21671+13 2231 32BC44 LD (MEM_FAT_COUNT1),A
346:
347:21684+10 2234 21D141 LD HL,MEM_IDE_POINTER ;read first sector
348:21694+7 2237 0601 LD B,1
349:21701+7 2239 3E01 ld a,1
350:21708+10 223B 11B642 LD DE, MEM_IDE_BUFFER ;where to store data?
351:21718+17 223E CD6115 call read_lba_sector
352:
353:21735+10 2241 21B642 LD HL, MEM_IDE_BUFFER ;set buffer start
354:21745+7 2244 0E10 LD C,16 ;set entries counter
355:
356: - 2246 _fat_lfs_loop:
357:21752+10 2246 11CF44 LD DE,[MEM_FAT_TMPFNAME]
358:21762+17 2249 CD4623 CALL compare_filename
359:21779+7+5 224C 3838 JR C, _fat_lfs_loop_compare_match ;on match
360:
361: ; prepare next entry
362:21786+4 224E 0D DEC C ;next sector after 16 entries
363:21790+7+5 224F 2807 JR Z,_fat_lfs_loop_compare_next_sector
364:21797+10 2251 112000 LD DE, 32 ;length of entry
365:21807+11 2254 19 ADD HL,DE ;increment
366:21818+10 2255 C34622 JP _fat_lfs_loop
367:
368: - 2258 _fat_lfs_loop_compare_next_sector:
369:21828+10 2258 21D141 ld hl,[MEM_IDE_POINTER]
370:21838+17 225B CDD022 call _fat_increment_32 ;increment sector
371:
372:21855+13 225E 3ABC44 LD A,(MEM_FAT_COUNT1) ; decrement sector count (max FAT length)
373:21868+4 2261 3D DEC A
374:21872+13 2262 32BC44 LD (MEM_FAT_COUNT1),A
375:21885+10 2265 CA8222 JP Z, _fat_lfs_loop_compare_end ; if DE is 0, mmax is reached. End here
376: ;call print_a_hex
377:
378:21895+10 2268 21D141 LD HL,MEM_IDE_POINTER ;read next sector
379:21905+7 226B 0601 LD B,1
380:21912+7 226D 3E01 ld a,1
381:21919+10 226F 11B642 LD DE, MEM_IDE_BUFFER ;where to store data?
382:21929+17 2272 CD6115 call read_lba_sector
383:
384:21946+10 2275 21B642 LD HL, MEM_IDE_BUFFER ;set buffer start
385:21956+7 2278 0E10 LD C,16 ;set entries counter
386:
387:21963+7 227A 7E ld a,(HL)
388:21970+4 227B B7 or a
389:21974+10 227C CA8222 jp z, _fat_lfs_loop_compare_end ;skip empty sectors
390:
391:21984+10 227F C34622 JP _fat_lfs_loop
392:
393: - 2282 _fat_lfs_loop_compare_end:
394:21994+10 2282 D1 POP DE
395:22004+7 2283 3EFF ld a,0xFF
396:22011+10 2285 C9 RET
397:
398: - 2286 _fat_lfs_loop_compare_match:
399: ; get entry
400:22021+10 2286 D1 POP DE
401:
402: ; HL points to Start of Table item
403:22031+11 2287 E5 PUSH HL
404:22042+14 2288 DDE1 POP IX
405: ; get important information
406:22056+19 228A DD7E1B ld a,(ix+0x1B) ;first cluster number
407:22075+13 228D 323245 ld (MEM_FAT_OF0_CCLUST+1),a
408:22088+19 2290 DD7E1A ld a,(ix+0x1A)
409:22107+13 2293 323145 ld (MEM_FAT_OF0_CCLUST+0),a
410:22120+19 2296 DD7E0B ld a,(ix+0x0B)
411:22139+13 2299 322F45 ld (MEM_FAT_OF0_ATTRIBUTE+0),a
412:
413:22152+4 229C AF xor a ;clear carry ;set MEM_FAT_OF0_DATREM to remaining sectors
414:22156+19 229D DD7E1F ld a,(ix+0x1F) ;cluste length shift by 256
415:22175+4 22A0 1F rra
416:22179+13 22A1 32CB44 ld (MEM_FAT_FILEREMAIN+2),a
417:22192+19 22A4 DD7E1E ld a,(ix+0x1E)
418:22211+4 22A7 1F rra
419:22215+13 22A8 32CA44 ld (MEM_FAT_FILEREMAIN+1),a
420:22228+19 22AB DD7E1D ld a,(ix+0x1D)
421:22247+4 22AE 1F rra
422:22251+13 22AF 32C944 ld (MEM_FAT_FILEREMAIN+0),a
423:22264+7 22B2 3E00 ld a,0
424:22271+13 22B4 32CC44 ld (MEM_FAT_FILEREMAIN+3),a
425:22284+17 22B7 CD6221 call fat_getfatsec ;get sector information
426:
427:22301+4 22BA AF xor a
428:22305+10 22BB C9 RET
429:
430:
431: ;=================== UTIL Functions ===========================
432: ; 32 Bit addition to pointer
433: ; HL has value
434: ;deprecated!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
435: - 22BC _fat_math_sector_add_16:
436:22315+16 22BC 22BD44 ld (MEM_FAT_TMPPOINTER), hl
437:22331+4 22BF AF xor a
438:22335+13 22C0 32BF44 ld (MEM_FAT_TMPPOINTER+2),a
439:22348+13 22C3 32C044 ld (MEM_FAT_TMPPOINTER+3),a
440:
441:22361+10 22C6 11BD44 ld de,[MEM_FAT_TMPPOINTER]
442:22371+10 22C9 01D141 ld bc,[MEM_IDE_POINTER]
443:22381+17 22CC CDE422 call _fat_math_add32
444:22398+10 22CF C9 ret
445: ;deprecated!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
446:
447: ;hl contains pointer
448: - 22D0 _fat_increment_32
449:22408+7 22D0 7E ld a,(HL) ; byte 0
450:22415+7 22D1 C601 add 1
451:22422+7 22D3 77 ld (hl),a
452:22429+6 22D4 23 inc hl
453:22435+7 22D5 7E ld a,(HL) ; byte 1
454:22442+7 22D6 CE00 adc 0
455:22449+7 22D8 77 ld (hl),a
456:22456+6 22D9 23 inc hl
457:22462+7 22DA 7E ld a,(HL) ; byte 2
458:22469+7 22DB CE00 adc 0
459:22476+7 22DD 77 ld (hl),a
460:22483+6 22DE 23 inc hl
461:22489+7 22DF 7E ld a,(HL) ; byte 3
462:22496+7 22E0 CE00 adc 0
463:22503+7 22E2 77 ld (hl),a
464:22510+10 22E3 C9 ret
465: ;bc contains pointer to a (also result)
466: ;de contains pointer to b
467: - 22E4 _fat_math_add32
468:22520+11 22E4 E5 push hl
469:22531+11 22E5 C5 push bc
470:22542+11 22E6 D5 push de
471:22553+7 22E7 1A ld a,(de) ; load lower 16bit for B int from (DE) to HL
472:22560+4 22E8 6F ld l,a
473:22564+6 22E9 13 inc de
474:22570+7 22EA 1A ld a,(de)
475:22577+4 22EB 67 ld h,a
476:22581+6 22EC 13 inc de
477: ; HL, DE dirty
478:22587+7 22ED 0A ld a,(bc) ; load lower 16bit for A int from (BC) to DE
479:22594+4 22EE 5F ld e,a
480:22598+6 22EF 03 inc bc
481:22604+7 22F0 0A ld a,(bc)
482:22611+4 22F1 57 ld d,a
483: ; HL now contains A, DE now contains D
484:22615+11 22F2 19 add hl,de ;add lower bytes, store carry
485:22626+10 22F3 D1 pop de ;restore pointers
486:22636+10 22F4 C1 pop bc ;both now cointain first byte of long-value
487:22646+4 22F5 7D ld a,l ;store lower result in (bc)
488:22650+7 22F6 02 ld (bc),a
489:22657+6 22F7 03 inc bc
490:22663+4 22F8 7C ld a,h
491:22667+7 22F9 02 ld (bc),a
492:22674+6 22FA 03 inc bc
493:22680+6 22FB 13 inc de ;also increment de to next byte
494:22686+6 22FC 13 inc de
495: ; DE and HL now start at the upper byte
496:22692+11 22FD C5 push bc
497:22703+11 22FE D5 push de
498:22714+7 22FF 1A ld a,(de) ; load upper 16bit for B
499:22721+4 2300 6F ld l,a
500:22725+6 2301 13 inc de
501:22731+7 2302 1A ld a,(de)
502:22738+4 2303 67 ld h,a
503:22742+6 2304 13 inc de
504:22748+7 2305 0A ld a,(bc) ; load upper 16bit for A
505:22755+4 2306 5F ld e,a
506:22759+6 2307 03 inc bc
507:22765+7 2308 0A ld a,(bc)
508:22772+4 2309 57 ld d,a
509:22776+15 230A ED5A adc hl,de ;add upper bytes, store carry
510:22791+10 230C D1 pop de
511:22801+10 230D C1 pop bc
512:22811+4 230E 7D ld a,l ;store lower result in (bc)
513:22815+7 230F 02 ld(bc),a
514:22822+6 2310 03 inc bc
515:22828+4 2311 7C ld a,h
516:22832+7 2312 02 ld(bc),a
517:22839+10 2313 E1 pop hl
518:22849+10 2314 C9 ret
519:
520:
521: ; Multiply 16-bit values (with 32-bit result)
522: ; Operands BC, DE
523: ; Result -> BCHL
524: - 2315 _fat_math_mul32:
525:22859+4 2315 79 ld a,c
526:22863+4 2316 48 ld c,b
527:22867+10 2317 210000 ld hl,0
528:22877+7 231A 0610 ld b,16
529: - 231C _fat_math_mul32_l:
530:22884+11 231C 29 add hl,hl
531:22895+4 231D 17 rla
532:22899+8 231E CB11 rl c
533:22907+7+5 2320 3007 jr nc,_fat_math_mul32_noadd
534:22914+11 2322 19 add hl,de
535:22925+7 2323 CE00 adc a,0
536:22932+10 2325 D22923 jp nc,_fat_math_mul32_noadd
537:22942+4 2328 0C inc c
538: - 2329 _fat_math_mul32_noadd:
539:22946+8+5 2329 10F1 djnz _fat_math_mul32_l
540:22954+4 232B 41 ld b,c
541:22958+4 232C 4F ld c,a
542:22962+10 232D C9 ret
543:
544: ; reset LBA pointer to first sector in selected partition
545: - 232E fat_reset_pointer:
546:22972+17 232E CD3A15 call ideif_get_drv_pointer
547:22989+10 2331 DD23 inc ix
548:22999+10 2333 DD23 inc ix
549:23009+15 2335 DDE5 push ix
550:23024+10 2337 E1 pop hl ;copy poiter to hl
551:23034+10 2338 11D141 ld de, MEM_IDE_POINTER
552:23044+12 233B 1800 jr fat_copy_lba_pointer
553:
554: ; resets LBA pointer (4-byte) to partition start
555: ; HL = from here
556: ; DE = to this destimation
557: - 233D fat_copy_lba_pointer:
558:23056+11 233D C5 PUSH BC
559:23067+7 233E 0600 LD B,0
560:23074+7 2340 0E04 LD C,4
561:23081+16+5 2342 EDB0 LDIR
562:23097+10 2344 C1 POP BC
563:23107+10 2345 C9 ret
564:
565: ; compares filenames
566: ; HL points to name1
567: ; DE points to name2
568: ; Carry is set if match
569: ; Destroys DE, AF
570: - 2346 compare_filename:
571:23117+11 2346 E5 PUSH HL
572:23128+11 2347 C5 push BC
573:23139+7 2348 060B LD B, 11 ;Counter
574: - 234A _compare_filename_loop:
575:23146+7 234A 1A LD A,(DE)
576:23153+4 234B 4F LD C,A
577:23157+7 234C 7E LD A,(HL)
578:23164+6 234D 23 INC HL
579:23170+6 234E 13 INC DE
580:23176+4 234F A9 XOR C ;check if identical (should return 0)
581:23180+7+5 2350 2006 JR NZ, _compare_filename_nomatch
582:23187+8+5 2352 10F6 djnz _compare_filename_loop ;if not last, continue
583:23195+10 2354 C1 POP BC
584:23205+10 2355 E1 POP HL
585:23215+4 2356 37 SCF
586:23219+10 2357 C9 RET
587: - 2358 _compare_filename_nomatch:
588:23229+10 2358 C1 POP BC
589:23239+10 2359 E1 POP HL
590:23249+4 235A AF XOR A ; clear carry flag
591:23253+10 235B C9 RET
592:
593: ; formats filename to 8+3 format
594: ; DE points to source filename to string
595: ; HL points to destination
596: - 235C format_filename_fat16:
597:23263+7 235C 060B LD B, 11 ;counter
598:23270+11 235E E5 PUSH HL
599:23281+7 235F 3E20 LD A, ' '
600: - 2361 _format_filename_fat16_clean:
601:23288+7 2361 77 LD (HL),A
602:23295+6 2362 23 INC HL
603:23301+8+5 2363 10FC DJNZ _format_filename_fat16_clean
604:23309+10 2365 E1 POP HL ; continue with copy
605:23319+7 2366 060D LD B, 13
606: - 2368 _format_filename_fat16_loop:
607:23326+7 2368 1A LD A, (DE) ; load byte
608:23333+4 2369 B7 OR A
609:23337+5+6 236A C8 RET Z ;exit on 0byte
610:23342+4 236B 05 DEC B ;reduce counter
611:23346+5+6 236C C8 RET Z ;exit after 12 bytes 8+.+3
612:23351+7 236D FE2E CP '.' ; check if dot
613:23358+7+5 236F 200A JR NZ, _format_filename_fat16_loop_copy ; if not continue as usual
614:23365+6 2371 13 INC DE ;else skip char
615: - 2372 _format_filename_fat16_loop_skip_8:
616:23371+4 2372 78 LD A,B
617:23375+7 2373 FE05 CP 5
618:23382+7+5 2375 38F1 JR C, _format_filename_fat16_loop
619:23389+6 2377 23 INC HL
620:23395+4 2378 05 DEC B
621:23399+12 2379 18F7 JR _format_filename_fat16_loop_skip_8
622:
623: - 237B _format_filename_fat16_loop_copy:
624:23411+7 237B 1A LD A, (DE) ; load byte
625:23418+7 237C 77 LD (HL), A ; copy byte
626:23425+6 237D 23 INC HL
627:23431+6 237E 13 INC DE
**** main.asm ****
207:23437+10 237F C36823 JP _format_filename_fat16_loop
208: .include "fat16_cmd.s"
**** include/fat16_cmd.s ****
1: ;-------------------------------------
2: ; Print current fat directory of MEM_FAT_CURRDIR
3: ;-------------------------------------
4: - 2382 fat_print_directory:
5:23447+10 2382 213F45 ld hl,MEM_FAT_CURRDIR
6:23457+10 2385 11D141 ld de,MEM_IDE_POINTER
7:23467+16 2388 EDA0 ldi
8:23483+16 238A EDA0 ldi
9:23499+16 238C EDA0 ldi
10:23515+16 238E EDA0 ldi
11:
12:23531+20 2390 ED5BB944 LD DE,(MEM_FAT_SECTORS)
13:23551+20 2394 ED53BC44 LD (MEM_FAT_COUNT1),DE
14:23571+10 2398 21D141 LD HL,MEM_IDE_POINTER ;read first sector
15:23581+7 239B 0601 LD B,1
16:23588+7 239D 3E01 ld a,1
17:23595+10 239F 11B642 LD DE, MEM_IDE_BUFFER ;where to store data?
18:23605+17 23A2 CD6115 call read_lba_sector
19:
20:23622+17 23A5 CDD001 call PRINTINLINE
21: - 23A8 0A0D2020 db 10,13," Filename Cluster Size",10,13,0
46696C65
6E616D65
20202020
20436C75
73746572
2053697A
650A0D00
22:
23:23639+10 23C8 21B642 LD HL, MEM_IDE_BUFFER ;set buffer start
24:23649+7 23CB 0E10 LD C,16 ;set entries counter
25:
26: - 23CD _fat_print_directory_loop: ;loop over each entry (32byte)
27:23656+7 23CD 7E LD A,(HL) ; check first byte
28:23663+11 23CE E5 PUSH HL ;backup start of entry
29:23674+14 23CF DDE1 POP IX
30:23688+11 23D1 E5 PUSH HL
31: ;ignore unwanted entries
32:23699+7 23D2 FE41 CP 0x41 ;skip invisible
33:23706+10 23D4 CA6524 JP Z, _fat_print_directory_loop_next
34:23716+7 23D7 FEE5 CP 0xE5 ;skip deleted
35:23723+10 23D9 CA6524 JP Z, _fat_print_directory_loop_next
36:23733+7 23DC FE00 CP 0x00 ;reached end
37:23740+10 23DE CA9924 JP Z, _fat_print_directory_loop_break
38:
39: ;check file attribute
40:23750+19 23E1 DD7E0B ld a,(IX+0x0B)
41:23769+7 23E4 FE10 cp 0x10 ;if subdirectors
42:23776+10 23E6 CA3A24 jp z, _fat_print_directory_dir ;print dir
43: ;else print file
44: - 23E9 _fat_print_directory_loop_file
45: ;print filename
46:23786+7 23E9 3E20 ld a,' '
47:23793+17 23EB CD1501 call print_char
48:23810+7 23EE 3E20 ld a,' '
49:23817+17 23F0 CD1501 call print_char
50:23834+7 23F3 0608 LD B,8
51:23841+17 23F5 CDAA18 call print_str_fixed
52:23858+7 23F8 3E2E ld A,'.'
53:23865+17 23FA CD1501 call print_char
54:23882+7 23FD 0603 LD B,3
55:23889+17 23FF CDAA18 call print_str_fixed
56:
57:23906+17 2402 CDD001 call PRINTINLINE
58: - 2405 20307800 db " 0x",0
59: ;first cluster number
60:23923+19 2409 DD7E1B ld a,(ix+0x1B)
61:23942+17 240C CD4301 call print_a_hex
62:23959+19 240F DD7E1A ld a,(ix+0x1A)
63:23978+17 2412 CD4301 call print_a_hex
64:23995+17 2415 CDD001 call PRINTINLINE
65: - 2418 20203078 db " 0x",0
00
66:24012+19 241D DD7E1F ld a,(ix+0x1F)
67:24031+17 2420 CD4301 call print_a_hex
68:24048+19 2423 DD7E1E ld a,(ix+0x1E)
69:24067+17 2426 CD4301 call print_a_hex
70:24084+19 2429 DD7E1D ld a,(ix+0x1D)
71:24103+17 242C CD4301 call print_a_hex
72:24120+19 242F DD7E1C ld a,(ix+0x1C)
73:24139+17 2432 CD4301 call print_a_hex
74:24156+17 2435 CD2D01 call print_newLine
75:24173+12 2438 182B jr _fat_print_directory_loop_next
76: - 243A _fat_print_directory_dir
77:24185+7 243A 3E44 ld a,'D'
78:24192+17 243C CD1501 call print_char
79:24209+7 243F 3E20 ld a,' '
80:24216+17 2441 CD1501 call print_char
81:24233+7 2444 0608 LD B,8
82:24240+17 2446 CDAA18 call print_str_fixed
83:24257+17 2449 CDD001 call PRINTINLINE
84: - 244C 20202020 db " 0x",0
20307800
85: ;first cluster number
86:24274+19 2454 DD7E1B ld a,(ix+0x1B)
87:24293+17 2457 CD4301 call print_a_hex
88:24310+19 245A DD7E1A ld a,(ix+0x1A)
89:24329+17 245D CD4301 call print_a_hex
90:24346+17 2460 CD2D01 call print_newLine
91:24363+12 2463 1800 jr _fat_print_directory_loop_next
92:
93: - 2465 _fat_print_directory_loop_next: ; read next entry
94:24375+4 2465 0D DEC C ;next sector after 32 entries
95:24379+7+5 2466 2808 JR Z,_fat_print_directory_loop_next_sector
96:24386+10 2468 E1 POP HL ;restore start
97:24396+10 2469 112000 LD DE, 32 ;length of entry
98:24406+11 246C 19 ADD HL,DE ;increment
99:24417+10 246D C3CD23 JP _fat_print_directory_loop
100:
101: - 2470 _fat_print_directory_loop_next_sector: ; end fo sector. read next sector from disk
102:24427+10 2470 E1 POP HL ;clear stack from old hl
103:24437+7 2471 2600 LD H,0
104:24444+7 2473 2E01 LD L,1
105:24451+17 2475 CDBC22 call _fat_math_sector_add_16 ;increment sector
106:
107:24468+20 2478 ED5BBC44 LD DE,(MEM_FAT_COUNT1) ; decrement sector count (max FAT length)
108:24488+6 247C 1B DEC DE
109:24494+20 247D ED53BC44 LD (MEM_FAT_COUNT1),DE
110:24514+4 2481 7A LD A,D
111:24518+4 2482 B3 OR E
112:24522+5+6 2483 C8 RET Z ; if DE is 0, mmax is reached. End here
113:
114:24527+10 2484 21D141 LD HL,MEM_IDE_POINTER ;read next sector
115:24537+7 2487 0601 LD B,1
116:24544+7 2489 3E01 ld a,1
117:24551+10 248B 11B642 LD DE, MEM_IDE_BUFFER ;where to store data?
118:24561+17 248E CD6115 call read_lba_sector
119:
120:24578+10 2491 21B642 LD HL, MEM_IDE_BUFFER ;set buffer start
121:24588+7 2494 0E10 LD C,16 ;set entries counter
122:24595+10 2496 C3CD23 JP _fat_print_directory_loop
123:
124: - 2499 _fat_print_directory_loop_break
125:24605+10 2499 E1 POP HL
126:24615+10 249A C9 ret
127:
128: ;-------------------------------------
129: ; Changes current fat directory of MEM_FAT_CURRDIR
130: ; input is relativ path
131: ; DE points to path
132: ;-------------------------------------
133: - 249B fat_cd_single:
134:24625+11 249B D5 push de
135: ; check if user wants to go back (input = '..')
136:24636+7 249C 1A ld a,(de)
137:24643+7 249D FE2E cp '.'
138:24650+7+5 249F 205E jr nz, _fat_cd_navigate; if not, skip
139:24657+6 24A1 13 inc de ;check next
140:24663+7 24A2 1A ld a,(de)
141:24670+7 24A3 FE2E cp '.'
142:24677+7+5 24A5 2058 jr nz, _fat_cd_navigate; if not, skip
143:24684+13 24A7 3A7A41 ld a,(var_dir+79) ;last byte contains depth
144:24697+4 24AA B7 or a; Test if 0
145:24701+10 24AB CA5725 jp z, _fat_cd_navigate_error ;cannot go back any more (already at root)
146: ; check if .. exists in directory
147:24711+7 24AE 3E2E ld a,'.' ;prepare filename buffer
148:24718+10 24B0 21CF44 ld hl,[MEM_FAT_TMPFNAME]
149:24728+7 24B3 77 ld (hl),a
150:24735+6 24B4 23 inc hl
151:24741+7 24B5 77 ld (hl),a
152:24748+6 24B6 23 inc hl
153:24754+7 24B7 3E20 ld a,0x20 ;clear char 3-11
154:24761+7 24B9 060B ld b,11
155: - 24BB _fat_cd_navigate_goback_fl:
156:24768+7 24BB 77 ld (hl),a
157:24775+6 24BC 23 inc hl
158:24781+8+5 24BD 10FC djnz _fat_cd_navigate_goback_fl ;fill loop end
159:24789+17 24BF CD1F22 call fat_openfile_noprepare ;load file table (only 1st sector needed)
160:24806+4 24C2 B7 or a ;check for error
161:24810+10 24C3 C25725 jp nz, _fat_cd_navigate_error ;entry not found exception
162:
163:
164: ; find end of path
165:24820+10 24C6 212E41 ld hl,[var_dir+3] ;current position
166:24830+10 24C9 014C00 ld bc,76
167:24840+7 24CC 3E00 ld a,0x00 ;termination char
168:24847+16+5 24CE EDB1 cpir ;find end
169:24863+10 24D0 E26525 jp po,_fat_cd_navigate_inerror ;in case of error, abort
170: ;hl is now at end of string
171:24873+10 24D3 014C00 ld bc,76
172:24883+7 24D6 3E5C ld a,'\' ;seperation char
173:24890+16+5 24D8 EDB9 cpdr ;serach backwards for "/"
174:24906+10 24DA E26525 jp po,_fat_cd_navigate_inerror ;in case of error, abort
175: ;hl is now at end of string
176:24916+6 24DD 23 inc hl
177:24922+4 24DE AF xor a
178:24926+7 24DF 77 ld (hl),a ;set termination char
179:24933+6 24E0 23 inc hl
180:24939+7 24E1 77 ld (hl),a ;set termination char
181:24946+13 24E2 3A7A41 ld a,(var_dir+79)
182:24959+4 24E5 3D dec a
183:24963+13 24E6 327A41 ld (var_dir+79),a ;decrement dir depth counter
184:
185:24976+10 24E9 D1 pop de
186:
187:24986+10 24EA 212D41 ld hl,[var_dir+2]
188:24996+7 24ED 3E5C ld a,'\'
189:25003+7 24EF 77 ld (hl),a ;set first /
190:
191:25010+10 24F0 213745 ld hl,MEM_FAT_OF0_DATSEC ;setup directory pointer
192:25020+10 24F3 113F45 ld de,MEM_FAT_CURRDIR
193:25030+16 24F6 EDA0 ldi
194:25046+16 24F8 EDA0 ldi
195:25062+16 24FA EDA0 ldi
196:25078+16 24FC EDA0 ldi
197:
198:25094+10 24FE C9 ret
199:
200: - 24FF _fat_cd_navigate
201:25104+10 24FF D1 pop de ;get pointer to directory namme
202:25114+11 2500 D5 push de ;and re-store it for next use
203:25125+17 2501 CD1722 call fat_openfile ;find 'file' in current directory
204: - 2504 _fat_cd_navigate_findsec
205:25142+4 2504 B7 or a
206:25146+10 2505 C25725 jp nz, _fat_cd_navigate_error ;entry not found
207:25156+13 2508 3A2F45 ld a, (MEM_FAT_OF0_ATTRIBUTE)
208:25169+7 250B FE10 cp 0x10
209:25176+10 250D C26D25 jp nz, _fat_cd_navigate_errfile
210:25186+13 2510 3A7A41 ld a,(var_dir+79)
211:25199+4 2513 3C inc a
212:25203+13 2514 327A41 ld (var_dir+79),a ;increment dir depth counter
213:25216+10 2517 212D41 ld hl,[var_dir+2] ;load start of path string
214:25226+7 251A 3E00 ld a,0 ;load termination char
215:25233+10 251C 014C00 ld bc,76 ;max length of string
216:25243+16+5 251F EDB1 cpir ;find end of path string
217:25259+6 2521 2B dec hl
218:25265+10 2522 E26525 jp po,_fat_cd_navigate_inerror ;in case of error, abort
219: ;HL now has last element, BC has remaining max length
220:25275+13 2525 3A7A41 ld a,(var_dir+79) ;last byte contains depth
221:25288+7 2528 FE01 cp 1 ;if first path, skip /
222:25295+7+5 252A 2804 jr z, _fat_cd_navigate_findsec_skipslash
223:25302+7 252C 3E5C ld a,'\'
224:25309+7 252E 77 ld (hl),a
225:25316+6 252F 23 inc hl
226: - 2530 _fat_cd_navigate_findsec_skipslash
227:25322+10 2530 D1 pop de ;get argument from stack
228:25332+4 2531 EB ex de,hl
229:25336+11 2532 D5 push de ;store start to stack
230: ;HL now has start of input string, DE has end of current path
231:25347+10 2533 010900 ld bc,09 ;maximum length of directory name +1
232: - 2536 _fat_cd_navigate_l2: ;copy new subdirectory
233:25357+16 2536 EDA0 ldi ;copy
234:25373+10 2538 E25F25 jp po,_fat_cd_navigate_inerrorS ;in case of error, abort
235:25383+7 253B 7E ld a,(hl) ;check next char
236:25390+7 253C FE5C cp '\' ;end at '\'
237:25397+7+5 253E 2805 jr z, _fat_cd_navigate_end ;else next byte
238:25404+4 2540 B7 or a ;or and at 0x00
239:25408+7+5 2541 2802 jr z, _fat_cd_navigate_end ;else next byte
240:25415+12 2543 18F1 jr _fat_cd_navigate_l2
241: - 2545 _fat_cd_navigate_end:
242:25427+4 2545 AF xor a
243:25431+7 2546 12 ld (de),a ;set last byte to 0x00 (termination)
244:25438+10 2547 213745 ld hl,MEM_FAT_OF0_DATSEC
245: ;setup directory pointer
246:25448+10 254A 113F45 ld de,MEM_FAT_CURRDIR
247:25458+16 254D EDA0 ldi
248:25474+16 254F EDA0 ldi
249:25490+16 2551 EDA0 ldi
250:25506+16 2553 EDA0 ldi
251:25522+10 2555 D1 pop de ;stack cleanup
252:25532+10 2556 C9 ret
253:
254: - 2557 _fat_cd_navigate_error:
255:25542+10 2557 217525 ld hl,[_fat_cd_navigate_error_str]
256:25552+17 255A CD1D01 call print_str
257:25569+10 255D D1 pop de
258:25579+10 255E C9 ret
259:
260: - 255F _fat_cd_navigate_inerrorS: ;with path reset
261:25589+10 255F D1 pop de ;restore former path
262:25599+6 2560 1B dec de ;change pointer to remove previous '\' as well
263:25605+4 2561 AF xor a ;clear a to 0x00
264:25609+7 2562 12 ld (de),a ;set last byte to 0x00 (termination)
265:25616+12 2563 1801 jr _fat_cd_navigate_inerrore
266: - 2565 _fat_cd_navigate_inerror: ;without path reset
267:25628+10 2565 D1 pop de
268: - 2566 _fat_cd_navigate_inerrore:
269:25638+10 2566 218C25 ld hl,[_fat_cd_navigate_inputerr_str]
270:25648+17 2569 CD1D01 call print_str
271:25665+10 256C C9 ret
272: - 256D _fat_cd_navigate_errfile:
273:25675+10 256D D1 pop de
274:25685+10 256E 219F25 ld hl,[_fat_cd_navigate_errfile_str]
275:25695+17 2571 CD1D01 call print_str
276:25712+10 2574 C9 ret
277:
278: - 2575 _fat_cd_navigate_error_str:
279: - 2575 0A0D4E6F db 10,13,"No such directory!",10,13,0
20737563
68206469
72656374
6F727921
0A0D00
280: - 258C _fat_cd_navigate_inputerr_str:
281: - 258C 0A0D496E db 10,13,"Invalid input!",10,13,0
76616C69
6420696E
70757421
0A0D00
282: - 259F _fat_cd_navigate_errfile_str:
283: - 259F 0A0D4361 db 10,13,"Cannot cd to file!",10,13,0
6E6E6F74
20636420
746F2066
696C6521
0A0D00
284:
285: - 25B6 fat_exec:
286:25722+11 25B6 D5 push de
287: ;DE has pointer to arguments
288:25733+17 25B7 CD1722 call fat_openfile
289:25750+4 25BA B7 or a
290:25754+10 25BB C24C26 jp nz, _fat_exec_notfound ;if not found, abort
291: ;call fat_print_dbg
292: ;load header
293:25764+10 25BE 11B642 ld de, MEM_IDE_BUFFER
294:25774+17 25C1 CDEA21 call fat_readfilesec
295:
296:
297: ;ld hl, MEM_IDE_BUFFER ;print sector
298: ;ld b,0x20
299: ;call dump_pretty
300:
301:25791+13 25C4 3AB642 ld a,(MEM_IDE_BUFFER)
302:25804+7 25C7 FEC3 cp 0xC3
303:25811+10 25C9 C26526 jp nz, _fat_exec_notexec
304:
305:25821+17 25CC CDD001 call PRINTINLINE
306: - 25CF 0A0D4C6F db 10,13,"Loading ",0
6164696E
672000
307:25838+10 25DA E1 pop hl ;get and re-store pointer ot filename from and to stack
308:25848+11 25DB E5 push hl
309:25859+17 25DC CD1D01 call print_str
310:25876+17 25DF CDD001 call PRINTINLINE
311: - 25E2 20746F20 db " to 0x",0
307800
312: ;get start address
313:25893+20 25E9 ED4BC042 ld bc,(MEM_IDE_BUFFER + 10)
314:25913+4 25ED 78 ld a,b
315:25917+17 25EE CD4301 call print_a_hex
316:25934+4 25F1 79 ld a,c
317:25938+17 25F2 CD4301 call print_a_hex
318:25955+17 25F5 CDD001 call PRINTINLINE
319: - 25F8 202E2E2E db " ... ",0
2000
320: ;bc has start addr
321:25972+20 25FE ED434345 ld (MEM_FAT_EXEC_CURR),bc
322:25992+20 2602 ED434745 ld (MEM_FAT_EXEC_START),bc
323:
324: ;get amount of sectors to load
325:26012+16 2606 2AC442 ld hl,(MEM_IDE_BUFFER + 14)
326:26028+4 2609 6C ld l,h
327:26032+8 260A CB3D srl l
328:26040+7 260C 2600 ld h,0 ;divide by 512
329:26047+6 260E 23 inc hl ;increment because first sector is always loaded
330: ; hl contains sector count
331:26053+16 260F 224545 ld (MEM_FAT_EXEC_COUNT), hl
332:
333:26069+10 2612 D1 pop de ; restore filename
334:26079+17 2613 CD1722 call fat_openfile ;reset file information
335: ;start reading
336: - 2616 _fat_exec_readloop1:
337:26096+20 2616 ED5B4345 ld de,(MEM_FAT_EXEC_CURR)
338:26116+17 261A CDEA21 call fat_readfilesec
339:26133+16 261D 2A4345 ld hl,(MEM_FAT_EXEC_CURR)
340:26149+10 2620 110002 ld de,512
341:26159+11 2623 19 add hl,de
342:26170+16 2624 224345 ld (MEM_FAT_EXEC_CURR),hl
343:
344:26186+16 2627 2A4545 ld hl,(MEM_FAT_EXEC_COUNT)
345:26202+6 262A 2B dec hl
346:26208+16 262B 224545 ld (MEM_FAT_EXEC_COUNT),hl
347:26224+4 262E 7C ld a,h
348:26228+4 262F B5 or l
349:26232+7+5 2630 2802 jr z, _fat_exec_read_done
350:26239+12 2632 18E2 jr _fat_exec_readloop1
351: - 2634 _fat_exec_read_done:
352:26251+17 2634 CDD001 call PRINTINLINE
353: - 2637 4C6F6164 db "Load complete!",10,13,0
20636F6D
706C6574
65210A0D
00
354:26268+16 2648 2A4745 ld hl,(MEM_FAT_EXEC_START)
355:26284+4 264B E9 jp (hl)
356:
357:
358: - 264C _fat_exec_notfound:
359:26288+10 264C D1 pop de
360:26298+17 264D CDD001 call PRINTINLINE
361: - 2650 0A0D4669 db 10,13,"File not found!",10,13,0
6C65206E
6F742066
6F756E64
210A0D00
362:26315+10 2664 C9 ret
363:
364: - 2665 _fat_exec_notexec:
365:26325+10 2665 D1 pop de
366:26335+17 2666 CDD001 call PRINTINLINE
367: - 2669 0A0D4669 db 10,13,"File is not an executable!",10,13,0
6C652069
73206E6F
7420616E
20657865
63757461
626C6521
0A0D00
**** main.asm ****
209:26352+10 2688 C9 ret
210:
211: ;================================================================
212: ; Strings
213: ;================================================================
214: - 2689 STR_Banner_Start:
215: - 2689 5A384320 db "Z8C Monitor V2.1 by Dennis Gunia (2022-2024)",0
4D6F6E69
746F7220
56322E31
20627920
44656E6E
69732047
756E6961
20283230
32322D32
30323429
00
Statistics:
4 passes
0 jr promotions
578 symbols
11070 bytes
2 macro calls
244 macro bytes
8 invented symbols
Symbol Table:
?a0000 14A5 5285
?a0001 1562 5474
ADDR_RTC =D0 208
A_RTS_OFF 1BE 446
A_RTS_ON 1C7 455
BOOT_PHASE0 83 131
BOOT_PHASE1 A5 165
BOOT_PHASE1_LOOP AE 174
BOOT_PHASE2 B9 185
B_BEEP 50 80
B_DSKSEL 71 113
B_FATCD 7A 122
B_FATCREATE 7D 125
B_FATOPEN 74 116
B_FATREAD 77 119
B_FATWRITE 80 128
B_IICRECV 56 86
B_IICSEND 53 83
B_KEYREAD 6B 107
B_KEYSEND 6E 110
B_PRINTAHEX 62 98
B_PRINTCHAR 59 89
B_PRINTINLINE 5F 95
B_PRINTLN 65 101
B_PRINTSTR 5C 92
B_READCHAR 68 104
COMMAND 1944 6468
COMMAND_BACKSPACE 1985 6533
COMMAND_LUT 18B2 6322
COMMAND_PROCESS 19AB 6571
COMMAND_PROCESS_FOUND 19E6 6630
COMMAND_PROCESS_LOOP 19AE 6574
COMMAND_PROCESS_LOOP_STR1 19B7 6583
COMMAND_PROCESS_LOOP_STR2 19CD 6605
COMMAND_PROCESS_NEXT_ENTRY 19D2 6610
COMMAND_PROCESS_NEXT_ENTRYI 19D1 6609
COMMAND_PROCESS_NOT_FOUND 19DD 6621
COMMAND_READ 1956 6486
CONSOLE_INIT DC 220
CONSOLE_INIT_CTC DC 220
CONSOLE_INIT_SIO E4 228
CS_APU_CTRL =F9 249
CS_APU_DATA =F8 248
CS_BANK =00 0
CS_CTC_0 =04 4
CS_CTC_1 =05 5
CS_CTC_2 =06 6
CS_CTC_3 =07 7
CS_DIP =01 1
CS_PIA_CR =33 51
CS_PIA_PA =30 48
CS_PIA_PB =31 49
CS_PIA_PC =32 50
CS_PIO_AC =F6 246
CS_PIO_AD =F4 244
CS_PIO_BC =F7 247
CS_PIO_BD =F5 245
CS_SIO_A_C =09 9
CS_SIO_A_D =08 8
CS_SIO_B_C =0B 11
CS_SIO_B_D =0A 10
DHEX_TO_BYTE 235 565
DHEX_TO_BYTE_FAILED 251 593
ERR_SYNTAX 19FC 6652
EXEC_RST_08 DD5 3541
EXEC_RST_10 DD9 3545
EXEC_RST_18 DE5 3557
HEX_TO_BIN 255 597
HEX_TO_BIN_2 263 611
HEX_TO_INVALID_2 26A 618
IDE_CMD_IDENT =EC 236
IDE_CMD_READSEC=20 32
IDE_DEV_TABLE 1307 4871
IDE_RD =40 64
IDE_REG_ALTSTS =16 22
IDE_REG_CMDSTS =0F 15
IDE_REG_DATA =08 8
IDE_REG_DRVADDR=17 23
IDE_REG_ERROR =09 9
IDE_REG_HCYL =0D 13
IDE_REG_HEAD =0E 14
IDE_REG_LBA0 =0B 11
IDE_REG_LBA1 =0C 12
IDE_REG_LBA2 =0D 13
IDE_REG_LBA3 =0E 14
IDE_REG_LCYL =0C 12
IDE_REG_SECTOR =0A 10
IDE_REG_SSECTOR=0B 11
IDE_RST =80 128
IDE_WR =20 32
IIC_CLK =01 1
IIC_DATA =02 2
INT_VEC 1B 27
IO_AY0_ADDR =40 64
IO_AY0_DATA =41 65
IO_AY1_ADDR =42 66
IO_AY1_DATA =43 67
IO_REG0 =20 32
IO_RTC_AMPM =25 37
IO_RTC_CTR_D =2D 45
IO_RTC_CTR_E =2E 46
IO_RTC_CTR_F =2F 47
IO_RTC_DAY0 =26 38
IO_RTC_DAY1 =27 39
IO_RTC_HOUR =24 36
IO_RTC_MIN0 =22 34
IO_RTC_MIN1 =23 35
IO_RTC_MON0 =28 40
IO_RTC_MON1 =29 41
IO_RTC_SEC0 =20 32
IO_RTC_SEC1 =21 33
IO_RTC_WEEK =2C 44
IO_RTC_YEAR1 =2B 43
IO_RTC_YERR0 =2A 42
MEM_FAT_AMOUNT 44B8 17592
MEM_FAT_CLUSTERLEN 44BB 17595
MEM_FAT_COUNT1 44BC 17596
MEM_FAT_CURDIR 44DF 17631
MEM_FAT_CURRDIR 453F 17727
MEM_FAT_DATASTART 44C1 17601
MEM_FAT_DIRSEC 44CD 17613
MEM_FAT_EXEC_COUNT 4545 17733
MEM_FAT_EXEC_CURR 4543 17731
MEM_FAT_EXEC_START 4547 17735
MEM_FAT_FILEREMAIN 44C9 17609
MEM_FAT_OF0_ATTRIBUTE 452F 17711
MEM_FAT_OF0_CCLUST 4531 17713
MEM_FAT_OF0_DATREM 453B 17723
MEM_FAT_OF0_DATSEC 4537 17719
MEM_FAT_OF0_FATSEC 4533 17715
MEM_FAT_RESERVED 44B6 17590
MEM_FAT_ROOTSTART 44C5 17605
MEM_FAT_SECTORS 44B9 17593
MEM_FAT_TMPFNAME 44CF 17615
MEM_FAT_TMPPOINTER 44BD 17597
MEM_IDE_BUFFER 42B6 17078
MEM_IDE_DEVICE 41CB 16843
MEM_IDE_DEV_TABLE 41D5 16853
MEM_IDE_FSBUFFER 44B6 17590
MEM_IDE_PARTITION 41CD 16845
MEM_IDE_POINTER 41D1 16849
MEM_IDE_SELECTED 4215 16917
MEM_IDE_STATUS 41CC 16844
MEM_IDE_STRING_0 4216 16918
MEM_IDE_STRING_1 423E 16958
MEM_IDE_STRING_2 4266 16998
MEM_IDE_STRING_3 428E 17038
MSG_CLEAR 1B6 438
NOT_IMPLEMENTED 19F5 6645
OP_CALL 1A57 6743
OP_CD 1E27 7719
OP_CLR 1BEB 7147
OP_DASM 1AD8 6872
OP_DIR 1E23 7715
OP_DUMP 1A77 6775
OP_EXEC 1A3E 6718
OP_FSEXEC 1E44 7748
OP_IIC_IN 1B9F 7071
OP_IIC_OUT 1B3F 6975
OP_IO_IN 1B08 6920
OP_IO_OUT 1B1E 6942
OP_LSDSK 1E00 7680
OP_RTIME 1BEF 7151
OP_SELDSK 1E04 7684
OP_SET 1AA7 6823
OP_STIME 1D87 7559
POST_CHECK_APU 1E7D 7805
POST_CHECK_IDE_30 1EA8 7848
POST_CHECK_IDE_40 1EBB 7867
POST_CHECK_PIO 1E58 7768
POST_START 1E48 7752
POST_TEST_RTC 1ED5 7893
PRG_RAM_START =4110 16656
PRG_RAM_TOP =FF00 65280
PRINTINLINE 1D0 464
PROG_MEM_START =4000 16384
PROG_ROM_START = 100 256
RST_00 00 0
RST_08 08 8
RST_10 10 16
RST_18 18 24
STACK_RAM_TOP =FFFF 65535
START_ROM =00 0
STRCONV_BYTES_TO_HEX 26C 620
STRCONV_BYTES_TO_HEX_1 27B 635
STRCONV_BYTES_TO_HEX_2 285 645
STR_Banner_Start 2689 9865
STR_PD_HEADER 186B 6251
SYS_BUF_START =4010 16400
SYS_RAM_START =4000 16384
VAR_CONSOLE_BAUD=18 24
VAR_CONSOLE_CONF=0F 15
VDP_MEM =80 128
VDP_REG =81 129
_COMMAND_PROCESS_FOUND 19F4 6644
_OP_CALL 1A76 6774
_OP_IIC_ACK_ERR 1B84 7044
_OP_IIC_ACK_ERR_str 1B8B 7051
_OP_IIC_IN_LOOP 1BD1 7121
_OP_IIC_IN_LOOP_TEXT 1BDE 7134
_OP_IIC_OUT_LOOP 1B55 6997
_OP_IIC_OUT_SEND 1B71 7025
_OP_RTIME_NN 1BF2 7154
_OP_RTIME_RD_CMD 1CAA 7338
_OP_SELDSK_INVALID 1E13 7699
_OP_SELDSK_INVALID_STR 1E2B 7723
_OP_SET_LOOP 1ABF 6847
_OP_STIME_INVALID 1D4D 7501
_OP_STIME_PROMPT 1D64 7524
_OP_STIME_PROMPT_ERR 1D7C 7548
_OP_STIME_STR_DAY 1CAB 7339
_OP_STIME_STR_HOUR 1CFC 7420
_OP_STIME_STR_MIN 1D17 7447
_OP_STIME_STR_MON 1CC6 7366
_OP_STIME_STR_SEC 1D32 7474
_OP_STIME_STR_YEAR 1CE1 7393
_POST_CHECK_APU_FAILED 1E9C 7836
_POST_CHECK_IDE_FAILED 1ECE 7886
_POST_CHECK_PIO_FAILED 1E71 7793
_POST_TEST_RTC_INVALID 1F0F 7951
_POST_TEST_RTC_NOTFOUND 1F08 7944
_STR_NOT_FOUND 1A17 6679
_STR_NOT_IMPLEMENTED 1A03 6659
_STR_SYNTAX 1A2B 6699
_beep_pause_l1 E01 3585
_compare_filename_loop 234A 9034
_compare_filename_nomatch 2358 9048
_fat_cd_navigate 24FF 9471
_fat_cd_navigate_end 2545 9541
_fat_cd_navigate_errfile 256D 9581
_fat_cd_navigate_errfile_str 259F 9631
_fat_cd_navigate_error 2557 9559
_fat_cd_navigate_error_str 2575 9589
_fat_cd_navigate_findsec 2504 9476
_fat_cd_navigate_findsec_skipslash 2530 9520
_fat_cd_navigate_goback_fl 24BB 9403
_fat_cd_navigate_inerror 2565 9573
_fat_cd_navigate_inerrorS 255F 9567
_fat_cd_navigate_inerrore 2566 9574
_fat_cd_navigate_inputerr_str 258C 9612
_fat_cd_navigate_l2 2536 9526
_fat_exec_notexec 2665 9829
_fat_exec_notfound 264C 9804
_fat_exec_read_done 2634 9780
_fat_exec_readloop1 2616 9750
_fat_get_root_table_invalid 213A 8506
_fat_getfatsec_notroot 2179 8569
_fat_increment_32 22D0 8912
_fat_lfs_loop 2246 8774
_fat_lfs_loop_compare_end 2282 8834
_fat_lfs_loop_compare_match 2286 8838
_fat_lfs_loop_compare_next_sector 2258 8792
_fat_math_add32 22E4 8932
_fat_math_mul32 2315 8981
_fat_math_mul32_l 231C 8988
_fat_math_mul32_noadd 2329 9001
_fat_math_sector_add_16 22BC 8892
_fat_print_directory_dir 243A 9274
_fat_print_directory_loop 23CD 9165
_fat_print_directory_loop_break 2499 9369
_fat_print_directory_loop_file 23E9 9193
_fat_print_directory_loop_next 2465 9317
_fat_print_directory_loop_next_sector 2470 9328
_format_filename_fat16_clean 2361 9057
_format_filename_fat16_loop 2368 9064
_format_filename_fat16_loop_copy 237B 9083
_format_filename_fat16_loop_skip_8 2372 9074
_ide_readsector_512_floop E5D 3677
_ideif_drv_sel_fail 15D2 5586
_ideif_drv_sel_fstr0 168F 5775
_ideif_drv_sel_pstr 1686 5766
_ideif_drv_sel_sstr0 169D 5789
_ideif_drv_sel_syn 16AA 5802
_ideif_init_drive_charloop 1499 5273
_ideif_init_drive_found 147B 5243
_ideif_init_drive_loop 1463 5219
_ideif_init_drive_nodrv 1476 5238
_ideif_init_drive_prt_fnd 14F7 5367
_ideif_init_drive_prt_l1 14E5 5349
_ideif_init_drive_prt_ln 14EF 5359
_ideif_prnt_devtable_hdr 1612 5650
_ideif_prnt_devtable_l1 1373 4979
_ideif_prnt_devtable_l1_e2 1439 5177
_ideif_prnt_devtable_l1_es 13B8 5048
_ideif_prnt_devtable_l1_ms 1436 5174
_ideif_prnt_devtable_l1_nxt 1380 4992
_ideif_prnt_devtable_l1_s00 13A6 5030
_ideif_prnt_devtable_l1_s01 13AB 5035
_ideif_prnt_devtable_l1_s02 13B0 5040
_ideif_prnt_devtable_l1_sFF 13B5 5045
_ideif_prnt_devtable_l1_sel 137E 4990
_ideif_prnt_devtable_master 1676 5750
_ideif_prnt_devtable_s00 164A 5706
_ideif_prnt_devtable_s01 1655 5717
_ideif_prnt_devtable_s02 1660 5728
_ideif_prnt_devtable_sFF 166B 5739
_ideif_prnt_devtable_slave 167E 5758
_read_bcd_invalid 18D 397
_shift4 1DFB 7675
beep DE8 3560
beep_loop DEA 3562
beep_pause E00 3584
compare_filename 2346 9030
dasm_00 9ED 2541
dasm_01 CD9 3289
dasm_02 A73 2675
dasm_03 CAB 3243
dasm_08 AF0 2800
dasm_09 C7E 3198
dasm_0A A55 2645
dasm_0B CC2 3266
dasm_10 A35 2613
dasm_12 A7E 2686
dasm_18 9F8 2552
dasm_1A A5F 2655
dasm_20 A12 2578
dasm_22 D1F 3359
dasm_27 AB8 2744
dasm_28 A0B 2571
dasm_2A CF0 3312
dasm_2F ABC 2748
dasm_30 A03 2563
dasm_32 A89 2697
dasm_37 AC8 2760
dasm_38 9FC 2556
dasm_3A A69 2665
dasm_3F AC4 2756
dasm_76 ACC 2764
dasm_80C6 B49 2889
dasm_BE AE6 2790
dasm_C3 9F1 2545
dasm_C88E B6F 2927
dasm_C9 A41 2625
dasm_CD A3B 2619
dasm_D9 AFD 2813
dasm_DD A23 2595
dasm_DD_01 CE0 3296
dasm_DD_09 C99 3225
dasm_DD_22 D35 3381
dasm_DD_23 CB0 3248
dasm_DD_2A D07 3335
dasm_DD_2B CC7 3271
dasm_DD_34 C49 3145
dasm_DD_35 C66 3174
dasm_DD_86 B51 2897
dasm_DD_8E B77 2935
dasm_DD_96 B9A 2970
dasm_DD_9E BBA 3002
dasm_DD_A6 BDB 3035
dasm_DD_AE C12 3090
dasm_DD_B6 BF7 3063
dasm_DD_BE C2E 3118
dasm_DD_E1 D87 3463
dasm_DD_E3 B0D 2829
dasm_DD_E5 D71 3441
dasm_DD_F9 D57 3415
dasm_E1 D81 3457
dasm_E3 B01 2817
dasm_E5 D6B 3435
dasm_E9 A1A 2586
dasm_ED_42 C90 3216
dasm_ED_43 D2B 3371
dasm_ED_44 AC0 2752
dasm_ED_45 A4B 2635
dasm_ED_46 AD7 2775
dasm_ED_4A C87 3207
dasm_ED_4B CFC 3324
dasm_ED_4D A46 2630
dasm_ED_56 ADC 2780
dasm_ED_5E AE1 2785
dasm_ED_A0 B25 2853
dasm_ED_A1 B37 2871
dasm_ED_A8 B2E 2862
dasm_ED_A9 B40 2880
dasm_ED_B0 B29 2857
dasm_ED_B1 B3B 2875
dasm_ED_B8 B32 2866
dasm_ED_B9 B44 2884
dasm_F3 AD1 2769
dasm_F9 D4D 3405
dasm_FB AD4 2772
dasm_FD A2C 2604
dasm_FD_01 CE8 3304
dasm_FD_09 CA2 3234
dasm_FD_22 D41 3393
dasm_FD_23 CB9 3257
dasm_FD_2A D13 3347
dasm_FD_2B CD0 3280
dasm_FD_34 C55 3157
dasm_FD_35 C72 3186
dasm_FD_86 B60 2912
dasm_FD_8E B86 2950
dasm_FD_96 BA6 2982
dasm_FD_9E BC8 3016
dasm_FD_A6 BE7 3047
dasm_FD_AE C1E 3102
dasm_FD_B6 C02 3074
dasm_FD_BE C39 3129
dasm_FD_E1 D8F 3471
dasm_FD_E3 B19 2841
dasm_FD_E5 D79 3449
dasm_FD_F9 D61 3425
dasm_FF A50 2640
dasm_UU D97 3479
dasm_UW D9B 3483
dasm__AND BD6 3030
dasm__CP C2A 3114
dasm__DEC C61 3169
dasm__ED_47 AA8 2728
dasm__ED_4F AB0 2736
dasm__ED_57 A98 2712
dasm__ED_5F AA0 2720
dasm__INC C44 3140
dasm__LD A94 2708
dasm__OR BF3 3059
dasm__SBC BB2 2994
dasm__SUB B95 2965
dasm__XOR C0D 3085
dasm_opcode_table 595 1429
dasm_print16hex_addr 3C2 962
dasm_print8hex 3DA 986
dasm_printFlags_table DA0 3488
dasm_printRegister8_table DB0 3504
dasm_printRegister8_table_HL DD0 3536
dasm_printRegisterIX_table DB8 3512
dasm_printRegisterIY_table DC0 3520
dasm_printRegisterSP_table DC8 3528
disassemble 286 646
disassemble_continue 36C 876
disassemble_err 35C 860
disassemble_next 28A 650
disassemble_print_opcode_params_end 359 857
disassemble_print_opcode_params_loop 305 773
disassemble_print_opcode_raw 2C7 711
disassemble_print_opcode_raw_fill 2DB 731
disassemble_table_first_match 39E 926
disassemble_table_found 3B8 952
disassemble_table_notfound 3BC 956
disassemble_table_seek 37A 890
disassemble_table_seek_loop 37E 894
dump_pretty 1810 6160
dump_pretty_ascii 183A 6202
dump_pretty_ascii_cont 1858 6232
dump_pretty_ascii_loop 1842 6210
dump_pretty_ascii_none 1853 6227
dump_pretty_col 182D 6189
dump_pretty_end 186A 6250
dump_pretty_nextrow 185E 6238
dump_pretty_row 1818 6168
endPrint 1DE 478
fat_cd_single 249B 9371
fat_copy_lba_pointer 233D 9021
fat_exec 25B6 9654
fat_get_root_table 206D 8301
fat_getfatsec 2162 8546
fat_openfile 2217 8727
fat_openfile_noprepare 221F 8735
fat_print_directory 2382 9090
fat_readfilesec 21EA 8682
fat_reset_pointer 232E 9006
format_filename_fat16 235C 9052
ide_printerror E94 3732
ide_readsector_512_fast E49 3657
ide_readsector_timeout E7E 3710
ide_regread_8 E33 3635
ide_regwrite_8 E19 3609
ide_reset E0D 3597
ide_writesector_256 E93 3731
ideif_drv_sel 159A 5530
ideif_get_drv_pointer 153A 5434
ideif_init_all 154E 5454
ideif_init_devtable 1347 4935
ideif_init_drive 145A 5210
ideif_prnt_devtable 1365 4965
iic_init 171C 5916
iic_read_ack 1763 5987
iic_receive_buffer 16ED 5869
iic_receive_buffer_done 1710 5904
iic_receive_buffer_err 1716 5910
iic_receive_buffer_loop 16FE 5886
iic_receive_byte 17E9 6121
iic_receive_byte_loop 17F6 6134
iic_send_ack 1789 6025
iic_send_buffer 16C3 5827
iic_send_buffer_done 16E1 5857
iic_send_buffer_err 16E7 5863
iic_send_buffer_loop 16D3 5843
iic_send_byte 17C3 6083
iic_send_byte_loop 17CF 6095
iic_send_ebit 1742 5954
iic_send_nack 17A6 6054
iic_send_sbit 1729 5929
interrupt_vectors 4000 16384
mon_var_template 44 68
mon_var_template_end 50F 1295
nxtILC 1D3 467
param_01 3E8 1000
param_02 40F 1039
param_03 42C 1068
param_03_done 464 1124
param_03_neg 44D 1101
param_04 468 1128
param_04_i 478 1144
param_05 47E 1150
param_06 48B 1163
param_07 4A5 1189
param_08 4B2 1202
param_09 4C7 1223
param_09_0A 4CD 1229
param_0A 4BE 1214
param_10 4DC 1244
param_11 4EC 1260
param_11_12 4FB 1275
param_11_12_all 51B 1307
param_11_12_def 50E 1294
param_11_12_ix 513 1299
param_11_12_iy 518 1304
param_12 4F4 1268
param_13 52C 1324
param_80 54B 1355
param_80_seek 552 1362
param_81 542 1346
param_comma 586 1414
param_printRegister 561 1377
param_printRegisterA 57F 1407
param_printRegisterHL 577 1399
print_16_hex 1A9 425
print_32_hex 190 400
print_a_hex 143 323
print_bcd 155 341
print_char 115 277
print_clear 126 294
print_newLine 12D 301
print_reg 1E3 483
print_str 11D 285
print_str_fixed 18AA 6314
print_wait_out 138 312
read_bcd 177 375
read_char 15B 347
read_in_sts 16D 365
read_lba_sector 1561 5473
str_dev_done 160A 5642
str_dev_waitready 15F2 5618
str_error_start EC9 3785
str_error_start1 EE6 3814
str_error_start2 EEF 3823
str_error_time EF8 3832
str_post_apu 1F67 8039
str_post_ide_30 1F16 7958
str_post_ide_40 1F31 7985
str_post_nd 1F9D 8093
str_post_ok 1FD5 8149
str_post_pio 1F4C 8012
str_post_rtc 1F82 8066
str_post_rtc_iv 1FAB 8107
var_apu_present 410A 16650
var_buffer_len 4100 16640
var_bytes_count=411A 16666
var_curserchar 4106 16646
var_curserlastaddr 4107 16647
var_curseron 4105 16645
var_curserstate 4104 16644
var_curserx 4102 16642
var_cursery 4103 16643
var_dir 412B 16683
var_idebuffer 41CB 16843
var_input 417B 16763
var_last_char 4101 16641
var_opcode =4114 16660
var_opcode_length=4116 16662
var_opcode_pcount=4119 16665
var_opcode_start=4110 16656
var_opcode_string=4117 16663
var_opcode_table=4112 16658
var_opcode_x =4115 16661
var_pio_present 4109 16649
var_ps2mem 411B 16667
var_scratch 410B 16651