X-Git-Url: http://cloudbase.mooo.com/gitweb/ddt180.git/blobdiff_plain/288de889d6e4d565f670deccd8777f13d69220b5..d1f2492ed211e8d3bfe8ee3cda94ceaef598847e:/ddt180.z80 diff --git a/ddt180.z80 b/ddt180.z80 index 56204fb..75b9b4e 100644 --- a/ddt180.z80 +++ b/ddt180.z80 @@ -14,74 +14,15 @@ TPA equ 0100h cseg .phase TPA - LD SP,ldr_end+(stack-ddtz_base) - LD DE,ldr_end+(expr_buf-ddtz_base) - LD C,BDOS_PSTR - CALL BDOS - - LD HL,ldr_end+ddtz_size ;start of reloc bitmap - ld bc,0108h ;init bit counter - - EXX - LD HL,(BDOS+1) - LD (ldr_end+1),HL - LD BC,ddtz_size-1 - LD D,B - LD E,0FFH - INC DE ;size rounded up to next page boundary - INC BC ;ddtz_size - OR A - SBC HL,DE ;BDOS - size - LD (BDOS+1),HL ;-> new BDOS entry - - push hl - PUSH BC - ld de,ldr_end - sbc hl,de - EX DE,HL ;-> DE - LD HL,ldr_size - add hl,bc - ld b,h - ld c,l - LD HL,TPA -reloc_lp: - EXX - djnz reloc_nl - ld b,c ;reload bit counter - LD e,(HL) ;get next 8 relocation bits - INC HL -reloc_nl: - sla e - EXX - JR NC,reloc_next - DEC HL - LD A,(HL) - ADD A,E - LD (HL),A - INC HL - LD A,(HL) - ADC A,D - LD (HL),A -reloc_next: - cpi - jp pe,reloc_lp - dec hl - - POP BC - pop de - EX DE,HL - ADD HL,BC - EX DE,HL - DEC DE - LDDR - LD HL,conbuf+2-ddtz_base - ADD HL,DE - JP (HL) + jp start ldr_end: ldr_size equ $ - TPA +current_phase defl $ .dephase +current_cseg defl $ + ;------------------------------------------------------------------------------- ; DDT/Z core ; @@ -95,8 +36,8 @@ CR equ 13 ; CP/M memory layout BDOS equ 5 -FCB equ 05ch -FCB2 equ 06ch +dfcb1 equ 05ch +dfcb2 equ 06ch DMA_BUF equ 080h TPA equ 0100h @@ -127,86 +68,101 @@ YREG_CNT equ 10 ;Number of Y registers (0..9) ;------------------------------------------------------------------------------- ddtz_base: - jp 0 ;0000 c3 00 00 . . . + jp ddtz_bdos l0003h: - rst 30h ;0003 f7 . + rst 30h sub_0004h: - nop ;0004 00 . - ret ;0005 c9 . + nop + ret +ddtz_bdos: + jp 0 + +current_cseg defl $ - current_cseg + .phase current_phase + current_cseg +signon: + db 'DDT/180',TAB + db '[8101] 002',CR,LF,'$' +msgz80: + db 'Z80 or better required!',cr,lf,'$' + +current_phase defl $ + .dephase +current_cseg defl $ + ds STACK_SIZE - (current_phase - signon) - ds STACK_SIZE stack: -reg.l2: db 000h ;0046 00 . -reg.h2: db 000h ;0047 00 . -reg.e2: db 000h ;0048 00 . -reg.d2: db 000h ;0049 00 . -reg.c2: db 000h ;004a 00 . -reg.b2: db 000h ;004b 00 . -reg.f2: db 000h ;004c 00 . -reg.a2: db 000h ;004d 00 . -l004eh: db 000h ;004e 00 . -reg.i: db 000h ;004f 00 . -reg.iy: dw 0000h ;0050 00 . -reg.ix: dw 0000h ;0052 00 . -reg.f: db 000h ;0054 00 . -reg.a: db 000h ;0055 00 . -reg.c: db 000h ;0056 00 . -reg.b: db 000h ;0057 00 . -reg.e: db 000h ;0058 00 . -reg.d: db 000h ;0059 00 . -reg.l: db 000h ;005a 00 . -reg.h: db 000h ;005b 00 . -reg_sp: dw TPA ;005c 00 01 . +reg.l2: db 000h +reg.h2: db 000h +reg.e2: db 000h +reg.d2: db 000h +reg.c2: db 000h +reg.b2: db 000h +reg.f2: db 000h +reg.a2: db 000h +l004eh: db 000h +reg.i: db 000h +reg.iy: dw 0000h +reg.ix: dw 0000h +reg.f: db 000h +reg.a: db 000h +reg.c: db 000h +reg.b: db 000h +reg.e: db 000h +reg.d: db 000h +reg.l: db 000h +reg.h: db 000h +reg_sp: dw TPA reg.iff: - db 0f3h ;005e f3 . - db 0c3h ;005f c3 . -REG.PC: dw TPA ;0060 00 01 . -l0062h: dw 0000h ;0062 00 00 . -offs.@: dw 0 ;0064 00 00 . + db 0f3h + db 0c3h +REG.PC: dw TPA +l0062h: dw 0000h +offs.@: dw 0 -CMD_ERR:dw l0146h ;0066 46 01 F . -cmd_rpt:dw mainloop ;0068 bd 00 . . +CMD_ERR:dw l0146h +cmd_rpt:dw mainloop conbuf: - db CONBUF_SIZE ;006a 50 P - - ld sp,stack ;006b 31 46 00 1 F . - exx ;006e d9 . - ld de,ddtz_base ;006f 11 00 00 . . . - or a ;0072 b7 . - sbc hl,de ;0073 ed 52 . R - add hl,de ;0075 19 . - jr c,l0079h ;0076 38 01 8 . - ex de,hl ;0078 eb . + db CONBUF_SIZE + + ld sp,stack + exx + ld de,ddtz_base + or a + sbc hl,de + add hl,de + jr c,l0079h + ex de,hl l0079h: - ld de,TPA ;0079 11 00 01 . . . + ld de,TPA l007ch: - dec hl ;007c 2b + - ld (hl),000h ;007d 36 00 6 . - ld a,h ;007f 7c | - sub d ;0080 92 . - ld b,a ;0081 47 G - ld a,l ;0082 7d } - sub e ;0083 93 . - or b ;0084 b0 . - jr nz,l007ch ;0085 20 f5 . - ld a,i ;0087 ed 57 . W - ld (reg.i),a ;0089 32 4f 00 2 O . - ld a,0f3h ;008c 3e f3 > . - jp po,l0093h ;008e e2 93 00 . . . - ld a,0fbh ;0091 3e fb > . + dec hl + ld (hl),000h + ld a,h + sub d + ld b,a + ld a,l + sub e + or b + jr nz,l007ch + ld a,i + ld (reg.i),a + ld a,0f3h + jp po,l0093h + ld a,0fbh l0093h: - ld (reg.iff),a ;0093 32 5e 00 2 ^ . - call sub_0004h ;0096 cd 04 00 . . . - ld hl,ddtz_base ;0099 21 00 00 ! . . - ld l,000h ;009c 2e 00 . . - ld (reg_sp),hl ;009e 22 5c 00 " \ . - ld a,(FCB+1) ;00a1 3a 5d 00 : ] . - cp ' ' ;00a4 fe 20 . - ld hl,0 ;00a6 21 00 00 ! . . - call nz,read_file ;00a9 c4 68 10 . h . - jr mainloop ;00ac 18 0f . . + ld (reg.iff),a + call sub_0004h + ld hl,ddtz_base + ld l,000h + ld (reg_sp),hl + call cpy_fcb2 + ld a,(dfcb1+1) + cp ' ' + ld hl,0 + call nz,read_file + jr mainloop ds CONBUF_SIZE + 3 - ($ - conbuf) @@ -249,33 +205,33 @@ exe_hl: jr mainloop ;010d 18 ae . . CMDTAB: - defw cmd_@ ;0110 92 0d . . - defw cmd_A ;0112 fe 11 . . - defw cmd_B ;0114 6d 07 m . - defw cmd_C ;0116 17 21 . ! - defw cmd_D ;0118 48 0f H . - defw ERROR ;011a 07 01 . . - defw cmd_F ;011c af 0f . . - defw cmd_G ;011e 31 07 1 . - defw cmd_H ;0120 3d 0e = . - defw cmd_I ;0122 a3 0d . . - defw ERROR ;0124 07 01 . . - defw ERROR ;0126 07 01 . . - defw cmd_L ;0128 cd 18 . . - defw cmd_M ;012a 19 0e . . - defw ERROR ;012c 07 01 . . - defw cmd_O ;012e c7 0d . . - defw ERROR ;0130 07 01 . . - defw cmd_Q ;0132 84 0e . . - defw cmd_R ;0134 62 10 b . - defw cmd_S ;0136 5a 0d Z . - defw cmd_T ;0138 1e 21 . ! - defw ERROR ;013a 07 01 . . - defw cmd_V ;013c ea 0d . . - defw cmd_W ;013e a0 11 . . - defw cmd_X ;0140 f1 0b . . - defw cmd_Y ;0142 b2 0b . . - defw cmd_Z ;0144 ba 0e . . + dw cmd_@ ;0110 92 0d . . + dw cmd_A ;0112 fe 11 . . + dw cmd_B ;0114 6d 07 m . + dw cmd_C ;0116 17 21 . ! + dw cmd_D ;0118 48 0f H . + dw ERROR ;011a 07 01 . . + dw cmd_F ;011c af 0f . . + dw cmd_G ;011e 31 07 1 . + dw cmd_H ;0120 3d 0e = . + dw cmd_I ;0122 a3 0d . . + dw ERROR ;0124 07 01 . . + dw ERROR ;0126 07 01 . . + dw cmd_L ;0128 cd 18 . . + dw cmd_M ;012a 19 0e . . + dw ERROR ;012c 07 01 . . + dw cmd_O ;012e c7 0d . . + dw ERROR ;0130 07 01 . . + dw cmd_Q ;0132 84 0e . . + dw cmd_R ;0134 62 10 b . + dw cmd_S ;0136 5a 0d Z . + dw cmd_T ;0138 1e 21 . ! + dw ERROR ;013a 07 01 . . + dw cmd_V ;013c ea 0d . . + dw cmd_W ;013e a0 11 . . + dw cmd_X ;0140 f1 0b . . + dw cmd_Y ;0142 b2 0b . . + dw cmd_Z ;0144 ba 0e . . l0146h: ld a,'?' ;0146 3e 3f > ? @@ -285,7 +241,7 @@ get_line: push hl ;014e e5 . ld de,conbuf ;014f 11 6a 00 . j . ld c,BDOS_CBUF ;0152 0e 0a . . - call ddtz_base ;0154 cd 00 00 . . . + call ddtz_bdos ;0154 cd 00 00 . . . call crlf ;0157 cd a3 02 . . . ld de,conbuf+1 ;015a 11 6b 00 . k . ld a,(de) ;015d 1a . @@ -484,7 +440,7 @@ outchar: and 07fh ;0261 e6 7f .  ld e,a ;0263 5f _ ld c,BDOS_COUT ;0264 0e 02 . . - call ddtz_base ;0266 cd 00 00 . . . + call ddtz_bdos ;0266 cd 00 00 . . . ld hl,con_col ;0269 21 72 02 ! r . inc (hl) ;026c 34 4 pop af ;026d f1 . @@ -492,18 +448,17 @@ outchar: pop de ;026f d1 . pop hl ;0270 e1 . ret ;0271 c9 . -con_col: - db 0 ;0272 00 . + inchar: push hl ;0273 e5 . push de ;0274 d5 . push bc ;0275 c5 . ld c,BDOS_CSTAT ;0276 0e 0b . . - call ddtz_base ;0278 cd 00 00 . . . + call ddtz_bdos ;0278 cd 00 00 . . . and a ;027b a7 . jr z,l0284h ;027c 28 06 ( . ld c,BDOS_CIN ;027e 0e 01 . . - call ddtz_base ;0280 cd 00 00 . . . + call ddtz_bdos ;0280 cd 00 00 . . . scf ;0283 37 7 l0284h: pop bc ;0284 c1 . @@ -514,15 +469,21 @@ pstr: ld c,0 ;0288 0e 00 . . l028ah: ld a,(hl) ;028a 7e ~ + inc hl ;0291 23 # and a ;028b a7 . ret z ;028c c8 . call outchar ;028d cd 5d 02 . ] . inc c ;0290 0c . - inc hl ;0291 23 # and a ;0292 a7 . ret m ;0293 f8 . jr l028ah ;0294 18 f4 . . +pstr_inl: + ex (sp),hl + call pstr + ex (sp),hl + ret + outbl6: call outbl2 ;0296 cd 9c 02 . . . outbl4: @@ -542,6 +503,7 @@ crlf: ld (con_col),a ;02b2 32 72 02 2 r . jp c,mainloop ;02b5 da bd 00 . . . ret ;02b8 c9 . + add_hl_a: add a,l ;02b9 85 . ld l,a ;02ba 6f o @@ -853,12 +815,12 @@ tab_eq_le_ge: db '=<>',0 tab_func_eqlege: - defw do_op_eq ;0423 da 03 . . - defw do_op_lt ;0425 e4 03 . . - defw do_op_gt ;0427 e8 03 . . - defw do_op_le ;0429 e2 03 . . - defw do_op_ge ;042b ea 03 . . - defw do_op_ne ;042d de 03 . . + dw do_op_eq ;0423 da 03 . . + dw do_op_lt ;0425 e4 03 . . + dw do_op_gt ;0427 e8 03 . . + dw do_op_le ;0429 e2 03 . . + dw do_op_ge ;042b ea 03 . . + dw do_op_ne ;042d de 03 . . do_subexpr: call do_factor ;042f cd e4 04 . . . @@ -1013,15 +975,15 @@ tab_op_a: DB '+-*/%&!#',0 tblf_opa: - defw doop_add ;04cb 4c 04 L . - defw doop_sub ;04cd 50 04 P . - defw doop_mlt ;04cf 55 04 U . - defw doop_div ;04d1 6a 04 j . - defw doop_mod ;04d3 6f 04 o . - defw doop_and ;04d5 96 04 . . - defw doop_or ;04d7 9e 04 . . - defw doop_xor ;04d9 a6 04 . . - defw 0 ;04db 00 00 . . + dw doop_add ;04cb 4c 04 L . + dw doop_sub ;04cd 50 04 P . + dw doop_mlt ;04cf 55 04 U . + dw doop_div ;04d1 6a 04 j . + dw doop_mod ;04d3 6f 04 o . + dw doop_and ;04d5 96 04 . . + dw doop_or ;04d7 9e 04 . . + dw doop_xor ;04d9 a6 04 . . + dw 0 ;04db 00 00 . . fact_factor: call do_factor ;04dd cd e4 04 . . . @@ -1033,7 +995,7 @@ do_factor: call get.number ;04e7 cd aa 05 . . . ret nc ;04ea d0 . inc de ;04eb 13 . - ld hl,ddtz_base-1 ;04ec 21 ff ff ! . . + ld hl,(BDOS+1) ;04ec 21 ff ff ! . . cp 'T' ;04ef fe 54 . T ret z ;04f1 c8 . ld hl,(high_load) ;04f2 2a 9c 11 * . . @@ -1245,33 +1207,33 @@ sub_060ch: jr l0614h ;060f 18 03 . . get.hexdigit: - ld a,(de) ;0611 1a . + ld a,(de) hex_digit: - cp 'F'+1 ;0612 fe 47 . G + cp 'F'+1 l0614h: - ccf ;0614 3f ? - ret c ;0615 d8 . - cp 'A' ;0616 fe 41 . A - jr c,l061eh ;0618 38 04 8 . - sub 'A'-10 ;061a d6 37 . 7 - ret ;061c c9 . + ccf + ret c + cp 'A' + jr c,l061eh + sub 'A'-10 + ret get.decdigit: - ld a,(de) ;061d 1a . + ld a,(de) l061eh: - cp '9'+1 ;061e fe 3a . : - jr l0625h ;0620 18 03 . . + cp '9'+1 + jr l0625h get.bindigit: - ld a,(de) ;0622 1a . - cp '1'+1 ;0623 fe 32 . 2 + ld a,(de) + cp '1'+1 l0625h: - ccf ;0625 3f ? - ret c ;0626 d8 . - cp '0' ;0627 fe 30 . 0 - ret c ;0629 d8 . - sub '0' ;062a d6 30 . 0 - ret ;062c c9 . + ccf + ret c + cp '0' + ret c + sub '0' + ret p_cpustat0: call assert_eol ;062d cd d6 02 . . . @@ -1388,43 +1350,43 @@ b_06e9_start: DC 'HL ' DC 'SP' DC 'PC' - DC 'A''' - DC 'BC''' - DC 'DE''' - DC 'HL''' + DC 'a''' + DC 'bc''' + DC 'de''' + DC 'hl''' DC 'IX' DC 'IY' DC 'I' DB 0 b_0709_start: - defw reg.a ;0709 55 00 U . - defb 000h ;070b 00 . - defw reg.c ;070c 56 00 V . - defb 001h ;070e 01 . - defw reg.e ;070f 58 00 X . - defb 001h ;0711 01 . - defw reg.l ;0712 5a 00 Z . - defb 001h ;0714 01 . - defw reg_sp ;0715 5c 00 \ . - defb 001h ;0717 01 . - defw REG.PC ;0718 60 00 ` . - defb 002h ;071a 02 . - defw reg.a2 ;071b 4d 00 M . - defb 000h ;071d 00 . - defw reg.c2 ;071e 4a 00 J . - defb 001h ;0720 01 . - defw reg.e2 ;0721 48 00 H . - defb 001h ;0723 01 . - defw reg.l2 ;0724 46 00 F . - defb 001h ;0726 01 . - defw reg.ix ;0727 52 00 R . - defb 001h ;0729 01 . - defw reg.iy ;072a 50 00 P . - defb 001h ;072c 01 . - defw reg.i ;072d 4f 00 O . - defb 000h ;072f 00 . - defb 000h ;0730 00 . + dw reg.a ;0709 55 00 U . + db 000h ;070b 00 . + dw reg.c ;070c 56 00 V . + db 001h ;070e 01 . + dw reg.e ;070f 58 00 X . + db 001h ;0711 01 . + dw reg.l ;0712 5a 00 Z . + db 001h ;0714 01 . + dw reg_sp ;0715 5c 00 \ . + db 001h ;0717 01 . + dw REG.PC ;0718 60 00 ` . + db 002h ;071a 02 . + dw reg.a2 ;071b 4d 00 M . + db 000h ;071d 00 . + dw reg.c2 ;071e 4a 00 J . + db 001h ;0720 01 . + dw reg.e2 ;0721 48 00 H . + db 001h ;0723 01 . + dw reg.l2 ;0724 46 00 F . + db 001h ;0726 01 . + dw reg.ix ;0727 52 00 R . + db 001h ;0729 01 . + dw reg.iy ;072a 50 00 P . + db 001h ;072c 01 . + dw reg.i ;072d 4f 00 O . + db 000h ;072f 00 . + db 000h ;0730 00 . cmd_G: sub a ;0731 97 . @@ -1711,9 +1673,6 @@ l0938h: ex af,af' ;093f 08 . ret ;0940 c9 . -l0941h: - db 0 ;0941 00 . - sub_0942h: ex af,af' ;0942 08 . res 7,a ;0943 cb bf . . @@ -1919,32 +1878,6 @@ l0ab0h: ld (iy+007h),d ;0ab4 fd 72 07 . r . ret ;0ab7 c9 . -bp_tab: - rept BP_CNT - rept BP_SIZE - db 0 - endm - endm - -expr_p1: - defw expr_buf ;0b18 1c 0b . . -expr_p2: - defw expr_buf ;0b1a 1c 0b . . - -expr_buf: - db 'DDT/180',TAB - db '[8101] 001',CR,LF,'$' - - ds EXPR_BUF_SIZE - ($ - expr_buf) -expr_bufe: - -msg_Y: - dc 'Yn' ;0b9c 59 ee Y n. -reg_Y: - rept YREG_CNT - dw 0 - endm - cmd_Y: call get.decdigit ;0bb2 cd 1d 06 . . . jr c,l0bc3h ;0bb5 38 0c 8 . @@ -2024,6 +1957,7 @@ l0c30h: pop af ;0c30 f1 . pop hl ;0c31 e1 . ret ;0c32 c9 . + l0c33h: ld b,c ;0c33 41 A call pstr ;0c34 cd 88 02 . . . @@ -2147,70 +2081,70 @@ b_0cc3_start: DB 0 b_0cfa_start: - defb 003h ;0cfa 03 . - defw reg.c2 ;0cfb 4a 00 J . - defb 003h ;0cfd 03 . - defw reg.e2 ;0cfe 48 00 H . - defb 003h ;0d00 03 . - defw reg.l2 ;0d01 46 00 F . - defb 003h ;0d03 03 . - defw reg.c ;0d04 56 00 V . - defb 003h ;0d06 03 . - defw reg.e ;0d07 58 00 X . - defb 003h ;0d09 03 . - defw reg.l ;0d0a 5a 00 Z . - defb 000h ;0d0c 00 . - defw reg.a2 ;0d0d 4d 00 M . - defb 000h ;0d0f 00 . - defw reg.b2 ;0d10 4b 00 K . - defb 000h ;0d12 00 . - defw reg.c2 ;0d13 4a 00 J . - defb 000h ;0d15 00 . - defw reg.d2 ;0d16 49 00 I . - defb 000h ;0d18 00 . - defw reg.e2 ;0d19 48 00 H . - defb 000h ;0d1b 00 . - defw reg.h2 ;0d1c 47 00 G . - defb 000h ;0d1e 00 . - defw reg.l2 ;0d1f 46 00 F . - defb 000h ;0d21 00 . - defw reg.a ;0d22 55 00 U . - defb 000h ;0d24 00 . - defw reg.b ;0d25 57 00 W . - defb 000h ;0d27 00 . - defw reg.c ;0d28 56 00 V . - defb 000h ;0d2a 00 . - defw reg.d ;0d2b 59 00 Y . - defb 000h ;0d2d 00 . - defw reg.e ;0d2e 58 00 X . - defb 000h ;0d30 00 . - defw reg.h ;0d31 5b 00 [ . - defb 000h ;0d33 00 . - defw reg.l ;0d34 5a 00 Z . - defb 003h ;0d36 03 . - defw reg.ix ;0d37 52 00 R . - defb 003h ;0d39 03 . - defw reg.iy ;0d3a 50 00 P . - defb 003h ;0d3c 03 . - defw reg_sp ;0d3d 5c 00 \ . - defb 003h ;0d3f 03 . - defw REG.PC ;0d40 60 00 ` . - defb 003h ;0d42 03 . - defw reg.ix ;0d43 52 00 R . - defb 003h ;0d45 03 . - defw reg.iy ;0d46 50 00 P . - defb 003h ;0d48 03 . - defw reg_sp ;0d49 5c 00 \ . - defb 003h ;0d4b 03 . - defw REG.PC ;0d4c 60 00 ` . - defb 000h ;0d4e 00 . - defw reg.i ;0d4f 4f 00 O . - defb 003h ;0d51 03 . - defw l004eh ;0d52 4e 00 N . - defb 000h ;0d54 00 . - defw reg.f2 ;0d55 4c 00 L . - defb 000h ;0d57 00 . - defw reg.f ;0d58 54 00 T . + db 003h ;0cfa 03 . + dw reg.c2 ;0cfb 4a 00 J . + db 003h ;0cfd 03 . + dw reg.e2 ;0cfe 48 00 H . + db 003h ;0d00 03 . + dw reg.l2 ;0d01 46 00 F . + db 003h ;0d03 03 . + dw reg.c ;0d04 56 00 V . + db 003h ;0d06 03 . + dw reg.e ;0d07 58 00 X . + db 003h ;0d09 03 . + dw reg.l ;0d0a 5a 00 Z . + db 000h ;0d0c 00 . + dw reg.a2 ;0d0d 4d 00 M . + db 000h ;0d0f 00 . + dw reg.b2 ;0d10 4b 00 K . + db 000h ;0d12 00 . + dw reg.c2 ;0d13 4a 00 J . + db 000h ;0d15 00 . + dw reg.d2 ;0d16 49 00 I . + db 000h ;0d18 00 . + dw reg.e2 ;0d19 48 00 H . + db 000h ;0d1b 00 . + dw reg.h2 ;0d1c 47 00 G . + db 000h ;0d1e 00 . + dw reg.l2 ;0d1f 46 00 F . + db 000h ;0d21 00 . + dw reg.a ;0d22 55 00 U . + db 000h ;0d24 00 . + dw reg.b ;0d25 57 00 W . + db 000h ;0d27 00 . + dw reg.c ;0d28 56 00 V . + db 000h ;0d2a 00 . + dw reg.d ;0d2b 59 00 Y . + db 000h ;0d2d 00 . + dw reg.e ;0d2e 58 00 X . + db 000h ;0d30 00 . + dw reg.h ;0d31 5b 00 [ . + db 000h ;0d33 00 . + dw reg.l ;0d34 5a 00 Z . + db 003h ;0d36 03 . + dw reg.ix ;0d37 52 00 R . + db 003h ;0d39 03 . + dw reg.iy ;0d3a 50 00 P . + db 003h ;0d3c 03 . + dw reg_sp ;0d3d 5c 00 \ . + db 003h ;0d3f 03 . + dw REG.PC ;0d40 60 00 ` . + db 003h ;0d42 03 . + dw reg.ix ;0d43 52 00 R . + db 003h ;0d45 03 . + dw reg.iy ;0d46 50 00 P . + db 003h ;0d48 03 . + dw reg_sp ;0d49 5c 00 \ . + db 003h ;0d4b 03 . + dw REG.PC ;0d4c 60 00 ` . + db 000h ;0d4e 00 . + dw reg.i ;0d4f 4f 00 O . + db 003h ;0d51 03 . + dw l004eh ;0d52 4e 00 N . + db 000h ;0d54 00 . + dw reg.f2 ;0d55 4c 00 L . + db 000h ;0d57 00 . + dw reg.f ;0d58 54 00 T . cmd_S: ld hl,(last_S) ;0d5a 2a 90 0d * . . @@ -2242,8 +2176,6 @@ l0d8ah: call sub_0ef8h ;0d8b cd f8 0e . . . jr l0d60h ;0d8e 18 d0 . . -last_S: - defw TPA ;0d90 00 01 . . cmd_@: call assert_eol ;0d92 cd d6 02 . . . ld hl,msg_offset ;0d95 21 a0 0d ! . . @@ -2254,8 +2186,6 @@ cmd_@: msg_offset: dc '@' ;0da0 c0 . -last_I: - defw 0 ;0da1 00 00 . . cmd_I: ld hl,cmd_I ;0da3 21 a3 0d ! . . ld (cmd_rpt),hl ;0da6 22 68 00 " h . @@ -2272,10 +2202,6 @@ cmd_I: call out.bin.b ;0dbe cd c7 01 . . . jp crlf ;0dc1 c3 a3 02 . . . -last_O_addr: - dw 0 ;0dc4 00 . -last_O_val: - db 0 ;0dc6 00 . cmd_O: ld hl,cmd_O ;0dc7 21 c7 0d ! . . ld (cmd_rpt),hl ;0dca 22 68 00 " h . @@ -2388,9 +2314,6 @@ l0e5eh: call out.ascii ;0e7d cd 34 02 . 4 . jp crlf ;0e80 c3 a3 02 . . . -cmd_Q_jopt: - db -1 ;0e83 ff . - cmd_Q: ld a,(de) ;0e84 1a . sub 'J' ;0e85 d6 4a . J @@ -2452,9 +2375,6 @@ l0ed3h: pop hl ;0ed3 e1 . ret ;0ed4 c9 . -last_D: - dw TPA - sub_0ed7h: push hl ;0ed7 e5 d5 . . push de @@ -2614,24 +2534,33 @@ l0fach: ret ;0fae c9 . cmd_F: - push de ;0faf d5 . - ld hl,DMA_BUF+1 ;0fb0 21 81 00 ! . . - ld (hl),' ' ;0fb3 36 20 6 - inc hl ;0fb5 23 # + push de + ld hl,DMA_BUF+1 + ld (hl),' ' + inc hl l0fb6h: - ld a,(de) ;0fb6 1a . - ld (hl),a ;0fb7 77 w - inc hl ;0fb8 23 # - inc de ;0fb9 13 . - and a ;0fba a7 . - jr nz,l0fb6h ;0fbb 20 f9 . - ld a,l ;0fbd 7d } - sub DMA_BUF+2 ;0fbe d6 82 . . - ld (DMA_BUF),a ;0fc0 32 80 00 2 . . - pop hl ;0fc3 e1 . - ld de,FCB ;0fc4 11 5c 00 . \ . - call parse_filename ;0fc7 cd cd 0f . . . - ld de,FCB2 ;0fca 11 6c 00 . l . + ld a,(de) + ld (hl),a + inc hl + inc de + and a + jr nz,l0fb6h + ld a,l + sub DMA_BUF+2 + ld (DMA_BUF),a + pop hl + ld de,dfcb1 + call parse_filename + ld de,dfcb2 + call parse_filename + ;fall thru + +cpy_fcb2: + ld hl,dfcb2 + ld de,fcbsym + ld bc,16 + ldir + ret parse_filename: call sub_102ch ;0fcd cd 2c 10 . , . @@ -2732,120 +2661,32 @@ sub_1043h: cp ',' ;1049 fe 2c . , ret ;104b c9 . -fcb_clear_rc: - xor a ;104c af . - ld hl,FCB+12 ;104d 21 68 00 ! h . - ld b,21 ;1050 06 15 . . +setup_fcb: + push de + ld hl,12 + add hl,de + xor a + ld b,21 l1052h: - ld (hl),a ;1052 77 w - inc hl ;1053 23 # - djnz l1052h ;1054 10 fc . . - ld de,DMA_BUF ;1056 11 80 00 . . . - ld c,BDOS_SETDMA ;1059 0e 1a . . - call ddtz_base ;105b cd 00 00 . . . - ld de,FCB ;105e 11 5c 00 . \ . - ret ;1061 c9 . + ld (hl),a + inc hl + djnz l1052h + ld de,DMA_BUF + ld c,BDOS_SETDMA + call ddtz_bdos + pop de + ret -cmd_R: - ld hl,0 ;1062 21 00 00 ! . . - call get_lastarg_def ;1065 cd 69 03 . i . -read_file: - push hl ;1068 e5 . - ld hl,0 ;1069 21 00 00 ! . . - ld (high_load),hl ;106c 22 9c 11 " . . - call fcb_clear_rc ;106f cd 4c 10 . L . +file_open: + ld (cur_fcb),de + call setup_fcb ;106f cd 4c 10 . L . ld c,BDOS_OPEN ;1072 0e 0f . . - call ddtz_base ;1074 cd 00 00 . . . + call ddtz_bdos ;1074 cd 00 00 . . . inc a ;1077 3c < jp z,ERROR ;1078 ca 07 01 . . . - ld hl,FCB+9 ;107b 21 65 00 ! e . - ld de,str_hex ;107e 11 a5 10 . . . - ld b,3 ;1081 06 03 . . - call strncmp ;1083 cd 67 11 . g . - pop hl ;1086 e1 . - jr z,read_hexfile ;1087 28 1f ( . - ld de,TPA ;1089 11 00 01 . . . - add hl,de ;108c 19 . - push hl ;108d e5 . -l108eh: - call read_sector ;108e cd 21 11 . ! . - pop hl ;1091 e1 . - jp z,p_max_high ;1092 ca 72 11 . r . - ld de,DMA_BUF ;1095 11 80 00 . . . - ld b,080h ;1098 06 80 . . -l109ah: - ld a,(de) ;109a 1a . - call cmdR_storebyte ;109b cd 36 11 . 6 . - inc de ;109e 13 . - inc hl ;109f 23 # - djnz l109ah ;10a0 10 f8 . . - push hl ;10a2 e5 . - jr l108eh ;10a3 18 e9 . . - -str_hex: - db 'HEX' ;10a5 48 H E X - -read_hexfile: - push hl ;10a8 e5 . ld a,080h ;10a9 3e 80 > . ld (cmdR_rindex),a ;10ab 32 20 11 2 . -l10aeh: - call read_byte ;10ae cd 05 11 . . . - jr z,rdhex_done ;10b1 28 31 ( 1 - cp ':' ;10b3 fe 3a . : - jr nz,l10aeh ;10b5 20 f7 . - ld c,0 ;10b7 0e 00 . . - call read_hexchar ;10b9 cd e8 10 . . . - ld b,a ;10bc 47 G - call read_hexchar ;10bd cd e8 10 . . . - ld h,a ;10c0 67 g - call read_hexchar ;10c1 cd e8 10 . . . - ld l,a ;10c4 6f o - ld a,b ;10c5 78 x - and a ;10c6 a7 . - jr z,rdhex_done ;10c7 28 1b ( . - call read_hexchar ;10c9 cd e8 10 . . . -l10cch: - call read_hexchar ;10cc cd e8 10 . . . - pop de ;10cf d1 . - push de ;10d0 d5 . - push hl ;10d1 e5 . - add hl,de ;10d2 19 . - call cmdR_storebyte ;10d3 cd 36 11 . 6 . - pop hl ;10d6 e1 . - inc hl ;10d7 23 # - djnz l10cch ;10d8 10 f2 . . - call read_hexchar ;10da cd e8 10 . . . - ld a,c ;10dd 79 y - and a ;10de a7 . - jp nz,ERROR ;10df c2 07 01 . . . - jr l10aeh ;10e2 18 ca . . -rdhex_done: - pop hl ;10e4 e1 . - jp p_max_high ;10e5 c3 72 11 . r . - -read_hexchar: - call read_hexdigit ;10e8 cd f9 10 . . . - rlca ;10eb 07 . - rlca ;10ec 07 . - rlca ;10ed 07 . - rlca ;10ee 07 . - ld d,a ;10ef 57 W - call read_hexdigit ;10f0 cd f9 10 . . . - add a,d ;10f3 82 . - ld d,a ;10f4 57 W - add a,c ;10f5 81 . - ld c,a ;10f6 4f O - ld a,d ;10f7 7a z - ret ;10f8 c9 . - -read_hexdigit: - call read_byte ;10f9 cd 05 11 . . . - jr z,l1102h ;10fc 28 04 ( . - call hex_digit ;10fe cd 12 06 . . . - ret nc ;1101 d0 . -l1102h: - jp ERROR ;1102 c3 07 01 . . . + ret read_byte: ld a,(cmdR_rindex) ;1105 3a 20 11 : . @@ -2866,16 +2707,13 @@ l1111h: cp 01ah ;111d fe 1a . . ret ;111f c9 . -cmdR_rindex: - db 0 ;1120 00 . - read_sector: push hl ;1121 e5 . push de ;1122 d5 . push bc ;1123 c5 . - ld de,FCB ;1124 11 5c 00 . \ . + ld de,(cur_fcb) ;1124 11 5c 00 . \ . ld c,BDOS_READ ;1127 0e 14 . . - call ddtz_base ;1129 cd 00 00 . . . + call ddtz_bdos ;1129 cd 00 00 . . . dec a ;112c 3d = jr z,l1132h ;112d 28 03 ( . jp p,ERROR ;112f f2 07 01 . . . @@ -2918,28 +2756,224 @@ strncmp: djnz strncmp ;116c 10 f9 . . ret ;116e c9 . +str_hex: + db 'HEX' + +read_hexchar: + call read_hexdigit + rlca + rlca + rlca + rlca + ld d,a + call read_hexdigit + add a,d + ld d,a + add a,c + ld c,a + ld a,d + ret + +read_hexdigit: + call read_byte + jr z,error8 +hex_digit_v: + call hex_digit + ret nc +error8: + jp ERROR + +read_hexbyte: + call read_byte +read_hexbyte0: + push bc + call hex_digit_v + rlca + rlca + rlca + rlca + ld c,a + call read_byte + call hex_digit_v + or c + pop bc + ret + +cmd_R: + ld hl,0 ;1062 21 00 00 ! . . + call get_lastarg_def ;1065 cd 69 03 . i . +read_file: + ld de,dfcb1+1 + ld a,(de) + cp '?' + jr z,read_symfile + dec de + push hl ;1068 e5 . + ld hl,0 ;1069 21 00 00 ! . . + ld (high_load),hl ;106c 22 9c 11 " . . + call file_open + ld hl,dfcb1+9 ;107b 21 65 00 ! e . + ld de,str_hex ;107e 11 a5 10 . . . + ld b,3 ;1081 06 03 . . + call strncmp ;1083 cd 67 11 . g . + pop hl ;1086 e1 . + jr z,read_hexfile ;1087 28 1f ( . + ld de,TPA ;1089 11 00 01 . . . + add hl,de ;108c 19 . + push hl ;108d e5 . +l108eh: + call read_sector ;108e cd 21 11 . ! . + pop hl ;1091 e1 . + jr z,read_symfile ;1092 ca 72 11 . r . + ld de,DMA_BUF ;1095 11 80 00 . . . + ld b,080h ;1098 06 80 . . +l109ah: + ld a,(de) ;109a 1a . + call cmdR_storebyte ;109b cd 36 11 . 6 . + inc de ;109e 13 . + inc hl ;109f 23 # + djnz l109ah ;10a0 10 f8 . . + push hl ;10a2 e5 . + jr l108eh ;10a3 18 e9 . . + +read_hexfile: + push hl ;10a8 e5 . +l10aeh: + call read_byte ;10ae cd 05 11 . . . + jr z,rdhex_done ;10b1 28 31 ( 1 + cp ':' ;10b3 fe 3a . : + jr nz,l10aeh ;10b5 20 f7 . + ld c,0 ;10b7 0e 00 . . + call read_hexchar ;10b9 cd e8 10 . . . + ld b,a ;10bc 47 G + call read_hexchar ;10bd cd e8 10 . . . + ld h,a ;10c0 67 g + call read_hexchar ;10c1 cd e8 10 . . . + ld l,a ;10c4 6f o + ld a,b ;10c5 78 x + and a ;10c6 a7 . + jr z,rdhex_done ;10c7 28 1b ( . + call read_hexchar ;10c9 cd e8 10 . . . +l10cch: + call read_hexchar ;10cc cd e8 10 . . . + pop de ;10cf d1 . + push de ;10d0 d5 . + push hl ;10d1 e5 . + add hl,de ;10d2 19 . + call cmdR_storebyte ;10d3 cd 36 11 . 6 . + pop hl ;10d6 e1 . + inc hl ;10d7 23 # + djnz l10cch ;10d8 10 f2 . . + call read_hexchar ;10da cd e8 10 . . . + ld a,c ;10dd 79 y + and a ;10de a7 . + jr nz,error9 ;10df c2 07 01 . . . + jr l10aeh ;10e2 18 ca . . +rdhex_done: + pop hl ;10e4 e1 . + jr read_symfile ;10e5 c3 72 11 . r . + +read_symfile: + ld de,fcbsym+1 + ld a,(de) + cp ' ' + jp z,p_max_high + + call pstr_inl + db 'SYMBOLS',CR,LF+80h + + dec de + call file_open +;------------------------------------------------------------------------ +rs_1: + call read_byte +rs_2: + cp 1ah + jr z,p_max_high + cp '!' + jr c,rs_1 + call read_hexbyte0 + ld d,a + call read_hexbyte ; symval + ld e,a + push de ; symval + call read_byte + cp ' ' + jr z,rs_4 + pop hl ; discard symval +rs_3: call read_byte + cp ' ' + jr c,rs_2 + jr rs_3 +; +rs_4: ld hl,(BDOS+1) ; + ld e,0 ; setup symlen +rs_5: dec hl ; + call read_byte ; + cp TAB ; + jr z,rs_6 ; + cp CR ; + jr z,rs_6 ; + cp '!' ; + jr c,error9 ; + ld (hl),a ; + inc e ; symlen++ + ld a,e ; + cp 10h+1 ; + jr c,rs_5 ; +error9: + jp ERROR ; +; +rs_6: push de ; symlen + push hl ; + ex de,hl ; + ld hl,(BDOS+1) ; + inc hl ; + ld e,(hl) ; + inc hl ; + ld d,(hl) ; + pop hl ; + ld (hl),d ; + dec hl ; + ld (hl),e ; + dec hl ; + ld (hl),0c3h ; + + ld de,(max_load) ; + call cp_hl_de ; + jr c,error9 ; + + ld de,(reg_sp) ; + call cp_hl_de ; + jr nc,rs_61 ; + ld (reg_sp),hl ; +rs_61: + + ld de,(BDOS+1) ; + ld (BDOS+1),hl ; + ex de,hl ; + pop de ; + ld (hl),e ; symlen + inc hl ; + pop de ; symval + ld (hl),e ; + inc hl ; + ld (hl),d ; + jp rs_1 ; +;------------------------------------------------------------------------ + p_max_high0: - call assert_eol ;116f cd d6 02 . . . + call assert_eol p_max_high: - ld hl,msg_high ;1172 21 8d 11 ! . . - call pstr ;1175 cd 88 02 . . . - ld hl,(high_load) ;1178 2a 9c 11 * . . - call out_hl ;117b cd 13 02 . . . - ld hl,msg_max ;117e 21 94 11 ! . . - call pstr ;1181 cd 88 02 . . . - ld hl,(max_load) ;1184 2a 9e 11 * . . - call out_hl ;1187 cd 13 02 . . . - jp crlf ;118a c3 a3 02 . . . - -msg_high: + call pstr_inl DC 'High = ' -msg_max: + ld hl,(high_load) + call out_hl + call pstr_inl DC ' Max = ' - -high_load: - defw TPA ;119c 00 01 . . -max_load: - defw TPA ;119e 00 01 . . + ld hl,(max_load) + call out_hl + jp crlf cmd_W: call get_arg_range ;11a0 cd 7d 03 . } . @@ -2953,16 +2987,17 @@ l11adh: and 080h ;11ad e6 80 . . ld c,a ;11af 4f O push bc ;11b0 c5 . - ld a,(FCB+1) ;11b1 3a 5d 00 : ] . + ld a,(dfcb1+1) ;11b1 3a 5d 00 : ] . cp ' ' ;11b4 fe 20 . jr z,error5 ;11b6 28 3b ( ; - call fcb_clear_rc ;11b8 cd 4c 10 . L . + ld de,dfcb1 + call setup_fcb ;11b8 cd 4c 10 . L . push de ;11bb d5 . ld c,BDOS_DELETE ;11bc 0e 13 . . - call ddtz_base ;11be cd 00 00 . . . + call ddtz_bdos ;11be cd 00 00 . . . pop de ;11c1 d1 . ld c,BDOS_CREATE ;11c2 0e 16 . . - call ddtz_base ;11c4 cd 00 00 . . . + call ddtz_bdos ;11c4 cd 00 00 . . . inc a ;11c7 3c < jr z,error5 ;11c8 28 29 ( ) pop bc ;11ca c1 . @@ -2986,9 +3021,9 @@ l11cch: write_sector: push hl ;11e4 e5 . - ld de,FCB ;11e5 11 5c 00 . \ . + ld de,dfcb1 ;11e5 11 5c 00 . \ . ld c,BDOS_WRITE ;11e8 0e 15 . . - call ddtz_base ;11ea cd 00 00 . . . + call ddtz_bdos ;11ea cd 00 00 . . . pop hl ;11ed e1 . and a ;11ee a7 . ret z ;11ef c8 . @@ -2997,9 +3032,9 @@ error5: jp ERROR ;11f3 c3 07 01 . . . close_file: - ld de,FCB ;11f6 11 5c 00 . \ . + ld de,dfcb1 ;11f6 11 5c 00 . \ . ld c,BDOS_CLOSE ;11f9 0e 10 . . - jp ddtz_base ;11fb c3 00 00 . . . + jp ddtz_bdos ;11fb c3 00 00 . . . cmd_A: ld hl,(last_A) ;11fe 2a 64 12 * d . @@ -3051,13 +3086,6 @@ l1259h: ld sp,(l1262h) ;125c ed 7b 62 12 . { b . jr l1211h ;1260 18 af . . -l1262h: - dw 0 ;1262 00 00 . -last_A: - dw TPA ;1264 00 01 . -cmd_A_prev: - dw TPA ;1266 00 01 . . - sub_1268h: call skipbl ;1268 cd bf 02 . . . ld hl,t_MNEMONICS ;126b 21 c6 1e ! . . @@ -3082,161 +3110,161 @@ CALL_HL: jp (hl) ;1288 e9 . b_1289_start: - defw as.ADC_SBC ;ADC 1289 51 15 Q . - defb 088h ; 128b 88 . - defw as.ADD ;ADD 128c 71 15 q . - defb 080h ; 128e 80 . - defw as.AND_CP_OR_SUB_XOR ;AND 128f a8 15 . . - defb 0a0h ; 1291 a0 . - defw as.BITOP ;BIT 1292 09 16 . . - defb 040h ; 1294 40 @ - defw as.CALL ;CALL 1295 2d 16 - . - defb 0c4h ; 1297 c4 . - defw as.opc.noarg ;CCF 1298 3b 15 ; . - defb 03fh ; 129a 3f ? - defw as.AND_CP_OR_SUB_XOR ;CP 129b a8 15 . . - defb 0b8h ; 129d b8 . - defw gen.opc.ED2 ;CPD 129e 44 15 D . - defb 0a9h ; 12a0 a9 . - defw gen.opc.ED2 ;CPDR 12a1 44 15 D . - defb 0b9h ; 12a3 b9 . - defw gen.opc.ED2 ;CPI 12a4 44 15 D . - defb 0a1h ; 12a6 a1 . - defw gen.opc.ED2 ;CPIR 12a7 44 15 D . - defb 0b1h ; 12a9 b1 . - defw as.opc.noarg ;CPL 12aa 3b 15 ; . - defb 02fh ; 12ac 2f / - defw as.opc.noarg ;DAA 12ad 3b 15 ; . - defb 027h ; 12af 27 ' - defw as.DEC_INC ;DEC 12b0 98 17 . . - defb 005h ; 12b2 05 . - defw as.opc.noarg ;DI 12b3 3b 15 ; . - defb 0f3h ; 12b5 f3 . - defw as.DJNZ ;DJNZ 12b6 99 16 . . - defb 010h ; 12b8 10 . - defw as.opc.noarg ;EI 12b9 3b 15 ; . - defb 0fbh ; 12bb fb . - defw as.EX ;EX 12bc 49 17 I . - defb 0e3h ; 12be e3 . - defw as.opc.noarg ;EXX 12bf 3b 15 ; . - defb 0d9h ; 12c1 d9 . - defw as.opc.noarg ;HALT 12c2 3b 15 ; . - defb 076h ; 12c4 76 v - defw as.IM ;IM 12c5 b4 16 . . - defb 046h ; 12c7 46 F - defw as.IN ;IN 12c8 ed 16 . . - defb 040h ; 12ca 40 @ - defw as.DEC_INC ;INC 12cb 98 17 . . - defb 004h ; 12cd 04 . - defw gen.opc.ED2 ;IND 12ce 44 15 D . - defb 0aah ; 12d0 aa . - defw gen.opc.ED2 ;INDR 12d1 44 15 D . - defb 0bah ; 12d3 ba . - defw gen.opc.ED2 ;INI 12d4 44 15 D . - defb 0a2h ; 12d6 a2 . - defw gen.opc.ED2 ;INIR 12d7 44 15 D . - defb 0b2h ; 12d9 b2 . - defw as.JP ;JP 12da 53 16 S . - defb 0c2h ; 12dc c2 . - defw as.JR ;JR 12dd a0 16 . . - defb 020h ; 12df 20 - defw as.LD ;LD 12e0 52 13 R . - defb 040h ; 12e2 40 @ - defw gen.opc.ED2 ;LDD 12e3 44 15 D . - defb 0a8h ; 12e5 a8 . - defw gen.opc.ED2 ;LDDR 12e6 44 15 D . - defb 0b8h ; 12e8 b8 . - defw gen.opc.ED2 ;LDI 12e9 44 15 D . - defb 0a0h ; 12eb a0 . - defw gen.opc.ED2 ;LDIR 12ec 44 15 D . - defb 0b0h ; 12ee b0 . - defw gen.opc.ED2 ;NEG 12ef 44 15 D . - defb 044h ; 12f1 44 D - defw as.opc.noarg ;NOP 12f2 3b 15 ; . - defb 000h ; 12f4 00 . - defw as.AND_CP_OR_SUB_XOR ;OR 12f5 a8 15 . . - defb 0b0h ; 12f7 b0 . - defw gen.opc.ED2 ;OTDR 12f8 44 15 D . - defb 0bbh ; 12fa bb . - defw gen.opc.ED2 ;OTIR 12fb 44 15 D . - defb 0b3h ; 12fd b3 . - defw as.OUT ;OUT 12fe 21 17 ! . - defb 041h ; 1300 41 A - defw gen.opc.ED2 ;OUTD 1301 44 15 D . - defb 0abh ; 1303 ab . - defw gen.opc.ED2 ;OUTI 1304 44 15 D . - defb 0a3h ; 1306 a3 . - defw as.POP_PUSH ;POP 1307 d9 16 . . - defb 0c1h ; 1309 c1 . - defw as.POP_PUSH ;PUSH 130a d9 16 . . - defb 0c5h ; 130c c5 . - defw as.BITOP ;RES 130d 09 16 . . - defb 080h ; 130f 80 . - defw as.RET ;RET 1310 45 16 E . - defb 0c0h ; 1312 c0 . - defw gen.opc.ED2 ;RETI 1313 44 15 D . - defb 04dh ; 1315 4d M - defw gen.opc.ED2 ;RETN 1316 44 15 D . - defb 045h ; 1318 45 E - defw as.SHIFTOP ;RL 1319 d5 15 . . - defb 010h ; 131b 10 . - defw as.opc.noarg ;RLA 131c 3b 15 ; . - defb 017h ; 131e 17 . - defw as.SHIFTOP ;RLC 131f d5 15 . . - defb 000h ; 1321 00 . - defw as.opc.noarg ;RLCA 1322 3b 15 ; . - defb 007h ; 1324 07 . - defw gen.opc.ED2 ;RLD 1325 44 15 D . - defb 06fh ; 1327 6f o - defw as.SHIFTOP ;RR 1328 d5 15 . . - defb 018h ; 132a 18 . - defw as.opc.noarg ;RRA 132b 3b 15 ; . - defb 01fh ; 132d 1f . - defw as.SHIFTOP ;RRC 132e d5 15 . . - defb 008h ; 1330 08 . - defw as.opc.noarg ;RRCA 1331 3b 15 ; . - defb 00fh ; 1333 0f . - defw gen.opc.ED2 ;RRD 1334 44 15 D . - defb 067h ; 1336 67 g - defw as.RST ;RST 1337 ca 16 . . - defb 0c7h ; 1339 c7 . - defw as.ADC_SBC ;SBC 133a 51 15 Q . - defb 098h ; 133c 98 . - defw as.opc.noarg ;SCF 133d 3b 15 ; . - defb 037h ; 133f 37 7 - defw as.BITOP ;SET 1340 09 16 . . - defb 0c0h ; 1342 c0 . - defw as.SHIFTOP ;SLA 1343 d5 15 . . - defb 020h ; 1345 20 - defw as.SHIFTOP ;SRA 1346 d5 15 . . - defb 028h ; 1348 28 ( - defw as.SHIFTOP ;SRL 1349 d5 15 . . - defb 038h ; 134b 38 8 - defw as.AND_CP_OR_SUB_XOR ;SUB 134c a8 15 . . - defb 090h ; 134e 90 . - defw as.AND_CP_OR_SUB_XOR ;XOR 134f a8 15 . . - defb 0a8h ; 1351 a8 . - - defw as.IN0 ;IN0 - defb 000h ; - defw as.MLT ;MLT - defb 04ch ; - defw gen.opc.ED2 ;OTDM - defb 08bh ; - defw gen.opc.ED2 ;OTDMR - defb 09bh ; - defw gen.opc.ED2 ;OTIM - defb 083h ; - defw gen.opc.ED2 ;OTIMR - defb 093h ; - defw as.OUTO ;OUT0 - defb 001h ; - defw gen.opc.ED2 ;SLP - defb 076h ; - defw as.TST ;TST - defb 004h ; - defw as.TSTIO ;TSTIO - defb 074h ; + dw as.ADC_SBC ;ADC 1289 51 15 Q . + db 088h ; 128b 88 . + dw as.ADD ;ADD 128c 71 15 q . + db 080h ; 128e 80 . + dw as.AND_CP_OR_SUB_XOR ;AND 128f a8 15 . . + db 0a0h ; 1291 a0 . + dw as.BITOP ;BIT 1292 09 16 . . + db 040h ; 1294 40 @ + dw as.CALL ;CALL 1295 2d 16 - . + db 0c4h ; 1297 c4 . + dw as.opc.noarg ;CCF 1298 3b 15 ; . + db 03fh ; 129a 3f ? + dw as.AND_CP_OR_SUB_XOR ;CP 129b a8 15 . . + db 0b8h ; 129d b8 . + dw gen.opc.ED2 ;CPD 129e 44 15 D . + db 0a9h ; 12a0 a9 . + dw gen.opc.ED2 ;CPDR 12a1 44 15 D . + db 0b9h ; 12a3 b9 . + dw gen.opc.ED2 ;CPI 12a4 44 15 D . + db 0a1h ; 12a6 a1 . + dw gen.opc.ED2 ;CPIR 12a7 44 15 D . + db 0b1h ; 12a9 b1 . + dw as.opc.noarg ;CPL 12aa 3b 15 ; . + db 02fh ; 12ac 2f / + dw as.opc.noarg ;DAA 12ad 3b 15 ; . + db 027h ; 12af 27 ' + dw as.DEC_INC ;DEC 12b0 98 17 . . + db 005h ; 12b2 05 . + dw as.opc.noarg ;DI 12b3 3b 15 ; . + db 0f3h ; 12b5 f3 . + dw as.DJNZ ;DJNZ 12b6 99 16 . . + db 010h ; 12b8 10 . + dw as.opc.noarg ;EI 12b9 3b 15 ; . + db 0fbh ; 12bb fb . + dw as.EX ;EX 12bc 49 17 I . + db 0e3h ; 12be e3 . + dw as.opc.noarg ;EXX 12bf 3b 15 ; . + db 0d9h ; 12c1 d9 . + dw as.opc.noarg ;HALT 12c2 3b 15 ; . + db 076h ; 12c4 76 v + dw as.IM ;IM 12c5 b4 16 . . + db 046h ; 12c7 46 F + dw as.IN ;IN 12c8 ed 16 . . + db 040h ; 12ca 40 @ + dw as.DEC_INC ;INC 12cb 98 17 . . + db 004h ; 12cd 04 . + dw gen.opc.ED2 ;IND 12ce 44 15 D . + db 0aah ; 12d0 aa . + dw gen.opc.ED2 ;INDR 12d1 44 15 D . + db 0bah ; 12d3 ba . + dw gen.opc.ED2 ;INI 12d4 44 15 D . + db 0a2h ; 12d6 a2 . + dw gen.opc.ED2 ;INIR 12d7 44 15 D . + db 0b2h ; 12d9 b2 . + dw as.JP ;JP 12da 53 16 S . + db 0c2h ; 12dc c2 . + dw as.JR ;JR 12dd a0 16 . . + db 020h ; 12df 20 + dw as.LD ;LD 12e0 52 13 R . + db 040h ; 12e2 40 @ + dw gen.opc.ED2 ;LDD 12e3 44 15 D . + db 0a8h ; 12e5 a8 . + dw gen.opc.ED2 ;LDDR 12e6 44 15 D . + db 0b8h ; 12e8 b8 . + dw gen.opc.ED2 ;LDI 12e9 44 15 D . + db 0a0h ; 12eb a0 . + dw gen.opc.ED2 ;LDIR 12ec 44 15 D . + db 0b0h ; 12ee b0 . + dw gen.opc.ED2 ;NEG 12ef 44 15 D . + db 044h ; 12f1 44 D + dw as.opc.noarg ;NOP 12f2 3b 15 ; . + db 000h ; 12f4 00 . + dw as.AND_CP_OR_SUB_XOR ;OR 12f5 a8 15 . . + db 0b0h ; 12f7 b0 . + dw gen.opc.ED2 ;OTDR 12f8 44 15 D . + db 0bbh ; 12fa bb . + dw gen.opc.ED2 ;OTIR 12fb 44 15 D . + db 0b3h ; 12fd b3 . + dw as.OUT ;OUT 12fe 21 17 ! . + db 041h ; 1300 41 A + dw gen.opc.ED2 ;OUTD 1301 44 15 D . + db 0abh ; 1303 ab . + dw gen.opc.ED2 ;OUTI 1304 44 15 D . + db 0a3h ; 1306 a3 . + dw as.POP_PUSH ;POP 1307 d9 16 . . + db 0c1h ; 1309 c1 . + dw as.POP_PUSH ;PUSH 130a d9 16 . . + db 0c5h ; 130c c5 . + dw as.BITOP ;RES 130d 09 16 . . + db 080h ; 130f 80 . + dw as.RET ;RET 1310 45 16 E . + db 0c0h ; 1312 c0 . + dw gen.opc.ED2 ;RETI 1313 44 15 D . + db 04dh ; 1315 4d M + dw gen.opc.ED2 ;RETN 1316 44 15 D . + db 045h ; 1318 45 E + dw as.SHIFTOP ;RL 1319 d5 15 . . + db 010h ; 131b 10 . + dw as.opc.noarg ;RLA 131c 3b 15 ; . + db 017h ; 131e 17 . + dw as.SHIFTOP ;RLC 131f d5 15 . . + db 000h ; 1321 00 . + dw as.opc.noarg ;RLCA 1322 3b 15 ; . + db 007h ; 1324 07 . + dw gen.opc.ED2 ;RLD 1325 44 15 D . + db 06fh ; 1327 6f o + dw as.SHIFTOP ;RR 1328 d5 15 . . + db 018h ; 132a 18 . + dw as.opc.noarg ;RRA 132b 3b 15 ; . + db 01fh ; 132d 1f . + dw as.SHIFTOP ;RRC 132e d5 15 . . + db 008h ; 1330 08 . + dw as.opc.noarg ;RRCA 1331 3b 15 ; . + db 00fh ; 1333 0f . + dw gen.opc.ED2 ;RRD 1334 44 15 D . + db 067h ; 1336 67 g + dw as.RST ;RST 1337 ca 16 . . + db 0c7h ; 1339 c7 . + dw as.ADC_SBC ;SBC 133a 51 15 Q . + db 098h ; 133c 98 . + dw as.opc.noarg ;SCF 133d 3b 15 ; . + db 037h ; 133f 37 7 + dw as.BITOP ;SET 1340 09 16 . . + db 0c0h ; 1342 c0 . + dw as.SHIFTOP ;SLA 1343 d5 15 . . + db 020h ; 1345 20 + dw as.SHIFTOP ;SRA 1346 d5 15 . . + db 028h ; 1348 28 ( + dw as.SHIFTOP ;SRL 1349 d5 15 . . + db 038h ; 134b 38 8 + dw as.AND_CP_OR_SUB_XOR ;SUB 134c a8 15 . . + db 090h ; 134e 90 . + dw as.AND_CP_OR_SUB_XOR ;XOR 134f a8 15 . . + db 0a8h ; 1351 a8 . + + dw as.IN0 ;IN0 + db 000h ; + dw as.MLT ;MLT + db 04ch ; + dw gen.opc.ED2 ;OTDM + db 08bh ; + dw gen.opc.ED2 ;OTDMR + db 09bh ; + dw gen.opc.ED2 ;OTIM + db 083h ; + dw gen.opc.ED2 ;OTIMR + db 093h ; + dw as.OUTO ;OUT0 + db 001h ; + dw gen.opc.ED2 ;SLP + db 076h ; + dw as.TST ;TST + db 004h ; + dw as.TSTIO ;TSTIO + db 074h ; as.TST: call arg.r_HL_A ; @@ -3378,7 +3406,7 @@ l13d4h: jp z,ERROR ;13e9 ca 07 01 . . . l13ech: ld b,a ;13ec 47 G - jp as.opc.noarg ;13ed c3 3b 15 . ; . + jp as.opc.noarg ;13ed c3 3b 15 . ; . l13f0h: call arg.IDX_displcmnt ;13f0 cd 55 18 . U . jr nc,l1413h ;13f3 30 1e 0 . @@ -4151,9 +4179,6 @@ test_paren_close: inc de ;18ca 13 . ret ;18cb c9 . -prefix_ixiy: - db 0 ;18cc 00 . - cmd_L: ld hl,cmd_L ;18cd 21 cd 18 ! . . ld (cmd_rpt),hl ;18d0 22 68 00 " h . @@ -4255,14 +4280,11 @@ p_disas_instr: ret ;197e c9 . l197fh: - ld hl,msg_undef_opcode ;197f 21 89 19 ! . . - call pstr ;1982 cd 88 02 . . . - ld b,001h ;1985 06 01 . . - sub a ;1987 97 . - ret ;1988 c9 . - -msg_undef_opcode: + call pstr_inl DC '???' + ld b,001h + sub a + ret disas_get_instrlen: sub a ;198c 97 . @@ -4324,50 +4346,50 @@ l19edh: ; DD/FD 3 byte (ix+d)/(iy+d) b_19ef_start: - defb 034h ;19ef 34 4 - defb 035h ;19f0 35 5 - defb 036h ;19f1 36 6 - defb 046h ;19f2 46 F - defb 04eh ;19f3 4e N - defb 056h ;19f4 56 V - defb 05eh ;19f5 5e ^ - defb 066h ;19f6 66 f - defb 06eh ;19f7 6e n - defb 070h ;19f8 70 p - defb 071h ;19f9 71 q - defb 072h ;19fa 72 r - defb 073h ;19fb 73 s - defb 074h ;19fc 74 t - defb 075h ;19fd 75 u - defb 077h ;19ff 77 w - defb 07eh ;1a00 7e ~ - defb 086h ;1a01 86 . - defb 08eh ;1a02 8e . - defb 096h ;1a03 96 . - defb 09eh ;1a04 9e . - defb 0a6h ;1a05 a6 . - defb 0aeh ;1a06 ae . - defb 0b6h ;1a07 b6 . - defb 0beh ;1a08 be . - defb 0 ;1a09 00 . + db 034h ;19ef 34 4 + db 035h ;19f0 35 5 + db 036h ;19f1 36 6 + db 046h ;19f2 46 F + db 04eh ;19f3 4e N + db 056h ;19f4 56 V + db 05eh ;19f5 5e ^ + db 066h ;19f6 66 f + db 06eh ;19f7 6e n + db 070h ;19f8 70 p + db 071h ;19f9 71 q + db 072h ;19fa 72 r + db 073h ;19fb 73 s + db 074h ;19fc 74 t + db 075h ;19fd 75 u + db 077h ;19ff 77 w + db 07eh ;1a00 7e ~ + db 086h ;1a01 86 . + db 08eh ;1a02 8e . + db 096h ;1a03 96 . + db 09eh ;1a04 9e . + db 0a6h ;1a05 a6 . + db 0aeh ;1a06 ae . + db 0b6h ;1a07 b6 . + db 0beh ;1a08 be . + db 0 ;1a09 00 . ; DD/FD 2 byte l1a0ah: - defb 009h ;1a0a 09 . - defb 019h ;1a0b 19 . - defb 021h ;1a0c 21 ! - defb 022h ;1a0d 22 " - defb 023h ;1a0e 23 # - defb 029h ;1a0f 29 ) - defb 02ah ;1a10 2a * - defb 02bh ;1a11 2b + - defb 039h ;1a12 39 9 - defb 0e1h ;1a13 e1 . - defb 0e3h ;1a14 e3 . - defb 0e5h ;1a15 e5 . - defb 0e9h ;1a16 e9 . - defb 0f9h ;1a17 f9 . - defb 0 ;1a18 00 . + db 009h ;1a0a 09 . + db 019h ;1a0b 19 . + db 021h ;1a0c 21 ! + db 022h ;1a0d 22 " + db 023h ;1a0e 23 # + db 029h ;1a0f 29 ) + db 02ah ;1a10 2a * + db 02bh ;1a11 2b + + db 039h ;1a12 39 9 + db 0e1h ;1a13 e1 . + db 0e3h ;1a14 e3 . + db 0e5h ;1a15 e5 . + db 0e9h ;1a16 e9 . + db 0f9h ;1a17 f9 . + db 0 ;1a18 00 . disas_pfx.ED: inc iy ;1a19 fd 23 . # @@ -4759,12 +4781,9 @@ l1c98h: jp out_hex ;1c9d c3 18 02 . . . l1ca0h: - ld hl,b_1ca9_start ;1ca0 21 a9 1c ! . . - call pstr ;1ca3 cd 88 02 . . . - jp p_arg_hlixiy ;1ca6 c3 7e 1e . ~ . - -b_1ca9_start: + call pstr_inl ;1ca3 cd 88 02 . . . DC '(SP),' + jp p_arg_hlixiy ;1ca6 c3 7e 1e . ~ . l1caeh: call p_char_lparen ;1cb0 cd 5d 02 . ] . @@ -4776,12 +4795,9 @@ p_arg_ex_dehl: jp pstr ;1cbe c3 88 02 . . . l1cc1h: - ld hl,b_1cca_start ;1cc1 21 ca 1c ! . . - call pstr ;1cc4 cd 88 02 . . . - jp p_arg_hlixiy ;1cc7 c3 7e 1e . ~ . - -b_1cca_start: + call pstr_inl DC 'SP,' + jp p_arg_hlixiy p_arg_ex_afaf: ld hl,b_176d_start ;1ccd 21 6d 17 ! m . @@ -5234,15 +5250,6 @@ t__C_: DC '(C)' DB 0 -isprefix_ixiy: - db 0 ;1ff8 00 . -last_L: - dw TPA ;1ff9 00 01 . -l1ffbh: - dw 0 ;1ffb 00 00 . -l1ffdh: - db 0 ;1ffd 00 . - sub_1ffeh: ld hl,(REG.PC) ;1ffe 2a 60 00 * ` . ld a,h ;2001 7c | @@ -5530,17 +5537,178 @@ l21dah: ret ;21e1 c9 . b_21e2_start: - db 0 ;21e2 00 . + db 0 trace_call_flag: - db 0 ;1=call, 0=trace 21e3 00 . + db 0 ;1=call, 0=trace trace_UW_flag: - db 0 ;0 or 'U' or 'W' 21e4 00 . + db 0 ;0 or 'U' or 'W' trace_count: - dw 0 ;21e5 00 00 . + dw 0 trace_N_flag: - db 0 ;0 if 'N' 21e7 00 . + db 0 ;0 if 'N' trace_J_flag: - db 0 ;0 if 'J' 21e8 00 . + db 0 ;0 if 'J' + +;------------------------------------------------------------------------------- + +con_col: + db 0 + +l0941h: + db 0 + +bp_tab: + rept BP_CNT + rept BP_SIZE + db 0 + endm + endm + +expr_p1: + dw expr_buf +expr_p2: + dw expr_buf + +expr_buf: +current_cseg defl $ - current_cseg + .phase current_phase + current_cseg + +start: + LD SP,ldr_end+(stack-ddtz_base) + LD DE,signon ;ldr_end+(expr_buf-ddtz_base) + LD C,BDOS_PSTR + CALL BDOS + + xor a + dec a + jp po,reloc + ld de,msgz80 + LD C,BDOS_PSTR + CALL BDOS + jp 0 + +reloc: + LD HL,ldr_end+ddtz_size ;start of reloc bitmap + ld bc,0108h ;init bit counter + + EXX + LD HL,(BDOS+1) + LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL + LD BC,ddtz_size-1 + LD D,B + LD E,0FFH + INC DE ;size rounded up to next page boundary + INC BC ;ddtz_size + OR A + SBC HL,DE ;BDOS - size + LD (BDOS+1),HL ;-> new BDOS entry + + push hl + PUSH BC + ld de,ldr_end + sbc hl,de + EX DE,HL ;-> DE + LD HL,ldr_size + add hl,bc + ld b,h + ld c,l + LD HL,TPA +reloc_lp: + EXX + djnz reloc_nl + ld b,c ;reload bit counter + LD e,(HL) ;get next 8 relocation bits + INC HL +reloc_nl: + sla e + EXX + JR NC,reloc_next + DEC HL + LD A,(HL) + ADD A,E + LD (HL),A + INC HL + LD A,(HL) + ADC A,D + LD (HL),A +reloc_next: + cpi + jp pe,reloc_lp + dec hl + + POP BC + pop de + EX DE,HL + ADD HL,BC + EX DE,HL + DEC DE + LDDR + LD HL,conbuf+2-ddtz_base + ADD HL,DE + JP (HL) + +current_phase defl $ + .dephase +current_cseg defl $ + + ds EXPR_BUF_SIZE - ($ - expr_buf) +expr_bufe: + +msg_Y: + dc 'Yn' +reg_Y: + rept YREG_CNT + dw 0 + endm + +last_S: + dw TPA + +last_I: + dw 0 + +last_O_addr: + dw 0 +last_O_val: + db 0 + +cmd_Q_jopt: + db -1 + +last_D: + dw TPA + +cmdR_rindex: + db 0 + +high_load: + dw TPA +max_load: + dw TPA + +l1262h: + dw 0 +last_A: + dw TPA +cmd_A_prev: + dw TPA + +prefix_ixiy: + db 0 + +isprefix_ixiy: + db 0 +last_L: + dw TPA +l1ffbh: + dw 0 +l1ffdh: + db 0 + +cur_fcb: + dw 0 +fcbsym: + ds 33 ddtz_size equ $-ddtz_base ddtz_end: