summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo C2019-05-19 01:09:06 +0200
committerLeo C2019-05-19 01:09:28 +0200
commit0f3611859caa4fa0777f78079da1ac9b7cdcf0b7 (patch)
treed9b589524caafabbbb826f38f5f0827ebcde86be
parentefc2486ea0340c32c372f5565a48eea068687cac (diff)
downloadddt180-0f3611859caa4fa0777f78079da1ac9b7cdcf0b7.zip
reloc to current load address
-rw-r--r--Makefile4
-rw-r--r--ddt180.z80437
2 files changed, 258 insertions, 183 deletions
diff --git a/Makefile b/Makefile
index 905a397..0bf356d 100644
--- a/Makefile
+++ b/Makefile
@@ -25,12 +25,12 @@ all: $(PROG).com
-$(PROG).com: $(PROG).prl
+$(PROG).com: $(PROG).prl Makefile
@# Remove the PRL header record (256 bytes)
dd status=none bs=256 skip=1 if=$< of=$@
$(PROG).prl: $(OBJ)
- $(LINK) -'$(PROG)[op,$$SZ]'
+ $(LINK) -'$(PROG)[op]'
$(PROG).rel: version.inc
diff --git a/ddt180.z80 b/ddt180.z80
index 81b68b4..437cbcc 100644
--- a/ddt180.z80
+++ b/ddt180.z80
@@ -6,101 +6,90 @@
; - 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
+
+; Some greneral definitions
+
+BS equ 08h
+TAB equ 09h
+CR equ 0dh
+LF equ 0ah
+DEL equ 7fh
+CNTRX equ 'X'-'@'
+
+; CP/M memory layout
+
+BDOS equ 5
+TPA equ 0100h
+
+; ddtz specific definitions
+
+STACK_SIZE equ 80 ;ddtz internal stack
+CONBUF_SIZE equ 80 ;Size of console input buffer
+BP_CNT equ 12 ;Number of breakpoints
+BP_SIZE equ 4 ;Size of a breakpoint record
+
+bitmap_size equ (prog_size+7)/8
+
+;-------------------------------------------------------------------------------
cseg
-ldr_start:
- LD SP,stack
+start::
+ddtz_base::
+ jr reloc
+ nop
+l0003h:
+ rst 30h ;rst used by ddtz
+di_or_ei: ;ints enabled/disabled while ddtz is running
+ nop
+ ret
-; LD DE,signon
-; LD C,BDOS_PSTR
-; CALL BDOS
+?const: jp 0 ; return console input status
+?conin: jp 0 ; return console input character
+?cono: jp 0 ; send console output character
- 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
+ dc ' ('
;-------------------------------------------------------------------------------
-; Relocation loader
-;
- LD HL,ddtz_end ;start of reloc bitmap
- ld bc,0108h ;init bit counter
+; Determine current execution position
- 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
+reloc:
+ ld bc,(0)
+ ld de,(2)
+ ld sp,4
+ ld hl,0e9e1h ;opcpdes pop hl/jp (hl)
+ ld (0),hl
+ rst 0
+wearehere:
+ ld (0),bc
+ ld (2),de
+ ld de,-(wearehere-ddtz_base)
+ add hl,de ; hl:
- push hl
- PUSH BC
- ld de,ldr_end
+ ld de,ddtz_base ; de:
+ or a
sbc hl,de
- EX DE,HL ;-> DE
- LD HL,ldr_size
- add hl,bc
- ld b,h
- ld c,l
- LD HL,TPA
+ ex de,hl ; de: reloc offset
+ ld hl,ddtz_end ;start of reloc bitmap
+ add hl,de
+ ld a,l
+ exx
+ ld l,a
+ exx
+ ld a,h
+ exx
+ ld h,a
+ ld bc,0108h ;init bit counter b (c==reload val)
+ exx
+ LD HL,ddtz_base
+ add hl,de ;--> ddtz_base
+ ld bc,prog_size
reloc_lp:
EXX
djnz reloc_nl
@@ -125,106 +114,155 @@ reloc_next:
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)
-
-ldr_end:
-ldr_size equ $ - ldr_start
;-------------------------------------------------------------------------------
-; DDT/Z core
-;
-
-; Some greneral definitions
-
-BS equ 08h
-TAB equ 09h
-CR equ 0dh
-LF equ 0ah
-DEL equ 7fh
-CNTRX equ 'X'-'@'
-
-; CP/M memory layout
-
-BDOS equ 5
-TPA equ 0100h
-; BDOS function calls
-BDOS_PSTR equ 9 ;Print String
-
-; ddtz specific definitions
-
-STACK_SIZE equ 80 ;ddtz internal stack
-CONBUF_SIZE equ 80 ;Size of console input buffer
-BP_CNT equ 12 ;Number of breakpoints
-BP_SIZE equ 4 ;Size of a breakpoint record
;-------------------------------------------------------------------------------
-ddtz_base:
- jp 0
-l0003h:
- rst 30h
-di_or_ei:
- nop
- ret
-
- ds STACK_SIZE
-stack:
-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
- 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
- db 0c3h
-reg.pc: dw TPA
+init::
+ LD SP,stack
-cmd_rpt:dw mainloop
+ ld hl,(1) ;wboot addr
+ ld de,?const
+ ex de,hl
+ ld b,3
+vini_l:
+ inc de
+ inc de
+ inc de
+ inc hl
+ ld (hl),e
+ inc hl
+ ld (hl),d
+ inc hl
+ djnz vini_l
-;-------------------------------------------------------------------------------
+ ld hl,signon
+ call pstr
+ ld hl,ddtz_base
+ call out_hl
+ call pstr_inl
+ dc ' - '
+ ld de,prog_size+bitmap_size-1
+ add hl,de
+ call out_hl
+ call pstr_inl
+ dc ')',CR,LF
-conbuf:
- db CONBUF_SIZE
+ 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
- ds CONBUF_SIZE + 3 - ($ - conbuf)
+ jp mainloop
;-------------------------------------------------------------------------------
-?const: jp 0 ; return console input status
-?conin: jp 0 ; return console input character
-?cono: jp 0 ; send console output character
+;; Relocation loader
+;;
+;ldr_start::
+; LD HL,ddtz_end ;start of reloc bitmap
+; ld bc,0108h ;init bit counter
+;
+; EXX
+; LD HL,(BDOS+1)
+;; LD (ddtz_base+1),HL
+; LD BC,prog_size+bitmap_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,ddtz_base
+; sbc hl,de
+; EX DE,HL ;-> DE
+;; LD HL,ldr_size
+;; add hl,bc
+;; ld b,h
+;; ld c,l
+; ld bc,prog_size
+;; LD HL,TPA ;--> ddtz_base
+;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)
+;
+;ldr_end::
+;ldr_size equ $ - ldr_start
+;
+;; Entry from relocator
+;;
+;; 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
+;
+;; jp
+;
+;-------------------------------------------------------------------------------
-CMDTAB:
+CMDTAB::
dw ERROR ;cmd_@ ;examine/substitute the displacement register @
dw ERROR ;cmd_A ;Assemble
dw cmd_B ;Breakpoints display/set/clear
@@ -257,7 +295,7 @@ ERROR:
call pstr_inl
dc '?',CR,LF
;fall thru
-mainloop:
+mainloop::
ld sp,stack
ld hl,(reg.pc)
call bp_clr_temporary
@@ -479,7 +517,6 @@ DELC:
call DELC1
dec hl
dec b
- inc c
ld a,(hl)
cp ' '
ret nc
@@ -500,13 +537,10 @@ DELL:
get_line:
push hl ;
ld hl,conbuf ;
- ld c,(hl) ;
- inc hl ;
- ld b,000h ;
- inc hl ;
+ ld b,0 ;
inlnxtch:
- ld a,c ;
- or a ;
+ ld a,b ;
+ cp CONBUF_SIZE ;
jr z,inl_e ;
call incharw ;
cp CR ;
@@ -542,16 +576,12 @@ gl_5:
call outchar ;
inc hl ;
inc b ;
- dec c ;
jr inlnxtch ;
inl_e:
ld (hl),0
- ld hl,conbuf+1 ;
- ld (hl),b ;
call CRLF ;
- inc hl
- ex de,hl
+ ld de,conbuf ;
pop hl ;
ret ;
@@ -986,6 +1016,9 @@ do_factor:
ld hl,TPA
cp 'L'
ret z
+ ld hl,(reg.pc)
+ cp '$'
+ ret z
cp '-'
jr z,fact_factneg
cp '~'
@@ -2044,7 +2077,7 @@ cmd_M:
dec hl
dec de
lddr
- db 01h ;swallow ldir instruction (ld bc,...)
+ ret
cmdm_up:
ldir
ret
@@ -2143,9 +2176,9 @@ l0ed3h:
ret
sub_0ee6h:
- ld hl,conbuf+1
+ ld hl,conbuf
call sub_0ef7h
- ld de,conbuf+1
+ ld de,conbuf
and a
sbc hl,de
ld b,l
@@ -3723,8 +3756,50 @@ last_L:
pbl_loop_adr:
dw 0addeh
+;-------------------------------------------------------------------------------
+
+conbuf::
+ ds CONBUF_SIZE+1
+
+;-------------------------------------------------------------------------------
+
+ rept (STACK_SIZE+3)/4
+ db 0deh,0adh,0beh,0efh
+ endm
+stack::
+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
+ 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
+ db 0c3h
+reg.pc: dw TPA
+
+cmd_rpt:dw mainloop
+
+;-------------------------------------------------------------------------------
+
ddtz_size equ $-ddtz_base
-ddtz_end:
+prog_size equ $-start
+ddtz_end::
;-------------------------------------------------------------------------------