X-Git-Url: http://cloudbase.mooo.com/gitweb/ddt180.git/blobdiff_plain/8c416d5a86ae7c2c9557057b230438552f9f992b..efc2486ea0340c32c372f5565a48eea068687cac:/ddt180.z80 diff --git a/ddt180.z80 b/ddt180.z80 index 45b3ea5..81b68b4 100644 --- a/ddt180.z80 +++ b/ddt180.z80 @@ -6,22 +6,140 @@ ; - Use Digital Research Link-80 to generate a .PRL file (op switch). ; - Cut the .PRL header (first 256 byte) end rename the result to DDTZ.COM. +TPA equ 0100h + + cseg +ldr_start: + LD SP,stack + +; LD DE,signon +; LD C,BDOS_PSTR +; CALL BDOS + + ld hl,(1) ;wboot addr + ld de,?const + ld b,3 +vini_l: + inc hl + inc hl + inc hl + ex de,hl + inc hl + ld (hl),e + inc hl + ld (hl),d + inc hl + ex de,hl + djnz vini_l + +signon: + call pstr_inl + db 'DDTZ/180' + db ' - Version ' + maclib version.inc + defvers + dc CR,LF + +; ld sp,stack +; exx +; ld de,ddtz_base +; call cp_hl_de +; jr c,l0079h +; ex de,hl +;l0079h: +; ld de,TPA +;l007ch: +; 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 + call di_or_ei + ld hl,ddtz_base + ld l,000h + ld (reg_sp),hl + + jp mainloop + ;------------------------------------------------------------------------------- ; Relocation loader ; -TPA equ 0100h - cseg - .phase TPA + LD HL,ddtz_end ;start of reloc bitmap + ld bc,0108h ;init bit counter - jp start - ds 3 + EXX + LD HL,(BDOS+1) + LD (ddtz_base+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 -ldr_end: -ldr_size equ $ - TPA -current_phase defl $ + 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: + inc hl + dec bc + ld a,b + or c + jr nz,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) - .dephase -current_cseg defl $ +ldr_end: +ldr_size equ $ - ldr_start ;------------------------------------------------------------------------------- ; DDT/Z core @@ -49,38 +167,20 @@ BDOS_PSTR equ 9 ;Print String STACK_SIZE equ 80 ;ddtz internal stack CONBUF_SIZE equ 80 ;Size of console input buffer -EXPR_BUF_SIZE equ 128 ;expressen buffer for conditional breakpoints BP_CNT equ 12 ;Number of breakpoints BP_SIZE equ 4 ;Size of a breakpoint record ;------------------------------------------------------------------------------- ddtz_base: - jp ddtz_bdos + jp 0 l0003h: rst 30h di_or_ei: nop ret -ddtz_bdos: - jp 0 - -current_cseg defl $ - current_cseg - .phase current_phase + current_cseg -signon: - db 'DDTZ/180' - db ' - Version ' - maclib version.inc - defvers - db 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 @@ -116,54 +216,6 @@ cmd_rpt:dw mainloop conbuf: db CONBUF_SIZE - ld sp,stack - exx - ld de,ddtz_base - call cp_hl_de - jr c,l0079h - ex de,hl -l0079h: - ld de,TPA -l007ch: - 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 - call di_or_ei - ld hl,ddtz_base - ld l,000h - ld (reg_sp),hl - - ld hl,(1) ;wboot addr - ld de,?const - ld b,6 -vini_l: - inc hl - inc hl - inc hl - ex de,hl - inc hl - ld (hl),e - inc hl - ld (hl),d - inc hl - ex de,hl - djnz vini_l - - jr mainloop - ds CONBUF_SIZE + 3 - ($ - conbuf) ;------------------------------------------------------------------------------- @@ -171,9 +223,6 @@ vini_l: ?const: jp 0 ; return console input status ?conin: jp 0 ; return console input character ?cono: jp 0 ; send console output character -?list: jp 0 ; send list output character -?auxo: jp 0 ; send auxiliary output character -?auxi: jp 0 ; return auxiliary input character CMDTAB: dw ERROR ;cmd_@ ;examine/substitute the displacement register @ @@ -2493,15 +2542,6 @@ disas_nopfx: disas_pfx.ED: inc iy - ld hl,b_1bc9_start ;1 byte opcode, no arguments - call lookup_op - ld b,2 - ret c - ld hl,b_1bf4_start - call lookup_op_arg - ld b,2 - ret c - ld hl,l228bh call lookup_op_arg ld b,3 @@ -2509,6 +2549,32 @@ disas_pfx.ED: ld hl,b_1c40_start call lookup_op_arg ld b,4 + ret c + + ld hl,b_1bc9_start ;1 byte opcode, no arguments + call lookup_op + jr c,da_ed1 + + ld hl,b_1bf4_start + call lookup_op_arg + ret nc + + ld a,e + cp a_noarg + jr nz,da_ed0 + ld c,(iy+0) + ld a,c + rra + and 0ch + ld b,a + ld a,c + and 03h + call str_sel_ab + +da_ed0: + scf +da_ed1: + ld b,2 ret ;------------------------------------------------------------------------------- @@ -2605,22 +2671,6 @@ l1a0ah: ;------------------------------------------------------------------------------- -lookup_op: - ld a,(hl) - cp 0ffh - ret z - cp (iy+000h) - jr z,l1a7fh - inc hl - inc hl - jr lookup_op -l1a7fh: - ld e,a_noarg - inc hl - ld b,(hl) - jr get_mnemonic - - test_DDFD: ld a,(hl) and a @@ -2631,27 +2681,29 @@ test_DDFD: scf ret -lookup_op_arg: - ld a,(iy+000h) - and (hl) - inc hl - cp (hl) - inc hl - jr z,l1aa8h +lookup_op: + ld a,(hl) inc hl + cp 0ffh + ret z + cp (iy+000h) + jr z,l1a7fh inc hl - ld a,(hl) - and a - jr nz,lookup_op_arg - ret - -l1aa8h: + jr lookup_op +l1a7fh: ld b,(hl) - inc b + ld e,a_noarg + jr get_mnemonic + +lookup_op_arg: + call lookup_branch_op + ret nc + ld a,e + ld e,d + cp a,0ffh ret z ;carry clear - dec b - inc hl - ld e,(hl) + ld b,a + get_mnemonic: ld hl,t_MNEMONICS bit 7,b @@ -2662,6 +2714,7 @@ get_mnemonic: rra rra and 07h +str_sel_ab: add b ld b,a get_m1: @@ -2670,18 +2723,17 @@ get_m1: ret lookup_branch_op ;TODO - ld a,(iy+000h) - and (hl) + ld a,(hl) + and a + ret z inc hl + and (iy+000h) cp (hl) inc hl jr z,l1aa8_br inc hl inc hl - ld a,(hl) - and a - jr nz,lookup_branch_op - ret + jr lookup_branch_op l1aa8_br: ld e,(hl) @@ -2699,14 +2751,14 @@ b_1ab6_start: db 0f3h,i_DI ;di db 0fbh,i_EI ;ei db 000h,i_NOP ;nop - db 007h,i_RLCA ;rlca - db 00fh,i_RRCA ;rrca - db 017h,i_RLA ;rla - db 01fh,i_RRA ;rra - db 027h,i_DAA ;daa - db 02fh,i_CPL ;cpl - db 037h,i_SCF ;scf - db 03fh,i_CCF ;ccf +; db 007h,i_RLCA ;rlca +; db 00fh,i_RRCA ;rrca +; db 017h,i_RLA ;rla +; db 01fh,i_RRA ;rra +; db 027h,i_DAA ;daa +; db 02fh,i_CPL ;cpl +; db 037h,i_SCF ;scf +; db 03fh,i_CCF ;ccf db 0c9h,i_RET ;ret db 0ffh @@ -2717,22 +2769,27 @@ b_1ab6_start: b_1ad1_start: db 0c0h,040h,i_LD ;ld r[y],r[z] db a_rr - db 0f8h,080h,i_ADD ;add a,r[z] - db a_ar - db 0f8h,088h,i_ADC ;adc a,r[z] - db a_ar - db 0f8h,090h,i_SUB ;sub r[z] - db a_r - db 0f8h,098h,i_SBC ;sbc a,r[z] - db a_ar - db 0f8h,0a0h,i_AND ;and r[z] - db a_r - db 0f8h,0a8h,i_XOR ;xor r[z] - db a_r - db 0f8h,0b0h,i_OR ;or r[z] - db a_r - db 0f8h,0b8h,i_CP ;cp r[z] + + db 0c0h,080h,i_ADD+080h ;add a,r[z] db a_r + +; db 0f8h,080h,i_ADD ;add a,r[z] +; db a_ar +; db 0f8h,088h,i_ADC ;adc a,r[z] +; db a_ar +; db 0f8h,090h,i_SUB ;sub r[z] +; db a_r +; db 0f8h,098h,i_SBC ;sbc a,r[z] +; db a_ar +; db 0f8h,0a0h,i_AND ;and r[z] +; db a_r +; db 0f8h,0a8h,i_XOR ;xor r[z] +; db a_r +; db 0f8h,0b0h,i_OR ;or r[z] +; db a_r +; db 0f8h,0b8h,i_CP ;cp r[z] +; db a_r + db 0c7h,0c0h,i_RET ;ret cc db a_cc db 0c7h,0c7h,i_RST ;rst @@ -2765,28 +2822,37 @@ b_1ad1_start: db a_pa db 0efh,00ah,i_LD ;ld a,(rp) ;rp=bc,de db a_ap + + db 0c7h,007h,i_RLCA+080h;rlca + db a_noarg + db 0 ; 2 byte opcodes b_1b54_start: db 0c7h,006h,i_LD ;ld r[y],nn db a_rn - db 0ffh,0c6h,i_ADD ;add a,nn - db a_an - db 0ffh,0ceh,i_ADC ;adc a,nn - db a_an - db 0ffh,0d6h,i_SUB ;sub nn - db a_n - db 0ffh,0deh,i_SBC ;sbc a,nn - db a_an - db 0ffh,0e6h,i_AND ;and nn - db a_n - db 0ffh,0eeh,i_XOR ;xor nn - db a_n - db 0ffh,0f6h,i_OR ;or nn - db a_n - db 0ffh,0feh,i_CP ;cp nn + + db 0c7h,0c6h,i_ADD+080h ;add a,r[z] db a_n + +; db 0ffh,0c6h,i_ADD ;add a,nn +; db a_an +; db 0ffh,0ceh,i_ADC ;adc a,nn +; db a_an +; db 0ffh,0d6h,i_SUB ;sub nn +; db a_n +; db 0ffh,0deh,i_SBC ;sbc a,nn +; db a_an +; db 0ffh,0e6h,i_AND ;and nn +; db a_n +; db 0ffh,0eeh,i_XOR ;xor nn +; db a_n +; db 0ffh,0f6h,i_OR ;or nn +; db a_n +; db 0ffh,0feh,i_CP ;cp nn +; db a_n + db 0ffh,010h,i_DJNZ ;djnz db a_j db 0ffh,018h,i_JR ;jr @@ -2829,22 +2895,22 @@ b_1bc9_start: db 04dh,i_RETI ;reti db 067h,i_RRD ;rrd db 06fh,i_RLD ;rld - db 0a0h,i_LDI ;ldi - db 0a1h,i_CPI ;cpi - db 0a2h,i_INI ;ini - db 0a3h,i_OUTI ;outi - db 0a8h,i_LDD ;ldd - db 0a9h,i_CPD ;cpd - db 0aah,i_IND ;ind - db 0abh,i_OUTD ;outd - db 0b0h,i_LDIR ;ldir - db 0b1h,i_CPIR ;cpir - db 0b2h,i_INIR ;inir - db 0b3h,i_OTIR ;otir - db 0b8h,i_LDDR ;lddr - db 0b9h,i_CPDR ;cpdr - db 0bah,i_INDR ;indr - db 0bbh,i_OTDR ;otdr +; db 0a0h,i_LDI ;ldi +; db 0a1h,i_CPI ;cpi +; db 0a2h,i_INI ;ini +; db 0a3h,i_OUTI ;outi +; db 0a8h,i_LDD ;ldd +; db 0a9h,i_CPD ;cpd +; db 0aah,i_IND ;ind +; db 0abh,i_OUTD ;outd +; db 0b0h,i_LDIR ;ldir +; db 0b1h,i_CPIR ;cpir +; db 0b2h,i_INIR ;inir +; db 0b3h,i_OTIR ;otir +; db 0b8h,i_LDDR ;lddr +; db 0b9h,i_CPDR ;cpdr +; db 0bah,i_INDR ;indr +; db 0bbh,i_OTDR ;otdr db 08bh,i_OTDM ;otdm db 09bh,i_OTDMR ;otdmr db 083h,i_OTIM ;otim @@ -2853,6 +2919,8 @@ b_1bc9_start: db 0ffh ; b_1bf4_start: + db 0e4h,0a0h,i_LDI + db a_noarg db 0ffh,070h,i_IN ;in (c) ; db a_c db 0c7h,040h,i_IN ;in r,(c) ;r=b,c,d,e,h,l,a @@ -2906,20 +2974,23 @@ b_1c40_start: ; CB b_1c55_start: - db 0f8h,000h,i_RLC ;rlc g - db a_cbr - db 0f8h,008h,i_RRC ;rrc g - db a_cbr - db 0f8h,010h,i_RL ;rl g - db a_cbr - db 0f8h,018h,i_RR ;rr g - db a_cbr - db 0f8h,020h,i_SLA ;sla g - db a_cbr - db 0f8h,028h,i_SRA ;sra g - db a_cbr - db 0f8h,038h,i_SRL ;srl g + db 0c0h,000h,i_RLC+080h ;rlc g db a_cbr + +; db 0f8h,000h,i_RLC ;rlc g +; db a_cbr +; db 0f8h,008h,i_RRC ;rrc g +; db a_cbr +; db 0f8h,010h,i_RL ;rl g +; db a_cbr +; db 0f8h,018h,i_RR ;rr g +; db a_cbr +; db 0f8h,020h,i_SLA ;sla g +; db a_cbr +; db 0f8h,028h,i_SRA ;sra g +; db a_cbr +; db 0f8h,038h,i_SRL ;srl g +; db a_cbr db 0c0h,040h,i_BIT ;bit b,g db a_bcbr db 0c0h,080h,i_RES ;res b,g @@ -2973,8 +3044,8 @@ a_rr equ $-t_argf db fi_ry,',' ;ld r[y],r[z] a_r equ $-t_argf db fi_rz,0 ;op r[z] -a_ar equ $-t_argf - db 'A,',fi_rz,0 ;op A,r[z] +;a_ar equ $-t_argf +; db 'A,',fi_rz,0 ;op A,r[z] a_cc equ $-t_argf db fi_ccy,0 ;op cc[y] a_rst equ $-t_argf @@ -3003,8 +3074,8 @@ a_ap equ $-t_argf ; 2 byte opcodes a_rn equ $-t_argf db fi_ry,',',fi_n,0 ;ld r[y],n -a_an equ $-t_argf - db 'A,' ;op a,n +;a_an equ $-t_argf +; db 'A,' ;op a,n a_n equ $-t_argf db fi_n,0 ;op n a_ccj equ $-t_argf @@ -3247,25 +3318,13 @@ pstr_inl: opc macro x i_&x equ opc_index -o_&x equ $-opc_tabstart +;o_&x equ $-opc_tabstart dc '&x' opc_index defl opc_index+1 endm -opc1 macro x,y - -i_&x&y equ opc_index -o_&x&y equ $-opc_tabstart - db '&x' -i_&y equ opc_index+1 -o_&y equ $-opc_tabstart - dc '&y' -opc_index defl opc_index+2 - endm - - t_MNEMONICS: -opc_tabstart defl $ +;opc_tabstart defl $ opc_index defl 0 ; 1-byte other opc NOP @@ -3328,8 +3387,7 @@ opc_index defl 0 opc RRD opc RLD -;Block instructions -t_mn_bli: +; Block instructions opc LDI opc CPI opc INI @@ -3347,7 +3405,7 @@ t_mn_bli: opc INDR opc OTDR -;Z180 +; Z180 opc IN0 opc OUT0 opc TST @@ -3453,7 +3511,7 @@ t_op_branch: dw l20ach db 0ffh,0edh ;Prefix ED dw l20b8h -t_op_branch0: + db 0ffh,0cdh ;call mn dw l2080h db 0ffh,0c3h ;jp mn @@ -3636,91 +3694,6 @@ bp_tab: endm endm -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: - ;------------------------------------------------------------------------------- last_S: @@ -3748,7 +3721,7 @@ last_L: dw TPA pbl_loop_adr: - dw 0 + dw 0addeh ddtz_size equ $-ddtz_base ddtz_end: