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 C35000 jp BOOT_PHASE0 39: 40: - 0008 org 0x0008 41: - 0008 RST_08 ;Print Char 42: 10+10 0008 C3960D jp EXEC_RST_08 43: 44: - 0010 org 0x0010 45: - 0010 RST_10 ;receive char 46: 20+10 0010 C39A0D jp EXEC_RST_10 47: 48: - 0018 org 0x0018 49: - 0018 RST_18 ;Buffer length 50: 30+10 0018 C3A60D 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: 65: - 4000 var_buffer_len: 66: - 4000 00 defb 0 67: - 4001 var_last_char: 68: - 4001 00 defb 0 69: - 4002 var_curserx: 70: - 4002 00 defb 0 71: - 4003 var_cursery: 72: - 4003 00 defb 0 73: - 4004 var_curserstate: 74: - 4004 00 defb 0 75: - 4005 var_curseron: 76: - 4005 00 defb 0 77: - 4006 var_curserchar: 78: - 4006 00 defb 0 79: - 4007 var_curserlastaddr: 80: - 4007 0000 defw 0 81: - 4009 var_pio_present: 82: - 4009 00 defb 0 83: - 400A var_apu_present: 84: - 400A 00 defb 0 85: - 400B var_scratch: 86: - 400B ..401A 00 defs 16 ;16 bytes space for scratch vars 87: - 401B var_ps2mem: 88: - 401B ..402A 00 defs 16 ;16 bytes space for scratch vars 89: - 402B var_dir: 90: - 402B ..407A 00 defs 80 91: - 407B var_input: 92: - 407B ..40CA 00 defs 80 93: - 40CB var_idebuffer: 94: - 40CB ..43CA 00 defs 768 95: 96: - 040F dephase 97: - 040F mon_var_template_end: 98: 40+4 040F 00 nop 99: 100: ;================================================================ 101: ; Start of monitor 102: ;================================================================ 103: - 0050 org 0x0050 104: - 0050 BOOT_PHASE0: ;Setup Hardware 105: ;Setup Stack-Pointer 106: 44+10 0050 31FFFF ld sp, STACK_RAM_TOP 107: ;Disable Interrupts 108: 54+4 0053 F3 di 109: ;Setup PIO on MIO Board 110: 58+7 0054 3ECF LD A,0xCF 111: 65+11 0056 D3F6 OUT (CS_PIO_AC), A 112: 76+7 0058 3EF7 LD A,11110111b ;All pins inputs except speaker 113: 83+11 005A D3F6 OUT (CS_PIO_AC), A 114: 94+7 005C 3E03 LD A,00000011B ;Preset I2C pins to high 115: 101+11 005E D3F6 OUT (CS_PIO_AC), A 116: 117: ;Set variables 118: 112+13 0060 320440 ld (var_curserstate),a 119: 125+13 0063 320540 ld (var_curseron),a 120: 138+7 0066 3E20 ld a, " " 121: 145+13 0068 320640 ld (var_curserchar),a 122: ;Initialize Console (Serial-Port) 123: 158+17 006B CDA500 call CONSOLE_INIT 124: 125: - 006E BOOT_PHASE1: ;Copy default values to RAM 126: 175+10 006E 214400 ld hl,mon_var_template 127: 185+10 0071 110F04 ld de,mon_var_template_end 128: 195+10 0074 010040 ld bc,SYS_RAM_START 129: - 0077 BOOT_PHASE1_LOOP: 130: 205+7 0077 7E ld a,(hl) ;copy values 131: 212+7 0078 02 ld (bc),a 132: 219+6 0079 23 inc hl 133: 225+6 007A 03 inc bc 134: 231+11 007B E5 push hl ;check if end is reached 135: 242+15 007C ED52 sbc hl,de 136: 257+10 007E E1 pop hl 137: 267+10 007F C27700 jp nz, BOOT_PHASE1_LOOP 138: ;template copy done 139: 277+4 0082 AF xor a ;set dir to empty 140: 281+13 0083 322B40 ld (var_dir),a 141: 294+13 0086 322C40 ld (var_dir+1),a 142: 143: - 0089 BOOT_PHASE2: ;Hardware initialized. 144: ; Print banner 145: 307+17 0089 CDF100 call print_clear 146: 324+10 008C 214F26 ld hl, [STR_Banner_Start] 147: 334+17 008F CDE600 call print_str 148: 149: ; Power-On Self Tests 150: 351+17 0092 CD191E call POST_START 151: 152: ; Detect IDE drives 153: 368+17 0095 CD3015 call ideif_init_all 154: 155: ; Beep after start 156: 385+10 0098 114000 LD DE,0x40 157: 395+10 009B 014800 LD BC,0x48 158: 405+17 009E CDA90D CALL beep 159: 160: ; Start commandline 161: 422+10 00A1 C31519 jp COMMAND 162: 163: ; This instruction should never be reached 164: 432+4 00A4 76 halt 165: 166: ;================================================================ 167: ; Includes (2/2) 168: ;================================================================ 169: .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/ 5: ; 6: ;9600 -> 12 / 00110000 7: ; 8: 9: - 00A5 CONSOLE_INIT: 10: - 00A5 CONSOLE_INIT_CTC: 11: ;LD A,00001111b ; Set /16 Divider, CPU Trigger, Time COnstant Follows 12: 436+7 00A5 3E4F LD A,01001111b ; External Trigger, Time COnstant Follows 13: 443+11 00A7 D304 OUT (CS_CTC_0),A 14: 454+11 00A9 DB01 IN A,(CS_DIP) ; Read BAUD from DIP-Switches 15: ;LD A,39 16: 465+11 00AB D304 OUT (CS_CTC_0),A 17: - 00AD CONSOLE_INIT_SIO: 18: 476+7 00AD 3E30 LD A,00110000b ;write into WR0: error reset, select WR0 19: 483+11 00AF D309 OUT (CS_SIO_A_C),A 20: 494+7 00B1 3E18 LD a,018h ;write into WR0: channel reset 21: 501+11 00B3 D309 OUT (CS_SIO_A_C),A 22: 512+7 00B5 3E04 LD a,004h ;write into WR0: select WR4 23: 519+11 00B7 D309 OUT (CS_SIO_A_C),A 24: 530+7 00B9 3E44 LD a,01000100b ;write into WR4: clkx16,1 stop bit, no parity 25: 537+11 00BB D309 OUT (CS_SIO_A_C),A 26: 548+7 00BD 3E05 LD a,005h ;write into WR0: select WR5 27: 555+11 00BF D309 OUT (CS_SIO_A_C),A 28: 566+7 00C1 3EE8 LD a,11101000b ;DTR inactive, TX 8bit, BREAK off, TX on, RTS inactive 29: 573+11 00C3 D309 OUT (CS_SIO_A_C),A 30: 584+7 00C5 3E01 LD a,01h ;write into WR0: select WR1 31: 591+11 00C7 D309 OUT (CS_SIO_A_C),A 32: 602+7 00C9 3E04 LD a,00000100b ;no interrupt in CH B, special RX condition affects vect 33: 609+11 00CB D309 OUT (CS_SIO_A_C),A 34: 620+7 00CD 3E02 LD a,02h ;write into WR0: select WR2 35: 627+11 00CF D309 OUT (CS_SIO_A_C),A 36: 638+7 00D1 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: 645+11 00D3 D309 OUT (CS_SIO_A_C),A 39: 656+7 00D5 3E03 LD a,003h ;write into WR0: select WR3 40: 663+11 00D7 D309 OUT (CS_SIO_A_C),A 41: 674+7 00D9 3EC1 LD a,0C1h ;RX 8bit, auto enable off, RX on 42: 681+11 00DB D309 OUT (CS_SIO_A_C),A 43: ;Channel A RX active 44: 692+10 00DD C9 RET 45: 46: ; A contains char 47: ; Destroys A 48: - 00DE print_char: 49: 702+11 00DE F5 push af 50: 713+11 00DF D308 out (CS_SIO_A_D),a 51: 724+17 00E1 CD0301 call print_wait_out 52: 741+10 00E4 F1 pop af 53: ;call print_char 54: 751+10 00E5 C9 ret 55: ; HL contains pointer to string 56: ; Destroy A, HL 57: 58: - 00E6 print_str: 59: 761+7 00E6 7E ld a, (hl) 60: 768+4 00E7 B7 or a 61: 772+7+5 00E8 2806 jr z,print_str_end 62: 779+17 00EA CDDE00 call print_char 63: 796+6 00ED 23 inc hl 64: 802+12 00EE 18F6 jr print_str 65: - 00F0 print_str_end: 66: 814+10 00F0 C9 ret 67: 68: - 00F1 print_clear: 69: 824+10 00F1 217701 ld hl, [MSG_CLEAR] 70: 834+17 00F4 CDE600 call print_str 71: 851+10 00F7 C9 ret 72: 73: - 00F8 print_newLine: 74: 861+7 00F8 3E0A ld a,10 75: 868+17 00FA CDDE00 call print_char 76: 885+7 00FD 3E0D ld a,13 77: 892+17 00FF CDDE00 call print_char 78: 909+10 0102 C9 ret 79: ; destroys a 80: - 0103 print_wait_out: 81: ; check for TX buffer empty 82: 919+4 0103 97 sub a ;clear a, write into WR0: select RR0 83: 923+4 0104 3C inc a ;select RR1 84: 927+11 0105 D309 out (CS_SIO_A_C),A 85: 938+11 0107 DB09 in A,(CS_SIO_A_C) ;read RRx 86: 949+8 0109 CB47 bit 0,A 87: 957+7+5 010B 28F6 jr z,print_wait_out 88: 964+10 010D C9 ret 89: 90: - 010E print_a_hex: 91: 974+11 010E F5 push af 92: 985+11 010F C5 push bc 93: 996+11 0110 D5 push de 94: 1007+17 0111 CD2D02 call STRCONV_BYTES_TO_HEX 95: 1024+4 0114 78 ld a,b 96: 1028+17 0115 CDDE00 call print_char 97: 1045+4 0118 79 ld a,c 98: 1049+17 0119 CDDE00 call print_char 99: 1066+10 011C D1 pop de 100: 1076+10 011D C1 pop bc 101: 1086+10 011E F1 pop af 102: 1096+10 011F C9 ret 103: 104: - 0120 print_bcd: 105: 1106+7 0120 C630 ADD 48 ;offset for ascii number 106: 1113+17 0122 CDDE00 call print_char 107: 1130+10 0125 C9 ret 108: 109: - 0126 read_char: 110: 1140+17 0126 CD8801 call A_RTS_ON 111: 1157+4 0129 00 nop 112: 1161+4 012A AF xor a ; a = 0 113: 1165+11 012B D309 out (CS_SIO_A_C), a ; select reg 0 114: 1176+11 012D DB09 in a, (CS_SIO_A_C) ; read reg 0 115: 1187+7 012F E601 and 1 ; mask D0 (recieve char available) 116: 1194+17 0131 CD7F01 call A_RTS_OFF 117: 1211+5+6 0134 C8 ret Z ; return 0 if no char 118: 1216+11 0135 DB08 in a, (CS_SIO_A_D) ; read char if avail 119: 1227+10 0137 C9 ret ; return 120: 121: - 0138 read_bcd; 122: 1237+17 0138 CD2601 call read_char 123: 1254+10 013B CA3801 jp z, read_bcd 124: 1264+17 013E CDDE00 call print_char 125: 1281+7 0141 DE30 sbc 48 ;remove ascii offset 126: 1288+10 0143 DA4E01 jp c, _read_bcd_invalid ;if carry, wrong input 127: 1298+7 0146 FE0A cp 10 128: 1305+10 0148 CA4E01 jp z, _read_bcd_invalid ;if equal or greater than 10, also error 129: 1315+7 014B E60F and 0x0F ;mask unused bits 130: 1322+10 014D C9 ret 131: - 014E _read_bcd_invalid 132: 1332+7 014E 3EFF ld a, 0xFF 133: 1339+10 0150 C9 ret 134: 135: - 0151 print_32_hex: 136: 1349+19 0151 DD7E03 ld a,(ix+3) 137: 1368+17 0154 CD0E01 call print_a_hex 138: 1385+19 0157 DD7E02 ld a,(ix+2) 139: 1404+17 015A CD0E01 call print_a_hex 140: 1421+19 015D DD7E01 ld a,(ix+1) 141: 1440+17 0160 CD0E01 call print_a_hex 142: 1457+19 0163 DD7E00 ld a,(ix+0) 143: 1476+17 0166 CD0E01 call print_a_hex 144: 1493+10 0169 C9 ret 145: 146: - 016A print_16_hex: 147: 1503+19 016A DD7E01 ld a,(ix+1) 148: 1522+17 016D CD0E01 call print_a_hex 149: 1539+19 0170 DD7E00 ld a,(ix+0) 150: 1558+17 0173 CD0E01 call print_a_hex 151: 1575+10 0176 C9 ret 152: 153: 154: ;MSG_CRSR_0: 155: ; db 0x1B, "[?25h",0 156: ;MSG_CRSR_1: 157: ; db 0x1B, "[?25l",0 158: - 0177 MSG_CLEAR: 159: - 0177 1B5B324A db 27, '[2J', 27, '[H',0 1B5B4800 160: 161: 162: 163: ; Serial Util Functions 164: - 017F A_RTS_OFF: 165: 1585+7 017F 3E05 ld a,005h ;write into WR0: select WR5 166: 1592+11 0181 D309 out (CS_SIO_A_C),A 167: 1603+7 0183 3E68 ld a,068h ;DTR inactive, TX 8bit, BREAK off, TX on, RTS inactive 168: 1610+11 0185 D309 out (CS_SIO_A_C),A 169: 1621+10 0187 C9 ret 170: - 0188 A_RTS_ON: 171: 1631+7 0188 3E05 ld a,005h ;write into WR0: select WR5 172: 1638+11 018A D309 out (CS_SIO_A_C),A 173: 1649+7 018C 3EEA ld a,0EAh ;DTR active, TX 8bit, BREAK off, TX on, RTS active 174: 1656+11 018E D309 out (CS_SIO_A_C),A 175: 1667+10 0190 C9 ret 176: 177: ;------------------------------------------------------------------------------ 178: ; PRINTINLINE 179: ; 180: ; String output function 181: ; 182: ; Prints in-line data (bytes immediately following the PRINTINLINE call) 183: ; until a string terminator is encountered (0 - null char). 184: ;------------------------------------------------------------------------------ 185: - 0191 PRINTINLINE: 186: 1677+19 0191 E3 EX (SP),HL ; PUSH HL and put RET ADDress into HL 187: 1696+11 0192 F5 PUSH AF 188: 1707+11 0193 C5 PUSH BC 189: - 0194 nxtILC: 190: 1718+7 0194 7E LD A,(HL) 191: 1725+7 0195 FE00 CP 0 192: 1732+7+5 0197 2806 JR Z,endPrint 193: 1739+17 0199 CDDE00 CALL print_char 194: 1756+6 019C 23 INC HL 195: 1762+12 019D 18F5 JR nxtILC 196: - 019F endPrint: 197: 1774+6 019F 23 INC HL ; Get past "null" terminator 198: 1780+10 01A0 C1 POP BC 199: 1790+10 01A1 F1 POP AF 200: 1800+19 01A2 E3 EX (SP),HL ; PUSH new RET ADDress on stack and restore HL 201: 1819+10 01A3 C9 RET 202: 203: - 01A4 print_reg: 204: 1829+11 01A4 F5 push af 205: 1840+11 01A5 D5 push de 206: 1851+11 01A6 C5 push bc 207: 1862+11 01A7 E5 push hl 208: 1873+11 01A8 F5 push af 209: 1884+17 01A9 CD9101 call PRINTINLINE 210: - 01AC 0A0D413A db 10,13,"A: ",0 202000 211: 1901+10 01B3 F1 pop af 212: 1911+17 01B4 CD0E01 call print_a_hex 213: 1928+17 01B7 CD9101 call PRINTINLINE 214: - 01BA 0A0D4243 db 10,13,"BC: ",0 3A2000 215: 1945+4 01C1 78 ld a,b 216: 1949+17 01C2 CD0E01 call print_a_hex 217: 1966+4 01C5 79 ld a,c 218: 1970+17 01C6 CD0E01 call print_a_hex 219: 1987+17 01C9 CD9101 call PRINTINLINE 220: - 01CC 0A0D4445 db 10,13,"DE: ",0 3A2000 221: 2004+4 01D3 7A ld a,d 222: 2008+17 01D4 CD0E01 call print_a_hex 223: 2025+4 01D7 7B ld a,e 224: 2029+17 01D8 CD0E01 call print_a_hex 225: 2046+10 01DB F1 pop af 226: 2056+17 01DC CD9101 call PRINTINLINE 227: - 01DF 0A0D484C db 10,13,"HL: ",0 3A2000 228: 2073+4 01E6 7C ld a,h 229: 2077+17 01E7 CD0E01 call print_a_hex 230: 2094+4 01EA 7D ld a,l 231: 2098+17 01EB CD0E01 call print_a_hex 232: 2115+17 01EE CDF800 call print_newLine 233: 2132+10 01F1 E1 pop hl 234: 2142+10 01F2 C1 pop bc 235: 2152+10 01F3 D1 pop de 236: 2162+10 01F4 F1 pop af **** main.asm **** 170: 2172+10 01F5 C9 ret 171: .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: - 01F6 DHEX_TO_BYTE: 7: 2182+11 01F6 E5 PUSH HL ;Backup pointer 8: ; Load First Byte 9: 2193+7 01F7 7E LD A,(HL) ;Load first char (high) 10: 2200+17 01F8 CD1602 CALL HEX_TO_BIN ;Conv chart to 4bit 11: 2217+7+5 01FB 3815 jr C, DHEX_TO_BYTE_FAILED ;If error jmp to DHEX_TO_BYTE_FAILED 12: 2224+8 01FD CB27 SLA A ;shift result to upper 4 bits 13: 2232+8 01FF CB27 SLA A 14: 2240+8 0201 CB27 SLA A 15: 2248+8 0203 CB27 SLA A 16: 2256+4 0205 57 LD D,A ;store result in D 17: 18: 2260+6 0206 23 INC HL ;next byte 19: 2266+7 0207 7E LD A,(HL) ;load 2nd char (lower) 20: 2273+17 0208 CD1602 CALL HEX_TO_BIN ;Conv chart to 4bit 21: 2290+7+5 020B 3805 jr C, DHEX_TO_BYTE_FAILED ;If error jmp to DHEX_TO_BYTE_FAILED 22: 2297+4 020D B2 OR D ;merge D with accumulator 23: 24: 2301+10 020E E1 POP HL ;restor original pointer 25: 2311+7 020F 1E00 LD E,0x00 ;set error to 0x00 = no error 26: 2318+10 0211 C9 RET 27: - 0212 DHEX_TO_BYTE_FAILED: 28: 2328+7 0212 1EFF LD E,0xFF ;set error to oxFF 29: ;LD A,0x00 30: 2335+10 0214 E1 POP HL 31: 2345+10 0215 C9 RET 32: 33: ; REG A Contains CHAR-Low 34: ; If failed, Carry is set 35: - 0216 HEX_TO_BIN: 36: 2355+7 0216 D630 SUB 48 ; 0 is 0 37: 2362+10 0218 EA2B02 jp PE, HEX_TO_INVALID_2; to low (SUB overflow) 38: 2372+7 021B FE0A CP 10 ; Value is between 0 and 9 39: 2379+7+5 021D 3805 JR C, HEX_TO_BIN_2 40: 2386+7 021F D607 SUB 7 41: 2393+10 0221 EA2B02 jp PE, HEX_TO_INVALID_2; to low (SUB overflow) 42: - 0224 HEX_TO_BIN_2: 43: 2403+7 0224 FE10 CP 16 44: 2410+7+5 0226 3003 JR NC, HEX_TO_INVALID_2; if bigger than 15-> fail 45: 2417+7 0228 E60F AND 0x0F 46: 2424+10 022A C9 RET 47: - 022B HEX_TO_INVALID_2: 48: 2434+4 022B 37 SCF ;set carry flag 49: 2438+10 022C 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: - 022D STRCONV_BYTES_TO_HEX: 63: 2448+11 022D F5 PUSH AF;Backup A Register 64: 2459+4 022E 1F RRA 65: 2463+4 022F 1F RRA 66: 2467+4 0230 1F RRA 67: 2471+4 0231 1F RRA 68: 2475+17 0232 CD3C02 CALL STRCONV_BYTES_TO_HEX_1 69: ;LD A,D 70: 2492+4 0235 47 LD B,A 71: 2496+10 0236 F1 POP AF ; Reload first Byte 72: 2506+17 0237 CD3C02 CALL STRCONV_BYTES_TO_HEX_1 73: ;LD A,D 74: 2523+4 023A 4F LD C,A 75: 2527+10 023B C9 RET 76: 77: - 023C STRCONV_BYTES_TO_HEX_1: 78: 2537+7 023C E60F AND 0x0F 79: 2544+7 023E C630 ADD 48 80: 2551+7 0240 FE3A CP 58 ; Check if less than 58 (less than ASCII 9) 81: ;JR C, STRCONV_BYTES_TO_HEX_2 82: 2558+5+6 0242 D8 RET C 83: 2563+7 0243 C607 ADD 7 ; A-F 84: 2570+10 0245 C9 RET 85: - 0246 STRCONV_BYTES_TO_HEX_2: 86: ;LD D,A 87: 2580+10 0246 C9 RET 88: 89: **** main.asm **** 172: .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: - 0247 disassemble: 12: 2590+4 0247 78 ld a,b 13: 2594+13 0248 321A41 ld (var_bytes_count),a 14: - 024B disassemble_next: 15: 16: 17: 2607+16 024B 221041 ld (var_opcode_start), hl ;16 bit pointer to opcode in mem 18: 2623+7 024E 7E ld a,(hl) ;load opcode to find in A 19: 2630+13 024F 321441 ld (var_opcode), a ;8 bit opcode value 20: 2643+6 0252 23 inc hl 21: 2649+7 0253 7E ld a,(hl) ;load opcode to find in A 22: 2656+13 0254 321541 ld (var_opcode_x), a ;8 bit opcode extended value 23: 2669+6 0257 2B dec hl 24: 2675+17 0258 CD3B03 call disassemble_table_seek 25: 2692+4 025B 78 ld a,b 26: 2696+4 025C B1 or c 27: 2700+10 025D CA1D03 jp z, disassemble_err ;if bc==0000h 28: 29: 2710+20 0260 ED431241 ld (var_opcode_table), bc ;16 bit pointer to opcode in table 30: 31: ;load params 32: 2730+6 0264 03 inc bc 33: 2736+6 0265 03 inc bc 34: 2742+6 0266 03 inc bc 35: 2748+6 0267 03 inc bc 36: 2754+7 0268 0A ld a,(bc) 37: 2761+13 0269 321641 ld (var_opcode_length),A ;8 bit opcode length (in bytes) 38: 2774+6 026C 03 inc bc 39: 2780+7 026D 0A ld a, (bc) 40: 2787+4 026E 5F ld e,a 41: 2791+6 026F 03 inc bc 42: 2797+7 0270 0A ld a, (bc) 43: 2804+4 0271 57 ld d,a 44: 2808+20 0272 ED531741 ld (var_opcode_string),de ;16 bit pointer to opcode string 45: 2828+6 0276 03 inc bc 46: 2834+7 0277 0A ld a,(bc) 47: 2841+13 0278 321941 ld (var_opcode_pcount),A ;8 bit opcode param count 48: 49: ;values are prepared. Continue with print 50: 51: 2854+16 027B 2A1041 ld hl,(var_opcode_start) ;print address 52: 2870+17 027E CD8303 call dasm_print16hex_addr 53: 54: 2887+13 0281 3A1641 ld a,(var_opcode_length) 55: 2900+4 0284 47 ld b, a 56: 57: ;print up to 4 opcode bytes 58: 2904+16 0285 2A1041 ld hl,(var_opcode_start) 59: 60: - 0288 disassemble_print_opcode_raw 61: 2920+7 0288 7E ld a,(hl) ;load first byte 62: 2927+17 0289 CD0E01 call print_a_hex 63: 2944+6 028C 23 inc hl 64: 2950+8+5 028D 10F9 djnz disassemble_print_opcode_raw 65: 66: 2958+7 028F 3E68 ld a,"h" 67: 2965+17 0291 CDDE00 call print_char 68: ;fill empty spots 69: 2982+13 0294 3A1641 ld a,(var_opcode_length) 70: 2995+4 0297 47 ld b,a 71: 2999+7 0298 3E06 ld a,6 72: 3006+4 029A 90 sub b 73: 3010+4 029B 47 ld b,a 74: 75: - 029C disassemble_print_opcode_raw_fill: 76: 3014+7 029C 3E20 ld a," " 77: 3021+17 029E CDDE00 call print_char 78: 3038+7 02A1 3E20 ld a," " 79: 3045+17 02A3 CDDE00 call print_char 80: 3062+8+5 02A6 10F4 djnz disassemble_print_opcode_raw_fill 81: 3070+7 02A8 3E20 ld a," " 82: 3077+17 02AA CDDE00 call print_char 83: 84: 3094+11 02AD E5 push hl 85: ;print opcode 86: 3105+16 02AE 2A1741 ld hl,(var_opcode_string) 87: 3121+17 02B1 CDE600 call print_str 88: 89: 90: ;print params 91: 3138+13 02B4 3A1941 ld a,(var_opcode_pcount) 92: 3151+4 02B7 B7 or a 93: 3155+10 02B8 CA1A03 jp z, disassemble_print_opcode_params_end ;skip if no params 94: 95: 3165+16 02BB 2A1241 ld hl,(var_opcode_table) 96: 3181+10 02BE 010800 ld bc, 8 97: 3191+11 02C1 09 add hl,bc ;hl now has address of first param 98: 3202+13 02C2 3A1941 ld a,(var_opcode_pcount) 99: 3215+4 02C5 47 ld b,a 100: - 02C6 disassemble_print_opcode_params_loop: 101: ;ld a,(hl) ;load param 102: ;call print_a_hex 103: 3219+7 02C6 7E ld a,(hl) ;load param 104: 105: 3226+7 02C7 FE01 cp 0x01 106: 3233+10+7 02C9 CCA903 call z, param_01 107: 3243+7 02CC FE02 cp 0x02 108: 3250+10+7 02CE CCD003 call z, param_02 109: 3260+7 02D1 FE03 cp 0x03 110: 3267+10+7 02D3 CCED03 call z, param_03 111: 3277+7 02D6 FE04 cp 0x04 112: 3284+10+7 02D8 CC2904 call z, param_04 113: 3294+7 02DB FE05 cp 0x05 114: 3301+10+7 02DD CC3F04 call z, param_05 115: 3311+7 02E0 FE06 cp 0x06 116: 3318+10+7 02E2 CC4C04 call z, param_06 117: 3328+7 02E5 FE07 cp 0x07 118: 3335+10+7 02E7 CC6604 call z, param_07 119: 3345+7 02EA FE08 cp 0x08 120: 3352+10+7 02EC CC7304 call z, param_08 121: 3362+7 02EF FE09 cp 0x09 122: 3369+10+7 02F1 CC8804 call z, param_09 123: 3379+7 02F4 FE10 cp 0x10 124: 3386+10+7 02F6 CC9D04 call z, param_10 125: 3396+7 02F9 FE11 cp 0x11 126: 3403+10+7 02FB CCAD04 call z, param_11 127: 3413+7 02FE FE12 cp 0x12 128: 3420+10+7 0300 CCB504 call z, param_12 129: 3430+7 0303 FE13 cp 0x13 130: 3437+10+7 0305 CCED04 call z, param_13 131: 3447+7 0308 FE0A cp 0x0A 132: 3454+10+7 030A CC7F04 call z, param_0A 133: ;strings 134: 3464+7 030D FE80 cp 0x80 135: 3471+10+7 030F CC0C05 call z, param_80 136: 3481+7 0312 FE81 cp 0x81 137: 3488+10+7 0314 CC0305 call z, param_81 138: 3498+6 0317 23 inc hl 139: 3504+8+5 0318 10AC djnz disassemble_print_opcode_params_loop 140: - 031A disassemble_print_opcode_params_end: 141: 3512+10 031A E1 pop hl 142: 3522+12 031B 1810 jr disassemble_continue 143: 144: 145: - 031D disassemble_err: 146: 3534+17 031D CD8303 call dasm_print16hex_addr 147: 3551+7 0320 7E ld a,(hl) 148: 3558+17 0321 CD9B03 call dasm_print8hex ;print value 149: 3575+6 0324 23 inc hl 150: 3581+11 0325 E5 push hl 151: 3592+10 0326 21580D ld hl, [dasm_UU] 152: 3602+17 0329 CDE600 call print_str 153: 3619+10 032C E1 pop hl 154: 155: - 032D disassemble_continue: 156: 157: 3629+17 032D CDF800 call print_newLine 158: ;inc hl 159: 3646+13 0330 3A1A41 ld a,(var_bytes_count) 160: 3659+4 0333 3D dec a 161: 3663+13 0334 321A41 ld (var_bytes_count),a 162: 3676+10 0337 C24B02 jp nz, disassemble_next 163: 3686+10 033A C9 ret 164: 165: 166: 167: ;A contains opcode 168: ;BC contains returned position 169: - 033B disassemble_table_seek: 170: 3696+11 033B E5 push hl 171: 3707+10 033C 215605 ld hl, [dasm_opcode_table] 172: - 033F disassemble_table_seek_loop: 173: 3717+13 033F 3A1441 ld a,(var_opcode) 174: 3730+4 0342 4F ld c,a 175: 3734+7 0343 7E ld a,(hl) 176: 3741+7 0344 FEFF cp 0xFF ; if null 177: 3748+10 0346 CA7D03 jp z, disassemble_table_notfound 178: 179: ;apply mask 180: 3758+11 0349 F5 push af 181: 3769+6 034A 23 inc hl 182: 3775+7 034B 46 ld b,(hl) ;load mask 183: 3782+6 034C 2B dec hl 184: 3788+4 034D 79 ld a,c 185: 3792+4 034E A0 and b ;apply mask 186: 3796+4 034F 4F ld c,a 187: 3800+10 0350 F1 pop af 188: 189: 3810+4 0351 B9 cp c ; if match 190: 3814+7+5 0352 280B jr z, disassemble_table_first_match 191: 3821+7 0354 0600 ld b,0 192: 3828+7 0356 0E07 ld c,7 193: 3835+11 0358 09 add hl,bc 194: 3846+7 0359 7E ld a,(hl) 195: 3853+4 035A 4F ld c,a 196: 3857+11 035B 09 add hl,bc 197: 3868+6 035C 23 inc hl 198: 3874+12 035D 18E0 jr disassemble_table_seek_loop 199: 200: - 035F disassemble_table_first_match 201: 3886+6 035F 23 inc hl 202: 3892+6 0360 23 inc hl 203: 3898+7 0361 4E ld c,(hl) ;load opcode x from table 204: 3905+6 0362 23 inc hl 205: 3911+13 0363 3A1541 ld a,(var_opcode_x) ;load current opcode x 206: 3924+7 0366 46 ld b,(hl) ;load mask 207: 3931+4 0367 A0 and b ;apply mask 208: 3935+4 0368 B9 cp c ;compare to table 209: 3939+6 0369 2B dec hl 210: 3945+6 036A 2B dec hl 211: 3951+6 036B 2B dec hl 212: 3957+7+5 036C 280B jr z, disassemble_table_found ;IF FOUND 213: 3964+7 036E 0600 ld b,0 ;else continue with next 214: 215: 3971+7 0370 0E07 ld c,7 216: 3978+11 0372 09 add hl,bc 217: 3989+7 0373 7E ld a,(hl) 218: 3996+4 0374 4F ld c,a 219: 4000+11 0375 09 add hl,bc 220: 4011+6 0376 23 inc hl 221: 4017+12 0377 18C6 jr disassemble_table_seek_loop 222: 223: - 0379 disassemble_table_found 224: 4029+4 0379 44 ld b,H 225: 4033+4 037A 4D ld c,l 226: 4037+10 037B E1 pop hl 227: 4047+10 037C C9 ret 228: 229: - 037D disassemble_table_notfound 230: 4057+7 037D 0600 ld b,0 231: 4064+7 037F 0E00 ld c,0 232: 4071+10 0381 E1 pop hl 233: 4081+10 0382 C9 ret 234: 235: 236: 237: 238: - 0383 dasm_print16hex_addr: 239: 4091+7 0383 3E24 ld a,"$" 240: 4098+17 0385 CDDE00 call print_char 241: 4115+4 0388 7C ld a,h 242: 4119+17 0389 CD0E01 call print_a_hex 243: 4136+4 038C 7D ld a,l 244: 4140+17 038D CD0E01 call print_a_hex 245: 4157+7 0390 3E68 ld a,"h" 246: 4164+17 0392 CDDE00 call print_char 247: 4181+7 0395 3E20 ld a," " 248: 4188+17 0397 CDDE00 call print_char 249: 4205+10 039A C9 ret 250: 251: - 039B dasm_print8hex: 252: 4215+17 039B CD0E01 call print_a_hex 253: 4232+7 039E 3E68 ld a,"h" 254: 4239+17 03A0 CDDE00 call print_char 255: 4256+7 03A3 3E20 ld a," " 256: 4263+17 03A5 CDDE00 call print_char 257: 4280+10 03A8 C9 ret 258: 259: 260: 261: 262: 263: 264: 265: - 03A9 param_01: ; 0x01 16bit address pointer 266: 4290+11 03A9 E5 push hl 267: 4301+20 03AA ED5B1041 ld de,(var_opcode_start) 268: 4321+6 03AE 13 inc de 269: 4327+7 03AF 1A ld a,(de) 270: 4334+4 03B0 6F ld l,a 271: 4338+6 03B1 13 inc de 272: 4344+7 03B2 1A ld a,(de) 273: 4351+4 03B3 67 ld h,a 274: 275: 4355+7 03B4 3E24 ld a,"$" 276: 4362+17 03B6 CDDE00 call print_char 277: 4379+4 03B9 7C ld a,h 278: 4383+17 03BA CD0E01 call print_a_hex 279: 4400+4 03BD 7D ld a,l 280: 4404+17 03BE CD0E01 call print_a_hex 281: 4421+7 03C1 3E68 ld a,"h" 282: 4428+17 03C3 CDDE00 call print_char 283: 4445+7 03C6 3E20 ld a," " 284: 4452+17 03C8 CDDE00 call print_char 285: 4469+17 03CB CD4705 call param_comma 286: 4486+10 03CE E1 pop hl 287: 4496+10 03CF C9 ret 288: 289: - 03D0 param_02: 290: 4506+11 03D0 C5 push bc 291: 4517+20 03D1 ED5B1041 ld de,(var_opcode_start) 292: 4537+7 03D5 1A ld a,(de) 293: 4544+4 03D6 1F rra 294: 4548+4 03D7 1F rra 295: 4552+7 03D8 E60E and 0x0E 296: 297: 4559+11 03DA E5 push hl 298: 4570+10 03DB 21610D ld hl, [dasm_printFlags_table] 299: 4580+7 03DE 0600 ld b,0 300: 4587+4 03E0 4F ld c,a 301: 4591+11 03E1 09 add hl,bc 302: 4602+17 03E2 CDE600 call print_str 303: 4619+7 03E5 3E20 ld a, " " 304: 4626+17 03E7 CDDE00 call print_char 305: 4643+10 03EA E1 pop hl 306: 4653+10 03EB C1 pop bc 307: 4663+10 03EC C9 ret 308: 309: 310: - 03ED param_03: 311: 4673+20 03ED ED5B1041 ld de,(var_opcode_start) 312: 4693+6 03F1 13 inc de 313: 4699+7 03F2 1A ld a,(de) 314: 315: 4706+11 03F3 F5 push af 316: 4717+7 03F4 E680 and 0x80 317: 4724+10 03F6 C20E04 jp nz, param_03_neg 318: 4734+7 03F9 3E24 ld a,"$" 319: 4741+17 03FB CDDE00 call print_char 320: 4758+7 03FE 3E2B ld a,"+" 321: 4765+17 0400 CDDE00 call print_char 322: 4782+10 0403 F1 pop af 323: 4792+17 0404 CD0E01 call print_a_hex 324: 4809+7 0407 3E68 ld a,"h" 325: 4816+17 0409 CDDE00 call print_char 326: 4833+12 040C 1817 jr param_03_done 327: 328: - 040E param_03_neg: 329: 4845+7 040E 3E24 ld a,"$" 330: 4852+17 0410 CDDE00 call print_char 331: 4869+7 0413 3E2D ld a,"-" 332: 4876+17 0415 CDDE00 call print_char 333: 4893+10 0418 F1 pop af 334: 4903+8 0419 ED44 neg 335: 4911+17 041B CD0E01 call print_a_hex 336: 4928+7 041E 3E68 ld a,"h" 337: 4935+17 0420 CDDE00 call print_char 338: 4952+12 0423 1800 jr param_03_done 339: 340: - 0425 param_03_done: 341: 4964+17 0425 CD4705 call param_comma 342: 4981+10 0428 C9 ret 343: 344: 345: - 0429 param_04: 346: 4991+20 0429 ED5B1041 ld de,(var_opcode_start) 347: 5011+6 042D 13 inc de 348: 5017+7 042E 1A ld a,(de) 349: 5024+7 042F FE4D cp 0x4D 350: 5031+7+5 0431 2806 jr z,param_04_i 351: 5038+7 0433 3E4E ld a,"N" 352: 5045+17 0435 CDDE00 call print_char 353: 5062+10 0438 C9 ret 354: - 0439 param_04_i: 355: 5072+7 0439 3E49 ld a,"I" 356: 5079+17 043B CDDE00 call print_char 357: 5096+10 043E C9 ret 358: 359: - 043F param_05: 360: 5106+11 043F C5 push bc 361: 5117+20 0440 ED5B1041 ld de,(var_opcode_start) 362: 5137+7 0444 1A ld a,(de) 363: 5144+7 0445 E638 and 0x38 364: ; print hex char 365: 5151+17 0447 CD9B03 call dasm_print8hex 366: 5168+10 044A C1 pop bc 367: 5178+10 044B C9 ret 368: 369: 370: - 044C param_06: 371: 5188+11 044C C5 push bc 372: 5199+20 044D ED5B1041 ld de,(var_opcode_start) 373: 5219+7 0451 1A ld a,(de) 374: 5226+4 0452 1F rra 375: 5230+4 0453 1F rra 376: 5234+4 0454 1F rra 377: 5238+7 0455 E607 and 0x07 378: 5245+17 0457 CD2205 call param_printRegister 379: 5262+7 045A 3E20 ld a," " 380: 5269+17 045C CDDE00 call print_char 381: 5286+7 045F 3E2C ld a,"," 382: 5293+17 0461 CDDE00 call print_char 383: 5310+10 0464 C1 pop bc 384: 5320+10 0465 C9 ret 385: 386: - 0466 param_07: 387: 5330+11 0466 C5 push bc 388: 5341+20 0467 ED5B1041 ld de,(var_opcode_start) 389: 5361+7 046B 1A ld a,(de) 390: 5368+7 046C E607 and 0x07 391: 392: 5375+17 046E CD2205 call param_printRegister 393: 5392+10 0471 C1 pop bc 394: 5402+10 0472 C9 ret 395: 396: - 0473 param_08: 397: 5412+11 0473 C5 push bc 398: 5423+20 0474 ED5B1041 ld de,(var_opcode_start) 399: 5443+6 0478 13 inc de 400: 5449+7 0479 1A ld a,(de) 401: 5456+17 047A CD9B03 call dasm_print8hex 402: 5473+10 047D C1 pop bc 403: 5483+10 047E C9 ret 404: 405: 406: - 047F param_0A: 407: 5493+11 047F E5 push hl 408: 5504+20 0480 ED5B1041 ld de,(var_opcode_start) 409: 5524+6 0484 13 inc de 410: 5530+6 0485 13 inc de 411: 5536+12 0486 1806 jr param_09_0A 412: - 0488 param_09: 413: 5548+11 0488 E5 push hl 414: 5559+20 0489 ED5B1041 ld de,(var_opcode_start) 415: 5579+6 048D 13 inc de 416: - 048E param_09_0A: 417: 5585+7 048E 1A ld a,(de) 418: 5592+4 048F 6F ld l,a 419: 5596+6 0490 13 inc de 420: 5602+7 0491 1A ld a,(de) 421: 5609+4 0492 67 ld h,a 422: 5613+4 0493 7C ld a,h 423: 5617+17 0494 CD0E01 call print_a_hex 424: 5634+4 0497 7D ld a,l 425: 5638+17 0498 CD0E01 call print_a_hex 426: 5655+10 049B E1 pop hl 427: 5665+10 049C C9 ret 428: 429: - 049D param_10: 430: 5675+11 049D C5 push bc 431: 5686+20 049E ED5B1041 ld de,(var_opcode_start) 432: 5706+7 04A2 1A ld a,(de) 433: 5713+4 04A3 1F rra 434: 5717+4 04A4 1F rra 435: 5721+4 04A5 1F rra 436: 5725+7 04A6 E607 and 0x07 437: 5732+17 04A8 CD2205 call param_printRegister 438: 5749+10 04AB C1 pop bc 439: 5759+10 04AC C9 ret 440: 441: 442: - 04AD param_11: 443: 5769+11 04AD E5 push hl 444: 5780+11 04AE C5 push bc 445: 5791+20 04AF ED5B1041 ld de,(var_opcode_start) 446: 5811+12 04B3 1807 jr param_11_12 447: - 04B5 param_12: 448: 5823+11 04B5 E5 push hl 449: 5834+11 04B6 C5 push bc 450: 5845+20 04B7 ED5B1041 ld de,(var_opcode_start) 451: 5865+6 04BB 13 inc de 452: 453: - 04BC param_11_12: 454: 5871+7 04BC 1A ld a,(de) 455: 5878+4 04BD 1F rra 456: 5882+4 04BE 1F rra 457: 5886+4 04BF 1F rra 458: 5890+7 04C0 E606 and 0x06 459: 5897+11 04C2 F5 push af 460: ;check which table to use 461: 5908+16 04C3 2A1041 ld hl, (var_opcode_start) 462: 5924+7 04C6 7E ld a,(hl) 463: 5931+7 04C7 FEDD cp 0xDD 464: 5938+7+5 04C9 2809 jr z,param_11_12_ix 465: 5945+7 04CB FEFD cp 0xFD 466: 5952+7+5 04CD 280A jr z,param_11_12_iy 467: - 04CF param_11_12_def: 468: 5959+10 04CF 21710D ld hl, [dasm_printRegister8_table] 469: 5969+12 04D2 1808 jr param_11_12_all 470: - 04D4 param_11_12_ix: 471: 5981+10 04D4 21790D ld hl, [dasm_printRegisterIX_table] 472: 5991+12 04D7 1803 jr param_11_12_all 473: - 04D9 param_11_12_iy: 474: 6003+10 04D9 21810D ld hl, [dasm_printRegisterIY_table] 475: - 04DC param_11_12_all: 476: 6013+10 04DC F1 pop af 477: 6023+7 04DD 0600 ld b,0 478: 6030+4 04DF 4F ld c,a 479: 6034+11 04E0 09 add hl, bc 480: 6045+7 04E1 7E ld a,(hl) 481: 6052+17 04E2 CDDE00 call print_char 482: 6069+6 04E5 23 inc hl 483: 6075+7 04E6 7E ld a,(hl) 484: 6082+17 04E7 CDDE00 call print_char 485: 6099+10 04EA C1 pop bc 486: 6109+10 04EB E1 pop hl 487: 6119+10 04EC C9 ret 488: 489: - 04ED param_13: 490: 6129+11 04ED E5 push hl 491: 6140+11 04EE C5 push bc 492: 6151+20 04EF ED5B1041 ld de,(var_opcode_start) 493: 6171+7 04F3 1A ld a,(de) 494: 6178+4 04F4 1F rra 495: 6182+4 04F5 1F rra 496: 6186+4 04F6 1F rra 497: 6190+7 04F7 E606 and 0x06 498: 6197+11 04F9 F5 push af 499: ;check which table to use 500: 6208+16 04FA 2A1041 ld hl, (var_opcode_start) 501: 6224+7 04FD 7E ld a,(hl) 502: 6231+10 04FE 21890D ld hl, [dasm_printRegisterSP_table] 503: 6241+12 0501 18D9 jr param_11_12_all ;reuse code from 11_12 504: 505: 506: - 0503 param_81: 507: 6253+11 0503 E5 push hl 508: 6264+11 0504 C5 push bc 509: 6275+16 0505 2A1741 ld hl, (var_opcode_string) 510: 6291+7 0508 0602 ld b,2 511: 6298+12 050A 1807 jr param_80_seek 512: - 050C param_80: 513: 6310+11 050C E5 push hl 514: 6321+11 050D C5 push bc 515: 6332+16 050E 2A1741 ld hl, (var_opcode_string) 516: 6348+7 0511 0601 ld b,1 517: - 0513 param_80_seek: 518: 6355+7 0513 7E ld a,(hl) 519: 6362+6 0514 23 inc hl 520: 6368+4 0515 A7 and a 521: 6372+7+5 0516 20FB jr nz, param_80_seek 522: ;found 523: 6379+4 0518 05 dec b ;found but counter too high 524: 6383+10 0519 C21305 jp nz, param_80_seek 525: 526: 6393+17 051C CDE600 call print_str 527: 6410+10 051F C1 pop bc 528: 6420+10 0520 E1 pop hl 529: 6430+10 0521 C9 ret 530: 531: 532: 533: - 0522 param_printRegister: 534: 6440+11 0522 E5 push hl 535: 6451+7 0523 FE06 cp 0x06 536: 6458+7+5 0525 2811 jr z, param_printRegisterHL 537: 6465+7 0527 FE07 cp 0x07 538: 6472+7+5 0529 2815 jr z, param_printRegisterA 539: 6479+10 052B 21710D ld hl, [dasm_printRegister8_table] 540: 6489+7 052E 0600 ld b,0 541: 6496+4 0530 4F ld c,a 542: 6500+11 0531 09 add hl,bc 543: 6511+7 0532 7E ld a, (hl) 544: 6518+17 0533 CDDE00 call print_char 545: 6535+10 0536 E1 pop hl 546: 6545+10 0537 C9 ret 547: 548: - 0538 param_printRegisterHL: 549: 6555+10 0538 21910D ld hl, [dasm_printRegister8_table_HL] 550: 6565+17 053B CDE600 call print_str 551: 6582+10 053E E1 pop hl 552: 6592+10 053F C9 ret 553: 554: - 0540 param_printRegisterA: 555: 6602+7 0540 3E41 ld a,"A" 556: 6609+17 0542 CDDE00 call print_char 557: 6626+10 0545 E1 pop hl 558: 6636+10 0546 C9 ret 559: 560: 561: - 0547 param_comma: 562: 6646+4 0547 78 ld a,b 563: 6650+7 0548 FE01 cp 1 564: 6657+5+6 054A C8 ret z 565: 6662+7 054B 3E20 ld a," " 566: 6669+17 054D CDDE00 call print_char 567: 6686+7 0550 3E2C ld a,"," 568: 6693+17 0552 CDDE00 call print_char **** main.asm **** 173: 6710+10 0555 C9 ret 174: .include "disassembler_table.s" **** include/disassembler_table.s **** 1: ;disassembler tables 2: 3: - 0556 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: - 0556 00FF0000 defb 0x00, 0xFF, 0x00, 0x00, 1, [dasm_00], [dasm_00]>>8,0 ;NOP 01AE0900 29: ;General-Purpose Arithmetic and CPU Control Groups 30: - 055E 27FF0000 defb 0x27, 0xFF, 0x00, 0x00, 1, [dasm_27], [dasm_27]>>8, 0 ;DAA 01790A00 31: - 0566 2FFF0000 defb 0x2F, 0xFF, 0x00, 0x00, 1, [dasm_2F], [dasm_2F]>>8, 0 ;CPL 017D0A00 32: - 056E EDFF44FF defb 0xED, 0xFF, 0x44, 0xFF, 2, [dasm_ED_44], [dasm_ED_44]>>8, 0 ;NEG 02810A00 33: - 0576 3FFF0000 defb 0x3f, 0xFF, 0x00, 0x00, 1, [dasm_3F], [dasm_3F]>>8, 0 ;CCF 01850A00 34: - 057E 37FF0000 defb 0x37, 0xFF, 0x00, 0x00, 1, [dasm_37], [dasm_37]>>8, 0 ;SCF 01890A00 35: ;defb 0x00, 0xFF, 0x00, 0x00, 1, [dasm_00], [dasm_00]>>8,0 ;NOP -> already at top for performance reasons 36: - 0586 76FF0000 defb 0x76, 0xFF, 0x00, 0x00, 1, [dasm_76], [dasm_76]>>8, 0 ;HALT 018D0A00 37: - 058E F3FF0000 defb 0xF3, 0xFF, 0x00, 0x00, 1, [dasm_F3], [dasm_F3]>>8, 0 ;DI 01920A00 38: - 0596 FBFF0000 defb 0xFB, 0xFF, 0x00, 0x00, 1, [dasm_FB], [dasm_FB]>>8, 0 ;EI 01950A00 39: - 059E EDFF46FF defb 0xED, 0xFF, 0x46, 0xFF, 2, [dasm_ED_46], [dasm_ED_46]>>8, 0 ;IM 0 02980A00 40: - 05A6 EDFF56FF defb 0xED, 0xFF, 0x56, 0xFF, 2, [dasm_ED_56], [dasm_ED_56]>>8, 0 ;IM 1 029D0A00 41: - 05AE EDFF5EFF defb 0xED, 0xFF, 0x5E, 0xFF, 2, [dasm_ED_5E], [dasm_ED_5E]>>8, 0 ;IM 2 02A20A00 42: 43: ;Exchange, Block Transfer, and Search Group 44: - 05B6 EBFF0000 defb 0xEB, 0xFF, 0x00, 0x00, 1, [dasm_BE], [dasm_BE]>>8, 0 ;EX DE, HL 01A70A00 45: - 05BE 08FF0000 defb 0x08, 0xFF, 0x00, 0x00, 1, [dasm_08], [dasm_08]>>8, 0 ;EX AF, AF′ 01B10A00 46: - 05C6 D9FF0000 defb 0xD9, 0xFF, 0x00, 0x00, 1, [dasm_D9], [dasm_D9]>>8, 0 ;EXX 01BE0A00 47: - 05CE E3FF0000 defb 0xE3, 0xFF, 0x00, 0x00, 1, [dasm_E3], [dasm_E3]>>8, 0 ;EX (SP), HL 01C20A00 48: - 05D6 DDFFE3FF defb 0xDD, 0xFF, 0xE3, 0xFF, 2, [dasm_DD_E3], [dasm_DD_E3]>>8, 0 ;EX (SP), IX 02CE0A00 49: - 05DE FDFFE3FF defb 0xFD, 0xFF, 0xE3, 0xFF, 2, [dasm_FD_E3], [dasm_FD_E3]>>8, 0 ;EX (SP), IY 02DA0A00 50: - 05E6 EDFFA0FF defb 0xED, 0xFF, 0xA0, 0xFF, 2, [dasm_ED_A0], [dasm_ED_A0]>>8, 0 ;LDI 02E60A00 51: - 05EE EDFFB0FF defb 0xED, 0xFF, 0xB0, 0xFF, 2, [dasm_ED_B0], [dasm_ED_B0]>>8, 0 ;LDIR 02EA0A00 52: - 05F6 EDFFA8FF defb 0xED, 0xFF, 0xA8, 0xFF, 2, [dasm_ED_A8], [dasm_ED_A8]>>8, 0 ;LDD 02EF0A00 53: - 05FE EDFFB8FF defb 0xED, 0xFF, 0xB8, 0xFF, 2, [dasm_ED_B8], [dasm_ED_B8]>>8, 0 ;LDDR 02F30A00 54: - 0606 EDFFA1FF defb 0xED, 0xFF, 0xA1, 0xFF, 2, [dasm_ED_A1], [dasm_ED_A1]>>8, 0 ;CPI 02F80A00 55: - 060E EDFFB1FF defb 0xED, 0xFF, 0xB1, 0xFF, 2, [dasm_ED_B1], [dasm_ED_B1]>>8, 0 ;CPIR 02FC0A00 56: - 0616 EDFFA9FF defb 0xED, 0xFF, 0xA9, 0xFF, 2, [dasm_ED_A9], [dasm_ED_A9]>>8, 0 ;CPD 02010B00 57: - 061E EDFFB9FF defb 0xED, 0xFF, 0xB9, 0xFF, 2, [dasm_ED_B9], [dasm_ED_B9]>>8, 0 ;CPDR 02050B00 58: 59: ;JUMP Group 60: - 0626 C3FF0000 defb 0xC3, 0xFF, 0x00, 0x00, 3, [dasm_C3], [dasm_C3]>>8,1, 0x01 ;JP nn 03B20901 01 61: - 062F C2C70000 defb 0xC2, 0xC7, 0x00, 0x00, 3, [dasm_C3], [dasm_C3]>>8,3, 0x02, 0x80, 0x01 ;JP cc,nn 03B20903 028001 62: - 063A 18FF0000 defb 0x18, 0xFF, 0x00, 0x00, 2, [dasm_18], [dasm_18]>>8,1, 0x03 ;JR e 02B90901 03 63: - 0643 38FF0000 defb 0x38, 0xFF, 0x00, 0x00, 2, [dasm_38], [dasm_38]>>8,1, 0x03 ;JR C,e 02BD0901 03 64: - 064C 30FF0000 defb 0x30, 0xFF, 0x00, 0x00, 2, [dasm_30], [dasm_30]>>8,1, 0x03 ;JR NC,e 02C40901 03 65: - 0655 28FF0000 defb 0x28, 0xFF, 0x00, 0x00, 2, [dasm_28], [dasm_28]>>8,1, 0x03 ;JR Z,e 02CC0901 03 66: - 065E 20FF0000 defb 0x20, 0xFF, 0x00, 0x00, 2, [dasm_20], [dasm_20]>>8,1, 0x03 ;JR NZ,e 02D30901 03 67: - 0667 E9FF0000 defb 0xE9, 0xFF, 0x00, 0x00, 2, [dasm_E9], [dasm_E9]>>8,0 ;JP (HL) 02DB0900 68: - 066F DDFFE9FF defb 0xDD, 0xFF, 0xE9, 0xFF, 2, [dasm_DD], [dasm_DD]>>8,0 ;JP (IX) 02E40900 69: - 0677 FDFFE9FF defb 0xFD, 0xFF, 0xE9, 0xFF, 2, [dasm_FD], [dasm_FD]>>8,0 ;JP (IY) 02ED0900 70: - 067F 10FF0000 defb 0x10, 0xFF, 0x00, 0x00, 2, [dasm_10], [dasm_10]>>8,1, 0x03 ;DJNZ, e 02F60901 03 71: ;Call and Return Group 72: - 0688 CDFF0000 defb 0xCD, 0xFF, 0x00, 0x00, 3, [dasm_CD], [dasm_CD]>>8,1, 0x01 ;CALL nn 03FC0901 01 73: - 0691 C4C70000 defb 0xC4, 0xC7, 0x00, 0x00, 3, [dasm_CD], [dasm_CD]>>8,2, 0x02, 0x01 ;CALL cc,nn 03FC0902 0201 74: - 069B C9FF0000 defb 0xC9, 0xFF, 0x00, 0x00, 1, [dasm_C9], [dasm_C9]>>8,0 ;RET 01020A00 75: - 06A3 C0C70000 defb 0xC0, 0xC7, 0x00, 0x00, 1, [dasm_C9], [dasm_C9]>>8,1, 0x02 ;RET cc 01020A01 02 76: - 06AC EDFF4DFF defb 0xED, 0xFF, 0x4D, 0xFF, 2, [dasm_ED_4D], [dasm_ED_4D]>>8,0 ;RETI 02070A00 77: - 06B4 EDFF45FF defb 0xED, 0xFF, 0x45, 0xFF, 2, [dasm_ED_45], [dasm_ED_45]>>8,0 ;RETN 020C0A00 78: 79: - 06BC C7C70000 defb 0xC7, 0xC7, 0x00, 0x00, 1, [dasm_FF], [dasm_FF]>>8,1, 0x05 ;RST 01110A01 05 80: ;8-Bit load group 81: - 06C5 0AFF0000 defb 0x0A, 0xFF, 0x00, 0x00, 1, [dasm_0A], [dasm_0A]>>8, 0 ;LD A, (BC) 01160A00 82: - 06CD 1AFF0000 defb 0x1A, 0xFF, 0x00, 0x00, 1, [dasm_1A], [dasm_1A]>>8, 0 ;LD A, (DE) 01200A00 83: - 06D5 3AFF0000 defb 0x3A, 0xFF, 0x00, 0x00, 3, [dasm_3A], [dasm_3A]>>8, 2, 0x09, 0x80 ;LD A, (nn) 032A0A02 0980 84: - 06DF 02FF0000 defb 0x02, 0xFF, 0x00, 0x00, 1, [dasm_02], [dasm_02]>>8, 0 ;LD (BC), A 01340A00 85: - 06E7 12FF0000 defb 0x12, 0xFF, 0x00, 0x00, 1, [dasm_12], [dasm_12]>>8, 0 ;LD (DE), A 013F0A00 86: - 06EF 32FF0000 defb 0x32, 0xFF, 0x00, 0x00, 3, [dasm_32], [dasm_32]>>8, 2, 0x09, 0x80 ;LD (nn), A 034A0A02 0980 87: - 06F9 EDFF57FF defb 0xED, 0xFF, 0x57, 0xFF, 2, [dasm__ED_57], [dasm__ED_57]>>8, 0 ;LD A, I 02590A00 88: - 0701 EDFF5FFF defb 0xED, 0xFF, 0x5F, 0xFF, 2, [dasm__ED_5F], [dasm__ED_5F]>>8, 0 ;LD A, R 02610A00 89: - 0709 EDFF47FF defb 0xED, 0xFF, 0x47, 0xFF, 2, [dasm__ED_47], [dasm__ED_47]>>8, 0 ;LD I, A 02690A00 90: - 0711 EDFF4FFF defb 0xED, 0xFF, 0x4F, 0xFF, 2, [dasm__ED_4F], [dasm__ED_4F]>>8, 0 ;LD R, A 02710A00 91: 92: - 0719 06C70000 defb 0x06, 0xC7, 0x00, 0x00, 2, [dasm__LD], [dasm__LD]>>8, 2, 0x06, 0x08 ;LD r, n 02550A02 0608 93: - 0723 40C00000 defb 0x40, 0xC0, 0x00, 0x00, 1, [dasm__LD], [dasm__LD]>>8, 2, 0x06, 0x07 ;LD r, r' / LD r, (HL) / LD (HL), r 01550A02 0607 94: 95: ;8-Bit Arithmetic Group 96: - 072D 80F80000 defb 0x80, 0xF8, 0x00, 0x00, 1, [dasm_80C6], [dasm_80C6]>>8, 1, 0x07 ;ADD A, r / ADD A, (HL) 010A0B01 07 97: - 0736 C6FF0000 defb 0xC6, 0xFF, 0x00, 0x00, 2, [dasm_80C6], [dasm_80C6]>>8, 1, 0x08 ;ADD A, n 020A0B01 08 98: - 073F DDFF86FF defb 0xDD, 0xFF, 0x86, 0xFF, 3, [dasm_DD_86], [dasm_DD_86]>>8, 2, 0x08, 0x80 ;ADD A, (IX + d) 03120B02 0880 99: - 0749 FDFF86FF defb 0xFD, 0xFF, 0x86, 0xFF, 3, [dasm_FD_86], [dasm_FD_86]>>8, 2, 0x08, 0x80 ;ADD A, (IY + d) 03210B02 0880 100: - 0753 C8F80000 defb 0xC8, 0xF8, 0x00, 0x00, 1, [dasm_C88E], [dasm_C88E]>>8, 1, 0x07 ;ADC A, r / ADC A, (HL) 01300B01 07 101: - 075C 8EF80000 defb 0x8E, 0xF8, 0x00, 0x00, 2, [dasm_C88E], [dasm_C88E]>>8, 1, 0x08 ;ADC A, n 02300B01 08 102: - 0765 DDFF8EFF defb 0xDD, 0xFF, 0x8E, 0xFF, 3, [dasm_DD_8E], [dasm_DD_8E]>>8, 2, 0x08, 0x80 ;ADC A, (IX + d) 03380B02 0880 103: - 076F FDFF8EFF defb 0xFD, 0xFF, 0x8E, 0xFF, 3, [dasm_FD_8E], [dasm_FD_8E]>>8, 2, 0x08, 0x80 ;ADC A, (IY + d) 03470B02 0880 104: - 0779 90F80000 defb 0x90, 0xF8, 0x00, 0x00, 1, [dasm__SUB], [dasm__SUB]>>8, 1, 0x07 ;SUB r / SUB A, (HL) 01560B01 07 105: - 0782 D6FF0000 defb 0xD6, 0xFF, 0x00, 0x00, 2, [dasm__SUB], [dasm__SUB]>>8, 1, 0x08 ;SUB n 02560B01 08 106: - 078B DDFF96FF defb 0xDD, 0xFF, 0x96, 0xFF, 3, [dasm_DD_96], [dasm_DD_96]>>8, 2, 0x08, 0x80 ;SUB (IX + d) 035B0B02 0880 107: - 0795 FDFF96FF defb 0xFD, 0xFF, 0x96, 0xFF, 3, [dasm_FD_96], [dasm_FD_96]>>8, 2, 0x08, 0x80 ;SUB (IY + d) 03670B02 0880 108: - 079F 94F80000 defb 0x94, 0xF8, 0x00, 0x00, 1, [dasm__SBC], [dasm__SBC]>>8, 1, 0x07 ;SBC A,r / SBC A, (HL) 01730B01 07 109: - 07A8 DEFF0000 defb 0xDE, 0xFF, 0x00, 0x00, 2, [dasm__SBC], [dasm__SBC]>>8, 1, 0x08 ;SBC A,n 02730B01 08 110: - 07B1 DDFF9EFF defb 0xDD, 0xFF, 0x9E, 0xFF, 3, [dasm_DD_9E], [dasm_DD_9E]>>8, 2, 0x08, 0x80 ;SBC A,(IX + d) 037B0B02 0880 111: - 07BB FDFF9EFF defb 0xFD, 0xFF, 0x9E, 0xFF, 3, [dasm_FD_9E], [dasm_FD_9E]>>8, 2, 0x08, 0x80 ;SBC A,(IY + d) 03890B02 0880 112: - 07C5 A0F80000 defb 0xA0, 0xF8, 0x00, 0x00, 1, [dasm__AND], [dasm__AND]>>8, 1, 0x07 ;AND A,r / AND A, (HL) 01970B01 07 113: - 07CE E6FF0000 defb 0xE6, 0xFF, 0x00, 0x00, 2, [dasm__AND], [dasm__AND]>>8, 1, 0x08 ;AND A,n 02970B01 08 114: - 07D7 DDFFA6FF defb 0xDD, 0xFF, 0xA6, 0xFF, 3, [dasm_DD_A6], [dasm_DD_A6]>>8, 2, 0x08, 0x80 ;AND A,(IX + d) 039C0B02 0880 115: - 07E1 FDFFA6FF defb 0xFD, 0xFF, 0xA6, 0xFF, 3, [dasm_FD_A6], [dasm_FD_A6]>>8, 2, 0x08, 0x80 ;AND A,(IY + d) 03A80B02 0880 116: - 07EB B0F80000 defb 0xB0, 0xF8, 0x00, 0x00, 1, [dasm__OR], [dasm__OR]>>8, 1, 0x07 ;OR A,r / OR A, (HL) 01B40B01 07 117: - 07F4 F6FF0000 defb 0xF6, 0xFF, 0x00, 0x00, 2, [dasm__OR], [dasm__OR]>>8, 1, 0x08 ;OR A,n 02B40B01 08 118: - 07FD DDFFB6FF defb 0xDD, 0xFF, 0xB6, 0xFF, 3, [dasm_DD_B6], [dasm_DD_B6]>>8, 2, 0x08, 0x80 ;OR A,(IX + d) 03B80B02 0880 119: - 0807 FDFFB6FF defb 0xFD, 0xFF, 0xB6, 0xFF, 3, [dasm_FD_B6], [dasm_FD_B6]>>8, 2, 0x08, 0x80 ;OR A,(IY + d) 03C30B02 0880 120: - 0811 A8F80000 defb 0xA8, 0xF8, 0x00, 0x00, 1, [dasm__XOR], [dasm__XOR]>>8, 1, 0x07 ;XOR A,r / XOR A, (HL) 01CE0B01 07 121: - 081A EEFF0000 defb 0xEE, 0xFF, 0x00, 0x00, 2, [dasm__XOR], [dasm__XOR]>>8, 1, 0x08 ;XOR A,n 02CE0B01 08 122: - 0823 DDFFAEFF defb 0xDD, 0xFF, 0xAE, 0xFF, 3, [dasm_DD_AE], [dasm_DD_AE]>>8, 2, 0x08, 0x80 ;XOR A,(IX + d) 03D30B02 0880 123: - 082D FDFFAEFF defb 0xFD, 0xFF, 0xAE, 0xFF, 3, [dasm_FD_AE], [dasm_FD_AE]>>8, 2, 0x08, 0x80 ;XOR A,(IY + d) 03DF0B02 0880 124: - 0837 B8F80000 defb 0xB8, 0xF8, 0x00, 0x00, 1, [dasm__CP], [dasm__CP]>>8, 1, 0x07 ;CP A,r / CP A, (HL) 01EB0B01 07 125: - 0840 FEFF0000 defb 0xFE, 0xFF, 0x00, 0x00, 2, [dasm__CP], [dasm__CP]>>8, 1, 0x08 ;CP A,n 02EB0B01 08 126: - 0849 DDFFBEFF defb 0xDD, 0xFF, 0xBE, 0xFF, 3, [dasm_DD_BE], [dasm_DD_BE]>>8, 2, 0x08, 0x80 ;CP A,(IX + d) 03EF0B02 0880 127: - 0853 FDFFBEFF defb 0xFD, 0xFF, 0xBE, 0xFF, 3, [dasm_FD_BE], [dasm_FD_BE]>>8, 2, 0x08, 0x80 ;CP A,(IY + d) 03FA0B02 0880 128: - 085D 04C70000 defb 0x04, 0xC7, 0x00, 0x00, 1, [dasm__INC], [dasm__INC]>>8, 1, 0x10 ;INC r / INC (HL) 01050C01 10 129: - 0866 DDFF34FF defb 0xDD, 0xFF, 0x34, 0xFF, 3, [dasm_DD_34], [dasm_DD_34]>>8, 2, 0x08, 0x80 ;INC (IX + d) 030A0C02 0880 130: - 0870 FDFF34FF defb 0xFD, 0xFF, 0x34, 0xFF, 3, [dasm_FD_34], [dasm_FD_34]>>8, 2, 0x08, 0x80 ;INC (IY + d) 03160C02 0880 131: - 087A 05C70000 defb 0x05, 0xC7, 0x00, 0x00, 1, [dasm__DEC], [dasm__DEC]>>8, 1, 0x10 ;DEC r / DEC (HL) 01220C01 10 132: - 0883 DDFF35FF defb 0xDD, 0xFF, 0x35, 0xFF, 3, [dasm_DD_35], [dasm_DD_35]>>8, 2, 0x08, 0x80 ;DEC (IX + d) 03270C02 0880 133: - 088D FDFF35FF defb 0xFD, 0xFF, 0x35, 0xFF, 3, [dasm_FD_35], [dasm_FD_35]>>8, 2, 0x08, 0x80 ;DEC (IY + d) 03330C02 0880 134: ;16-Bit Arithmetic Group 135: - 0897 09CF0000 defb 0x09, 0xCF, 0x00, 0x00, 1, [dasm_09], [dasm_09]>>8, 1, 0x11 ;ADD HL, ss 013F0C01 11 136: - 08A0 EDFF4ACF defb 0xED, 0xFF, 0x4A, 0xCF, 2, [dasm_ED_4A], [dasm_ED_4A]>>8, 1, 0x12 ;ADC HL, ss 02480C01 12 137: - 08A9 EDFF42CF defb 0xED, 0xFF, 0x42, 0xCF, 2, [dasm_ED_42], [dasm_ED_42]>>8, 1, 0x12 ;SBC HL, ss 02510C01 12 138: - 08B2 DDFF09CF defb 0xDD, 0xFF, 0x09, 0xCF, 2, [dasm_DD_09], [dasm_DD_09]>>8, 1, 0x12 ;ADD IX, ss 025A0C01 12 139: - 08BB FDFF09CF defb 0xFD, 0xFF, 0x09, 0xCF, 2, [dasm_FD_09], [dasm_FD_09]>>8, 1, 0x12 ;ADD IY, ss 02630C01 12 140: - 08C4 03CF0000 defb 0x03, 0xCF, 0x00, 0x00, 1, [dasm_03], [dasm_03]>>8, 1, 0x11 ;INC ss 016C0C01 11 141: - 08CD DDFF23FF defb 0xDD, 0xFF, 0x23, 0xFF, 2, [dasm_DD_23], [dasm_DD_23]>>8, 0 ;INC IX 02710C00 142: - 08D5 FDFF23FF defb 0xFD, 0xFF, 0x23, 0xFF, 2, [dasm_FD_23], [dasm_FD_23]>>8, 0 ;INC IY 027A0C00 143: - 08DD 0BCF0000 defb 0x0B, 0xCF, 0x00, 0x00, 1, [dasm_0B], [dasm_0B]>>8, 1, 0x11 ;DEC ss 01830C01 11 144: - 08E6 DDFF2BFF defb 0xDD, 0xFF, 0x2B, 0xFF, 2, [dasm_DD_2B], [dasm_DD_2B]>>8, 0 ;DEC IX 02880C00 145: - 08EE FDFF2BFF defb 0xFD, 0xFF, 0x2B, 0xFF, 2, [dasm_FD_2B], [dasm_FD_2B]>>8, 0 ;DEC IY 02910C00 146: ;16-Bit Load Group 147: - 08F6 01CF0000 defb 0x01, 0xCF, 0x00, 0x00, 3, [dasm_01], [dasm_01]>>8, 3, 0x11, 0x80, 0x09 ;LD dd, nn 039A0C03 118009 148: - 0901 DDFF21FF defb 0xDD, 0xFF, 0x21, 0xFF, 4, [dasm_DD_01], [dasm_DD_01]>>8, 1, 0x0A ;LD IX, nn 04A10C01 0A 149: - 090A FDFF21FF defb 0xFD, 0xFF, 0x21, 0xFF, 4, [dasm_FD_01], [dasm_FD_01]>>8, 1, 0x0A ;LD IY, nn 04A90C01 0A 150: - 0913 2AFF0000 defb 0x2A, 0xFF, 0x00, 0x00, 3, [dasm_2A], [dasm_2A]>>8, 2, 0x09, 0x80 ;LD HL, (nn) 03B10C02 0980 151: - 091D EDFF4BCF defb 0xED, 0xFF, 0x4B, 0xCF, 4, [dasm_ED_4B], [dasm_ED_4B]>>8, 4, 0x12, 0x80, 0x0A, 0x81 ;LD dd, (nn) 04BD0C04 12800A81 152: - 0929 DDFF2AFF defb 0xDD, 0xFF, 0x2A, 0xFF, 4, [dasm_DD_2A], [dasm_DD_2A]>>8, 1, 0x0A ;LD IX, (nn) 04C80C01 0A 153: - 0932 FDFF2AFF defb 0xFD, 0xFF, 0x2A, 0xFF, 4, [dasm_FD_2A], [dasm_FD_2A]>>8, 1, 0x0A ;LD IY, (nn) 04D40C01 0A 154: - 093B 22FF0000 defb 0x22, 0xFF, 0x00, 0x00, 3, [dasm_22], [dasm_22]>>8, 2, 0x0A, 0x80 ;LD (nn), HL 03E00C02 0A80 155: - 0945 EDFF43CF defb 0xED, 0xFF, 0x43, 0xCF, 4, [dasm_ED_43], [dasm_ED_43]>>8, 3, 0x0A, 0x80, 0x12 ;LD (nn), dd 04EC0C03 0A8012 156: - 0950 DDFF22CF defb 0xDD, 0xFF, 0x22, 0xCF, 4, [dasm_DD_22], [dasm_DD_22]>>8, 2, 0x0A, 0x80 ;LD (nn), IX 04F60C02 0A80 157: - 095A FDFF22CF defb 0xFD, 0xFF, 0x22, 0xCF, 4, [dasm_FD_22], [dasm_FD_22]>>8, 2, 0x0A, 0x80 ;LD (nn), IY 04020D02 0A80 158: - 0964 F9FF0000 defb 0xF9, 0xFF, 0x00, 0x00, 1, [dasm_F9], [dasm_F9]>>8, 0 ;LD SP, HL 010E0D00 159: - 096C DDFFF9FF defb 0xDD, 0xFF, 0xF9, 0xFF, 2, [dasm_DD_F9], [dasm_DD_F9]>>8, 0 ;LD SP, IX 02180D00 160: - 0974 FDFFF9FF defb 0xFD, 0xFF, 0xF9, 0xFF, 2, [dasm_FD_F9], [dasm_FD_F9]>>8, 0 ;LD SP, IY 02220D00 161: - 097C C5CF0000 defb 0xC5, 0xCF, 0x00, 0x00, 1, [dasm_E5], [dasm_E5]>>8, 1, 0x13 ;PUSH qq 012C0D01 13 162: - 0985 DDFFE5FF defb 0xDD, 0xFF, 0xE5, 0xFF, 2, [dasm_DD_E5], [dasm_DD_E5]>>8, 0 ;PUSH IX 02320D00 163: - 098D FDFFE5FF defb 0xFD, 0xFF, 0xE5, 0xFF, 2, [dasm_FD_E5], [dasm_FD_E5]>>8, 0 ;PUSH IY 023A0D00 164: - 0995 C1CF0000 defb 0xC1, 0xCF, 0x00, 0x00, 1, [dasm_E1], [dasm_E1]>>8, 1, 0x13 ;POP qq 01420D01 13 165: - 099E DDFFE1FF defb 0xDD, 0xFF, 0xE1, 0xFF, 2, [dasm_DD_E1], [dasm_DD_E1]>>8, 0 ;POP IX 02480D00 166: - 09A6 FDFFE1FF defb 0xFD, 0xFF, 0xE1, 0xFF, 2, [dasm_FD_E1], [dasm_FD_E1]>>8, 0 ;POP IY 02500D00 167: 168: 169: - 09AE 4E4F5000 dasm_00: db "NOP",0x00 170: ;JUMP Group 171: - 09B2 4A502000 dasm_C3: db "JP ",0x00,", ",0x00 2C2000 172: - 09B9 4A522000 dasm_18: db "JR ",0x00 173: - 09BD 4A522043 dasm_38: db "JR C, ",0x00 2C2000 174: - 09C4 4A52204E dasm_30: db "JR NC, ",0x00 432C2000 175: - 09CC 4A52205A dasm_28: db "JR Z, ",0x00 2C2000 176: - 09D3 4A52204E dasm_20: db "JR NZ, ",0x00 5A2C2000 177: - 09DB 4A502028 dasm_E9: db "JP (HL) ",0x00 484C2920 00 178: - 09E4 4A502028 dasm_DD: db "JP (IX) ",0x00 49582920 00 179: - 09ED 4A502028 dasm_FD: db "JP (IY) ",0x00 49592920 00 180: - 09F6 444A4E5A dasm_10: db "DJNZ ",0x00 2000 181: ;Call and Return Group 182: - 09FC 43414C4C dasm_CD: db "CALL ",0x00 2000 183: - 0A02 52455420 dasm_C9: db "RET ",0x00 00 184: - 0A07 52455449 dasm_ED_4D: db "RETI",0x00 00 185: - 0A0C 5245544E dasm_ED_45: db "RETN",0x00 00 186: - 0A11 52535420 dasm_FF: db "RST ",0x00 00 187: ;8-Bit load group 188: - 0A16 4C442041 dasm_0A: db "LD A,(BC)",0x00 2C284243 2900 189: - 0A20 4C442041 dasm_1A: db "LD A,(DE)",0x00 2C284445 2900 190: - 0A2A 4C442041 dasm_3A: db "LD A,(",0x00, "h)",0x00 2C280068 2900 191: - 0A34 4C442028 dasm_02: db "LD (BC), A",0x00 4243292C 204100 192: - 0A3F 4C442028 dasm_12: db "LD (DE), A",0x00 4445292C 204100 193: - 0A4A 4C442028 dasm_32: db "LD (",0x00, "h), A",0x00 0068292C 204100 194: - 0A55 4C442000 dasm__LD: db "LD ",0x00 195: - 0A59 4C442041 dasm__ED_57: db "LD A, I",0x00 2C204900 196: - 0A61 4C442041 dasm__ED_5F: db "LD A, R",0x00 2C205200 197: - 0A69 4C442049 dasm__ED_47: db "LD I, A",0x00 2C204100 198: - 0A71 4C442052 dasm__ED_4F: db "LD R, A",0x00 2C204100 199: ;General-Purpose Arithmetic and CPU Control Groups 200: - 0A79 44414100 dasm_27: db "DAA",0x00 201: - 0A7D 43504C00 dasm_2F: db "CPL",0x00 202: - 0A81 4E454700 dasm_ED_44: db "NEG",0x00 203: - 0A85 43434600 dasm_3F: db "CCF",0x00 204: - 0A89 53434600 dasm_37: db "SCF",0x00 205: - 0A8D 48414C54 dasm_76: db "HALT",0x00 00 206: - 0A92 444900 dasm_F3: db "DI",0x00 207: - 0A95 454900 dasm_FB: db "EI",0x00 208: - 0A98 494D2030 dasm_ED_46: db "IM 0",0x00 00 209: - 0A9D 494D2031 dasm_ED_56: db "IM 1",0x00 00 210: - 0AA2 494D2032 dasm_ED_5E: db "IM 2",0x00 00 211: ;Exchange, Block Transfer, and Search Group 212: - 0AA7 45582044 dasm_BE: db "EX DE, HL",0x00 452C2048 4C00 213: - 0AB1 45582041 dasm_08: db "EX AF, AF′",0x00 462C2041 46E280B2 00 214: - 0ABE 45585800 dasm_D9: db "EXX",0x00 215: - 0AC2 45582028 dasm_E3: db "EX (SP), HL",0x00 5350292C 20484C00 216: - 0ACE 45582028 dasm_DD_E3: db "EX (SP), IX",0x00 5350292C 20495800 217: - 0ADA 45582028 dasm_FD_E3: db "EX (SP), IY",0x00 5350292C 20495900 218: - 0AE6 4C444900 dasm_ED_A0: db "LDI",0x00 219: - 0AEA 4C444952 dasm_ED_B0: db "LDIR",0x00 00 220: - 0AEF 4C444400 dasm_ED_A8: db "LDD",0x00 221: - 0AF3 4C444452 dasm_ED_B8: db "LDDR",0x00 00 222: - 0AF8 43504900 dasm_ED_A1: db "CPI",0x00 223: - 0AFC 43504952 dasm_ED_B1: db "CPIR",0x00 00 224: - 0B01 43504400 dasm_ED_A9: db "CPD",0x00 225: - 0B05 43504452 dasm_ED_B9: db "CPDR",0x00 00 226: ;8-Bit Arithmetic Group 227: - 0B0A 41444420 dasm_80C6: db "ADD A, ", 0x00 412C2000 228: - 0B12 41444420 dasm_DD_86: db "ADD A, (IX+", 0x00, "h)",0x00 412C2028 49582B00 682900 229: - 0B21 41444420 dasm_FD_86: db "ADD A, (IY+", 0x00, "h)",0x00 412C2028 49592B00 682900 230: - 0B30 41444320 dasm_C88E: db "ADC A, ", 0x00 412C2000 231: - 0B38 41444320 dasm_DD_8E: db "ADC A, (IX+", 0x00, "h)",0x00 412C2028 49582B00 682900 232: - 0B47 41444320 dasm_FD_8E: db "ADC A, (IY+", 0x00, "h)",0x00 412C2028 49592B00 682900 233: - 0B56 53554220 dasm__SUB: db "SUB ", 0x00 00 234: - 0B5B 53554220 dasm_DD_96: db "SUB (IX+", 0x00, "h)",0x00 2849582B 00682900 235: - 0B67 53554220 dasm_FD_96: db "SUB (IY+", 0x00, "h)",0x00 2849592B 00682900 236: - 0B73 53424320 dasm__SBC: db "SBC A, ", 0x00 412C2000 237: - 0B7B 53424320 dasm_DD_9E: db "SBC A,(IX+", 0x00, "h)",0x00 412C2849 582B0068 2900 238: - 0B89 53424320 dasm_FD_9E: db "SBC A,(IY+", 0x00, "h)",0x00 412C2849 592B0068 2900 239: - 0B97 414E4420 dasm__AND: db "AND ", 0x00 00 240: - 0B9C 414E4420 dasm_DD_A6: db "AND (IX+", 0x00, "h)",0x00 2849582B 00682900 241: - 0BA8 414E4420 dasm_FD_A6: db "AND (IY+", 0x00, "h)",0x00 2849592B 00682900 242: - 0BB4 4F522000 dasm__OR: db "OR ", 0x00 243: - 0BB8 4F522028 dasm_DD_B6: db "OR (IX+", 0x00, "h)",0x00 49582B00 682900 244: - 0BC3 4F522028 dasm_FD_B6: db "OR (IY+", 0x00, "h)",0x00 49592B00 682900 245: - 0BCE 584F5220 dasm__XOR: db "XOR ", 0x00 00 246: - 0BD3 584F5220 dasm_DD_AE: db "XOR (IX+", 0x00, "h)",0x00 2849582B 00682900 247: - 0BDF 584F5220 dasm_FD_AE: db "XOR (IY+", 0x00, "h)",0x00 2849592B 00682900 248: - 0BEB 43502000 dasm__CP: db "CP ", 0x00 249: - 0BEF 43502028 dasm_DD_BE: db "CP (IX+", 0x00, "h)",0x00 49582B00 682900 250: - 0BFA 43502028 dasm_FD_BE: db "CP (IY+", 0x00, "h)",0x00 49592B00 682900 251: - 0C05 494E4320 dasm__INC: db "INC ", 0x00 00 252: - 0C0A 494E4320 dasm_DD_34: db "INC (IX+", 0x00, "h)",0x00 2849582B 00682900 253: - 0C16 494E4320 dasm_FD_34: db "INC (IY+", 0x00, "h)",0x00 2849592B 00682900 254: - 0C22 44454320 dasm__DEC: db "DEC ", 0x00 00 255: - 0C27 44454320 dasm_DD_35: db "DEC (IX+", 0x00, "h)",0x00 2849582B 00682900 256: - 0C33 44454320 dasm_FD_35: db "DEC (IY+", 0x00, "h)",0x00 2849592B 00682900 257: ;16-Bit Arithmetic Group 258: - 0C3F 41444420 dasm_09: db "ADD HL, ",0x00 484C2C20 00 259: - 0C48 41444320 dasm_ED_4A: db "ADC HL, ",0x00 484C2C20 00 260: - 0C51 53424320 dasm_ED_42: db "SBC HL, ",0x00 484C2C20 00 261: - 0C5A 41444420 dasm_DD_09: db "ADD IX, ",0x00 49582C20 00 262: - 0C63 41444420 dasm_FD_09: db "ADD IY, ",0x00 49592C20 00 263: - 0C6C 494E4320 dasm_03: db "INC ",0x00 00 264: - 0C71 494E4320 dasm_DD_23: db "INC IX, ",0x00 49582C20 00 265: - 0C7A 494E4320 dasm_FD_23: db "INC IY, ",0x00 49592C20 00 266: - 0C83 44454320 dasm_0B: db "DEC ",0x00 00 267: - 0C88 44454320 dasm_DD_2B: db "DEC IX, ",0x00 49582C20 00 268: - 0C91 44454320 dasm_FD_2B: db "DEC IY, ",0x00 49592C20 00 269: ;16-Bit Load Group 270: - 0C9A 4C442000 dasm_01: db "LD ",0x00, ", ",0x00 2C2000 271: - 0CA1 4C442049 dasm_DD_01: db "LD IX, ",0x00 582C2000 272: - 0CA9 4C442049 dasm_FD_01: db "LD IY, ",0x00 592C2000 273: - 0CB1 4C442048 dasm_2A: db "LD HL, (",0x00,"h)",0x00 4C2C2028 00682900 274: - 0CBD 4C442000 dasm_ED_4B: db "LD ",0x00,", (",0x00,"h)",0x00 2C202800 682900 275: - 0CC8 4C442049 dasm_DD_2A: db "LD IX, (",0x00,"h)",0x00 582C2028 00682900 276: - 0CD4 4C442049 dasm_FD_2A: db "LD IY, (",0x00,"h)",0x00 592C2028 00682900 277: - 0CE0 4C442028 dasm_22: db "LD (",0x00,"h), HL",0x00 0068292C 20484C00 278: - 0CEC 4C442028 dasm_ED_43: db "LD (",0x00,"h), ",0x00 0068292C 2000 279: - 0CF6 4C442028 dasm_DD_22: db "LD (",0x00,"h), IX",0x00 0068292C 20495800 280: - 0D02 4C442028 dasm_FD_22: db "LD (",0x00,"h), IY",0x00 0068292C 20495900 281: - 0D0E 4C442053 dasm_F9: db "LD SP, HL",0x00 502C2048 4C00 282: - 0D18 4C442053 dasm_DD_F9: db "LD SP, IX",0x00 502C2049 5800 283: - 0D22 4C442053 dasm_FD_F9: db "LD SP, IY",0x00 502C2049 5900 284: - 0D2C 50555348 dasm_E5: db "PUSH ",0x00 2000 285: - 0D32 50555348 dasm_DD_E5: db "PUSH IX",0x00 20495800 286: - 0D3A 50555348 dasm_FD_E5: db "PUSH IY",0x00 20495900 287: - 0D42 50555348 dasm_E1: db "PUSH ",0x00 2000 288: - 0D48 50555348 dasm_DD_E1: db "PUSH IX",0x00 20495800 289: - 0D50 50555348 dasm_FD_E1: db "PUSH IY",0x00 20495900 290: 291: ;Misc 292: - 0D58 2E3F2E00 dasm_UU: db ".?.",0x00 293: - 0D5C 20202020 dasm_UW: db " ",0x00 00 294: 295: - 0D61 dasm_printFlags_table: 296: - 0D61 4E5A db "NZ" 297: - 0D63 5A00 db "Z",0 298: - 0D65 4E43 db "NC" 299: - 0D67 4300 db "C",0 300: - 0D69 504F db "PO" 301: - 0D6B 5045 db "PE" 302: - 0D6D 5000 db "P",0 303: - 0D6F 4D00 db "M",0 304: 305: - 0D71 dasm_printRegister8_table: 306: - 0D71 42 db "B" 307: - 0D72 43 db "C" 308: - 0D73 44 db "D" 309: - 0D74 45 db "E" 310: - 0D75 48 db "H" 311: - 0D76 4C db "L" 312: - 0D77 53 db "S" ;only 18 bit (SP) 313: - 0D78 50 db "P" ;only 18 bit (SP) 314: 315: - 0D79 dasm_printRegisterIX_table: 316: - 0D79 4243 db "BC" 317: - 0D7B 4445 db "DE" 318: - 0D7D 4958 db "IX" 319: - 0D7F 5350 db "SP" 320: - 0D81 dasm_printRegisterIY_table: 321: - 0D81 4243 db "BC" 322: - 0D83 4445 db "DE" 323: - 0D85 4959 db "IY" 324: - 0D87 5350 db "SP" 325: 326: - 0D89 dasm_printRegisterSP_table: 327: - 0D89 4243 db "BC" 328: - 0D8B 4445 db "DE" 329: - 0D8D 484C db "HL" 330: - 0D8F 4146 db "AF" 331: 332: - 0D91 dasm_printRegister8_table_HL: **** main.asm **** 175: - 0D91 28484C29 db "(HL)", 0 00 176: .include "rst.s" **** include/rst.s **** 1: - 0D96 EXEC_RST_08: 2: 6720+17 0D96 CDDE00 call print_char 3: 6737+10 0D99 C9 ret 4: 5: 6: - 0D9A EXEC_RST_10: 7: 6747+11 0D9A C5 push bc 8: 6758+11 0D9B D5 push de 9: 6769+11 0D9C E5 push hl 10: ;call vdp_cursor_on 11: 6780+17 0D9D CD2601 call read_char 12: 6797+11 0DA0 F5 push af 13: ;call vdp_cursor_off 14: 6808+10 0DA1 F1 pop af 15: 6818+10 0DA2 E1 pop hl 16: 6828+10 0DA3 D1 pop de 17: 6838+10 0DA4 C1 pop bc 18: 6848+10 0DA5 C9 ret 19: 20: - 0DA6 EXEC_RST_18: 21: 6858+7 0DA6 3E00 ld a,0 22: 6865+10 0DA8 C9 ret **** main.asm **** 177: .include "beep.s" **** include/beep.s **** 1: ;------------------------------------------------------------------------------ 2: ; beep 3: ; 4: ; Beeps the speaker 5: ; DE sets duration 6: ;------------------------------------------------------------------------------ 7: - 0DA9 beep: 8: 6875+11 0DA9 F5 push AF 9: 6886+11 0DAA D5 push DE 10: - 0DAB beep_loop: 11: 6897+7 0DAB 3E08 LD A,0x08 12: 6904+11 0DAD D3F4 OUT (CS_PIO_AD), A 13: 6915+17 0DAF CDC10D CALL beep_pause 14: 6932+7 0DB2 3E00 LD A,0x00 15: 6939+11 0DB4 D3F4 OUT (CS_PIO_AD), A 16: 6950+17 0DB6 CDC10D CALL beep_pause 17: 6967+6 0DB9 1B DEC DE 18: 6973+4 0DBA 7A ld A,D 19: 6977+4 0DBB B3 or E 20: 6981+7+5 0DBC 20ED jr NZ, beep_loop 21: 6988+10 0DBE D1 pop de 22: 6998+10 0DBF F1 pop af 23: 7008+10 0DC0 C9 ret 24: 25: - 0DC1 beep_pause: 26: 7018+11 0DC1 C5 PUSH BC 27: - 0DC2 _beep_pause_l1: 28: ;NEG ; 8 T-states 29: ;NEG ; 8 T-states 30: 7029+8 0DC2 ED44 NEG ; 8 T-states 31: 7037+8 0DC4 ED44 NEG ; 8 T-states 32: 7045+6 0DC6 0B DEC BC ; 6 T-states 33: 7051+4 0DC7 79 LD A,C ; 9 T-states 34: 7055+4 0DC8 B0 OR B ; 4 T-states 35: 7059+10 0DC9 C2C20D JP NZ,_beep_pause_l1 ; 10 T-states 36: 7069+10 0DCC C1 POP BC **** main.asm **** 178: 7079+10 0DCD C9 RET ; Pause complete, RETurn 179: .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: 41: ;================================================================ 42: ; I/O access functions 43: ;================================================================ 44: 45: ;------------------------------------------------------------------------------ 46: ; ide_reset 47: ; 48: ; resets drives on bus 49: ;------------------------------------------------------------------------------ 50: - 0DCE ide_reset: 51: 52: 7089+7 0DCE 3E80 LD A, 10000000b ;CommandByte-A, Mode 0, PA Out, PC Out, PB Out 53: 7096+11 0DD0 D333 OUT (CS_PIA_CR), A ;Set Data direction to out 54: 7107+7 0DD2 3E80 LD A, IDE_RST 55: 7114+11 0DD4 D332 OUT (CS_PIA_PC), A ;Reset IDE Device 56: 7125+4 0DD6 00 NOP 57: 7129+4 0DD7 AF XOR A 58: 7133+11 0DD8 D332 OUT (CS_PIA_PC), A ;end device reset 59: 7144+10 0DDA C9 RET 60: 61: 62: ;------------------------------------------------------------------------------ 63: ; ide_regwrite_8 64: ; 65: ; Sends data to the IDE device 66: ; A contains DATA 67: ; B contains register number 68: ;------------------------------------------------------------------------------ 69: - 0DDB ide_regwrite_8: 70: 7154+11 0DDB F5 PUSH AF ;store date to stack 71: ; Prepare PIA Data Direction 72: 7165+7 0DDC 3E80 LD A, 10000000b ;CommandByte-A, Mode 0, PA Out, PC Out, PB Out 73: 7172+11 0DDE D333 OUT (CS_PIA_CR), A ;Set Data direction to out 74: ; Write Data out 75: 7183+10 0DE0 F1 POP AF 76: 7193+11 0DE1 D330 OUT (CS_PIA_PA), A ;Write Data to bit 0-7 77: ;Prepare Address 78: 7204+4 0DE3 78 LD A, B ;Load register address 79: 7208+7 0DE4 E61F AND 00011111b ;Mask unused bits 80: 7215+11 0DE6 D332 OUT (CS_PIA_PC), A ;Write Data to bit controll lines 81: 7226+7 0DE8 F620 OR IDE_WR ;Set Write bit 82: 7233+11 0DEA D332 OUT (CS_PIA_PC), A ;Set write signal 83: 7244+4 0DEC 00 NOP ;delay to wait for processing 84: 7248+4 0DED 78 LD A, B ;Load register address 85: 7252+7 0DEE E61F AND 00011111b ;Mask unused bits 86: 7259+11 0DF0 D332 OUT (CS_PIA_PC), A ;disable write signal 87: 7270+4 0DF2 00 NOP 88: 7274+4 0DF3 AF XOR A ;clear register A 89: 7278+11 0DF4 D332 OUT (CS_PIA_PC), A ;clear controll lines 90: 7289+10 0DF6 C9 RET 91: 92: 93: ;------------------------------------------------------------------------------ 94: ; ide_regread_8 95: ; 96: ; Sends data to the IDE device 97: ; B contains register number 98: ; A returns data 99: ;------------------------------------------------------------------------------ 100: - 0DF7 ide_regread_8: 101: 7299+7 0DF7 3E92 LD A, 10010010b ;CommandByte-A, Mode 0, PA IN, PC Out, PB IN 102: 7306+11 0DF9 D333 OUT (CS_PIA_CR), A ;Set Data direction to in 103: ;Prepare Address 104: 7317+4 0DFB 78 LD A, B ;Load register address 105: 7321+7 0DFC E61F AND 00011111b ;Mask unused bits 106: 7328+11 0DFE D332 OUT (CS_PIA_PC), A ;Write Data to bit controll lines 107: 7339+7 0E00 F640 OR IDE_RD ;Set Write bit 108: 7346+11 0E02 D332 OUT (CS_PIA_PC), A ;Write Data to bit controll lines 109: 7357+4 0E04 00 NOP ;delay to wait for processing 110: 7361+11 0E05 F5 PUSH AF 111: 7372+10 0E06 F1 POP AF 112: 7382+11 0E07 F5 PUSH AF 113: 7393+10 0E08 F1 POP AF 114: 7403+11 0E09 F5 PUSH AF 115: 7414+10 0E0A F1 POP AF 116: 7424+11 0E0B F5 PUSH AF 117: 7435+10 0E0C F1 POP AF 118: 7445+11 0E0D DB30 IN A,(CS_PIA_PA) ;read data from ide device to b (because a is used later) 119: 7456+11 0E0F F5 PUSH AF 120: 7467+4 0E10 AF XOR A ;clear register A 121: 7471+11 0E11 D332 OUT (CS_PIA_PC), A ;clear controll lines 122: 7482+10 0E13 F1 POP AF ;put data in accumulator 123: 7492+10 0E14 C9 RET 124: 125: 126: ;------------------------------------------------------------------------------ 127: ; ide_readsector_256 128: ; 129: ; Reads IDE Data 130: ; HL contains destination address 131: ;------------------------------------------------------------------------------ 132: - 0E15 ide_readsector_256: 133: 7502+7 0E15 0E00 LD C,0 ;Setup counter for 256 words 134: 135: - 0E17 ide_readsector_256_waitloop: 136: 7509+7 0E17 060F LD B, IDE_REG_CMDSTS 137: 7516+17 0E19 CDF70D CALL ide_regread_8 138: 7533+8 0E1C CB47 BIT 0,a ;Error Bit set. 139: 7541+10 0E1E C2890E JP NZ, ide_printerror 140: 7551+8 0E21 CB5F BIT 3,a ;DRQ Bit set. If set, disk has data 141: 7559+7+5 0E23 28F2 JR Z, ide_readsector_256_waitloop ;If not set, wait 142: 143: 7566+7 0E25 3E92 LD A, 10010010b ;CommandByte-A, Mode 0, PA IN, PC Out, PB IN 144: 7573+11 0E27 D333 OUT (CS_PIA_CR), A ;Set Data direction to IN 145: 7584+7 0E29 3E08 LD A, IDE_REG_DATA ;CS0 and A=0 -> I/O register 146: 7591+11 0E2B D332 OUT (CS_PIA_PC), A ;set register 147: 7602+7 0E2D F640 OR IDE_RD ;Set Read bit 148: 7609+11 0E2F D332 OUT (CS_PIA_PC), A ;Write Read to bit controll lines 149: 7620+4 0E31 00 NOP 150: ;NOP 151: ;NOP 152: 7624+11 0E32 DB31 IN A,(CS_PIA_PB) ;Load 16-Bit data to buffer 153: 7635+7 0E34 77 LD (HL), A 154: 7642+6 0E35 23 INC HL 155: 7648+11 0E36 DB30 IN A,(CS_PIA_PA) 156: 7659+7 0E38 77 LD (HL), A 157: 7666+6 0E39 23 INC HL 158: 7672+4 0E3A 0D DEC C 159: 7676+5+6 0E3B C8 RET Z 160: 7681+12 0E3C 18D9 JR ide_readsector_256_waitloop 161: 162: - 0E3E ide_readsector_512_inv: 163: 7693+7 0E3E 0E00 LD C,0 ;Setup counter for 256 words 164: 7700+10 0E40 110010 LD DE, 4096 ;Timeout counter 165: - 0E43 ide_readsector_512_inv_waitloop: 166: 7710+6 0E43 1B DEC DE 167: 7716+4 0E44 7A LD A,D 168: 7720+4 0E45 B3 OR E 169: 7724+10 0E46 CA730E JP Z, ide_readsector_timeout 170: ;timeout checked. continue 171: 7734+7 0E49 060F LD B, IDE_REG_CMDSTS 172: 7741+17 0E4B CDF70D CALL ide_regread_8 173: 7758+8 0E4E CB47 BIT 0,a ;Error Bit set. 174: 7766+10 0E50 C2890E JP NZ, ide_printerror 175: 7776+8 0E53 CB5F BIT 3,a ;DRQ Bit set. If set, disk has data 176: 7784+7+5 0E55 28EC JR Z, ide_readsector_512_inv_waitloop ;If not set, wait 177: 7791+10 0E57 110008 LD DE, 2048 ;Timeout counter 178: 179: 7801+7 0E5A 3E92 LD A, 10010010b ;CommandByte-A, Mode 0, PA IN, PC Out, PB IN 180: 7808+11 0E5C D333 OUT (CS_PIA_CR), A ;Set Data direction to IN 181: 7819+7 0E5E 3E08 LD A, IDE_REG_DATA ;CS0 and A=0 -> I/O register 182: 7826+11 0E60 D332 OUT (CS_PIA_PC), A ;set register 183: 7837+7 0E62 F640 OR IDE_RD ;Set Read bit 184: 7844+11 0E64 D332 OUT (CS_PIA_PC), A ;Write Read to bit controll lines 185: ;NOP 186: ;NOP 187: 7855+4 0E66 00 NOP 188: 189: 7859+11 0E67 DB30 IN A,(CS_PIA_PA) ;Load 16-Bit data to buffer 190: 7870+7 0E69 77 LD (HL), A 191: 7877+6 0E6A 23 INC HL 192: 7883+11 0E6B DB31 IN A,(CS_PIA_PB) 193: 7894+7 0E6D 77 LD (HL), A 194: 7901+6 0E6E 23 INC HL 195: 196: 7907+4 0E6F 0D DEC C 197: 7911+5+6 0E70 C8 RET Z 198: 7916+12 0E71 18D0 JR ide_readsector_512_inv_waitloop 199: 200: - 0E73 ide_readsector_timeout: 201: 7928+10 0E73 21EB0E LD HL, [str_error_time] 202: 7938+17 0E76 CDE600 CALL print_str 203: 7955+4 0E79 79 LD A, C 204: 7959+17 0E7A CD0E01 CALL print_a_hex 205: 7976+7 0E7D 3E0A LD A,10 206: 7983+17 0E7F CDDE00 CALL print_char 207: 8000+7 0E82 3E0D LD A,13 208: 8007+17 0E84 CDDE00 CALL print_char 209: 8024+10 0E87 C9 RET 210: 211: 212: 213: 214: ;------------------------------------------------------------------------------ 215: ; ide_writesector_256 216: ; 217: ; Writes 512 bytes (256 words) of IDE Data 218: ; HL contains data start address 219: ;------------------------------------------------------------------------------ 220: - 0E88 ide_writesector_256: 221: 8034+10 0E88 C9 RET ;NOT IMPLEMENTED 222: 223: 224: ;================================================================ 225: ; utility functions 226: ;================================================================ 227: 228: ;------------------------------------------------------------------------------ 229: ; ide_printerror 230: ; 231: ; prints IDE error to console 232: ;------------------------------------------------------------------------------ 233: - 0E89 ide_printerror: 234: 8044+10 0E89 21BC0E LD HL, [str_error_start] 235: 8054+17 0E8C CDE600 CALL print_str 236: 8071+7 0E8F 060F LD B, IDE_REG_CMDSTS 237: 8078+17 0E91 CDF70D CALL ide_regread_8 238: 8095+17 0E94 CD0E01 CALL print_a_hex 239: 8112+10 0E97 21D90E LD HL, [str_error_start1] 240: 8122+17 0E9A CDE600 CALL print_str 241: 8139+13 0E9D 3ACB40 LD A,(MEM_IDE_DEVICE) 242: 8152+17 0EA0 CD0E01 CALL print_a_hex 243: 8169+10 0EA3 21E20E LD HL, [str_error_start2] 244: 8179+17 0EA6 CDE600 CALL print_str 245: 8196+7 0EA9 0609 LD B, IDE_REG_ERROR 246: 8203+17 0EAB CDF70D CALL ide_regread_8 247: 8220+17 0EAE CD0E01 CALL print_a_hex 248: 8237+7 0EB1 3E0A LD A,10 249: 8244+17 0EB3 CDDE00 CALL print_char 250: 8261+7 0EB6 3E0D LD A,13 251: 8268+17 0EB8 CDDE00 CALL print_char 252: 253: 8285+10 0EBB C9 RET 254: 255: - 0EBC str_error_start: 256: - 0EBC 0D0A4469 db 13,10,"Disk I/O error. Status: 0x",0 736B2049 2F4F2065 72726F72 2E205374 61747573 3A203078 00 257: - 0ED9 str_error_start1: 258: - 0ED9 20446576 db " Dev: 0x",0 3A203078 00 259: - 0EE2 str_error_start2: 260: - 0EE2 20457272 db " Err: 0x",0 3A203078 00 261: 262: - 0EEB str_error_time: 263: - 0EEB 0D0A4469 db 13,10,"Disk I/O error. Data timeout @ 0x",0 736B2049 2F4F2065 72726F72 2E204461 74612074 696D656F 75742040 20307800 **** main.asm **** 180: .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: - 40CB phase var_idebuffer 16: - 40CB MEM_IDE_DEVICE: 17: - 40CB ..40CB 00 defs 1 18: - 40CC MEM_IDE_STATUS: 19: - 40CC ..40CC 00 defs 1 ;1Byte: 0x00 if status is okay 20: - 40CD MEM_IDE_PARTITION: 21: - 40CD ..40D0 00 defs 4 ;4*16Bytes: LBA first sector 22: - 40D1 MEM_IDE_POINTER: 23: - 40D1 ..40D4 00 defs 4 ;4*16Bytes: LBA first sector 24: - 40D5 MEM_IDE_DEV_TABLE: 25: - 40D5 ..4114 00 defs 16*4 26: - 4115 MEM_IDE_SELECTED: 27: - 4115 ..4115 00 defs 1 28: - 4116 MEM_IDE_STRING_0: 29: - 4116 ..413D 00 defs 40 30: - 413E MEM_IDE_STRING_1: 31: - 413E ..4165 00 defs 40 32: - 4166 MEM_IDE_STRING_2: 33: - 4166 ..418D 00 defs 40 34: - 418E MEM_IDE_STRING_3: 35: - 418E ..41B5 00 defs 40 36: - 41B6 MEM_IDE_BUFFER: 37: - 41B6 ..43B5 00 defs 512 38: - 43B6 MEM_IDE_FSBUFFER: 39: - 43B6 ..44B5 00 defs 256 40: - 12FA dephase 41: ;DEV-Table layout 42: ; 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: - 12FA IDE_DEV_TABLE: 51: - 12FA 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 16410000 52: - 130A 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 3E410000 53: - 131A 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 66410000 54: - 132A 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 8E410000 55: 56: ;================================================================ 57: ; IDE funtions 58: ;================================================================ 59: 60: ;------------------------------------------------------------------------------ 61: ; ideif_init_table 62: ; 63: ; initializes drive table 64: ;------------------------------------------------------------------------------ 65: - 133A ideif_init_devtable: 66: ;copy default values to ram 67: 8295+10 133A 21FA12 ld hl,[IDE_DEV_TABLE] 68: 8305+10 133D 11D540 ld de,[MEM_IDE_DEV_TABLE] 69: 8315+10 1340 014000 ld bc,16*4 70: 8325+16+5 1343 EDB0 ldir 71: ;set selected device 72: 8341+7 1345 3E00 ld a,0 73: 8348+13 1347 321541 ld (MEM_IDE_SELECTED),a 74: ;set empty names 75: 8361+4 134A AF xor a 76: 8365+13 134B 321641 ld (MEM_IDE_STRING_0),a 77: 8378+13 134E 323E41 ld (MEM_IDE_STRING_1),a 78: 8391+13 1351 326641 ld (MEM_IDE_STRING_2),a 79: 8404+13 1354 328E41 ld (MEM_IDE_STRING_3),a 80: 8417+10 1357 C9 ret 81: 82: ;------------------------------------------------------------------------------ 83: ; ideif_prnt_devtable 84: ; 85: ; prints drive table 86: ;------------------------------------------------------------------------------ 87: - 1358 ideif_prnt_devtable: 88: 8427+17 1358 CDF800 call print_newLine 89: 8444+10 135B 21EB15 ld hl,[_ideif_prnt_devtable_hdr] 90: 8454+17 135E CDE600 call print_str 91: 8471+10 1361 21D540 ld hl,[MEM_IDE_DEV_TABLE] 92: 8481+7 1364 0600 ld b,0 ;device number 93: - 1366 _ideif_prnt_devtable_l1: ;loop 1 -> for each device 94: ;print if selected 95: 8488+13 1366 3A1541 ld a,(MEM_IDE_SELECTED) 96: 8501+4 1369 B8 cp b 97: 8505+10 136A CA7113 jp z,_ideif_prnt_devtable_l1_sel 98: 8515+7 136D 3E20 ld a, ' ' 99: 8522+12 136F 1802 jr _ideif_prnt_devtable_l1_nxt 100: - 1371 _ideif_prnt_devtable_l1_sel: 101: 8534+7 1371 3E2A ld a, '*' 102: - 1373 _ideif_prnt_devtable_l1_nxt: 103: 8541+17 1373 CDDE00 call print_char 104: ;print drive letter 105: 8558+4 1376 78 ld a,b 106: 8562+7 1377 C645 add 69 ;offset letter to D 107: 8569+17 1379 CDDE00 call print_char 108: 8586+7 137C 3E3A ld a, ':' 109: 8593+17 137E CDDE00 call print_char 110: 8610+7 1381 3E20 ld a, ' ' 111: 8617+17 1383 CDDE00 call print_char 112: ;print status 113: 8634+11 1386 E5 push hl 114: 8645+7 1387 7E ld a,(HL) 115: 8652+4 1388 B7 or a 116: 8656+7+5 1389 280E jr z, _ideif_prnt_devtable_l1_s00 117: 8663+7 138B FE01 cp 0x01 118: 8670+7+5 138D 280F jr z, _ideif_prnt_devtable_l1_s01 119: 8677+7 138F FE02 cp 0x02 120: 8684+7+5 1391 2810 jr z, _ideif_prnt_devtable_l1_s02 121: 8691+7 1393 FEFF cp 0xFF 122: 8698+7+5 1395 2811 jr z, _ideif_prnt_devtable_l1_sFF 123: 8705+12 1397 180F jr _ideif_prnt_devtable_l1_sFF 124: - 1399 _ideif_prnt_devtable_l1_s00 125: 8717+10 1399 212316 ld hl,[_ideif_prnt_devtable_s00] 126: 8727+12 139C 180D jr _ideif_prnt_devtable_l1_es 127: - 139E _ideif_prnt_devtable_l1_s01 128: 8739+10 139E 212E16 ld hl,[_ideif_prnt_devtable_s01] 129: 8749+12 13A1 1808 jr _ideif_prnt_devtable_l1_es 130: - 13A3 _ideif_prnt_devtable_l1_s02 131: 8761+10 13A3 213916 ld hl,[_ideif_prnt_devtable_s02] 132: 8771+12 13A6 1803 jr _ideif_prnt_devtable_l1_es 133: - 13A8 _ideif_prnt_devtable_l1_sFF 134: 8783+10 13A8 214416 ld hl,[_ideif_prnt_devtable_sFF] 135: - 13AB _ideif_prnt_devtable_l1_es 136: 8793+17 13AB CDE600 call print_str 137: 8810+10 13AE E1 pop hl 138: 8820+6 13AF 23 inc hl 139: ;print FS-Type 140: 8826+7 13B0 3E30 ld a,'0' 141: 8833+17 13B2 CDDE00 call print_char 142: 8850+7 13B5 3E78 ld a,'x' 143: 8857+17 13B7 CDDE00 call print_char 144: 8874+7 13BA 7E ld a,(HL) 145: 8881+17 13BB CD0E01 call print_a_hex 146: 8898+7 13BE 3E20 ld a,' ' 147: 8905+17 13C0 CDDE00 call print_char 148: 8922+6 13C3 23 inc hl 149: ;print first sector 150: 8928+11 13C4 E5 push hl 151: 8939+14 13C5 DDE1 pop ix 152: 153: 8953+6 13C7 23 inc hl 154: 8959+6 13C8 23 inc hl 155: 8965+6 13C9 23 inc hl 156: 8971+6 13CA 23 inc hl 157: 8977+6 13CB 23 inc hl 158: 8983+6 13CC 23 inc hl 159: 8989+6 13CD 23 inc hl 160: 8995+6 13CE 23 inc hl 161: 162: 9001+19 13CF DD7E03 ld a,(ix+3) 163: 9020+17 13D2 CD0E01 call print_a_hex 164: 9037+19 13D5 DD7E02 ld a,(ix+2) 165: 9056+17 13D8 CD0E01 call print_a_hex 166: 9073+19 13DB DD7E01 ld a,(ix+1) 167: 9092+17 13DE CD0E01 call print_a_hex 168: 9109+19 13E1 DD7E00 ld a,(ix+0) 169: 9128+17 13E4 CD0E01 call print_a_hex 170: 9145+7 13E7 3E20 ld a,' ' 171: 9152+17 13E9 CDDE00 call print_char 172: ;print length 173: 9169+19 13EC DD7E07 ld a,(ix+7) 174: 9188+17 13EF CD0E01 call print_a_hex 175: 9205+19 13F2 DD7E06 ld a,(ix+6) 176: 9224+17 13F5 CD0E01 call print_a_hex 177: 9241+19 13F8 DD7E05 ld a,(ix+5) 178: 9260+17 13FB CD0E01 call print_a_hex 179: 9277+19 13FE DD7E04 ld a,(ix+4) 180: 9296+17 1401 CD0E01 call print_a_hex 181: 9313+7 1404 3E20 ld a,' ' 182: 9320+17 1406 CDDE00 call print_char 183: ;print Port 184: 9337+7 1409 3E30 ld a,'0' 185: 9344+17 140B CDDE00 call print_char 186: 9361+7 140E 3E78 ld a,'x' 187: 9368+17 1410 CDDE00 call print_char 188: 9385+7 1413 7E ld a,(HL) 189: 9392+17 1414 CD0E01 call print_a_hex 190: 9409+7 1417 3E20 ld a,' ' 191: 9416+17 1419 CDDE00 call print_char 192: 9433+6 141C 23 inc hl 193: ;print M/S 194: 9439+7 141D 7E ld a,(HL) 195: 9446+11 141E E5 push hl 196: 9457+4 141F B7 or a 197: 9461+10 1420 CA2914 jp z,_ideif_prnt_devtable_l1_ms 198: 9471+10 1423 215716 ld hl,[_ideif_prnt_devtable_slave] 199: 9481+10 1426 C32C14 jp _ideif_prnt_devtable_l1_e2 200: - 1429 _ideif_prnt_devtable_l1_ms 201: 9491+10 1429 214F16 ld hl,[_ideif_prnt_devtable_master] 202: - 142C _ideif_prnt_devtable_l1_e2 203: 9501+17 142C CDE600 call print_str 204: 9518+10 142F E1 pop hl 205: 9528+6 1430 23 inc hl 206: ;print str 207: 9534+11 1431 C5 push bc 208: 9545+7 1432 7E ld a,(hl) 209: 9552+4 1433 4F ld c,a 210: 9556+6 1434 23 inc hl 211: 9562+7 1435 7E ld a,(hl) 212: 9569+4 1436 47 ld b,a 213: 9573+6 1437 23 inc hl 214: 9579+11 1438 E5 push hl 215: 9590+4 1439 60 ld h,b 216: 9594+4 143A 69 ld l,c 217: 9598+17 143B CDE600 call print_str 218: 9615+17 143E CDF800 call print_newLine 219: 9632+10 1441 E1 pop hl 220: 9642+10 1442 C1 pop bc 221: ;next 222: 9652+6 1443 23 inc hl 223: 9658+6 1444 23 inc hl 224: 9664+4 1445 04 inc b 225: 9668+4 1446 78 ld a,b 226: 9672+7 1447 FE04 cp 4 227: 9679+5+6 1449 C8 ret z 228: 9684+10 144A C36613 jp _ideif_prnt_devtable_l1 229: ;------------------------------------------------------------------------------ 230: ; ideif_init_drive 231: ; 232: ; initializes selected drive in table 233: ;------------------------------------------------------------------------------ 234: - 144D ideif_init_drive: 235: 9694+17 144D CD1C15 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: 9711+17 1450 CDCE0D call ide_reset 242: 243: 9728+10 1453 01FF5F ld bc, 0x5FFF ;preload timeout counter 244: - 1456 _ideif_init_drive_loop: 245: 9738+7 1456 060F ld b, IDE_REG_CMDSTS 246: 9745+17 1458 CDF70D call ide_regread_8 ;read drive status register 247: 9762+4 145B B7 or a 248: 9766+7+5 145C 280B jr z,_ideif_init_drive_nodrv ;no drive found 249: 9773+8 145E CB77 bit 6,a 250: 9781+7+5 1460 200C jr nz, _ideif_init_drive_found 251: 9788+6 1462 1B dec de 252: 9794+4 1463 7A ld a,d 253: 9798+4 1464 B3 or e 254: 9802+7+5 1465 2802 jr z, _ideif_init_drive_nodrv 255: 9809+12 1467 18ED jr _ideif_init_drive_loop 256: 257: - 1469 _ideif_init_drive_nodrv: 258: 9821+19 1469 DD360001 ld(ix+0),0x01 259: 9840+10 146D C9 ret 260: 261: - 146E _ideif_init_drive_found: 262: 9850+19 146E DD360002 ld (ix+0),0x02 263: ;get drive name 264: 9869+7 1472 060F ld b, IDE_REG_CMDSTS ;Get drive identification 265: 9876+7 1474 3EEC ld a, IDE_CMD_IDENT 266: 9883+17 1476 CDDB0D call ide_regwrite_8 ;Write command to drive 267: 9900+10 1479 21B641 ld hl, MEM_IDE_BUFFER ;set read/write buffer start address 268: 9910+17 147C CD150E call ide_readsector_256 ;read 256 words from device 269: 9927+10 147F 21EC41 ld hl,MEM_IDE_BUFFER + 54 ;print device serial 270: 9937+19 1482 DD7E0C ld a,(ix+12) ;load str pointer into de 271: 9956+4 1485 5F ld e,a 272: 9960+19 1486 DD7E0D ld a,(ix+13) 273: 9979+4 1489 57 ld d,a 274: 9983+10 148A 012800 ld bc,40 ;copy 40 char 275: 9993+16+5 148D EDB0 ldir 276: ;get partition table 277: ;read bootsector 278:10009+7 148F 3E01 ld a,1 ;read 1 sector 279:10016+7 1491 060A ld B,IDE_REG_SECTOR 280:10023+17 1493 CDDB0D call ide_regwrite_8 281:10040+7 1496 3E01 ld a,1 ;read sector 0 282:10047+7 1498 060B ld b,IDE_REG_SSECTOR 283:10054+17 149A CDDB0D call ide_regwrite_8 284:10071+7 149D 3E00 ld a,0 ;read cylinder 0 285:10078+7 149F 060C ld b,IDE_REG_LCYL 286:10085+17 14A1 CDDB0D call ide_regwrite_8 287:10102+7 14A4 3E00 ld a,0 288:10109+7 14A6 060D ld b,IDE_REG_HCYL 289:10116+17 14A8 CDDB0D call ide_regwrite_8 290:10133+7 14AB 3EA0 ld a,10100000b ;read head 0 291:10140+7 14AD 060E ld b,IDE_REG_HEAD 292:10147+17 14AF CDDB0D call ide_regwrite_8 293:10164+7 14B2 3E20 ld a,IDE_CMD_READSEC ;send read command 294:10171+7 14B4 060F ld b,IDE_REG_CMDSTS 295:10178+17 14B6 CDDB0D call ide_regwrite_8 296:10195+10 14B9 21B641 ld hl, MEM_IDE_BUFFER ;set read/write buffer start address 297:10205+17 14BC CD3E0E call ide_readsector_512_inv ;read 256 words from device 298: ;prepare partitions 299:10222+7 14BF 0604 ld b,4 ;Partition table length 300:10229+7 14C1 0E00 ld c,0 ;Partition ID counter 301:10236+14 14C3 FD217443 ld iy,MEM_IDE_BUFFER+446 ;Load offest of first partition table entry 302: - 14C7 _ideif_init_drive_prt_l1: 303:10250+19 14C7 FD7E04 ld a,(iy+4) ;load status byte 304:10269+4 14CA B7 or a 305:10273+10 14CB C2D914 jp NZ, _ideif_init_drive_prt_fnd ;If not zero, jump to print function 306:10283+10 14CE C3D114 jp _ideif_init_drive_prt_ln 307: - 14D1 _ideif_init_drive_prt_ln: 308:10293+10 14D1 111000 ld de,16 309:10303+15 14D4 FD19 add iy,de 310:10318+8+5 14D6 10EF djnz _ideif_init_drive_prt_l1 311:10326+10 14D8 C9 ret 312: - 14D9 _ideif_init_drive_prt_fnd; 313:10336+19 14D9 FD7E04 ld a,(iy+4) 314:10355+19 14DC DD7701 ld (ix+1),a ;store partition type 315:10374+7 14DF FE0E cp 0x0E ;if not 0xE0, continue with next entry 316:10381+7+5 14E1 20EE jr nz, _ideif_init_drive_prt_ln 317: ;get start LBA 318:10388+19 14E3 FD7E08 ld a,(iy+0x08) 319:10407+19 14E6 DD7702 ld (ix+0x02),a 320:10426+19 14E9 FD7E09 ld a,(iy+0x09) 321:10445+19 14EC DD7703 ld (ix+0x03),a 322:10464+19 14EF FD7E0A ld a,(iy+0x0A) 323:10483+19 14F2 DD7704 ld (ix+0x04),a 324:10502+19 14F5 FD7E0B ld a,(iy+0x0B) 325:10521+19 14F8 DD7705 ld (ix+0x05),a 326:10540+19 14FB DD360000 ld (ix+0),0x00 327: ;get count LBA 328:10559+19 14FF FD7E0C ld a,(iy+0x0C) 329:10578+19 1502 DD7706 ld (ix+0x06),a 330:10597+19 1505 FD7E0D ld a,(iy+0x0D) 331:10616+19 1508 DD7707 ld (ix+0x07),a 332:10635+19 150B FD7E0E ld a,(iy+0x0E) 333:10654+19 150E DD7708 ld (ix+0x08),a 334:10673+19 1511 FD7E0F ld a,(iy+0x0F) 335:10692+19 1514 DD7709 ld (ix+0x09),a 336:10711+19 1517 DD360000 ld (ix+0),0x00 337:10730+10 151B C9 ret 338: 339: ;------------------------------------------------------------------------------ 340: ; ideif_get_drv_pointer 341: ; 342: ; gets pointer to selected drive in table in IX 343: ;------------------------------------------------------------------------------ 344: - 151C ideif_get_drv_pointer: 345:10740+11 151C F5 push af 346:10751+11 151D C5 push bc 347: ;get selected drive 348:10762+13 151E 3A1541 ld a,(MEM_IDE_SELECTED) 349: ;multiply a *8 350:10775+4 1521 07 rlca ;*2 351:10779+4 1522 07 rlca ;*4 352:10783+4 1523 07 rlca ;*8 353:10787+7 1524 0600 ld b,0 354:10794+4 1526 4F ld c,a 355:10798+14 1527 DD21D540 ld ix,[MEM_IDE_DEV_TABLE] 356:10812+15 152B DD09 add ix,bc 357:10827+10 152D C1 pop bc 358:10837+10 152E F1 pop af 359:10847+10 152F C9 ret 360: 361: ;------------------------------------------------------------------------------ 362: ; ideif_init_all 363: ; 364: ; initializes interface 365: ;------------------------------------------------------------------------------ 366: - 1530 ideif_init_all: 367:10857+10 1530 21CB15 ld hl, [str_dev_waitready] 368:10867+17 1533 CDE600 call print_str ;print waiting message 369: 370:10884+17 1536 CD3A13 call ideif_init_devtable 371:10901+17 1539 CD4D14 call ideif_init_drive 372: 373:10918+10 153C 21E315 ld hl, [str_dev_done] 374:10928+17 153F CDE600 call print_str 375:10945+10 1542 C9 RET 376: 377: 378: ;------------------------------------------------------------------------------ 379: ; ideif_drv_sel 380: ; 381: ; Selects drive from table and initializes the fat16 file system 382: ; A contains drive id 383: ;------------------------------------------------------------------------------ 384: 385: 386: 387: ;------------------------------------------------------------------------------ 388: ; read_lba_sector 389: ; 390: ; Reads A*512 byte sector into memory 391: ; HL contains pointer to LBA address 392: ; DE contains destination location 393: ; A contains sector count 394: ;------------------------------------------------------------------------------ 395: - 1543 read_lba_sector: 396:10955+7 1543 060A LD B,IDE_REG_SECTOR ;amount of sectores 397:10962+17 1545 CDDB0D CALL ide_regwrite_8 398: 399:10979+7 1548 7E LD A,(HL) 400:10986+7 1549 060B LD B,IDE_REG_LBA0 401:10993+17 154B CDDB0D CALL ide_regwrite_8 402:11010+6 154E 23 INC HL 403:11016+7 154F 7E LD A,(HL) 404:11023+7 1550 060C LD B,IDE_REG_LBA1 405:11030+17 1552 CDDB0D CALL ide_regwrite_8 406:11047+6 1555 23 INC HL 407:11053+7 1556 7E LD A,(HL) 408:11060+7 1557 060D LD B,IDE_REG_LBA2 409:11067+17 1559 CDDB0D CALL ide_regwrite_8 410:11084+6 155C 23 INC HL 411:11090+7 155D 7E LD A,(HL) 412:11097+7 155E E60F AND 00001111b 413:11104+7 1560 F6E0 OR 11100000b 414:11111+7 1562 060E LD B,IDE_REG_LBA3 415:11118+17 1564 CDDB0D CALL ide_regwrite_8 416: 417:11135+7 1567 3E20 LD A,IDE_CMD_READSEC ;send read command 418:11142+7 1569 060F LD B,IDE_REG_CMDSTS 419:11149+17 156B CDDB0D CALL ide_regwrite_8 420: ;LD HL,MEM_IDE_BUFFER ;set read/write buffer start address 421:11166+4 156E EB EX DE,HL ;transfer destination in DE to HL 422:11170+17 156F CD3E0E call ide_readsector_512_inv ;read 256 words from device 423:11187+10 1572 C9 ret 424: 425: ;------------------------------------------------------------------------------ 426: ; ideif_drv_sel 427: ; 428: ; Select drive from table 429: ; Prepare variables 430: ; 431: ; A contains drive number 432: ;------------------------------------------------------------------------------ 433: - 1573 ideif_drv_sel: 434:11197+13 1573 321541 ld (MEM_IDE_SELECTED),a 435:11210+11 1576 F5 push af 436:11221+17 1577 CD1C15 call ideif_get_drv_pointer ;test if drive is marked as available 437:11238+19 157A DD7E00 ld a,(ix+0) 438:11257+4 157D B7 or a 439:11261+10 157E C2AB15 jp nz, _ideif_drv_sel_fail ;if not-> fail 440: 441:11271+17 1581 CD3E20 call fat_get_root_table ;else get root table 442: 443:11288+10 1584 215F16 ld hl,[_ideif_drv_sel_pstr] ;print success message 444:11298+17 1587 CDE600 call print_str 445:11315+10 158A F1 pop af 446:11325+7 158B C645 add 69 447:11332+13 158D 322B40 ld (var_dir),a ;store drive letter 448:11345+17 1590 CDDE00 call print_char 449:11362+7 1593 3E3A ld a, ':' 450:11369+13 1595 322C40 ld (var_dir+1),a 451:11382+7 1598 3E5C ld a, '\' 452:11389+13 159A 322D40 ld (var_dir+2),a 453:11402+4 159D AF xor a ;set dir to empty 454:11406+13 159E 322E40 ld (var_dir+3),a 455:11419+13 15A1 327A40 ld (var_dir+79),a ;set depth counter 456:11432+10 15A4 217616 ld hl,[_ideif_drv_sel_sstr0] 457:11442+17 15A7 CDE600 call print_str 458:11459+10 15AA C9 ret 459: - 15AB _ideif_drv_sel_fail: 460:11469+10 15AB 215F16 ld hl,[_ideif_drv_sel_pstr] 461:11479+17 15AE CDE600 call print_str 462:11496+10 15B1 F1 pop af 463:11506+7 15B2 C645 add 69 464:11513+17 15B4 CDDE00 call print_char 465:11530+10 15B7 216816 ld hl,[_ideif_drv_sel_fstr0] 466:11540+17 15BA CDE600 call print_str 467:11557+4 15BD AF xor a ;set dir to empty 468:11561+13 15BE 322B40 ld (var_dir),a 469:11574+10 15C1 112000 LD DE,0x20 470:11584+10 15C4 017000 LD BC,0x70 471:11594+17 15C7 CDA90D CALL beep 472:11611+10 15CA C9 ret 473: 474: 475: 476: 477: ;================================================================ 478: ; IDE strings 479: ;=============================================================== 480: 481: - 15CB str_dev_waitready: 482: - 15CB 0D0A4465 db 13,10,"Detecting drives ... ",0 74656374 696E6720 64726976 6573202E 2E2E2000 483: - 15E3 str_dev_done: 484: - 15E3 646F6E65 db "done!",13,10,0 210D0A00 485: 486: - 15EB _ideif_prnt_devtable_hdr: 487: - 15EB 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 488: - 1623 _ideif_prnt_devtable_s00: 489: - 1623 41766169 db "Avail ",0 6C202020 202000 490: - 162E _ideif_prnt_devtable_s01: 491: - 162E 4E6F7420 db "Not Found ",0 466F756E 642000 492: - 1639 _ideif_prnt_devtable_s02: 493: - 1639 556E6B6F db "Unkown FS ",0 776E2046 532000 494: - 1644 _ideif_prnt_devtable_sFF: 495: - 1644 4374726C db "Ctrl. Err ",0 2E204572 722000 496: - 164F _ideif_prnt_devtable_master: 497: - 164F 4D617374 db "Master ",0 65722000 498: - 1657 _ideif_prnt_devtable_slave: 499: - 1657 536C6176 db "Slave ",0 65202000 500: - 165F _ideif_drv_sel_pstr: 501: - 165F 0A0D4472 db 10,13,"Drive ",0 69766520 00 502: - 1668 _ideif_drv_sel_fstr0: 503: - 1668 3A206E6F db ": not ready",10,13,0 74207265 6164790A 0D00 504: - 1676 _ideif_drv_sel_sstr0: 505: - 1676 3A207365 db ": selected",10,13,0 6C656374 65640A0D 00 506: - 1683 _ideif_drv_sel_syn: 507: - 1683 0A0D496E db 10,13,"Invalid drive letter",10,13,0 76616C69 64206472 69766520 6C657474 65720A0D 00 **** main.asm **** 181: .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: - 169C iic_send_buffer: 28:11621+17 169C CDFE16 CALL iic_send_sbit ;Send startbit 29:11638+4 169F 79 LD A,C 30:11642+7 16A0 E6FE AND 0xFE ;Mask R/W bit (must be 0 for write) 31:11649+17 16A2 CD9417 CALL iic_send_byte ;Send Address 32:11666+17 16A5 CD3417 CALL iic_read_ack 33:11683+4 16A8 B7 OR A ; if no ack, error 34:11687+10 16A9 C2C016 JP NZ, iic_send_buffer_err 35: - 16AC iic_send_buffer_loop; 36:11697+7 16AC 7E LD A,(HL) 37:11704+6 16AD 23 INC HL 38:11710+17 16AE CD9417 CALL iic_send_byte 39:11727+17 16B1 CD3417 CALL iic_read_ack 40:11744+4 16B4 B7 OR A ; if no ack, error 41:11748+10 16B5 C2C016 JP NZ, iic_send_buffer_err 42:11758+8+5 16B8 10F2 DJNZ iic_send_buffer_loop ;loop for remaining bytes 43: - 16BA iic_send_buffer_done: 44:11766+17 16BA CD1317 CALL iic_send_ebit 45:11783+7 16BD 3E00 LD A,0 46:11790+10 16BF C9 RET 47: - 16C0 iic_send_buffer_err: 48:11800+17 16C0 CD1317 CALL iic_send_ebit 49:11817+7 16C3 3E01 LD A,1 50:11824+10 16C5 C9 RET 51: 52: ;HL contains buffer location 53: ;B defines amount of bytes to send 54: ;C contains device address 55: - 16C6 iic_receive_buffer: 56:11834+4 16C6 05 DEC B 57:11838+17 16C7 CDFE16 CALL iic_send_sbit ;Send startbit 58:11855+4 16CA 79 LD A,C 59:11859+7 16CB F601 OR 0x01 ;set R/W bit (must be 1 for read) 60:11866+17 16CD CD9417 CALL iic_send_byte ;Send Address 61:11883+17 16D0 CD3417 CALL iic_read_ack 62:11900+4 16D3 B7 OR A ; if no ack, error 63:11904+10 16D4 C2EF16 JP NZ, iic_receive_buffer_err 64: - 16D7 iic_receive_buffer_loop: 65:11914+17 16D7 CDBA17 CALL iic_receive_byte 66:11931+7 16DA 77 LD (HL),A 67:11938+6 16DB 23 INC HL 68:11944+17 16DC CD5A17 CALL iic_send_ack 69:11961+8+5 16DF 10F6 DJNZ iic_receive_buffer_loop 70: ; last time: 71:11969+17 16E1 CDBA17 CALL iic_receive_byte 72:11986+7 16E4 77 LD (HL),A 73:11993+6 16E5 23 INC HL 74:11999+17 16E6 CD7717 CALL iic_send_nack 75: 76: - 16E9 iic_receive_buffer_done: 77:12016+17 16E9 CD1317 CALL iic_send_ebit 78:12033+7 16EC 3E00 LD A,0 79:12040+10 16EE C9 RET 80: - 16EF iic_receive_buffer_err: 81:12050+17 16EF CD1317 CALL iic_send_ebit 82:12067+7 16F2 3E01 LD A,1 83:12074+10 16F4 C9 RET 84: 85: 86: 87: ;================================================================ 88: ; I/O access functions 89: ;================================================================ 90: 91: ;Reset PIO configuration 92: - 16F5 iic_init: 93: ;Set port to controll mode (MODE3) 94:12084+7 16F5 3ECF LD A,0xCF 95:12091+11 16F7 D3F6 OUT (CS_PIO_AC), A 96: ;Set inputs/outputs 97:12102+7 16F9 3EF0 LD A,0xF0 98:12109+11 16FB D3F6 OUT (CS_PIO_AC), A 99:12120+10 16FD C9 RET 100: 101: ; send start bit 102: - 16FE iic_send_sbit: 103: ;Set port to controll mode (MODE3) 104:12130+7 16FE 3ECF LD A,0xCF 105:12137+11 1700 D3F6 OUT (CS_PIO_AC), A 106: ;Set inputs/outputs (SDA and SCL is now output) 107:12148+7 1702 3EFC LD A,0xFC 108:12155+11 1704 D3F6 OUT (CS_PIO_AC), A 109: ;SCL HIGH, SDA LOW 110:12166+7 1706 3E02 LD A,0x02 111:12173+11 1708 D3F4 OUT (CS_PIO_AD), A 112:12184+4 170A 00 NOP 113:12188+4 170B 00 NOP 114:12192+7 170C 3E00 LD A,0x00 115:12199+11 170E D3F4 OUT (CS_PIO_AD), A 116:12210+4 1710 00 NOP 117:12214+4 1711 00 NOP 118:12218+10 1712 C9 RET 119: 120: ; send end/stop bit 121: - 1713 iic_send_ebit: 122: ;Set port to controll mode (MODE3) 123:12228+7 1713 3ECF LD A,0xCF 124:12235+11 1715 D3F6 OUT (CS_PIO_AC), A 125: 126: ;Set inputs/outputs (SDA and SCL is now output) 127:12246+7 1717 3EFC LD A,0xFC 128:12253+11 1719 D3F6 OUT (CS_PIO_AC), A 129: ;SCL HIGH, SDA LOW 130:12264+7 171B 3E02 LD A,0x02 131:12271+11 171D D3F4 OUT (CS_PIO_AD), A 132:12282+4 171F 00 NOP 133:12286+4 1720 00 NOP 134:12290+7 1721 3E03 LD A,0x03 ; both high 135:12297+11 1723 D3F4 OUT (CS_PIO_AD), A 136:12308+4 1725 00 NOP 137:12312+4 1726 00 NOP 138: ;release bus 139: ;Set port to controll mode (MODE3) 140:12316+7 1727 3ECF LD A,0xCF 141:12323+11 1729 D3F6 OUT (CS_PIO_AC), A 142:12334+4 172B 00 NOP 143:12338+4 172C 00 NOP 144: ;Set inputs/outputs (SDA and SCL is now input, sound enabled) 145:12342+7 172D 3EF7 LD A,11110111b 146:12349+11 172F D3F6 OUT (CS_PIO_AC), A 147:12360+4 1731 00 NOP 148:12364+4 1732 00 NOP 149:12368+10 1733 C9 RET 150: 151: 152: - 1734 iic_read_ack: 153:12378+7 1734 3ECF LD A,0xCF 154:12385+11 1736 D3F6 OUT (CS_PIO_AC), A 155: ;Set inputs/outputs (SCL is now output, SDA input) 156:12396+7 1738 3EFD LD A,0xFD 157:12403+11 173A D3F6 OUT (CS_PIO_AC), A 158:12414+4 173C 00 NOP 159:12418+4 173D 00 NOP 160:12422+7 173E 3E00 LD A,0x00 ;set SCL LOW 161:12429+11 1740 D3F4 OUT (CS_PIO_AD), A 162:12440+4 1742 00 NOP 163:12444+4 1743 00 NOP 164:12448+7 1744 EE02 XOR 0x02 ;set SCL HIGH 165:12455+11 1746 D3F4 OUT (CS_PIO_AD), A 166:12466+4 1748 00 NOP 167:12470+11 1749 DBF4 IN A,(CS_PIO_AD) ; Read SDA 168:12481+4 174B 00 NOP 169:12485+4 174C 00 NOP 170:12489+11 174D F5 PUSH AF 171:12500+7 174E E6FE AND 0xFE ; Filter input 172:12507+7 1750 EE02 XOR 0x02 ;set SCL LOW 173:12514+11 1752 D3F4 OUT (CS_PIO_AD), A 174:12525+4 1754 00 NOP 175:12529+4 1755 00 NOP 176:12533+10 1756 F1 POP AF 177:12543+7 1757 E601 AND 1 178:12550+10 1759 C9 RET 179: 180: - 175A iic_send_ack: 181: ;Set port to controll mode (MODE3) 182:12560+7 175A 3ECF LD A,0xCF 183:12567+11 175C D3F6 OUT (CS_PIO_AC), A 184: ;Set inputs/outputs (SDA and SCL is now output) 185:12578+7 175E 3EFC LD A,0xFC 186:12585+11 1760 D3F6 OUT (CS_PIO_AC), A 187:12596+4 1762 00 NOP 188:12600+4 1763 00 NOP 189:12604+7 1764 3E00 LD A,0x00 ; SCL LOW, SDA LOW 190:12611+11 1766 D3F4 OUT (CS_PIO_AD), A 191:12622+4 1768 00 NOP 192:12626+4 1769 00 NOP 193:12630+7 176A 3E02 LD A,0x02 ; SCL HIGH, SDA LOW 194:12637+11 176C D3F4 OUT (CS_PIO_AD), A 195:12648+4 176E 00 NOP 196:12652+4 176F 00 NOP 197:12656+7 1770 3E00 LD A,0x00 ; SCL LOW, SDA LOW 198:12663+11 1772 D3F4 OUT (CS_PIO_AD), A 199:12674+4 1774 00 NOP 200:12678+4 1775 00 NOP 201:12682+10 1776 C9 RET 202: 203: - 1777 iic_send_nack: 204: ;Set port to controll mode (MODE3) 205:12692+7 1777 3ECF LD A,0xCF 206:12699+11 1779 D3F6 OUT (CS_PIO_AC), A 207: ;Set inputs/outputs (SDA and SCL is now output) 208:12710+7 177B 3EFC LD A,0xFC 209:12717+11 177D D3F6 OUT (CS_PIO_AC), A 210:12728+4 177F 00 NOP 211:12732+4 1780 00 NOP 212:12736+7 1781 3E02 LD A,0x02 ; SCL LOW, SDA HIGH 213:12743+11 1783 D3F4 OUT (CS_PIO_AD), A 214:12754+4 1785 00 NOP 215:12758+4 1786 00 NOP 216:12762+7 1787 3E03 LD A,0x03 ; both high 217:12769+11 1789 D3F4 OUT (CS_PIO_AD), A 218:12780+4 178B 00 NOP 219:12784+4 178C 00 NOP 220:12788+7 178D 3E02 LD A,0x02 ; SCL LOW, SDA HIGH 221:12795+11 178F D3F4 OUT (CS_PIO_AD), A 222:12806+4 1791 00 NOP 223:12810+4 1792 00 NOP 224:12814+10 1793 C9 RET 225: 226: ;A contains byte 227: - 1794 iic_send_byte: 228:12824+11 1794 C5 PUSH BC 229:12835+4 1795 4F LD C,A ;buffer 230: ;Set port to controll mode (MODE3) 231:12839+7 1796 3ECF LD A,0xCF 232:12846+11 1798 D3F6 OUT (CS_PIO_AC), A 233: ;Set inputs/outputs (SDA and SCL is now output) 234:12857+7 179A 3EFC LD A,0xFC 235:12864+11 179C D3F6 OUT (CS_PIO_AC), A 236:12875+7 179E 0608 LD B,8 ;bit counter 237: 238: - 17A0 iic_send_byte_loop: 239: ;prepare data 240:12882+8 17A0 CB11 RL C 241:12890+7 17A2 3E00 LD A,0 242:12897+4 17A4 17 RLA ; set SCA bit from carry, SCL LOW 243:12901+11 17A5 D3F4 OUT (CS_PIO_AD), A 244:12912+4 17A7 00 NOP 245:12916+4 17A8 00 NOP 246:12920+7 17A9 EE02 XOR 0x02 ;set SCL HIGH 247:12927+11 17AB D3F4 OUT (CS_PIO_AD), A 248:12938+4 17AD 00 NOP 249:12942+4 17AE 00 NOP 250:12946+7 17AF EE02 XOR 0x02 ;set SCL LOW 251:12953+11 17B1 D3F4 OUT (CS_PIO_AD), A 252:12964+4 17B3 00 NOP 253:12968+4 17B4 00 NOP 254:12972+8+5 17B5 10E9 DJNZ iic_send_byte_loop ;loop until counter is 0 255: ;transmittion end / end loop 256:12980+4 17B7 79 LD A,C 257:12984+10 17B8 C1 POP BC 258:12994+10 17B9 C9 RET 259: 260: - 17BA iic_receive_byte: 261:13004+11 17BA C5 PUSH BC 262: ;Set port to controll mode (MODE3) 263:13015+7 17BB 3ECF LD A,0xCF 264:13022+11 17BD D3F6 OUT (CS_PIO_AC), A 265: ;Set inputs/outputs (SCL is now output, SDA input) 266:13033+7 17BF 3EFD LD A,0xFD 267:13040+11 17C1 D3F6 OUT (CS_PIO_AC), A 268:13051+7 17C3 0608 LD B,8 ;bit counter 269:13058+7 17C5 0E00 LD C,0 270: - 17C7 iic_receive_byte_loop: 271:13065+4 17C7 AF XOR A ;set SCL LOW 272:13069+11 17C8 D3F4 OUT (CS_PIO_AD), A 273:13080+4 17CA 00 NOP 274:13084+4 17CB 00 NOP 275:13088+7 17CC 3E02 LD A,2 ;set SCL HIGH 276:13095+11 17CE D3F4 OUT (CS_PIO_AD), A 277:13106+4 17D0 00 NOP 278:13110+11 17D1 DBF4 IN A, (CS_PIO_AD) 279:13121+4 17D3 00 NOP 280:13125+4 17D4 1F RRA ;read SDA bit 281:13129+8 17D5 CB11 RL C ;store bit 282:13137+4 17D7 AF XOR A ;set SCL LOW again 283:13141+11 17D8 D3F4 OUT (CS_PIO_AD), A 284:13152+4 17DA 00 NOP 285:13156+4 17DB 00 NOP 286:13160+8+5 17DC 10E9 DJNZ iic_receive_byte_loop 287:13168+4 17DE 79 LD A,C 288:13172+10 17DF C1 POP BC **** main.asm **** 182:13182+10 17E0 C9 RET 183: .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: - 17E1 dump_pretty: 15:13192+11 17E1 E5 PUSH HL 16:13203+10 17E2 213C18 LD HL,[STR_PD_HEADER] ;Print header 17:13213+17 17E5 CDE600 CALL print_str 18:13230+10 17E8 E1 POP HL 19: - 17E9 dump_pretty_row: 20:13240+4 17E9 78 LD A,B ;Check row counter 21:13244+4 17EA B7 OR A 22:13248+10 17EB CA3B18 JP Z, dump_pretty_end ;If counter is 0, exit 23:13258+4 17EE 05 DEC B ;Decrement row counter by 1 24:13262+7 17EF 0E10 LD C, 16 ;Load column counter 25:13269+4 17F1 7C LD A, H ;Print base address 26:13273+17 17F2 CD0E01 CALL print_a_hex 27:13290+4 17F5 7D LD A, L 28:13294+17 17F6 CD0E01 CALL print_a_hex 29:13311+7 17F9 3E20 LD A, ' ' 30:13318+17 17FB CDDE00 CALL print_char 31: - 17FE dump_pretty_col: ;Loop for column 32:13335+7 17FE 7E LD A,(HL) ;Load byte to disply 33:13342+17 17FF CD0E01 CALL print_a_hex 34:13359+7 1802 3E20 LD A, ' ' 35:13366+17 1804 CDDE00 CALL print_char 36:13383+6 1807 23 INC HL 37:13389+4 1808 0D DEC C ;Decrement column counter 38:13393+7+5 1809 20F3 JR NZ, dump_pretty_col ;Loop if not 0 39: - 180B dump_pretty_ascii: 40:13400+11 180B C5 PUSH BC 41:13411+11 180C E5 PUSH HL 42:13422+7 180D 0600 LD B,0 43:13429+7 180F 0E10 LD C,16 44:13436+15 1811 ED42 SBC HL,BC ;Reset HL by column count 45: - 1813 dump_pretty_ascii_loop: 46:13451+7 1813 7E LD A,(HL) 47:13458+6 1814 23 INC HL 48:13464+7 1815 FE20 CP 32 49:13471+10 1817 DA2418 JP C, dump_pretty_ascii_none ;if less than 32, it is not a char 50:13481+7 181A FE7F CP 127 51:13488+10 181C D22418 JP NC, dump_pretty_ascii_none ;if greater or equal than 128, it is not a char 52:13498+17 181F CDDE00 call print_char 53:13515+12 1822 1805 jr dump_pretty_ascii_cont 54: - 1824 dump_pretty_ascii_none: 55:13527+7 1824 3E2E LD A,'.' 56:13534+17 1826 CDDE00 call print_char 57: - 1829 dump_pretty_ascii_cont: 58:13551+4 1829 0D DEC C 59:13555+10 182A C21318 JP NZ, dump_pretty_ascii_loop 60: 61: 62:13565+10 182D E1 POP HL 63:13575+10 182E C1 POP BC 64: - 182F dump_pretty_nextrow: 65:13585+7 182F 3E0A LD A,10 ;New line 66:13592+17 1831 CDDE00 CALL print_char 67:13609+7 1834 3E0D LD A,13 68:13616+17 1836 CDDE00 CALL print_char 69:13633+12 1839 18AE JR dump_pretty_row ;Else next line 70: - 183B dump_pretty_end: 71:13645+10 183B C9 RET 72: 73: - 183C STR_PD_HEADER: 74: - 183C 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: - 187B print_str_fixed: 85:13655+7 187B 7E LD A,(HL) 86:13662+6 187C 23 INC HL 87:13668+17 187D CDDE00 CALL print_char 88:13685+8+5 1880 10F9 DJNZ print_str_fixed 89:13693+10 1882 C9 RET 90: **** main.asm **** 184: .include "command.s" **** include/command.s **** 1: - 1883 COMMAND_LUT: 2: - 1883 64617465 db "date", 0 , [OP_RTIME], [OP_RTIME]>>8 ;Read time 00C01B 3: - 188A 73657464 db "setdate", 0 , [OP_STIME], [OP_STIME]>>8 ;Read time 61746500 581D 4: - 1894 70696E20 db "pin ", 0 , [OP_IO_IN], [OP_IO_IN]>>8 ;Read port 00D91A 5: - 189B 64756D70 db "dump ",0, [OP_DUMP], [OP_DUMP]>>8 ;print pretty hexdump 2000481A 6: - 18A3 706F7574 db "pout ", 0 , [OP_IO_OUT], [OP_IO_OUT]>>8 ;Write port 2000EF1A 7: - 18AB 69696E20 db "iin ", 0, [OP_IIC_IN], [OP_IIC_IN]>>8 ;Read IIC 00701B 8: - 18B2 696F7574 db "iout ", 0, [OP_IIC_OUT], [OP_IIC_OUT]>>8 ;Write IIC 2000101B 9: - 18BA 63616C6C db "call ", 0, [OP_CALL], [OP_CALL]>>8 ;Call to addr 2000281A 10: - 18C2 636C7200 db "clr", 0, [OP_CLR], [OP_CLR]>>8 ;Call to addr BC1B 11: - 18C8 6461736D db "dasm ", 0, [OP_DASM], [OP_DASM]>>8 ;Call to addr 2000A91A 12: - 18D0 6A702000 db "jp ", 0,[OP_EXEC], [OP_EXEC]>>8 ;jump to addr 0F1A 13: - 18D6 72737400 db "rst", 0,0x00,0x00 ;soft reset 0000 14: - 18DC 6C736473 db "lsdsk", 0,[OP_LSDSK], [OP_LSDSK]>>8 ;list disks 6B00D11D 15: - 18E4 73656C64 db "seldsk ", 0,[OP_SELDSK], [OP_SELDSK]>>8 ;select disk 736B2000 D51D 16: - 18EE 63642000 db "cd ", 0 , [OP_CD], [OP_CD]>>8 ;Read time F81D 17: - 18F4 6C7300F4 db "ls", 0 , [OP_DIR], [OP_DIR]>>8 ;Read time 1D 18: - 18F9 72756E20 db "run ", 0 , [OP_FSEXEC], [OP_FSEXEC]>>8 ;Read time 00151E 19: - 1900 24000F1A db "$", 0, [OP_EXEC], [OP_EXEC]>>8 ;jump to addr 20: - 1904 6900D91A db "i", 0, [OP_IO_IN], [OP_IO_IN]>>8 ;Read port 21: - 1908 6F00EF1A db "o", 0, [OP_IO_OUT], [OP_IO_OUT]>>8 ;Write port 22: - 190C 2100781A db "!", 0, [OP_SET], [OP_SET]>>8 ;Write memory 23: - 1910 3F00481A db "?", 0, [OP_DUMP], [OP_DUMP]>>8 ;Print memory 24: - 1914 FF db 0xFF ;End of Table 25: 26: - 1915 COMMAND: 27:13703+17 1915 CDF800 call print_newLine 28:13720+10 1918 212B40 ld hl,[var_dir] 29:13730+17 191B CDE600 call print_str 30:13747+7 191E 3E3E ld a,'>' 31:13754+17 1920 CDDE00 call print_char 32:13771+4 1923 AF xor a ;reset buffer len 33:13775+13 1924 320040 ld (var_buffer_len),a ;set buffer len to 0 34: - 1927 COMMAND_READ: 35:13788+17 1927 CD2601 call read_char 36:13805+10 192A CA2719 jp z, COMMAND_READ ;wait for input 37:13815+7 192D FE0D cp 13 ; enter 38:13822+10 192F CA7C19 jp z,COMMAND_PROCESS 39:13832+7 1932 FE0A cp 10 40:13839+10 1934 CA2719 jp z, COMMAND_READ; skip LF for file load 41:13849+7 1937 FE08 cp 0x08 ; backspace 0x08 VT102 0x7f Putty 42:13856+10 1939 CA5619 jp z,COMMAND_BACKSPACE 43: 44:13866+11 193C F5 push af 45: ; a contains latest char 46:13877+10 193D 217B40 ld hl,[var_input] 47:13887+7 1940 1600 ld d,0 48:13894+13 1942 3A0040 ld a,(var_buffer_len) 49:13907+4 1945 5F ld e,a 50:13911+11 1946 19 add hl,de ;hl now contains pointer to last position in buffer 51:13922+4 1947 3C inc a 52:13926+13 1948 320040 ld (var_buffer_len),a ;store incremented buffer length 53: 54:13939+10 194B F1 pop af 55:13949+7 194C 77 ld (hl),a 56:13956+17 194D CDDE00 call print_char 57:13973+6 1950 23 inc hl 58:13979+4 1951 AF xor a ;a = 0 59:13983+7 1952 77 ld (hl),a ;always add null termination after last char 60:13990+10 1953 C32719 jp COMMAND_READ 61: 62: 63: - 1956 COMMAND_BACKSPACE: 64:14000+13 1956 3A0040 ld a,(var_buffer_len) 65:14013+4 1959 A7 and a 66:14017+10 195A CA2719 jp z, COMMAND_READ ; do not continue if already at char 0 67:14027+4 195D 3D dec a ;decrement length 68:14031+13 195E 320040 ld (var_buffer_len),a ;and store it 69:14044+4 1961 5F ld e,a ;load de with decremented value 70:14048+7 1962 1600 ld d,0 71:14055+10 1964 217B40 ld hl,[var_input] 72:14065+11 1967 19 add hl,de ;hl now contains pointer to last position in buffer 73:14076+4 1968 AF xor a ; store null byte to current location 74:14080+7 1969 77 ld (hl),a 75: ;call print_delete 76:14087+7 196A 3E08 ld a, 0x08 77:14094+17 196C CDDE00 call print_char 78:14111+7 196F 3E20 ld a, 0x20 79:14118+17 1971 CDDE00 call print_char 80:14135+7 1974 3E08 ld a, 0x08 81:14142+17 1976 CDDE00 call print_char 82:14159+10 1979 C32719 jp COMMAND_READ 83: - 197C COMMAND_PROCESS: 84: ;compare 85:14169+10 197C 218318 LD HL,[COMMAND_LUT] ;Lookup table 86: - 197F COMMAND_PROCESS_LOOP: 87:14179+10 197F 117B40 LD DE,[var_input] ;Buffer 88:14189+7 1982 7E LD A,(HL) ;Load first byte of entry 89:14196+7 1983 FEFF CP 0xFF 90:14203+10 1985 CAAE19 JP Z,COMMAND_PROCESS_NOT_FOUND ;if first byte is 0xFF, End is reached 91: ; compare string loop 92: - 1988 COMMAND_PROCESS_LOOP_STR1: 93:14213+7 1988 1A LD A,(DE) 94:14220+4 1989 47 LD B,A 95:14224+7 198A 7E LD A,(HL) 96:14231+4 198B B0 OR B ;not 0 -> match 97:14235+10 198C CAB719 JP Z, COMMAND_PROCESS_FOUND ;match 98: 99:14245+7 198F 1A LD A,(DE) 100:14252+4 1990 47 LD B,A 101: ;LD A,(HL) ;Load first byte of entry 102: ;call print_a_hex 103:14256+7 1991 7E LD A,(HL) 104: ;compare byte 105:14263+4 1992 A8 XOR B 106:14267+4 1993 B7 OR A ;if identical = resoult shopuld be zero 107:14271+10 1994 CA9E19 JP Z, COMMAND_PROCESS_LOOP_STR2 ;then continue 108: ; if not identical 109:14281+7 1997 7E LD A,(HL) 110:14288+4 1998 B7 OR A ;if reached end of compare string 111:14292+10 1999 CAB719 JP Z, COMMAND_PROCESS_FOUND ;match 112:14302+12 199C 1805 JR COMMAND_PROCESS_NEXT_ENTRY ;next entry on no match 113: 114: - 199E COMMAND_PROCESS_LOOP_STR2: ;continue with next char 115:14314+6 199E 23 INC HL 116:14320+6 199F 13 INC DE 117:14326+12 19A0 18E6 JR COMMAND_PROCESS_LOOP_STR1 118: 119: - 19A2 COMMAND_PROCESS_NEXT_ENTRYI: ;do not jump here 120:14338+6 19A2 23 INC HL 121: - 19A3 COMMAND_PROCESS_NEXT_ENTRY: ;jump here 122:14344+7 19A3 7E LD A,(HL) 123:14351+4 19A4 B7 OR A 124:14355+10 19A5 C2A219 JP NZ,COMMAND_PROCESS_NEXT_ENTRYI ;loop until end of string 125:14365+6 19A8 23 INC HL ;skip pointer 126:14371+6 19A9 23 INC HL 127:14377+6 19AA 23 INC HL 128:14383+10 19AB C37F19 JP COMMAND_PROCESS_LOOP 129: - 19AE COMMAND_PROCESS_NOT_FOUND: 130:14393+10 19AE 21E819 LD HL,[_STR_NOT_FOUND] 131:14403+17 19B1 CDE600 CALL print_str 132:14420+10 19B4 C31519 JP COMMAND 133: 134: - 19B7 COMMAND_PROCESS_FOUND: 135:14430+11 19B7 E5 PUSH HL 136:14441+10 19B8 C1 POP BC 137:14451+6 19B9 03 INC BC 138:14457+7 19BA 0A LD A,(BC) 139:14464+4 19BB 6F LD L,A 140:14468+6 19BC 03 INC BC 141:14474+7 19BD 0A LD A,(BC) 142:14481+4 19BE 67 LD H,A 143: 144: ;HL: pointer to start of routine 145: ;DE: buffer start of arguments 146:14485+17 19BF CDC519 CALL _COMMAND_PROCESS_FOUND 147:14502+10 19C2 C31519 JP COMMAND 148: - 19C5 _COMMAND_PROCESS_FOUND 149:14512+4 19C5 E9 JP (HL) 150: 151: - 19C6 NOT_IMPLEMENTED: 152:14516+10 19C6 21D419 LD HL,[_STR_NOT_IMPLEMENTED] 153:14526+17 19C9 CDE600 CALL print_str 154:14543+10 19CC C9 RET 155: 156: - 19CD ERR_SYNTAX: 157:14553+10 19CD 21FC19 LD HL,[_STR_SYNTAX] 158:14563+17 19D0 CDE600 CALL print_str 159:14580+10 19D3 C9 RET 160: 161: - 19D4 _STR_NOT_IMPLEMENTED: 162: - 19D4 0A0D6E6F db 10,13,"not implemented",10,13,0 7420696D 706C656D 656E7465 640A0D00 163: 164: - 19E8 _STR_NOT_FOUND: 165: - 19E8 0A0D696E db 10,13,"invalid command",10,13,0 76616C69 6420636F 6D6D616E 640A0D00 166: 167: - 19FC _STR_SYNTAX: **** main.asm **** 185: - 19FC 0A0D696E db 10,13,"invalid syntax",10,13,0 76616C69 64207379 6E746178 0A0D00 186: .include "cmd_mem.s" **** include/cmd_mem.s **** 1: - 1A0F OP_EXEC: 2: ;DE contains pointer 3:14590+11 1A0F D5 push DE 4:14601+10 1A10 E1 pop HL 5:14611+17 1A11 CDF601 call DHEX_TO_BYTE 6:14628+4 1A14 47 ld b,a ;store result in b 7:14632+4 1A15 7B ld a,e ;check for error 8:14636+4 1A16 A7 and a 9:14640+10 1A17 C2CD19 jp nz, ERR_SYNTAX 10:14650+6 1A1A 23 inc HL 11:14656+6 1A1B 23 inc HL 12:14662+17 1A1C CDF601 call DHEX_TO_BYTE 13:14679+4 1A1F 4F ld c,a 14:14683+4 1A20 7B ld a,e ;check for error 15:14687+4 1A21 A7 and a 16:14691+10 1A22 C2CD19 jp nz, ERR_SYNTAX 17:14701+4 1A25 60 ld h,b 18:14705+4 1A26 69 ld l,c 19:14709+4 1A27 E9 jp (hl) 20: - 1A28 OP_CALL: 21: ;DE contains pointer 22:14713+11 1A28 D5 push DE 23:14724+10 1A29 E1 pop HL 24:14734+17 1A2A CDF601 call DHEX_TO_BYTE 25:14751+4 1A2D 47 ld b,a ;store result in b 26:14755+4 1A2E 7B ld a,e ;check for error 27:14759+4 1A2F A7 and a 28:14763+10 1A30 C2CD19 jp nz, ERR_SYNTAX 29:14773+6 1A33 23 inc HL 30:14779+6 1A34 23 inc HL 31:14785+17 1A35 CDF601 call DHEX_TO_BYTE 32:14802+4 1A38 4F ld c,a 33:14806+4 1A39 7B ld a,e ;check for error 34:14810+4 1A3A A7 and a 35:14814+10 1A3B C2CD19 jp nz, ERR_SYNTAX 36:14824+4 1A3E 60 ld h,b 37:14828+4 1A3F 69 ld l,c 38:14832+17 1A40 CD471A call _OP_CALL 39:14849+17 1A43 CDF800 call print_newLine 40:14866+10 1A46 C9 ret 41: - 1A47 _OP_CALL 42:14876+4 1A47 E9 jp (hl) 43: 44: - 1A48 OP_DUMP: 45: ;DE contains pointer 46:14880+11 1A48 D5 push DE 47:14891+10 1A49 E1 pop HL 48:14901+17 1A4A CDF601 call DHEX_TO_BYTE ;parse start address 49:14918+4 1A4D 47 ld b,a ;store result in b 50:14922+4 1A4E 7B ld a,e ;check for error 51:14926+4 1A4F A7 and a 52:14930+10 1A50 C2CD19 jp nz, ERR_SYNTAX 53:14940+6 1A53 23 inc HL 54:14946+6 1A54 23 inc HL 55:14952+17 1A55 CDF601 call DHEX_TO_BYTE 56:14969+4 1A58 4F ld c,a 57:14973+4 1A59 7B ld a,e ;check for error 58:14977+4 1A5A A7 and a 59:14981+10 1A5B C2CD19 jp nz, ERR_SYNTAX 60:14991+6 1A5E 23 inc HL 61:14997+6 1A5F 23 inc HL 62:15003+7 1A60 7E ld a,(HL) 63:15010+7 1A61 FE20 cp ' ' 64:15017+10 1A63 C2CD19 jp nz, ERR_SYNTAX 65:15027+6 1A66 23 inc HL 66:15033+17 1A67 CDF601 call DHEX_TO_BYTE 67:15050+11 1A6A F5 push af 68:15061+4 1A6B 7B ld a,e ;check for error 69:15065+4 1A6C A7 and a 70:15069+10 1A6D C2CD19 jp nz, ERR_SYNTAX 71:15079+10 1A70 F1 pop af 72: 73:15089+4 1A71 60 ld h,b 74:15093+4 1A72 69 ld l,c 75:15097+4 1A73 47 ld b,a 76: 77:15101+17 1A74 CDE117 call dump_pretty 78:15118+10 1A77 C9 ret 79: 80: - 1A78 OP_SET: 81: ;DE contains pointer 82:15128+11 1A78 D5 push DE 83:15139+10 1A79 E1 pop HL 84:15149+17 1A7A CDF601 call DHEX_TO_BYTE ;parse start address 85:15166+4 1A7D 47 ld b,a ;store result in b 86:15170+4 1A7E 7B ld a,e ;check for error 87:15174+4 1A7F A7 and a 88:15178+10 1A80 C2CD19 jp nz, ERR_SYNTAX 89:15188+6 1A83 23 inc HL 90:15194+6 1A84 23 inc HL 91:15200+17 1A85 CDF601 call DHEX_TO_BYTE 92:15217+4 1A88 4F ld c,a 93:15221+4 1A89 7B ld a,e ;check for error 94:15225+4 1A8A A7 and a 95:15229+10 1A8B C2CD19 jp nz, ERR_SYNTAX 96: ;bc now contains the start address 97:15239+6 1A8E 23 INC HL 98:15245+6 1A8F 23 INC HL 99: ;hl now cointains start addr of data bytes 100: - 1A90 _OP_SET_LOOP: 101:15251+7 1A90 7E ld a,(hl) 102:15258+7 1A91 FE00 cp 0 ;if 0 then end 103:15265+5+6 1A93 C8 RET Z 104:15270+7 1A94 FE20 cp ' ' 105:15277+10 1A96 C2CD19 jp nz, ERR_SYNTAX 106:15287+6 1A99 23 inc hl ;next byte 107:15293+17 1A9A CDF601 call DHEX_TO_BYTE 108:15310+7 1A9D 02 ld (bc),a ;load byte to 109:15317+4 1A9E 7B ld a,e 110:15321+4 1A9F A7 and a 111:15325+10 1AA0 C2CD19 jp nz, ERR_SYNTAX 112:15335+6 1AA3 03 inc bc 113:15341+6 1AA4 23 inc hl 114:15347+6 1AA5 23 inc hl 115:15353+10 1AA6 C3901A jp _OP_SET_LOOP 116: 117: - 1AA9 OP_DASM: 118:15363+11 1AA9 D5 push DE 119:15374+10 1AAA E1 pop HL 120:15384+17 1AAB CDF601 call DHEX_TO_BYTE 121:15401+4 1AAE 47 ld b,a ;store result in b 122:15405+4 1AAF 7B ld a,e ;check for error 123:15409+4 1AB0 A7 and a 124:15413+10 1AB1 C2CD19 jp nz, ERR_SYNTAX 125:15423+6 1AB4 23 inc hl 126:15429+6 1AB5 23 inc hl 127:15435+17 1AB6 CDF601 call DHEX_TO_BYTE 128:15452+4 1AB9 4F ld c,a 129:15456+4 1ABA 7B ld a,e ;check for error 130:15460+4 1ABB A7 and a 131:15464+10 1ABC C2CD19 jp nz, ERR_SYNTAX 132:15474+6 1ABF 23 inc hl 133:15480+6 1AC0 23 inc hl 134:15486+7 1AC1 7E ld a,(HL) 135:15493+7 1AC2 FE20 cp ' ' 136:15500+10 1AC4 C2CD19 jp nz, ERR_SYNTAX 137:15510+6 1AC7 23 inc hl 138:15516+17 1AC8 CDF601 call DHEX_TO_BYTE 139:15533+11 1ACB F5 push af 140:15544+4 1ACC 7B ld a,e ;check for error 141:15548+4 1ACD A7 and a 142:15552+10 1ACE C2CD19 jp nz, ERR_SYNTAX 143:15562+4 1AD1 60 ld h,b 144:15566+4 1AD2 69 ld l,c 145:15570+10 1AD3 F1 pop af ;restore af 146:15580+4 1AD4 47 ld b,a 147:15584+17 1AD5 CD4702 call disassemble **** main.asm **** 187:15601+10 1AD8 C9 ret 188: .include "cmd_io.s" **** include/cmd_io.s **** 1: - 1AD9 OP_IO_IN: 2:15611+11 1AD9 D5 push DE 3:15622+10 1ADA E1 pop HL 4:15632+17 1ADB CDF601 call DHEX_TO_BYTE 5:15649+4 1ADE 4F ld c,a ;store result in b 6:15653+4 1ADF 7B ld a,e ;check for error 7:15657+4 1AE0 A7 and a 8:15661+10 1AE1 C2CD19 jp nz, ERR_SYNTAX 9:15671+12 1AE4 ED78 in a,(c) 10:15683+11 1AE6 F5 push af 11:15694+17 1AE7 CDF800 call print_newLine 12:15711+10 1AEA F1 pop af 13:15721+17 1AEB CD0E01 call print_a_hex 14:15738+10 1AEE C9 ret 15: 16: - 1AEF OP_IO_OUT: 17:15748+11 1AEF D5 push DE 18:15759+10 1AF0 E1 pop HL 19:15769+17 1AF1 CDF601 call DHEX_TO_BYTE 20:15786+4 1AF4 4F ld c,a ;store result in b 21:15790+4 1AF5 7B ld a,e ;check for error 22:15794+4 1AF6 A7 and a 23:15798+10 1AF7 C2CD19 jp nz, ERR_SYNTAX 24:15808+6 1AFA 23 inc hl 25:15814+6 1AFB 23 inc hl 26:15820+7 1AFC 7E ld a,(hl) 27:15827+7 1AFD FE20 cp ' ' 28:15834+10 1AFF C2CD19 jp nz, ERR_SYNTAX 29:15844+6 1B02 23 inc hl 30:15850+17 1B03 CDF601 call DHEX_TO_BYTE 31:15867+11 1B06 F5 push af 32:15878+4 1B07 7B ld a,e ;check for error 33:15882+4 1B08 A7 and a 34:15886+10 1B09 C2CD19 jp nz, ERR_SYNTAX 35:15896+10 1B0C F1 pop af 36:15906+12 1B0D ED79 out (c),a 37:15918+10 1B0F C9 ret 38: 39: - 1B10 OP_IIC_OUT: 40:15928+11 1B10 D5 push DE 41:15939+10 1B11 E1 pop HL 42:15949+17 1B12 CDF601 call DHEX_TO_BYTE ;load start addr 43:15966+13 1B15 320C40 ld (var_scratch+1),A ;store result in ram 44:15979+4 1B18 7B ld a,e ;check for error 45:15983+4 1B19 A7 and a 46:15987+10 1B1A C2CD19 jp nz, ERR_SYNTAX 47:15997+6 1B1D 23 inc hl 48:16003+6 1B1E 23 inc hl 49:16009+10 1B1F 010D40 LD BC,[var_scratch + 2] 50:16019+4 1B22 AF XOR A 51:16023+13 1B23 320B40 LD (var_scratch),A 52: - 1B26 _OP_IIC_OUT_LOOP: 53:16036+7 1B26 7E ld a,(hl) 54:16043+7 1B27 FE00 cp 0 ;if 0 then end 55:16050+10 1B29 CA421B jp z,_OP_IIC_OUT_SEND 56:16060+7 1B2C FE20 cp ' ' 57:16067+10 1B2E C2CD19 jp nz, ERR_SYNTAX 58:16077+6 1B31 23 inc hl ;next byte 59: 60:16083+17 1B32 CDF601 call DHEX_TO_BYTE 61:16100+7 1B35 02 ld (bc),a 62:16107+6 1B36 03 inc bc ;incerement pointer 63:16113+13 1B37 3A0B40 ld a,(var_scratch) 64:16126+4 1B3A 3C inc a ;increment counter 65:16130+13 1B3B 320B40 ld (var_scratch),a 66:16143+6 1B3E 23 inc HL 67:16149+6 1B3F 23 inc HL 68:16155+12 1B40 18E4 jr _OP_IIC_OUT_LOOP 69: - 1B42 _OP_IIC_OUT_SEND: 70:16167+10 1B42 210D40 ld hl,[var_scratch + 2] 71:16177+13 1B45 3A0B40 ld a,(var_scratch) ;load amount of bytes 72:16190+4 1B48 47 ld b,a 73:16194+13 1B49 3A0C40 ld a,(var_scratch+1) ;load start addr 74:16207+4 1B4C 4F ld c,a 75:16211+17 1B4D CD9C16 call iic_send_buffer 76:16228+4 1B50 B7 or a 77:16232+10 1B51 C2551B jp nz, _OP_IIC_ACK_ERR 78:16242+10 1B54 C9 ret 79: 80: - 1B55 _OP_IIC_ACK_ERR: 81:16252+10 1B55 215C1B LD HL,[_OP_IIC_ACK_ERR_str] 82:16262+17 1B58 CDE600 call print_str 83:16279+10 1B5B C9 ret 84: - 1B5C _OP_IIC_ACK_ERR_str: 85: - 1B5C 0A0D6275 db 10,13,"bus-error: no ACK",0 732D6572 726F723A 206E6F20 41434B00 86: 87: - 1B70 OP_IIC_IN: 88:16289+11 1B70 D5 push DE 89:16300+10 1B71 E1 pop HL 90:16310+17 1B72 CDF601 call DHEX_TO_BYTE ;load start addr 91:16327+4 1B75 4F ld C,a ;store start addr to B 92:16331+4 1B76 7B ld a,e ;check for error 93:16335+4 1B77 A7 and a 94:16339+10 1B78 C2CD19 jp nz, ERR_SYNTAX 95:16349+6 1B7B 23 inc hl 96:16355+6 1B7C 23 inc hl 97:16361+7 1B7D 7E ld a,(hl) 98:16368+7 1B7E FE20 cp ' ' 99:16375+10 1B80 C2CD19 jp nz, ERR_SYNTAX 100:16385+6 1B83 23 inc hl 101:16391+17 1B84 CDF601 call DHEX_TO_BYTE ;read length 102:16408+4 1B87 47 ld b,a ;store length in B 103:16412+11 1B88 C5 push bc 104:16423+4 1B89 7B ld a,e ;check for error 105:16427+4 1B8A A7 and a 106:16431+10 1B8B C2CD19 jp nz, ERR_SYNTAX 107:16441+10 1B8E 210B40 ld hl,[var_scratch] 108:16451+17 1B91 CDC616 call iic_receive_buffer 109:16468+10 1B94 C1 pop bc 110:16478+4 1B95 B7 or a 111:16482+10 1B96 C2551B jp nz, _OP_IIC_ACK_ERR 112:16492+10 1B99 21AF1B ld hl,[_OP_IIC_IN_LOOP_TEXT] 113:16502+17 1B9C CDE600 call print_str 114:16519+10 1B9F 210B40 ld hl,[var_scratch] 115: ;print data 116: - 1BA2 _OP_IIC_IN_LOOP: 117:16529+7 1BA2 7E ld a,(hl) 118:16536+17 1BA3 CD0E01 call print_a_hex 119:16553+7 1BA6 3E20 ld a, ' ' 120:16560+17 1BA8 CDDE00 call print_char 121:16577+6 1BAB 23 inc hl 122:16583+8+5 1BAC 10F4 djnz _OP_IIC_IN_LOOP 123:16591+10 1BAE C9 ret 124: 125: - 1BAF _OP_IIC_IN_LOOP_TEXT: 126: - 1BAF 0A0D7265 db 10,13,"rec-buff: ",0 632D6275 66663A20 00 127: 128: - 1BBC OP_CLR: 129:16601+17 1BBC CDF100 call print_clear **** main.asm **** 189:16618+10 1BBF C9 ret 190: .include "cmd_date.s" **** include/cmd_date.s **** 1: - 00D0 ADDR_RTC .equ 0xD0 2: 3: - 1BC0 OP_RTIME: 4:16628+17 1BC0 CDF800 call print_newLine 5: - 1BC3 _OP_RTIME_NN: 6: ;set pointer 7:16645+10 1BC3 217B1C ld hl,[_OP_RTIME_RD_CMD] 8:16655+7 1BC6 0601 ld b, 1 9:16662+7 1BC8 0ED0 ld c, ADDR_RTC 10:16669+17 1BCA CD9C16 call iic_send_buffer 11:16686+4 1BCD B7 or a 12:16690+10 1BCE C2551B jp nz, _OP_IIC_ACK_ERR 13: ;read RTC data 14:16700+10 1BD1 210B40 ld hl,[var_scratch] 15:16710+7 1BD4 0608 ld b,8 16:16717+7 1BD6 0ED0 ld c, ADDR_RTC 17:16724+17 1BD8 CDC616 call iic_receive_buffer 18:16741+4 1BDB B7 or a 19:16745+10 1BDC C2551B jp nz, _OP_IIC_ACK_ERR 20: ;process display hours 21:16755+13 1BDF 3A0D40 ld a,(var_scratch+2) 22:16768+7 1BE2 E630 and 00110000b 23:16775+4 1BE4 1F RRA 24:16779+4 1BE5 1F RRA 25:16783+4 1BE6 1F RRA 26:16787+4 1BE7 1F RRA 27:16791+17 1BE8 CD2001 call print_bcd 28:16808+13 1BEB 3A0D40 ld a,(var_scratch+2) 29:16821+7 1BEE E60F and 00001111b 30:16828+17 1BF0 CD2001 call print_bcd 31:16845+7 1BF3 3E3A ld a,':' 32:16852+17 1BF5 CDDE00 call print_char 33: ;display minutes 34:16869+13 1BF8 3A0C40 ld a,(var_scratch+1) 35:16882+7 1BFB E670 and 01110000b 36:16889+4 1BFD 1F RRA 37:16893+4 1BFE 1F RRA 38:16897+4 1BFF 1F RRA 39:16901+4 1C00 1F RRA 40:16905+17 1C01 CD2001 call print_bcd 41:16922+13 1C04 3A0C40 ld a,(var_scratch+1) 42:16935+7 1C07 E60F and 00001111b 43:16942+17 1C09 CD2001 call print_bcd 44:16959+7 1C0C 3E3A ld a,':' 45:16966+17 1C0E CDDE00 call print_char 46: ;display seconds 47:16983+13 1C11 3A0B40 ld a,(var_scratch+0) 48:16996+7 1C14 E670 and 01110000b 49:17003+4 1C16 1F RRA 50:17007+4 1C17 1F RRA 51:17011+4 1C18 1F RRA 52:17015+4 1C19 1F RRA 53:17019+17 1C1A CD2001 call print_bcd 54:17036+13 1C1D 3A0B40 ld a,(var_scratch+0) 55:17049+7 1C20 E60F and 00001111b 56:17056+17 1C22 CD2001 call print_bcd 57:17073+7 1C25 3E20 ld a,' ' 58:17080+17 1C27 CDDE00 call print_char 59: ;display date 60:17097+13 1C2A 3A0F40 ld a,(var_scratch+4) 61:17110+7 1C2D E630 and 00110000b 62:17117+4 1C2F 1F RRA 63:17121+4 1C30 1F RRA 64:17125+4 1C31 1F RRA 65:17129+4 1C32 1F RRA 66:17133+17 1C33 CD2001 call print_bcd 67:17150+13 1C36 3A0F40 ld a,(var_scratch+4) 68:17163+7 1C39 E60F and 00001111b 69:17170+17 1C3B CD2001 call print_bcd 70:17187+7 1C3E 3E2E ld a,'.' 71:17194+17 1C40 CDDE00 call print_char 72:17211+13 1C43 3A1040 ld a,(var_scratch+5) 73:17224+7 1C46 E610 and 00010000b 74:17231+4 1C48 1F RRA 75:17235+4 1C49 1F RRA 76:17239+4 1C4A 1F RRA 77:17243+4 1C4B 1F RRA 78:17247+17 1C4C CD2001 call print_bcd 79:17264+13 1C4F 3A1040 ld a,(var_scratch+5) 80:17277+7 1C52 E60F and 00001111b 81:17284+17 1C54 CD2001 call print_bcd 82:17301+7 1C57 3E2E ld a,'.' 83:17308+17 1C59 CDDE00 call print_char 84:17325+7 1C5C 3E32 ld a,'2' 85:17332+17 1C5E CDDE00 call print_char 86:17349+7 1C61 3E30 ld a,'0' 87:17356+17 1C63 CDDE00 call print_char 88:17373+13 1C66 3A1140 ld a,(var_scratch+6) 89:17386+7 1C69 E6F0 and 11110000b 90:17393+4 1C6B 1F RRA 91:17397+4 1C6C 1F RRA 92:17401+4 1C6D 1F RRA 93:17405+4 1C6E 1F RRA 94:17409+17 1C6F CD2001 call print_bcd 95:17426+13 1C72 3A1140 ld a,(var_scratch+6) 96:17439+7 1C75 E60F and 00001111b 97:17446+17 1C77 CD2001 call print_bcd 98: 99:17463+10 1C7A C9 RET 100: - 1C7B _OP_RTIME_RD_CMD: 101: - 1C7B 00 db 0x00 102: 103: - 1C7C 0A0D456E _OP_STIME_STR_DAY: db 10,13,"Enter Date (00-31) : ",0 74657220 44617465 20202020 2830302D 33312920 3A2000 104: - 1C97 0A0D456E _OP_STIME_STR_MON: db 10,13,"Enter Month (00-12) : ",0 74657220 4D6F6E74 68202020 2830302D 31322920 3A2000 105: - 1CB2 0A0D456E _OP_STIME_STR_YEAR: db 10,13,"Enter Year (00-99) : ",0 74657220 59656172 20202020 2830302D 39392920 3A2000 106: - 1CCD 0A0D456E _OP_STIME_STR_HOUR: db 10,13,"Enter Hours (00-23) : ",0 74657220 486F7572 73202020 2830302D 32332920 3A2000 107: - 1CE8 0A0D456E _OP_STIME_STR_MIN: db 10,13,"Enter Minutes (00-59) : ",0 74657220 4D696E75 74657320 2830302D 35392920 3A2000 108: - 1D03 0A0D456E _OP_STIME_STR_SEC: db 10,13,"Enter Seconds (00-59) : ",0 74657220 5365636F 6E647320 2830302D 35392920 3A2000 109: - 1D1E 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: - 1D35 _OP_STIME_PROMPT: 113:17473+11 1D35 E5 push hl 114:17484+17 1D36 CDE600 call print_str 115:17501+10 1D39 E1 pop hl 116:17511+17 1D3A CD3801 call read_bcd 117:17528+7 1D3D FEFF cp 0xFF ;if failed 118:17535+10 1D3F CA4D1D jp Z, _OP_STIME_PROMPT_ERR 119:17545+4 1D42 47 ld b,a 120:17549+17 1D43 CD3801 call read_bcd 121:17566+7 1D46 FEFF cp 0xFF ;if failed 122:17573+10 1D48 CA4D1D jp Z, _OP_STIME_PROMPT_ERR 123:17583+4 1D4B 4F ld c,a 124:17587+10 1D4C C9 ret 125: - 1D4D _OP_STIME_PROMPT_ERR: 126:17597+11 1D4D E5 push HL 127:17608+10 1D4E 211E1D ld hl, [_OP_STIME_INVALID] 128:17618+17 1D51 CDE600 call print_str 129:17635+10 1D54 E1 pop hl 130:17645+10 1D55 C3351D jp _OP_STIME_PROMPT 131: 132: 133: 134: - 1D58 OP_STIME: 135:17655+4 1D58 AF xor a 136:17659+13 1D59 320B40 ld (var_scratch),a ;set pointer 137: ;date 138:17672+10 1D5C 217C1C ld hl, [_OP_STIME_STR_DAY] 139:17682+17 1D5F CD351D call _OP_STIME_PROMPT 140:17699+4 1D62 78 ld a,b 141:17703+17 1D63 CDCC1D call _shift4 142:17720+7 1D66 E630 and 00110000b ;mask bits; bit6 low -> 24h mode 143:17727+4 1D68 B1 or c ;add second digit 144:17731+13 1D69 321040 ld (var_scratch+5),a 145: ;month 146:17744+10 1D6C 21971C ld hl, [_OP_STIME_STR_MON] 147:17754+17 1D6F CD351D call _OP_STIME_PROMPT 148:17771+4 1D72 78 ld a,b 149:17775+17 1D73 CDCC1D call _shift4 150:17792+7 1D76 E610 and 00010000b ;mask bits; bit6 low -> 24h mode 151:17799+4 1D78 B1 or c ;add second digit 152:17803+13 1D79 321140 ld (var_scratch+6),a 153: ;year 154:17816+10 1D7C 21B21C ld hl, [_OP_STIME_STR_YEAR] 155:17826+17 1D7F CD351D call _OP_STIME_PROMPT 156:17843+4 1D82 78 ld a,b 157:17847+17 1D83 CDCC1D call _shift4 158:17864+7 1D86 E6F0 and 11110000b ;mask bits; bit6 low -> 24h mode 159:17871+4 1D88 B1 or c ;add second digit 160:17875+13 1D89 321240 ld (var_scratch+7),a 161: ;hours 162:17888+10 1D8C 21CD1C ld hl, [_OP_STIME_STR_HOUR] 163:17898+17 1D8F CD351D call _OP_STIME_PROMPT 164:17915+4 1D92 78 ld a,b 165:17919+17 1D93 CDCC1D call _shift4 166:17936+7 1D96 E630 and 00110000b ;mask bits; bit6 low -> 24h mode 167:17943+4 1D98 B1 or c ;add second digit 168:17947+13 1D99 320E40 ld (var_scratch+3),a 169: ; minutes 170:17960+10 1D9C 21E81C ld hl, [_OP_STIME_STR_MIN] 171:17970+17 1D9F CD351D call _OP_STIME_PROMPT 172:17987+4 1DA2 78 ld a,b 173:17991+17 1DA3 CDCC1D call _shift4 174:18008+7 1DA6 E670 and 01110000b ;mask bits 175:18015+4 1DA8 B1 or c ;add second digit 176:18019+13 1DA9 320D40 ld (var_scratch+2),a 177: ; seconds 178:18032+10 1DAC 21031D ld hl, [_OP_STIME_STR_SEC] 179:18042+17 1DAF CD351D call _OP_STIME_PROMPT 180:18059+4 1DB2 78 ld a,b 181:18063+17 1DB3 CDCC1D call _shift4 182:18080+7 1DB6 E670 and 01110000b ;mask bits / bit6 low -> 24h mode (enable clock) 183:18087+4 1DB8 B1 or c ;add second digit 184:18091+13 1DB9 320C40 ld (var_scratch+1),a 185:18104+6 1DBC 13 inc de ;next 186: 187:18110+7 1DBD 0ED0 ld c, ADDR_RTC 188:18117+7 1DBF 0608 ld b, 8 189:18124+10 1DC1 210B40 ld hl,[var_scratch] 190:18134+17 1DC4 CD9C16 call iic_send_buffer 191:18151+4 1DC7 B7 or a 192:18155+10 1DC8 C2551B jp nz, _OP_IIC_ACK_ERR 193: 194:18165+10 1DCB C9 ret 195: 196: - 1DCC _shift4: 197:18175+4 1DCC 07 RLCA 198:18179+4 1DCD 07 RLCA 199:18183+4 1DCE 07 RLCA 200:18187+4 1DCF 07 RLCA **** main.asm **** 191:18191+10 1DD0 C9 ret 192: .include "cmd_disk.s" **** include/cmd_disk.s **** 1: - 1DD1 OP_LSDSK: 2:18201+17 1DD1 CD5813 call ideif_prnt_devtable 3:18218+10 1DD4 C9 ret 4: 5: - 1DD5 OP_SELDSK: 6: ;DE contains pointer 7:18228+11 1DD5 D5 push de 8:18239+10 1DD6 E1 pop hl 9:18249+7 1DD7 7E ld a,(hl) 10:18256+7 1DD8 DE45 sbc 69 11:18263+7+5 1DDA 3808 jr c,_OP_SELDSK_INVALID 12:18270+7 1DDC FE04 cp 4 13:18277+7+5 1DDE 3004 jr nc, _OP_SELDSK_INVALID 14:18284+17 1DE0 CD7315 call ideif_drv_sel 15:18301+10 1DE3 C9 ret 16: 17: - 1DE4 _OP_SELDSK_INVALID: 18:18311+10 1DE4 21FC1D ld hl,[_OP_SELDSK_INVALID_STR] 19:18321+17 1DE7 CDE600 call print_str 20:18338+10 1DEA 112000 LD DE,0x20 21:18348+10 1DED 017000 LD BC,0x70 22:18358+17 1DF0 CDA90D CALL beep 23:18375+10 1DF3 C9 ret 24: 25: - 1DF4 OP_DIR: 26:18385+17 1DF4 CD4B23 CALL fat_print_directory 27:18402+10 1DF7 C9 ret 28: 29: - 1DF8 OP_CD: 30:18412+17 1DF8 CD6024 call fat_cd_single 31:18429+10 1DFB C9 ret 32: 33: - 1DFC _OP_SELDSK_INVALID_STR: 34: - 1DFC 0A0D496E db 10,13,"Invalid drive letter",10,13,0 76616C69 64206472 69766520 6C657474 65720A0D 00 35: 36: - 1E15 OP_FSEXEC: 37:18439+17 1E15 CD7B25 call fat_exec **** main.asm **** 193:18456+10 1E18 C9 ret 194: .include "post.s" **** include/post.s **** 1: ;Power-On self test 2: - 1E19 POST_START: 3:18466+17 1E19 CD291E call POST_CHECK_PIO 4:18483+17 1E1C CD4E1E call POST_CHECK_APU 5:18500+17 1E1F CDA61E call POST_TEST_RTC 6:18517+17 1E22 CD791E call POST_CHECK_IDE_30 7:18534+17 1E25 CD8C1E call POST_CHECK_IDE_40 8:18551+10 1E28 C9 ret 9: 10: - 1E29 POST_CHECK_PIO: 11:18561+10 1E29 211D1F ld hl,[str_post_pio] 12:18571+17 1E2C CDE600 call print_str 13:18588+11 1E2F DBF6 in a,(CS_PIO_AC) ;test read from pio 14:18599+7 1E31 FE00 cp 0x00 ;0x78 when not installed 15:18606+10 1E33 C2421E jp nz, _POST_CHECK_PIO_FAILED 16:18616+7 1E36 3E00 ld a, 0x00 ;set present flag 17:18623+13 1E38 320940 ld (var_pio_present),a 18:18636+10 1E3B 21A61F ld hl,[str_post_ok] 19:18646+17 1E3E CDE600 call print_str 20:18663+10 1E41 C9 ret 21: - 1E42 _POST_CHECK_PIO_FAILED: 22:18673+7 1E42 3EFF ld a, 0xFF 23:18680+13 1E44 320940 ld (var_pio_present),a 24:18693+10 1E47 216E1F ld hl,[str_post_nd] 25:18703+17 1E4A CDE600 call print_str 26:18720+10 1E4D C9 ret 27: 28: - 1E4E POST_CHECK_APU: 29:18730+10 1E4E 21381F ld hl,[str_post_apu] 30:18740+17 1E51 CDE600 call print_str 31: 32:18757+7 1E54 3EFF ld a, 0xFF 33:18764+11 1E56 D3F8 out (CS_APU_DATA),a 34:18775+4 1E58 00 nop 35:18779+4 1E59 00 nop 36:18783+11 1E5A DBF8 in a,(CS_APU_DATA) 37:18794+7 1E5C FEFF cp 0xFF 38:18801+10 1E5E C26D1E jp nz, _POST_CHECK_APU_FAILED 39:18811+7 1E61 3E00 ld a, 0x00 ;set present flag 40:18818+13 1E63 320A40 ld (var_apu_present),a 41:18831+10 1E66 21A61F ld hl,[str_post_ok] 42:18841+17 1E69 CDE600 call print_str 43:18858+10 1E6C C9 ret 44: - 1E6D _POST_CHECK_APU_FAILED: 45:18868+7 1E6D 3EFF ld a, 0xFF 46:18875+13 1E6F 320A40 ld (var_apu_present),a 47:18888+10 1E72 216E1F ld hl,[str_post_nd] 48:18898+17 1E75 CDE600 call print_str 49:18915+10 1E78 C9 ret 50: 51: - 1E79 POST_CHECK_IDE_30: 52:18925+10 1E79 21E71E ld hl,[str_post_ide_30] 53:18935+17 1E7C CDE600 call print_str 54:18952+11 1E7F DB30 in a,(0x30) 55:18963+4 1E81 B7 or a 56:18967+10 1E82 C29F1E jp nz, _POST_CHECK_IDE_FAILED 57:18977+10 1E85 21A61F ld hl,[str_post_ok] 58:18987+17 1E88 CDE600 call print_str 59:19004+10 1E8B C9 ret 60: - 1E8C POST_CHECK_IDE_40: 61:19014+10 1E8C 21021F ld hl,[str_post_ide_40] 62:19024+17 1E8F CDE600 call print_str 63:19041+11 1E92 DB40 in a,(0x40) 64:19052+4 1E94 B7 or a 65:19056+10 1E95 C29F1E jp nz, _POST_CHECK_IDE_FAILED 66:19066+10 1E98 21A61F ld hl,[str_post_ok] 67:19076+17 1E9B CDE600 call print_str 68:19093+10 1E9E C9 ret 69: 70: - 1E9F _POST_CHECK_IDE_FAILED 71:19103+10 1E9F 216E1F ld hl,[str_post_nd] 72:19113+17 1EA2 CDE600 call print_str 73:19130+10 1EA5 C9 ret 74: 75: - 1EA6 POST_TEST_RTC: 76:19140+7 1EA6 3E06 ld a, 0x06 77:19147+13 1EA8 320B40 ld (var_scratch),a 78:19160+10 1EAB 21531F ld hl,[str_post_rtc] 79:19170+17 1EAE CDE600 call print_str 80:19187+10 1EB1 210B40 ld hl,[var_scratch] 81:19197+7 1EB4 0601 ld b, 1 82:19204+7 1EB6 0ED0 ld c, ADDR_RTC 83:19211+17 1EB8 CD9C16 call iic_send_buffer 84:19228+4 1EBB B7 or a 85:19232+10 1EBC C2D91E jp nz, _POST_TEST_RTC_NOTFOUND 86:19242+10 1EBF 210B40 ld hl,[var_scratch] 87:19252+7 1EC2 0601 ld b, 1 88:19259+7 1EC4 0ED0 ld c, ADDR_RTC 89:19266+17 1EC6 CDC616 call iic_receive_buffer 90:19283+13 1EC9 3A0B40 ld a, (var_scratch) 91:19296+4 1ECC B7 or a 92:19300+10 1ECD CAE01E jp z, _POST_TEST_RTC_INVALID 93:19310+10 1ED0 21A61F ld hl,[str_post_ok] 94:19320+17 1ED3 CDE600 call print_str 95:19337+10 1ED6 C3C31B jp _OP_RTIME_NN 96: - 1ED9 _POST_TEST_RTC_NOTFOUND: 97:19347+10 1ED9 216E1F ld hl,[str_post_nd] 98:19357+17 1EDC CDE600 call print_str 99:19374+10 1EDF C9 ret 100: - 1EE0 _POST_TEST_RTC_INVALID: 101:19384+10 1EE0 217C1F ld hl,[str_post_rtc_iv] 102:19394+17 1EE3 CDE600 call print_str 103:19411+10 1EE6 C9 ret 104: 105: - 1EE7 str_post_ide_30: 106: - 1EE7 0D0A4368 db 13,10,"Check Diskctrl.@030h... ",0 65636B20 4469736B 6374726C 2E403033 30682E2E 2E2000 107: - 1F02 str_post_ide_40: 108: - 1F02 0D0A4368 db 13,10,"Check Diskctrl.@040h... ",0 65636B20 4469736B 6374726C 2E403034 30682E2E 2E2000 109: - 1F1D str_post_pio: 110: - 1F1D 0D0A4368 db 13,10,"Check IO-Controller ... ",0 65636B20 494F2D43 6F6E7472 6F6C6C65 72202E2E 2E2000 111: - 1F38 str_post_apu: 112: - 1F38 0D0A4368 db 13,10,"Check AMD8911 APU ... ",0 65636B20 414D4438 39313120 41505520 20202E2E 2E2000 113: - 1F53 str_post_rtc: 114: - 1F53 0D0A4368 db 13,10,"Check DS1307 RTC ... ",0 65636B20 44533133 30372052 54432020 20202E2E 2E2000 115: - 1F6E str_post_nd: 116: - 1F6E 6E6F7420 db "not detected!",0 64657465 63746564 2100 117: - 1F7C str_post_rtc_iv: 118: - 1F7C 6E6F7420 db "not set. Check battery and run 'setdate'!",0 7365742E 20436865 636B2062 61747465 72792061 6E642072 756E2027 73657464 61746527 2100 119: - 1FA6 str_post_ok: **** main.asm **** 195: - 1FA6 6F6B2120 db "ok! ",0 00 196: .include "fat16.s" **** include/fat16.s **** 1: ; VARS 2: 3: - 43B6 phase MEM_IDE_FSBUFFER 4: - 43B6 MEM_FAT_RESERVED: ; Reserved sectors (2byte) 5: - 43B6 ..43B7 00 defs 2 6: - 43B8 MEM_FAT_AMOUNT: ; Amount of FATs (1byte) 7: - 43B8 ..43B8 00 defs 1 8: - 43B9 MEM_FAT_SECTORS: ; Length of FAT (2byte) 9: - 43B9 ..43BA 00 defs 2 10: - 43BB MEM_FAT_CLUSTERLEN: ; Length of Cluster (1byte) 11: - 43BB ..43BB 00 defs 1 12: - 43BC MEM_FAT_COUNT1: ; Counter Var for reading FAT (2byte) 13: - 43BC ..43BC 00 defs 1 14: - 43BD MEM_FAT_TMPPOINTER: ; Temporary working pointer 15: - 43BD ..43C0 00 defs 4 16: - 43C1 MEM_FAT_DATASTART: ; Start of data area 17: - 43C1 ..43C4 00 defs 4 18: - 43C5 MEM_FAT_ROOTSTART: ; Start of Root directory 19: - 43C5 ..43C8 00 defs 4 20: - 43C9 MEM_FAT_FILEREMAIN: ; Remaining sectors in file 21: - 43C9 ..43CC 00 defs 4 22: - 43CD MEM_FAT_DIRSEC: ; Sectors per directory 23: - 43CD ..43CE 00 defs 2 24: - 43CF MEM_FAT_TMPFNAME: ; Temporary filename 25: - 43CF ..43DE 00 defs 16 26: - 43DF MEM_FAT_CURDIR: ; Current Directory 27: - 43DF ..442E 00 defs 80 28: - 442F MEM_FAT_OF0_ATTRIBUTE: ;Current file attribute 29: - 442F 0000 defw 0 30: - 4431 MEM_FAT_OF0_CCLUST: ;Current cluster of file 31: - 4431 0000 defw 0 32: - 4433 MEM_FAT_OF0_FATSEC: ;Current sector in FAT 33: - 4433 ..4436 00 defs 4 34: - 4437 MEM_FAT_OF0_DATSEC: ;Current sector in Data 35: - 4437 ..443A 00 defs 4 36: - 443B MEM_FAT_OF0_DATREM: ;Remaining bytes in Data 37: - 443B ..443E 00 defs 4 38: - 443F MEM_FAT_CURRDIR: ;Current directory 39: - 443F ..4442 00 defs 4 40: - 4443 MEM_FAT_EXEC_CURR: 41: - 4443 0000 defw 0 42: - 4445 MEM_FAT_EXEC_COUNT: 43: - 4445 0000 defw 0 44: - 4447 MEM_FAT_EXEC_START: 45: - 4447 0000 defw 0 46: 47: - 203E dephase 48: 49: ;------------------------------------- 50: ; Get FAT Root-Table position 51: ;------------------------------------- 52: - 203E fat_get_root_table: 53:19421+17 203E CDF722 call fat_reset_pointer ;reset fat pointer 54: 55: ; Load first sector on active partition 56:19438+10 2041 21D140 LD HL, MEM_IDE_POINTER ; pointer to LBA address 57:19448+7 2044 3E01 LD A,1 ;read 1 sector 58:19455+10 2046 11B641 LD DE, MEM_IDE_BUFFER ;where to store data? 59:19465+17 2049 CD4315 call read_lba_sector 60: 61: ; check for valid Boot sector 62:19482+13 204C 3AB641 ld a,(MEM_IDE_BUFFER) 63:19495+7 204F FEEB cp 0xEB ;first byte should be 0xEB 64:19502+10 2051 C20B21 jp nz, _fat_get_root_table_invalid 65: 66: ; Read and store FS Properties 67:19512+14 2054 DD21B641 LD IX,MEM_IDE_BUFFER 68:19526+19 2058 DD7E0D LD A,(IX+0x0D) 69:19545+13 205B 32BB43 LD (MEM_FAT_CLUSTERLEN),A 70:19558+19 205E DD7E0E LD A,(IX+0x0E) 71:19577+13 2061 32B643 LD (MEM_FAT_RESERVED),A 72:19590+19 2064 DD7E0F LD A,(IX+0x0F) 73:19609+13 2067 32B743 LD (MEM_FAT_RESERVED+1),A 74:19622+19 206A DD7E10 LD A,(IX+0x10) 75:19641+13 206D 32B843 LD (MEM_FAT_AMOUNT),A 76:19654+19 2070 DD7E16 LD A,(IX+0x16) 77:19673+13 2073 32B943 LD (MEM_FAT_SECTORS),A 78:19686+19 2076 DD7E17 LD A,(IX+0x17) 79:19705+13 2079 32BA43 LD (MEM_FAT_SECTORS+1),A 80: 81: ;Get Data Start Sector 82: ;calculate fat length 83:19718+20 207C ED4BB943 ld bc,(MEM_FAT_SECTORS) 84:19738+13 2080 3AB843 ld a,(MEM_FAT_AMOUNT) ;add fat to cluster number 85:19751+7 2083 1600 ld d,0 86:19758+4 2085 5F ld e,a 87:19762+17 2086 CDDE22 call _fat_math_mul32 88: ; BCHL contains result -> store to PTR.MEM_FAT_ROOTSTART 89:19779+16 2089 22C543 ld (MEM_FAT_ROOTSTART+0),hl 90:19795+20 208C ED43C743 ld (MEM_FAT_ROOTSTART+2),bc 91: 92: ;add offset (reserved sectors) 93:19815+16 2090 2AC441 ld hl,(MEM_IDE_BUFFER +0x0E) ; load sectors into hl 94:19831+16 2093 22BD43 ld (MEM_FAT_TMPPOINTER), hl 95:19847+4 2096 AF xor a 96:19851+13 2097 32BF43 ld (MEM_FAT_TMPPOINTER+2),a 97:19864+13 209A 32C043 ld (MEM_FAT_TMPPOINTER+3),a 98: 99:19877+10 209D 01C543 ld bc,[MEM_FAT_ROOTSTART] 100:19887+10 20A0 11BD43 ld de,[MEM_FAT_TMPPOINTER] 101:19897+17 20A3 CDAD22 call _fat_math_add32 ;MEM_FAT_ROOTSTART now contains the first sector 102: ;of the Root directory 103: 104: ;add offset (partition location) 105:19914+17 20A6 CD1C15 call ideif_get_drv_pointer 106:19931+10 20A9 DD23 inc ix 107:19941+10 20AB DD23 inc ix 108:19951+15 20AD DDE5 push ix 109:19966+10 20AF D1 pop de ;copy poiter to hl 110:19976+10 20B0 01C543 ld bc,[MEM_FAT_ROOTSTART] 111:19986+17 20B3 CDAD22 call _fat_math_add32 ;MEM_FAT_OF0_DATSEC now contains the first sector 112: ;of the cluster 113: ;copy value from MEM_FAT_ROOTSTART to MEM_IDE_POINTER 114:20003+10 20B6 21C543 ld hl,MEM_FAT_ROOTSTART 115:20013+10 20B9 11D140 ld de,MEM_IDE_POINTER 116:20023+16 20BC EDA0 ldi 117:20039+16 20BE EDA0 ldi 118:20055+16 20C0 EDA0 ldi 119:20071+16 20C2 EDA0 ldi 120: 121: ;copy value from MEM_FAT_ROOTSTART to MEM_IDE_POINTER 122:20087+10 20C4 21C543 ld hl,MEM_FAT_ROOTSTART 123:20097+10 20C7 11C143 ld de,MEM_FAT_DATASTART 124:20107+16 20CA EDA0 ldi 125:20123+16 20CC EDA0 ldi 126:20139+16 20CE EDA0 ldi 127:20155+16 20D0 EDA0 ldi 128: 129:20171+10 20D2 21C543 ld hl,MEM_FAT_ROOTSTART 130:20181+10 20D5 113F44 ld de,MEM_FAT_CURRDIR 131:20191+16 20D8 EDA0 ldi 132:20207+16 20DA EDA0 ldi 133:20223+16 20DC EDA0 ldi 134:20239+16 20DE EDA0 ldi 135: 136: ;add offset to data area 137: ;multiply cluster by length of cluster 138: 139: ;calculate sectors for root dir 140:20255+16 20E0 2AC741 ld hl,(MEM_IDE_BUFFER+0x11) ;load Maximum root directory entries 141:20271+4 20E3 7C ld a,h 142:20275+4 20E4 6F ld l,a 143:20279+4 20E5 AF xor a ;set a 0, clear carry flag 144:20283+4 20E6 67 ld h,a ;shift right by 8 bit = /512 145: 146: ;last step: multiply by 16 147:20287+4 20E7 EB ex de,hl 148:20291+10 20E8 011000 ld bc,16 149:20301+17 20EB CDDE22 call _fat_math_mul32 150: ; BCHL contains result -> store to PTR.MEM_FAT_TMPPOINTER 151:20318+16 20EE 22BD43 ld (MEM_FAT_TMPPOINTER+0),hl 152:20334+20 20F1 ED43BF43 ld (MEM_FAT_TMPPOINTER+2),bc 153: 154:20354+16 20F5 22CD43 ld (MEM_FAT_DIRSEC),hl 155: ; add offset to MEM_FAT_DATASTART 156:20370+10 20F8 11BD43 ld de,[MEM_FAT_TMPPOINTER] 157:20380+10 20FB 01C143 ld bc,[MEM_FAT_DATASTART] 158:20390+17 20FE CDAD22 call _fat_math_add32 ;MEM_FAT_DATASTART now contains the correct sector 159: ;at teh beginnig of the data area 160: 161: 162: ;done all FS vars populated 163: 164: ;navigate to root directory 165:20407+7 2101 3E5C ld a,'\' 166:20414+13 2103 32DF43 ld(MEM_FAT_CURDIR),a 167:20427+4 2106 AF xor a 168:20431+13 2107 32E043 ld(MEM_FAT_CURDIR+1),a 169: 170:20444+10 210A C9 ret 171: 172: - 210B _fat_get_root_table_invalid: 173:20454+17 210B CD9101 call PRINTINLINE 174: - 210E 0A0D4361 db 10,13,"Cannot find boot sector.",10,13,0 6E6E6F74 2066696E 6420626F 6F742073 6563746F 722E0A0D 00 175:20471+17 212B CD1C15 call ideif_get_drv_pointer 176:20488+19 212E DD360002 ld (ix+0),0x02 177:20507+10 2132 C9 ret 178: 179: ;------------------------------------- 180: ; fat_getfatsec 181: ; 182: ; gets sector in FAT table for the cluster stored in MEM_FAT_OF0_CCLUST 183: ; 184: ; store result in MEM_FAT_OF0_FATSEC 185: ; stores next cluster in MEM_FAT_OF0_CCLUST 186: ;------------------------------------- 187: - 2133 fat_getfatsec: 188:20517+16 2133 2A3144 ld HL,(MEM_FAT_OF0_CCLUST) ;load cluster 189:20533+4 2136 7C ld a,h ;if not 0x0000 190:20537+4 2137 B5 or l 191:20541+10 2138 C24A21 jp nz, _fat_getfatsec_notroot 192: ;if 0x0000, goto root directory 193:20551+10 213B 21C543 ld hl,MEM_FAT_ROOTSTART 194:20561+10 213E 113744 ld de,MEM_FAT_OF0_DATSEC 195:20571+16 2141 EDA0 ldi ;quick and dirty hack to go back to root directory 196:20587+16 2143 EDA0 ldi 197:20603+16 2145 EDA0 ldi 198:20619+16 2147 EDA0 ldi 199:20635+10 2149 C9 ret 200: 201: - 214A _fat_getfatsec_notroot: 202:20645+16 214A 2A3144 ld HL,(MEM_FAT_OF0_CCLUST) ;load cluster 203: ;each sector contains 256 clusters 204: ;first 8bits are not needed (/256) 205:20661+4 214D 7C ld a,h ;divide by 256 206:20665+4 214E 6F ld l,a 207:20669+4 214F AF xor a 208:20673+4 2150 67 ld h,a 209: 210:20677+20 2151 ED4BB643 ld bc,(MEM_FAT_RESERVED) ;add reserved sectors 211:20697+11 2155 09 add hl,bc 212:20708+16 2156 223344 ld(MEM_FAT_OF0_FATSEC+0),hl;store sector 213:20724+4 2159 AF xor a 214:20728+13 215A 323544 ld(MEM_FAT_OF0_FATSEC+2),a 215:20741+13 215D 323644 ld(MEM_FAT_OF0_FATSEC+3),a 216: 217:20754+17 2160 CD1C15 call ideif_get_drv_pointer 218:20771+10 2163 DD23 inc ix 219:20781+10 2165 DD23 inc ix 220:20791+15 2167 DDE5 push ix 221:20806+10 2169 D1 pop de ;copy poiter to hl 222:20816+10 216A 013344 ld bc,[MEM_FAT_OF0_FATSEC] 223:20826+17 216D CDAD22 call _fat_math_add32 ;MEM_FAT_OF0_FATSEC now contains the correct sector 224: ;in the FAT 225: 226: ;read FAT sector 227:20843+10 2170 213344 ld hl,MEM_FAT_OF0_FATSEC ;read next sector 228:20853+7 2173 0601 ld b,1 229:20860+10 2175 11B641 LD DE, MEM_IDE_BUFFER ;where to store data? 230:20870+17 2178 CD4315 call read_lba_sector 231: 232: ;calculate data sector 233: ;multiply cluster by length of cluster 234:20887+4 217B AF xor a ;clear carry 235:20891+13 217C 3ABB43 ld a,(MEM_FAT_CLUSTERLEN) 236:20904+7 217F 0600 ld b,0 237:20911+4 2181 4F ld c,a 238:20915+20 2182 ED5B3144 ld de,(MEM_FAT_OF0_CCLUST) ;load cluster number 239:20935+6 2186 1B dec de ; sub 2 becaus fat starts at 3 240:20941+6 2187 1B dec de 241:20947+17 2188 CDDE22 call _fat_math_mul32 242: ; BCHL contains result -> store to PTR.MEM_FAT_OF0_DATSEC 243:20964+16 218B 223744 ld (MEM_FAT_OF0_DATSEC+0),hl 244:20980+20 218E ED433944 ld (MEM_FAT_OF0_DATSEC+2),bc 245: 246: ; add start of data region to addr 247:21000+10 2192 013744 ld bc,[MEM_FAT_OF0_DATSEC] 248:21010+10 2195 11C143 ld de,[MEM_FAT_DATASTART] 249:21020+17 2198 CDAD22 call _fat_math_add32 ;MEM_FAT_OF0_FATSEC now contains the correct sector 250: ;in the FAT 251: ;MEM_FAT_OF0_DATSEC now has the first sector of the selected cluster 252: 253: ;reset MEM_FAT_OF0_DATREM to default cluster length 254:21037+13 219B 3ABB43 ld a,(MEM_FAT_CLUSTERLEN) 255:21050+4 219E 6F ld l,a 256:21054+7 219F 2600 ld h,0 257:21061+16 21A1 223B44 ld (MEM_FAT_OF0_DATREM), hl 258: 259: ;get next cluster 260: ;calculate offset address 261:21077+13 21A4 3A3144 ld a,(MEM_FAT_OF0_CCLUST) 262:21090+4 21A7 17 RLA ;shift to left (x2) 263:21094+4 21A8 6F ld l, a 264:21098+7 21A9 3E00 ld a,0 265:21105+4 21AB 17 RLA ;shift in carry flag 266:21109+4 21AC 67 ld h,a 267:21113+10 21AD 11B641 ld de,MEM_IDE_BUFFER 268:21123+11 21B0 19 add hl,de 269: ;copy pointer (hl to de) 270:21134+10 21B1 113144 ld de,MEM_FAT_OF0_CCLUST 271:21144+16 21B4 EDA0 ldi ;copy byte for next cluster from FAT 272:21160+16 21B6 EDA0 ldi 273:21176+10 21B8 C9 ret 274: ;store data 275: 276: ;------------------------------------- 277: ; fat_readfilesec 278: ; 279: ; reads single sector of file 280: ; must run fat_readfilesec before to initialize 281: ; if a ix 0x00, success 282: ; if a is 0xFF, end reached 283: ; 284: ; DE contains destination address 285: ;------------------------------------- 286: - 21B9 fat_readfilesec: 287: ;call fat_print_dbg 288:21186+10 21B9 213744 ld hl,[MEM_FAT_OF0_DATSEC] 289:21196+7 21BC 0601 ld b,1 290: ;LD DE, MEM_IDE_BUFFER ;where to store data? 291:21203+17 21BE CD4315 call read_lba_sector ;read sectore 292:21220+10 21C1 213744 ld hl,[MEM_FAT_OF0_DATSEC] ;increment pointer to next sector 293:21230+17 21C4 CD9922 call _fat_increment_32 ;*** 294:21247+16 21C7 2A3B44 ld hl,(MEM_FAT_OF0_DATREM) ;reduce counter 295:21263+4 21CA AF xor a 296:21267+10 21CB 110100 ld de,1 297:21277+15 21CE ED52 sbc hl,de ;decrement counter 298:21292+16 21D0 223B44 ld (MEM_FAT_OF0_DATREM),hl ;store decremented counter 299:21308+5+6 21D3 C0 ret nz ;when not zero, exit function 300: ;if zero: 301:21313+7 21D4 3EFF ld a, 0xFF ;preload error code 302:21320+16 21D6 2A3144 ld hl,(MEM_FAT_OF0_CCLUST) ;check next chunk 303:21336+10 21D9 11FFFF ld de,0xFFFF ;end mark 304:21346+15 21DC ED52 sbc hl,de ;if Z match 305:21361+5+6 21DE C8 ret z ;If 0xFFFF, end is reched. Return 306: ;if next cluster available: 307:21366+4 21DF AF xor a 308:21370+17 21E0 CD3321 call fat_getfatsec ; read next cluster information 309:21387+10 21E3 C9 ret 310: 311: 312: ;------------------------------------- 313: ; fat_openfile 314: ; search for entry in current directory 315: ; 316: ; DE pointer to file name 317: ; sets: 318: ; - MEM_FAT_OF0_CCLUST 319: ; - MEM_FAT_OF0_ATTRIBUTE 320: ; - MEM_FAT_FILEREMAIN 321: ; if a is 0x00, success 322: ; if a is 0xFF, end reached 323: ;------------------------------------- 324: - 21E4 fat_openfile: 325:21397+11 21E4 D5 PUSH DE 326: ;MEM_FAT_TMPFNAME now has valid text to compare 327:21408+10 21E5 21CF43 LD HL,[MEM_FAT_TMPFNAME] 328:21418+17 21E8 CD2523 call format_filename_fat16 329:21435+10 21EB D1 POP DE 330: - 21EC fat_openfile_noprepare: 331:21445+11 21EC D5 PUSH DE 332: ;prepare pointer 333:21456+10 21ED 213F44 ld hl,MEM_FAT_CURRDIR 334:21466+10 21F0 11D140 ld de,MEM_IDE_POINTER 335:21476+16 21F3 EDA0 ldi 336:21492+16 21F5 EDA0 ldi 337:21508+16 21F7 EDA0 ldi 338:21524+16 21F9 EDA0 ldi 339: 340:21540+13 21FB 3ACD43 LD A,(MEM_FAT_DIRSEC) ;init counter for FAT sectors 341:21553+13 21FE 32BC43 LD (MEM_FAT_COUNT1),A 342: 343:21566+10 2201 21D140 LD HL,MEM_IDE_POINTER ;read first sector 344:21576+7 2204 0601 LD B,1 345:21583+10 2206 11B641 LD DE, MEM_IDE_BUFFER ;where to store data? 346:21593+17 2209 CD4315 call read_lba_sector 347: 348:21610+10 220C 21B641 LD HL, MEM_IDE_BUFFER ;set buffer start 349:21620+7 220F 0E10 LD C,16 ;set entries counter 350: 351: - 2211 _fat_lfs_loop: 352:21627+10 2211 11CF43 LD DE,[MEM_FAT_TMPFNAME] 353:21637+17 2214 CD0F23 CALL compare_filename 354:21654+7+5 2217 3836 JR C, _fat_lfs_loop_compare_match ;on match 355: 356: ; prepare next entry 357:21661+4 2219 0D DEC C ;next sector after 16 entries 358:21665+7+5 221A 2807 JR Z,_fat_lfs_loop_compare_next_sector 359:21672+10 221C 112000 LD DE, 32 ;length of entry 360:21682+11 221F 19 ADD HL,DE ;increment 361:21693+10 2220 C31122 JP _fat_lfs_loop 362: 363: - 2223 _fat_lfs_loop_compare_next_sector: 364:21703+10 2223 21D140 ld hl,[MEM_IDE_POINTER] 365:21713+17 2226 CD9922 call _fat_increment_32 ;increment sector 366: 367:21730+13 2229 3ABC43 LD A,(MEM_FAT_COUNT1) ; decrement sector count (max FAT length) 368:21743+4 222C 3D DEC A 369:21747+13 222D 32BC43 LD (MEM_FAT_COUNT1),A 370:21760+10 2230 CA4B22 JP Z, _fat_lfs_loop_compare_end ; if DE is 0, mmax is reached. End here 371: ;call print_a_hex 372: 373:21770+10 2233 21D140 LD HL,MEM_IDE_POINTER ;read next sector 374:21780+7 2236 0601 LD B,1 375:21787+10 2238 11B641 LD DE, MEM_IDE_BUFFER ;where to store data? 376:21797+17 223B CD4315 call read_lba_sector 377: 378:21814+10 223E 21B641 LD HL, MEM_IDE_BUFFER ;set buffer start 379:21824+7 2241 0E10 LD C,16 ;set entries counter 380: 381:21831+7 2243 7E ld a,(HL) 382:21838+4 2244 B7 or a 383:21842+10 2245 CA4B22 jp z, _fat_lfs_loop_compare_end ;skip empty sectors 384: 385:21852+10 2248 C31122 JP _fat_lfs_loop 386: 387: - 224B _fat_lfs_loop_compare_end: 388:21862+10 224B D1 POP DE 389:21872+7 224C 3EFF ld a,0xFF 390:21879+10 224E C9 RET 391: 392: - 224F _fat_lfs_loop_compare_match: 393: ; get entry 394:21889+10 224F D1 POP DE 395: 396: ; HL points to Start of Table item 397:21899+11 2250 E5 PUSH HL 398:21910+14 2251 DDE1 POP IX 399: ; get important information 400:21924+19 2253 DD7E1B ld a,(ix+0x1B) ;first cluster number 401:21943+13 2256 323244 ld (MEM_FAT_OF0_CCLUST+1),a 402:21956+19 2259 DD7E1A ld a,(ix+0x1A) 403:21975+13 225C 323144 ld (MEM_FAT_OF0_CCLUST+0),a 404:21988+19 225F DD7E0B ld a,(ix+0x0B) 405:22007+13 2262 322F44 ld (MEM_FAT_OF0_ATTRIBUTE+0),a 406: 407:22020+4 2265 AF xor a ;clear carry ;set MEM_FAT_OF0_DATREM to remaining sectors 408:22024+19 2266 DD7E1F ld a,(ix+0x1F) ;cluste length shift by 256 409:22043+4 2269 1F rra 410:22047+13 226A 32CB43 ld (MEM_FAT_FILEREMAIN+2),a 411:22060+19 226D DD7E1E ld a,(ix+0x1E) 412:22079+4 2270 1F rra 413:22083+13 2271 32CA43 ld (MEM_FAT_FILEREMAIN+1),a 414:22096+19 2274 DD7E1D ld a,(ix+0x1D) 415:22115+4 2277 1F rra 416:22119+13 2278 32C943 ld (MEM_FAT_FILEREMAIN+0),a 417:22132+7 227B 3E00 ld a,0 418:22139+13 227D 32CC43 ld (MEM_FAT_FILEREMAIN+3),a 419:22152+17 2280 CD3321 call fat_getfatsec ;get sector information 420: 421:22169+4 2283 AF xor a 422:22173+10 2284 C9 RET 423: 424: 425: ;=================== UTIL Functions =========================== 426: ; 32 Bit addition to pointer 427: ; HL has value 428: ;deprecated!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 429: - 2285 _fat_math_sector_add_16: 430:22183+16 2285 22BD43 ld (MEM_FAT_TMPPOINTER), hl 431:22199+4 2288 AF xor a 432:22203+13 2289 32BF43 ld (MEM_FAT_TMPPOINTER+2),a 433:22216+13 228C 32C043 ld (MEM_FAT_TMPPOINTER+3),a 434: 435:22229+10 228F 11BD43 ld de,[MEM_FAT_TMPPOINTER] 436:22239+10 2292 01D140 ld bc,[MEM_IDE_POINTER] 437:22249+17 2295 CDAD22 call _fat_math_add32 438:22266+10 2298 C9 ret 439: ;deprecated!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 440: 441: ;hl contains pointer 442: - 2299 _fat_increment_32 443:22276+7 2299 7E ld a,(HL) ; byte 0 444:22283+7 229A C601 add 1 445:22290+7 229C 77 ld (hl),a 446:22297+6 229D 23 inc hl 447:22303+7 229E 7E ld a,(HL) ; byte 1 448:22310+7 229F CE00 adc 0 449:22317+7 22A1 77 ld (hl),a 450:22324+6 22A2 23 inc hl 451:22330+7 22A3 7E ld a,(HL) ; byte 2 452:22337+7 22A4 CE00 adc 0 453:22344+7 22A6 77 ld (hl),a 454:22351+6 22A7 23 inc hl 455:22357+7 22A8 7E ld a,(HL) ; byte 3 456:22364+7 22A9 CE00 adc 0 457:22371+7 22AB 77 ld (hl),a 458:22378+10 22AC C9 ret 459: ;bc contains pointer to a (also result) 460: ;de contains pointer to b 461: - 22AD _fat_math_add32 462:22388+11 22AD E5 push hl 463:22399+11 22AE C5 push bc 464:22410+11 22AF D5 push de 465:22421+7 22B0 1A ld a,(de) ; load lower 16bit for B int from (DE) to HL 466:22428+4 22B1 6F ld l,a 467:22432+6 22B2 13 inc de 468:22438+7 22B3 1A ld a,(de) 469:22445+4 22B4 67 ld h,a 470:22449+6 22B5 13 inc de 471: ; HL, DE dirty 472:22455+7 22B6 0A ld a,(bc) ; load lower 16bit for A int from (BC) to DE 473:22462+4 22B7 5F ld e,a 474:22466+6 22B8 03 inc bc 475:22472+7 22B9 0A ld a,(bc) 476:22479+4 22BA 57 ld d,a 477: ; HL now contains A, DE now contains D 478:22483+11 22BB 19 add hl,de ;add lower bytes, store carry 479:22494+10 22BC D1 pop de ;restore pointers 480:22504+10 22BD C1 pop bc ;both now cointain first byte of long-value 481:22514+4 22BE 7D ld a,l ;store lower result in (bc) 482:22518+7 22BF 02 ld (bc),a 483:22525+6 22C0 03 inc bc 484:22531+4 22C1 7C ld a,h 485:22535+7 22C2 02 ld (bc),a 486:22542+6 22C3 03 inc bc 487:22548+6 22C4 13 inc de ;also increment de to next byte 488:22554+6 22C5 13 inc de 489: ; DE and HL now start at the upper byte 490:22560+11 22C6 C5 push bc 491:22571+11 22C7 D5 push de 492:22582+7 22C8 1A ld a,(de) ; load upper 16bit for B 493:22589+4 22C9 6F ld l,a 494:22593+6 22CA 13 inc de 495:22599+7 22CB 1A ld a,(de) 496:22606+4 22CC 67 ld h,a 497:22610+6 22CD 13 inc de 498:22616+7 22CE 0A ld a,(bc) ; load upper 16bit for A 499:22623+4 22CF 5F ld e,a 500:22627+6 22D0 03 inc bc 501:22633+7 22D1 0A ld a,(bc) 502:22640+4 22D2 57 ld d,a 503:22644+15 22D3 ED5A adc hl,de ;add upper bytes, store carry 504:22659+10 22D5 D1 pop de 505:22669+10 22D6 C1 pop bc 506:22679+4 22D7 7D ld a,l ;store lower result in (bc) 507:22683+7 22D8 02 ld(bc),a 508:22690+6 22D9 03 inc bc 509:22696+4 22DA 7C ld a,h 510:22700+7 22DB 02 ld(bc),a 511:22707+10 22DC E1 pop hl 512:22717+10 22DD C9 ret 513: 514: 515: ; Multiply 16-bit values (with 32-bit result) 516: ; Operands BC, DE 517: ; Result -> BCHL 518: - 22DE _fat_math_mul32: 519:22727+4 22DE 79 ld a,c 520:22731+4 22DF 48 ld c,b 521:22735+10 22E0 210000 ld hl,0 522:22745+7 22E3 0610 ld b,16 523: - 22E5 _fat_math_mul32_l: 524:22752+11 22E5 29 add hl,hl 525:22763+4 22E6 17 rla 526:22767+8 22E7 CB11 rl c 527:22775+7+5 22E9 3007 jr nc,_fat_math_mul32_noadd 528:22782+11 22EB 19 add hl,de 529:22793+7 22EC CE00 adc a,0 530:22800+10 22EE D2F222 jp nc,_fat_math_mul32_noadd 531:22810+4 22F1 0C inc c 532: - 22F2 _fat_math_mul32_noadd: 533:22814+8+5 22F2 10F1 djnz _fat_math_mul32_l 534:22822+4 22F4 41 ld b,c 535:22826+4 22F5 4F ld c,a 536:22830+10 22F6 C9 ret 537: 538: ; reset LBA pointer to first sector in selected partition 539: - 22F7 fat_reset_pointer: 540:22840+17 22F7 CD1C15 call ideif_get_drv_pointer 541:22857+10 22FA DD23 inc ix 542:22867+10 22FC DD23 inc ix 543:22877+15 22FE DDE5 push ix 544:22892+10 2300 E1 pop hl ;copy poiter to hl 545:22902+10 2301 11D140 ld de, MEM_IDE_POINTER 546:22912+12 2304 1800 jr fat_copy_lba_pointer 547: 548: ; resets LBA pointer (4-byte) to partition start 549: ; HL = from here 550: ; DE = to this destimation 551: - 2306 fat_copy_lba_pointer: 552:22924+11 2306 C5 PUSH BC 553:22935+7 2307 0600 LD B,0 554:22942+7 2309 0E04 LD C,4 555:22949+16+5 230B EDB0 LDIR 556:22965+10 230D C1 POP BC 557:22975+10 230E C9 ret 558: 559: ; compares filenames 560: ; HL points to name1 561: ; DE points to name2 562: ; Carry is set if match 563: ; Destroys DE, AF 564: - 230F compare_filename: 565:22985+11 230F E5 PUSH HL 566:22996+11 2310 C5 push BC 567:23007+7 2311 060B LD B, 11 ;Counter 568: - 2313 _compare_filename_loop: 569:23014+7 2313 1A LD A,(DE) 570:23021+4 2314 4F LD C,A 571:23025+7 2315 7E LD A,(HL) 572:23032+6 2316 23 INC HL 573:23038+6 2317 13 INC DE 574:23044+4 2318 A9 XOR C ;check if identical (should return 0) 575:23048+7+5 2319 2006 JR NZ, _compare_filename_nomatch 576:23055+8+5 231B 10F6 djnz _compare_filename_loop ;if not last, continue 577:23063+10 231D C1 POP BC 578:23073+10 231E E1 POP HL 579:23083+4 231F 37 SCF 580:23087+10 2320 C9 RET 581: - 2321 _compare_filename_nomatch: 582:23097+10 2321 C1 POP BC 583:23107+10 2322 E1 POP HL 584:23117+4 2323 AF XOR A ; clear carry flag 585:23121+10 2324 C9 RET 586: 587: ; formats filename to 8+3 format 588: ; DE points to source filename to string 589: ; HL points to destination 590: - 2325 format_filename_fat16: 591:23131+7 2325 060B LD B, 11 ;counter 592:23138+11 2327 E5 PUSH HL 593:23149+7 2328 3E20 LD A, ' ' 594: - 232A _format_filename_fat16_clean: 595:23156+7 232A 77 LD (HL),A 596:23163+6 232B 23 INC HL 597:23169+8+5 232C 10FC DJNZ _format_filename_fat16_clean 598:23177+10 232E E1 POP HL ; continue with copy 599:23187+7 232F 060D LD B, 13 600: - 2331 _format_filename_fat16_loop: 601:23194+7 2331 1A LD A, (DE) ; load byte 602:23201+4 2332 B7 OR A 603:23205+5+6 2333 C8 RET Z ;exit on 0byte 604:23210+4 2334 05 DEC B ;reduce counter 605:23214+5+6 2335 C8 RET Z ;exit after 12 bytes 8+.+3 606:23219+7 2336 FE2E CP '.' ; check if dot 607:23226+7+5 2338 200A JR NZ, _format_filename_fat16_loop_copy ; if not continue as usual 608:23233+6 233A 13 INC DE ;else skip char 609: - 233B _format_filename_fat16_loop_skip_8: 610:23239+4 233B 78 LD A,B 611:23243+7 233C FE05 CP 5 612:23250+7+5 233E 38F1 JR C, _format_filename_fat16_loop 613:23257+6 2340 23 INC HL 614:23263+4 2341 05 DEC B 615:23267+12 2342 18F7 JR _format_filename_fat16_loop_skip_8 616: 617: - 2344 _format_filename_fat16_loop_copy: 618:23279+7 2344 1A LD A, (DE) ; load byte 619:23286+7 2345 77 LD (HL), A ; copy byte 620:23293+6 2346 23 INC HL 621:23299+6 2347 13 INC DE **** main.asm **** 197:23305+10 2348 C33123 JP _format_filename_fat16_loop 198: .include "fat16_cmd.s" **** include/fat16_cmd.s **** 1: ;------------------------------------- 2: ; Print current fat directory of MEM_FAT_CURRDIR 3: ;------------------------------------- 4: - 234B fat_print_directory: 5:23315+10 234B 213F44 ld hl,MEM_FAT_CURRDIR 6:23325+10 234E 11D140 ld de,MEM_IDE_POINTER 7:23335+16 2351 EDA0 ldi 8:23351+16 2353 EDA0 ldi 9:23367+16 2355 EDA0 ldi 10:23383+16 2357 EDA0 ldi 11: 12:23399+20 2359 ED5BB943 LD DE,(MEM_FAT_SECTORS) 13:23419+20 235D ED53BC43 LD (MEM_FAT_COUNT1),DE 14:23439+10 2361 21D140 LD HL,MEM_IDE_POINTER ;read first sector 15:23449+7 2364 0601 LD B,1 16:23456+10 2366 11B641 LD DE, MEM_IDE_BUFFER ;where to store data? 17:23466+17 2369 CD4315 call read_lba_sector 18: 19:23483+17 236C CD9101 call PRINTINLINE 20: - 236F 0A0D2020 db 10,13," Filename Cluster Size",10,13,0 46696C65 6E616D65 20202020 20436C75 73746572 2053697A 650A0D00 21: 22:23500+10 238F 21B641 LD HL, MEM_IDE_BUFFER ;set buffer start 23:23510+7 2392 0E10 LD C,16 ;set entries counter 24: 25: - 2394 _fat_print_directory_loop: ;loop over each entry (32byte) 26:23517+7 2394 7E LD A,(HL) ; check first byte 27:23524+11 2395 E5 PUSH HL ;backup start of entry 28:23535+14 2396 DDE1 POP IX 29:23549+11 2398 E5 PUSH HL 30: ;ignore unwanted entries 31:23560+7 2399 FE41 CP 0x41 ;skip invisible 32:23567+10 239B CA2C24 JP Z, _fat_print_directory_loop_next 33:23577+7 239E FEE5 CP 0xE5 ;skip deleted 34:23584+10 23A0 CA2C24 JP Z, _fat_print_directory_loop_next 35:23594+7 23A3 FE00 CP 0x00 ;reached end 36:23601+10 23A5 CA5E24 JP Z, _fat_print_directory_loop_break 37: 38: ;check file attribute 39:23611+19 23A8 DD7E0B ld a,(IX+0x0B) 40:23630+7 23AB FE10 cp 0x10 ;if subdirectors 41:23637+10 23AD CA0124 jp z, _fat_print_directory_dir ;print dir 42: ;else print file 43: - 23B0 _fat_print_directory_loop_file 44: ;print filename 45:23647+7 23B0 3E20 ld a,' ' 46:23654+17 23B2 CDDE00 call print_char 47:23671+7 23B5 3E20 ld a,' ' 48:23678+17 23B7 CDDE00 call print_char 49:23695+7 23BA 0608 LD B,8 50:23702+17 23BC CD7B18 call print_str_fixed 51:23719+7 23BF 3E2E ld A,'.' 52:23726+17 23C1 CDDE00 call print_char 53:23743+7 23C4 0603 LD B,3 54:23750+17 23C6 CD7B18 call print_str_fixed 55: 56:23767+17 23C9 CD9101 call PRINTINLINE 57: - 23CC 20307800 db " 0x",0 58: ;first cluster number 59:23784+19 23D0 DD7E1B ld a,(ix+0x1B) 60:23803+17 23D3 CD0E01 call print_a_hex 61:23820+19 23D6 DD7E1A ld a,(ix+0x1A) 62:23839+17 23D9 CD0E01 call print_a_hex 63:23856+17 23DC CD9101 call PRINTINLINE 64: - 23DF 20203078 db " 0x",0 00 65:23873+19 23E4 DD7E1F ld a,(ix+0x1F) 66:23892+17 23E7 CD0E01 call print_a_hex 67:23909+19 23EA DD7E1E ld a,(ix+0x1E) 68:23928+17 23ED CD0E01 call print_a_hex 69:23945+19 23F0 DD7E1D ld a,(ix+0x1D) 70:23964+17 23F3 CD0E01 call print_a_hex 71:23981+19 23F6 DD7E1C ld a,(ix+0x1C) 72:24000+17 23F9 CD0E01 call print_a_hex 73:24017+17 23FC CDF800 call print_newLine 74:24034+12 23FF 182B jr _fat_print_directory_loop_next 75: - 2401 _fat_print_directory_dir 76:24046+7 2401 3E44 ld a,'D' 77:24053+17 2403 CDDE00 call print_char 78:24070+7 2406 3E20 ld a,' ' 79:24077+17 2408 CDDE00 call print_char 80:24094+7 240B 0608 LD B,8 81:24101+17 240D CD7B18 call print_str_fixed 82:24118+17 2410 CD9101 call PRINTINLINE 83: - 2413 20202020 db " 0x",0 20307800 84: ;first cluster number 85:24135+19 241B DD7E1B ld a,(ix+0x1B) 86:24154+17 241E CD0E01 call print_a_hex 87:24171+19 2421 DD7E1A ld a,(ix+0x1A) 88:24190+17 2424 CD0E01 call print_a_hex 89:24207+17 2427 CDF800 call print_newLine 90:24224+12 242A 1800 jr _fat_print_directory_loop_next 91: 92: - 242C _fat_print_directory_loop_next: ; read next entry 93:24236+4 242C 0D DEC C ;next sector after 32 entries 94:24240+7+5 242D 2808 JR Z,_fat_print_directory_loop_next_sector 95:24247+10 242F E1 POP HL ;restore start 96:24257+10 2430 112000 LD DE, 32 ;length of entry 97:24267+11 2433 19 ADD HL,DE ;increment 98:24278+10 2434 C39423 JP _fat_print_directory_loop 99: 100: - 2437 _fat_print_directory_loop_next_sector: ; end fo sector. read next sector from disk 101:24288+10 2437 E1 POP HL ;clear stack from old hl 102:24298+7 2438 2600 LD H,0 103:24305+7 243A 2E01 LD L,1 104:24312+17 243C CD8522 call _fat_math_sector_add_16 ;increment sector 105: 106:24329+20 243F ED5BBC43 LD DE,(MEM_FAT_COUNT1) ; decrement sector count (max FAT length) 107:24349+6 2443 1B DEC DE 108:24355+20 2444 ED53BC43 LD (MEM_FAT_COUNT1),DE 109:24375+4 2448 7A LD A,D 110:24379+4 2449 B3 OR E 111:24383+5+6 244A C8 RET Z ; if DE is 0, mmax is reached. End here 112: 113:24388+10 244B 21D140 LD HL,MEM_IDE_POINTER ;read next sector 114:24398+7 244E 0601 LD B,1 115: 116:24405+10 2450 11B641 LD DE, MEM_IDE_BUFFER ;where to store data? 117:24415+17 2453 CD4315 call read_lba_sector 118: 119:24432+10 2456 21B641 LD HL, MEM_IDE_BUFFER ;set buffer start 120:24442+7 2459 0E10 LD C,16 ;set entries counter 121:24449+10 245B C39423 JP _fat_print_directory_loop 122: 123: - 245E _fat_print_directory_loop_break 124:24459+10 245E E1 POP HL 125:24469+10 245F C9 ret 126: 127: ;------------------------------------- 128: ; Changes current fat directory of MEM_FAT_CURRDIR 129: ; input is relativ path 130: ; DE points to path 131: ;------------------------------------- 132: - 2460 fat_cd_single: 133:24479+11 2460 D5 push de 134: ; check if user wants to go back (input = '..') 135:24490+7 2461 1A ld a,(de) 136:24497+7 2462 FE2E cp '.' 137:24504+7+5 2464 205E jr nz, _fat_cd_navigate; if not, skip 138:24511+6 2466 13 inc de ;check next 139:24517+7 2467 1A ld a,(de) 140:24524+7 2468 FE2E cp '.' 141:24531+7+5 246A 2058 jr nz, _fat_cd_navigate; if not, skip 142:24538+13 246C 3A7A40 ld a,(var_dir+79) ;last byte contains depth 143:24551+4 246F B7 or a; Test if 0 144:24555+10 2470 CA1C25 jp z, _fat_cd_navigate_error ;cannot go back any more (already at root) 145: ; check if .. exists in directory 146:24565+7 2473 3E2E ld a,'.' ;prepare filename buffer 147:24572+10 2475 21CF43 ld hl,[MEM_FAT_TMPFNAME] 148:24582+7 2478 77 ld (hl),a 149:24589+6 2479 23 inc hl 150:24595+7 247A 77 ld (hl),a 151:24602+6 247B 23 inc hl 152:24608+7 247C 3E20 ld a,0x20 ;clear char 3-11 153:24615+7 247E 060B ld b,11 154: - 2480 _fat_cd_navigate_goback_fl: 155:24622+7 2480 77 ld (hl),a 156:24629+6 2481 23 inc hl 157:24635+8+5 2482 10FC djnz _fat_cd_navigate_goback_fl ;fill loop end 158:24643+17 2484 CDEC21 call fat_openfile_noprepare ;load file table (only 1st sector needed) 159:24660+4 2487 B7 or a ;check for error 160:24664+10 2488 C21C25 jp nz, _fat_cd_navigate_error ;entry not found exception 161: 162: 163: ; find end of path 164:24674+10 248B 212E40 ld hl,[var_dir+3] ;current position 165:24684+10 248E 014C00 ld bc,76 166:24694+7 2491 3E00 ld a,0x00 ;termination char 167:24701+16+5 2493 EDB1 cpir ;find end 168:24717+10 2495 E22A25 jp po,_fat_cd_navigate_inerror ;in case of error, abort 169: ;hl is now at end of string 170:24727+10 2498 014C00 ld bc,76 171:24737+7 249B 3E5C ld a,'\' ;seperation char 172:24744+16+5 249D EDB9 cpdr ;serach backwards for "/" 173:24760+10 249F E22A25 jp po,_fat_cd_navigate_inerror ;in case of error, abort 174: ;hl is now at end of string 175:24770+6 24A2 23 inc hl 176:24776+4 24A3 AF xor a 177:24780+7 24A4 77 ld (hl),a ;set termination char 178:24787+6 24A5 23 inc hl 179:24793+7 24A6 77 ld (hl),a ;set termination char 180:24800+13 24A7 3A7A40 ld a,(var_dir+79) 181:24813+4 24AA 3D dec a 182:24817+13 24AB 327A40 ld (var_dir+79),a ;decrement dir depth counter 183: 184:24830+10 24AE D1 pop de 185: 186:24840+10 24AF 212D40 ld hl,[var_dir+2] 187:24850+7 24B2 3E5C ld a,'\' 188:24857+7 24B4 77 ld (hl),a ;set first / 189: 190:24864+10 24B5 213744 ld hl,MEM_FAT_OF0_DATSEC ;setup directory pointer 191:24874+10 24B8 113F44 ld de,MEM_FAT_CURRDIR 192:24884+16 24BB EDA0 ldi 193:24900+16 24BD EDA0 ldi 194:24916+16 24BF EDA0 ldi 195:24932+16 24C1 EDA0 ldi 196: 197:24948+10 24C3 C9 ret 198: 199: - 24C4 _fat_cd_navigate 200:24958+10 24C4 D1 pop de ;get pointer to directory namme 201:24968+11 24C5 D5 push de ;and re-store it for next use 202:24979+17 24C6 CDE421 call fat_openfile ;find 'file' in current directory 203: - 24C9 _fat_cd_navigate_findsec 204:24996+4 24C9 B7 or a 205:25000+10 24CA C21C25 jp nz, _fat_cd_navigate_error ;entry not found 206:25010+13 24CD 3A2F44 ld a, (MEM_FAT_OF0_ATTRIBUTE) 207:25023+7 24D0 FE10 cp 0x10 208:25030+10 24D2 C23225 jp nz, _fat_cd_navigate_errfile 209:25040+13 24D5 3A7A40 ld a,(var_dir+79) 210:25053+4 24D8 3C inc a 211:25057+13 24D9 327A40 ld (var_dir+79),a ;increment dir depth counter 212:25070+10 24DC 212D40 ld hl,[var_dir+2] ;load start of path string 213:25080+7 24DF 3E00 ld a,0 ;load termination char 214:25087+10 24E1 014C00 ld bc,76 ;max length of string 215:25097+16+5 24E4 EDB1 cpir ;find end of path string 216:25113+6 24E6 2B dec hl 217:25119+10 24E7 E22A25 jp po,_fat_cd_navigate_inerror ;in case of error, abort 218: ;HL now has last element, BC has remaining max length 219:25129+13 24EA 3A7A40 ld a,(var_dir+79) ;last byte contains depth 220:25142+7 24ED FE01 cp 1 ;if first path, skip / 221:25149+7+5 24EF 2804 jr z, _fat_cd_navigate_findsec_skipslash 222:25156+7 24F1 3E5C ld a,'\' 223:25163+7 24F3 77 ld (hl),a 224:25170+6 24F4 23 inc hl 225: - 24F5 _fat_cd_navigate_findsec_skipslash 226:25176+10 24F5 D1 pop de ;get argument from stack 227:25186+4 24F6 EB ex de,hl 228:25190+11 24F7 D5 push de ;store start to stack 229: ;HL now has start of input string, DE has end of current path 230:25201+10 24F8 010900 ld bc,09 ;maximum length of directory name +1 231: - 24FB _fat_cd_navigate_l2: ;copy new subdirectory 232:25211+16 24FB EDA0 ldi ;copy 233:25227+10 24FD E22425 jp po,_fat_cd_navigate_inerrorS ;in case of error, abort 234:25237+7 2500 7E ld a,(hl) ;check next char 235:25244+7 2501 FE5C cp '\' ;end at '\' 236:25251+7+5 2503 2805 jr z, _fat_cd_navigate_end ;else next byte 237:25258+4 2505 B7 or a ;or and at 0x00 238:25262+7+5 2506 2802 jr z, _fat_cd_navigate_end ;else next byte 239:25269+12 2508 18F1 jr _fat_cd_navigate_l2 240: - 250A _fat_cd_navigate_end: 241:25281+4 250A AF xor a 242:25285+7 250B 12 ld (de),a ;set last byte to 0x00 (termination) 243:25292+10 250C 213744 ld hl,MEM_FAT_OF0_DATSEC 244: ;setup directory pointer 245:25302+10 250F 113F44 ld de,MEM_FAT_CURRDIR 246:25312+16 2512 EDA0 ldi 247:25328+16 2514 EDA0 ldi 248:25344+16 2516 EDA0 ldi 249:25360+16 2518 EDA0 ldi 250:25376+10 251A D1 pop de ;stack cleanup 251:25386+10 251B C9 ret 252: 253: - 251C _fat_cd_navigate_error: 254:25396+10 251C 213A25 ld hl,[_fat_cd_navigate_error_str] 255:25406+17 251F CDE600 call print_str 256:25423+10 2522 D1 pop de 257:25433+10 2523 C9 ret 258: 259: - 2524 _fat_cd_navigate_inerrorS: ;with path reset 260:25443+10 2524 D1 pop de ;restore former path 261:25453+6 2525 1B dec de ;change pointer to remove previous '\' as well 262:25459+4 2526 AF xor a ;clear a to 0x00 263:25463+7 2527 12 ld (de),a ;set last byte to 0x00 (termination) 264:25470+12 2528 1801 jr _fat_cd_navigate_inerrore 265: - 252A _fat_cd_navigate_inerror: ;without path reset 266:25482+10 252A D1 pop de 267: - 252B _fat_cd_navigate_inerrore: 268:25492+10 252B 215125 ld hl,[_fat_cd_navigate_inputerr_str] 269:25502+17 252E CDE600 call print_str 270:25519+10 2531 C9 ret 271: - 2532 _fat_cd_navigate_errfile: 272:25529+10 2532 D1 pop de 273:25539+10 2533 216425 ld hl,[_fat_cd_navigate_errfile_str] 274:25549+17 2536 CDE600 call print_str 275:25566+10 2539 C9 ret 276: 277: - 253A _fat_cd_navigate_error_str: 278: - 253A 0A0D4E6F db 10,13,"No such directory!",10,13,0 20737563 68206469 72656374 6F727921 0A0D00 279: - 2551 _fat_cd_navigate_inputerr_str: 280: - 2551 0A0D496E db 10,13,"Invalid input!",10,13,0 76616C69 6420696E 70757421 0A0D00 281: - 2564 _fat_cd_navigate_errfile_str: 282: - 2564 0A0D4361 db 10,13,"Cannot cd to file!",10,13,0 6E6E6F74 20636420 746F2066 696C6521 0A0D00 283: 284: - 257B fat_exec: 285:25576+11 257B D5 push de 286: ;DE has pointer to arguments 287:25587+17 257C CDE421 call fat_openfile 288:25604+4 257F B7 or a 289:25608+10 2580 C21226 jp nz, _fat_exec_notfound ;if not found, abort 290: ;call fat_print_dbg 291: ;load header 292:25618+10 2583 11B641 ld de, MEM_IDE_BUFFER 293:25628+17 2586 CDB921 call fat_readfilesec 294: 295: 296: ;ld hl, MEM_IDE_BUFFER ;print sector 297: ;ld b,0x20 298: ;call dump_pretty 299: 300:25645+13 2589 3AB641 ld a,(MEM_IDE_BUFFER) 301:25658+7 258C FEC3 cp 0xC3 302:25665+10 258E C22B26 jp nz, _fat_exec_notexec 303: 304:25675+17 2591 CD9101 call PRINTINLINE 305: - 2594 0A0D4C6F db 10,13,"Loading ",0 6164696E 672000 306:25692+10 259F 218140 ld hl,[var_input+6] 307:25702+17 25A2 CDE600 call print_str 308:25719+17 25A5 CD9101 call PRINTINLINE 309: - 25A8 20746F20 db " to 0x",0 307800 310: ;get start address 311:25736+20 25AF ED4BC041 ld bc,(MEM_IDE_BUFFER + 10) 312:25756+4 25B3 78 ld a,b 313:25760+17 25B4 CD0E01 call print_a_hex 314:25777+4 25B7 79 ld a,c 315:25781+17 25B8 CD0E01 call print_a_hex 316:25798+17 25BB CD9101 call PRINTINLINE 317: - 25BE 202E2E2E db " ... ",0 2000 318: ;bc has start addr 319:25815+20 25C4 ED434344 ld (MEM_FAT_EXEC_CURR),bc 320:25835+20 25C8 ED434744 ld (MEM_FAT_EXEC_START),bc 321: 322: ;get amount of sectors to load 323:25855+16 25CC 2AC441 ld hl,(MEM_IDE_BUFFER + 14) 324:25871+4 25CF 6C ld l,h 325:25875+8 25D0 CB3D srl l 326:25883+7 25D2 2600 ld h,0 ;divide by 512 327:25890+6 25D4 23 inc hl ;increment because first sector is always loaded 328: ; hl contains sector count 329:25896+16 25D5 224544 ld (MEM_FAT_EXEC_COUNT), hl 330: 331:25912+10 25D8 D1 pop de ; restore filename 332:25922+17 25D9 CDE421 call fat_openfile ;reset file information 333: ;start reading 334: - 25DC _fat_exec_readloop1: 335:25939+20 25DC ED5B4344 ld de,(MEM_FAT_EXEC_CURR) 336:25959+17 25E0 CDB921 call fat_readfilesec 337:25976+16 25E3 2A4344 ld hl,(MEM_FAT_EXEC_CURR) 338:25992+10 25E6 110002 ld de,512 339:26002+11 25E9 19 add hl,de 340:26013+16 25EA 224344 ld (MEM_FAT_EXEC_CURR),hl 341: 342:26029+16 25ED 2A4544 ld hl,(MEM_FAT_EXEC_COUNT) 343:26045+6 25F0 2B dec hl 344:26051+16 25F1 224544 ld (MEM_FAT_EXEC_COUNT),hl 345:26067+4 25F4 7C ld a,h 346:26071+4 25F5 B5 or l 347:26075+7+5 25F6 2802 jr z, _fat_exec_read_done 348:26082+12 25F8 18E2 jr _fat_exec_readloop1 349: - 25FA _fat_exec_read_done: 350:26094+17 25FA CD9101 call PRINTINLINE 351: - 25FD 4C6F6164 db "Load complete!",10,13,0 20636F6D 706C6574 65210A0D 00 352:26111+16 260E 2A4744 ld hl,(MEM_FAT_EXEC_START) 353:26127+4 2611 E9 jp (hl) 354: 355: 356: - 2612 _fat_exec_notfound: 357:26131+10 2612 D1 pop de 358:26141+17 2613 CD9101 call PRINTINLINE 359: - 2616 0A0D4669 db 10,13,"File not found!",10,13,0 6C65206E 6F742066 6F756E64 210A0D00 360:26158+10 262A C9 ret 361: 362: - 262B _fat_exec_notexec: 363:26168+10 262B D1 pop de 364:26178+17 262C CD9101 call PRINTINLINE 365: - 262F 0A0D4669 db 10,13,"File is not an executable!",10,13,0 6C652069 73206E6F 7420616E 20657865 63757461 626C6521 0A0D00 **** main.asm **** 199:26195+10 264E C9 ret 200: 201: ;================================================================ 202: ; Strings 203: ;================================================================ 204: - 264F STR_Banner_Start: 205: - 264F 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 559 symbols 10756 bytes Symbol Table: ADDR_RTC =D0 208 A_RTS_OFF 17F 383 A_RTS_ON 188 392 BOOT_PHASE0 50 80 BOOT_PHASE1 6E 110 BOOT_PHASE1_LOOP 77 119 BOOT_PHASE2 89 137 COMMAND 1915 6421 COMMAND_BACKSPACE 1956 6486 COMMAND_LUT 1883 6275 COMMAND_PROCESS 197C 6524 COMMAND_PROCESS_FOUND 19B7 6583 COMMAND_PROCESS_LOOP 197F 6527 COMMAND_PROCESS_LOOP_STR1 1988 6536 COMMAND_PROCESS_LOOP_STR2 199E 6558 COMMAND_PROCESS_NEXT_ENTRY 19A3 6563 COMMAND_PROCESS_NEXT_ENTRYI 19A2 6562 COMMAND_PROCESS_NOT_FOUND 19AE 6574 COMMAND_READ 1927 6439 CONSOLE_INIT A5 165 CONSOLE_INIT_CTC A5 165 CONSOLE_INIT_SIO AD 173 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 1F6 502 DHEX_TO_BYTE_FAILED 212 530 ERR_SYNTAX 19CD 6605 EXEC_RST_08 D96 3478 EXEC_RST_10 D9A 3482 EXEC_RST_18 DA6 3494 HEX_TO_BIN 216 534 HEX_TO_BIN_2 224 548 HEX_TO_INVALID_2 22B 555 IDE_CMD_IDENT =EC 236 IDE_CMD_READSEC=20 32 IDE_DEV_TABLE 12FA 4858 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 43B8 17336 MEM_FAT_CLUSTERLEN 43BB 17339 MEM_FAT_COUNT1 43BC 17340 MEM_FAT_CURDIR 43DF 17375 MEM_FAT_CURRDIR 443F 17471 MEM_FAT_DATASTART 43C1 17345 MEM_FAT_DIRSEC 43CD 17357 MEM_FAT_EXEC_COUNT 4445 17477 MEM_FAT_EXEC_CURR 4443 17475 MEM_FAT_EXEC_START 4447 17479 MEM_FAT_FILEREMAIN 43C9 17353 MEM_FAT_OF0_ATTRIBUTE 442F 17455 MEM_FAT_OF0_CCLUST 4431 17457 MEM_FAT_OF0_DATREM 443B 17467 MEM_FAT_OF0_DATSEC 4437 17463 MEM_FAT_OF0_FATSEC 4433 17459 MEM_FAT_RESERVED 43B6 17334 MEM_FAT_ROOTSTART 43C5 17349 MEM_FAT_SECTORS 43B9 17337 MEM_FAT_TMPFNAME 43CF 17359 MEM_FAT_TMPPOINTER 43BD 17341 MEM_IDE_BUFFER 41B6 16822 MEM_IDE_DEVICE 40CB 16587 MEM_IDE_DEV_TABLE 40D5 16597 MEM_IDE_FSBUFFER 43B6 17334 MEM_IDE_PARTITION 40CD 16589 MEM_IDE_POINTER 40D1 16593 MEM_IDE_SELECTED 4115 16661 MEM_IDE_STATUS 40CC 16588 MEM_IDE_STRING_0 4116 16662 MEM_IDE_STRING_1 413E 16702 MEM_IDE_STRING_2 4166 16742 MEM_IDE_STRING_3 418E 16782 MSG_CLEAR 177 375 NOT_IMPLEMENTED 19C6 6598 OP_CALL 1A28 6696 OP_CD 1DF8 7672 OP_CLR 1BBC 7100 OP_DASM 1AA9 6825 OP_DIR 1DF4 7668 OP_DUMP 1A48 6728 OP_EXEC 1A0F 6671 OP_FSEXEC 1E15 7701 OP_IIC_IN 1B70 7024 OP_IIC_OUT 1B10 6928 OP_IO_IN 1AD9 6873 OP_IO_OUT 1AEF 6895 OP_LSDSK 1DD1 7633 OP_RTIME 1BC0 7104 OP_SELDSK 1DD5 7637 OP_SET 1A78 6776 OP_STIME 1D58 7512 POST_CHECK_APU 1E4E 7758 POST_CHECK_IDE_30 1E79 7801 POST_CHECK_IDE_40 1E8C 7820 POST_CHECK_PIO 1E29 7721 POST_START 1E19 7705 POST_TEST_RTC 1EA6 7846 PRG_RAM_START =4110 16656 PRG_RAM_TOP =FF00 65280 PRINTINLINE 191 401 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 22D 557 STRCONV_BYTES_TO_HEX_1 23C 572 STRCONV_BYTES_TO_HEX_2 246 582 STR_Banner_Start 264F 9807 STR_PD_HEADER 183C 6204 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 19C5 6597 _OP_CALL 1A47 6727 _OP_IIC_ACK_ERR 1B55 6997 _OP_IIC_ACK_ERR_str 1B5C 7004 _OP_IIC_IN_LOOP 1BA2 7074 _OP_IIC_IN_LOOP_TEXT 1BAF 7087 _OP_IIC_OUT_LOOP 1B26 6950 _OP_IIC_OUT_SEND 1B42 6978 _OP_RTIME_NN 1BC3 7107 _OP_RTIME_RD_CMD 1C7B 7291 _OP_SELDSK_INVALID 1DE4 7652 _OP_SELDSK_INVALID_STR 1DFC 7676 _OP_SET_LOOP 1A90 6800 _OP_STIME_INVALID 1D1E 7454 _OP_STIME_PROMPT 1D35 7477 _OP_STIME_PROMPT_ERR 1D4D 7501 _OP_STIME_STR_DAY 1C7C 7292 _OP_STIME_STR_HOUR 1CCD 7373 _OP_STIME_STR_MIN 1CE8 7400 _OP_STIME_STR_MON 1C97 7319 _OP_STIME_STR_SEC 1D03 7427 _OP_STIME_STR_YEAR 1CB2 7346 _POST_CHECK_APU_FAILED 1E6D 7789 _POST_CHECK_IDE_FAILED 1E9F 7839 _POST_CHECK_PIO_FAILED 1E42 7746 _POST_TEST_RTC_INVALID 1EE0 7904 _POST_TEST_RTC_NOTFOUND 1ED9 7897 _STR_NOT_FOUND 19E8 6632 _STR_NOT_IMPLEMENTED 19D4 6612 _STR_SYNTAX 19FC 6652 _beep_pause_l1 DC2 3522 _compare_filename_loop 2313 8979 _compare_filename_nomatch 2321 8993 _fat_cd_navigate 24C4 9412 _fat_cd_navigate_end 250A 9482 _fat_cd_navigate_errfile 2532 9522 _fat_cd_navigate_errfile_str 2564 9572 _fat_cd_navigate_error 251C 9500 _fat_cd_navigate_error_str 253A 9530 _fat_cd_navigate_findsec 24C9 9417 _fat_cd_navigate_findsec_skipslash 24F5 9461 _fat_cd_navigate_goback_fl 2480 9344 _fat_cd_navigate_inerror 252A 9514 _fat_cd_navigate_inerrorS 2524 9508 _fat_cd_navigate_inerrore 252B 9515 _fat_cd_navigate_inputerr_str 2551 9553 _fat_cd_navigate_l2 24FB 9467 _fat_exec_notexec 262B 9771 _fat_exec_notfound 2612 9746 _fat_exec_read_done 25FA 9722 _fat_exec_readloop1 25DC 9692 _fat_get_root_table_invalid 210B 8459 _fat_getfatsec_notroot 214A 8522 _fat_increment_32 2299 8857 _fat_lfs_loop 2211 8721 _fat_lfs_loop_compare_end 224B 8779 _fat_lfs_loop_compare_match 224F 8783 _fat_lfs_loop_compare_next_sector 2223 8739 _fat_math_add32 22AD 8877 _fat_math_mul32 22DE 8926 _fat_math_mul32_l 22E5 8933 _fat_math_mul32_noadd 22F2 8946 _fat_math_sector_add_16 2285 8837 _fat_print_directory_dir 2401 9217 _fat_print_directory_loop 2394 9108 _fat_print_directory_loop_break 245E 9310 _fat_print_directory_loop_file 23B0 9136 _fat_print_directory_loop_next 242C 9260 _fat_print_directory_loop_next_sector 2437 9271 _format_filename_fat16_clean 232A 9002 _format_filename_fat16_loop 2331 9009 _format_filename_fat16_loop_copy 2344 9028 _format_filename_fat16_loop_skip_8 233B 9019 _ideif_drv_sel_fail 15AB 5547 _ideif_drv_sel_fstr0 1668 5736 _ideif_drv_sel_pstr 165F 5727 _ideif_drv_sel_sstr0 1676 5750 _ideif_drv_sel_syn 1683 5763 _ideif_init_drive_found 146E 5230 _ideif_init_drive_loop 1456 5206 _ideif_init_drive_nodrv 1469 5225 _ideif_init_drive_prt_fnd 14D9 5337 _ideif_init_drive_prt_l1 14C7 5319 _ideif_init_drive_prt_ln 14D1 5329 _ideif_prnt_devtable_hdr 15EB 5611 _ideif_prnt_devtable_l1 1366 4966 _ideif_prnt_devtable_l1_e2 142C 5164 _ideif_prnt_devtable_l1_es 13AB 5035 _ideif_prnt_devtable_l1_ms 1429 5161 _ideif_prnt_devtable_l1_nxt 1373 4979 _ideif_prnt_devtable_l1_s00 1399 5017 _ideif_prnt_devtable_l1_s01 139E 5022 _ideif_prnt_devtable_l1_s02 13A3 5027 _ideif_prnt_devtable_l1_sFF 13A8 5032 _ideif_prnt_devtable_l1_sel 1371 4977 _ideif_prnt_devtable_master 164F 5711 _ideif_prnt_devtable_s00 1623 5667 _ideif_prnt_devtable_s01 162E 5678 _ideif_prnt_devtable_s02 1639 5689 _ideif_prnt_devtable_sFF 1644 5700 _ideif_prnt_devtable_slave 1657 5719 _read_bcd_invalid 14E 334 _shift4 1DCC 7628 beep DA9 3497 beep_loop DAB 3499 beep_pause DC1 3521 compare_filename 230F 8975 dasm_00 9AE 2478 dasm_01 C9A 3226 dasm_02 A34 2612 dasm_03 C6C 3180 dasm_08 AB1 2737 dasm_09 C3F 3135 dasm_0A A16 2582 dasm_0B C83 3203 dasm_10 9F6 2550 dasm_12 A3F 2623 dasm_18 9B9 2489 dasm_1A A20 2592 dasm_20 9D3 2515 dasm_22 CE0 3296 dasm_27 A79 2681 dasm_28 9CC 2508 dasm_2A CB1 3249 dasm_2F A7D 2685 dasm_30 9C4 2500 dasm_32 A4A 2634 dasm_37 A89 2697 dasm_38 9BD 2493 dasm_3A A2A 2602 dasm_3F A85 2693 dasm_76 A8D 2701 dasm_80C6 B0A 2826 dasm_BE AA7 2727 dasm_C3 9B2 2482 dasm_C88E B30 2864 dasm_C9 A02 2562 dasm_CD 9FC 2556 dasm_D9 ABE 2750 dasm_DD 9E4 2532 dasm_DD_01 CA1 3233 dasm_DD_09 C5A 3162 dasm_DD_22 CF6 3318 dasm_DD_23 C71 3185 dasm_DD_2A CC8 3272 dasm_DD_2B C88 3208 dasm_DD_34 C0A 3082 dasm_DD_35 C27 3111 dasm_DD_86 B12 2834 dasm_DD_8E B38 2872 dasm_DD_96 B5B 2907 dasm_DD_9E B7B 2939 dasm_DD_A6 B9C 2972 dasm_DD_AE BD3 3027 dasm_DD_B6 BB8 3000 dasm_DD_BE BEF 3055 dasm_DD_E1 D48 3400 dasm_DD_E3 ACE 2766 dasm_DD_E5 D32 3378 dasm_DD_F9 D18 3352 dasm_E1 D42 3394 dasm_E3 AC2 2754 dasm_E5 D2C 3372 dasm_E9 9DB 2523 dasm_ED_42 C51 3153 dasm_ED_43 CEC 3308 dasm_ED_44 A81 2689 dasm_ED_45 A0C 2572 dasm_ED_46 A98 2712 dasm_ED_4A C48 3144 dasm_ED_4B CBD 3261 dasm_ED_4D A07 2567 dasm_ED_56 A9D 2717 dasm_ED_5E AA2 2722 dasm_ED_A0 AE6 2790 dasm_ED_A1 AF8 2808 dasm_ED_A8 AEF 2799 dasm_ED_A9 B01 2817 dasm_ED_B0 AEA 2794 dasm_ED_B1 AFC 2812 dasm_ED_B8 AF3 2803 dasm_ED_B9 B05 2821 dasm_F3 A92 2706 dasm_F9 D0E 3342 dasm_FB A95 2709 dasm_FD 9ED 2541 dasm_FD_01 CA9 3241 dasm_FD_09 C63 3171 dasm_FD_22 D02 3330 dasm_FD_23 C7A 3194 dasm_FD_2A CD4 3284 dasm_FD_2B C91 3217 dasm_FD_34 C16 3094 dasm_FD_35 C33 3123 dasm_FD_86 B21 2849 dasm_FD_8E B47 2887 dasm_FD_96 B67 2919 dasm_FD_9E B89 2953 dasm_FD_A6 BA8 2984 dasm_FD_AE BDF 3039 dasm_FD_B6 BC3 3011 dasm_FD_BE BFA 3066 dasm_FD_E1 D50 3408 dasm_FD_E3 ADA 2778 dasm_FD_E5 D3A 3386 dasm_FD_F9 D22 3362 dasm_FF A11 2577 dasm_UU D58 3416 dasm_UW D5C 3420 dasm__AND B97 2967 dasm__CP BEB 3051 dasm__DEC C22 3106 dasm__ED_47 A69 2665 dasm__ED_4F A71 2673 dasm__ED_57 A59 2649 dasm__ED_5F A61 2657 dasm__INC C05 3077 dasm__LD A55 2645 dasm__OR BB4 2996 dasm__SBC B73 2931 dasm__SUB B56 2902 dasm__XOR BCE 3022 dasm_opcode_table 556 1366 dasm_print16hex_addr 383 899 dasm_print8hex 39B 923 dasm_printFlags_table D61 3425 dasm_printRegister8_table D71 3441 dasm_printRegister8_table_HL D91 3473 dasm_printRegisterIX_table D79 3449 dasm_printRegisterIY_table D81 3457 dasm_printRegisterSP_table D89 3465 disassemble 247 583 disassemble_continue 32D 813 disassemble_err 31D 797 disassemble_next 24B 587 disassemble_print_opcode_params_end 31A 794 disassemble_print_opcode_params_loop 2C6 710 disassemble_print_opcode_raw 288 648 disassemble_print_opcode_raw_fill 29C 668 disassemble_table_first_match 35F 863 disassemble_table_found 379 889 disassemble_table_notfound 37D 893 disassemble_table_seek 33B 827 disassemble_table_seek_loop 33F 831 dump_pretty 17E1 6113 dump_pretty_ascii 180B 6155 dump_pretty_ascii_cont 1829 6185 dump_pretty_ascii_loop 1813 6163 dump_pretty_ascii_none 1824 6180 dump_pretty_col 17FE 6142 dump_pretty_end 183B 6203 dump_pretty_nextrow 182F 6191 dump_pretty_row 17E9 6121 endPrint 19F 415 fat_cd_single 2460 9312 fat_copy_lba_pointer 2306 8966 fat_exec 257B 9595 fat_get_root_table 203E 8254 fat_getfatsec 2133 8499 fat_openfile 21E4 8676 fat_openfile_noprepare 21EC 8684 fat_print_directory 234B 9035 fat_readfilesec 21B9 8633 fat_reset_pointer 22F7 8951 format_filename_fat16 2325 8997 ide_printerror E89 3721 ide_readsector_256 E15 3605 ide_readsector_256_waitloop E17 3607 ide_readsector_512_inv E3E 3646 ide_readsector_512_inv_waitloop E43 3651 ide_readsector_timeout E73 3699 ide_regread_8 DF7 3575 ide_regwrite_8 DDB 3547 ide_reset DCE 3534 ide_writesector_256 E88 3720 ideif_drv_sel 1573 5491 ideif_get_drv_pointer 151C 5404 ideif_init_all 1530 5424 ideif_init_devtable 133A 4922 ideif_init_drive 144D 5197 ideif_prnt_devtable 1358 4952 iic_init 16F5 5877 iic_read_ack 1734 5940 iic_receive_buffer 16C6 5830 iic_receive_buffer_done 16E9 5865 iic_receive_buffer_err 16EF 5871 iic_receive_buffer_loop 16D7 5847 iic_receive_byte 17BA 6074 iic_receive_byte_loop 17C7 6087 iic_send_ack 175A 5978 iic_send_buffer 169C 5788 iic_send_buffer_done 16BA 5818 iic_send_buffer_err 16C0 5824 iic_send_buffer_loop 16AC 5804 iic_send_byte 1794 6036 iic_send_byte_loop 17A0 6048 iic_send_ebit 1713 5907 iic_send_nack 1777 6007 iic_send_sbit 16FE 5886 mon_var_template 44 68 mon_var_template_end 40F 1039 nxtILC 194 404 param_01 3A9 937 param_02 3D0 976 param_03 3ED 1005 param_03_done 425 1061 param_03_neg 40E 1038 param_04 429 1065 param_04_i 439 1081 param_05 43F 1087 param_06 44C 1100 param_07 466 1126 param_08 473 1139 param_09 488 1160 param_09_0A 48E 1166 param_0A 47F 1151 param_10 49D 1181 param_11 4AD 1197 param_11_12 4BC 1212 param_11_12_all 4DC 1244 param_11_12_def 4CF 1231 param_11_12_ix 4D4 1236 param_11_12_iy 4D9 1241 param_12 4B5 1205 param_13 4ED 1261 param_80 50C 1292 param_80_seek 513 1299 param_81 503 1283 param_comma 547 1351 param_printRegister 522 1314 param_printRegisterA 540 1344 param_printRegisterHL 538 1336 print_16_hex 16A 362 print_32_hex 151 337 print_a_hex 10E 270 print_bcd 120 288 print_char DE 222 print_clear F1 241 print_newLine F8 248 print_reg 1A4 420 print_str E6 230 print_str_end F0 240 print_str_fixed 187B 6267 print_wait_out 103 259 read_bcd 138 312 read_char 126 294 read_lba_sector 1543 5443 str_dev_done 15E3 5603 str_dev_waitready 15CB 5579 str_error_start EBC 3772 str_error_start1 ED9 3801 str_error_start2 EE2 3810 str_error_time EEB 3819 str_post_apu 1F38 7992 str_post_ide_30 1EE7 7911 str_post_ide_40 1F02 7938 str_post_nd 1F6E 8046 str_post_ok 1FA6 8102 str_post_pio 1F1D 7965 str_post_rtc 1F53 8019 str_post_rtc_iv 1F7C 8060 var_apu_present 400A 16394 var_buffer_len 4000 16384 var_bytes_count=411A 16666 var_curserchar 4006 16390 var_curserlastaddr 4007 16391 var_curseron 4005 16389 var_curserstate 4004 16388 var_curserx 4002 16386 var_cursery 4003 16387 var_dir 402B 16427 var_idebuffer 40CB 16587 var_input 407B 16507 var_last_char 4001 16385 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 4009 16393 var_ps2mem 401B 16411 var_scratch 400B 16395