macros to make relocation easier
This commit is contained in:
parent
5d56dd1e2a
commit
719bca04ac
104
path.s
104
path.s
|
@ -14,7 +14,7 @@
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;;
|
;;;
|
||||||
;;; Installed command memory structure:
|
;;; Installed command memory structure:
|
||||||
;;; * 3 pages - code, path buffers
|
;;; * 2 pages - code, path buffer
|
||||||
|
|
||||||
;;; TODO:
|
;;; TODO:
|
||||||
;;; * Support multi-segment path (e.g. /hd/bin:/hd/extras/bin)
|
;;; * Support multi-segment path (e.g. /hd/bin:/hd/extras/bin)
|
||||||
|
@ -118,16 +118,44 @@ CASE_MASK = $DF
|
||||||
|
|
||||||
;; Complete
|
;; Complete
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
new_page:
|
||||||
|
.byte 0
|
||||||
|
|
||||||
|
page_delta:
|
||||||
|
.byte 0
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
;;; ============================================================
|
||||||
|
;;;
|
||||||
|
;;; Relocatable Section
|
||||||
|
;;;
|
||||||
|
;;; ============================================================
|
||||||
|
|
||||||
|
;;; Use `reloc_counter ADDR` anywhere that needs the page updated
|
||||||
|
;;;
|
||||||
|
;;; Examples:
|
||||||
|
;;;
|
||||||
|
;;; reloc_point *+2 ; update MSB of following JSR
|
||||||
|
;;; jsr routine
|
||||||
|
;;;
|
||||||
|
;;; reloc_point *+1 ; update MSB used in following LDA
|
||||||
|
;;; lda #>routine
|
||||||
|
|
||||||
|
::reloc_counter .set 0
|
||||||
|
.macro reloc_point addr
|
||||||
|
::.ident (.sprintf ("RL%04X", ::reloc_counter)) := addr
|
||||||
|
::reloc_counter .set ::reloc_counter + 1
|
||||||
|
.endmacro
|
||||||
|
|
||||||
|
;;; Align handler to page boundary for easier relocation
|
||||||
|
.res $2100 - *, 0
|
||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;; Command Handler
|
;;; Command Handler
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
|
|
||||||
;; Align handler to page boundary for easier
|
|
||||||
;; relocation
|
|
||||||
.res $2100 - *, 0
|
|
||||||
|
|
||||||
.proc handler
|
.proc handler
|
||||||
ptr := $06 ; pointer into VPATH
|
ptr := $06 ; pointer into VPATH
|
||||||
tptr := $08 ; pointer into TOKEN_NAME_TABLE
|
tptr := $08 ; pointer into TOKEN_NAME_TABLE
|
||||||
|
@ -138,15 +166,15 @@ CASE_MASK = $DF
|
||||||
sta ptr+1
|
sta ptr+1
|
||||||
|
|
||||||
;; Check for this command, character by character.
|
;; Check for this command, character by character.
|
||||||
page_num9 := *+2 ; address needing updating
|
reloc_point *+2
|
||||||
jsr skip_leading_spaces
|
jsr skip_leading_spaces
|
||||||
|
|
||||||
ldy #0 ; position in command string
|
ldy #0 ; position in command string
|
||||||
|
|
||||||
page_num6 := *+2 ; address needing updating
|
reloc_point *+2
|
||||||
nxtchr: jsr to_upper_ascii
|
nxtchr: jsr to_upper_ascii
|
||||||
|
|
||||||
page_num1 := *+2 ; address needing updating
|
reloc_point *+2
|
||||||
cmp command_string,y
|
cmp command_string,y
|
||||||
bne check_if_token
|
bne check_if_token
|
||||||
inx
|
inx
|
||||||
|
@ -161,7 +189,7 @@ nxtchr: jsr to_upper_ascii
|
||||||
;; Point BI's parser at the command execution routine.
|
;; Point BI's parser at the command execution routine.
|
||||||
lda #<execute
|
lda #<execute
|
||||||
sta XTRNADDR
|
sta XTRNADDR
|
||||||
page_num2 := *+1 ; address needing updating
|
reloc_point *+1
|
||||||
lda #>execute
|
lda #>execute
|
||||||
sta XTRNADDR+1
|
sta XTRNADDR+1
|
||||||
|
|
||||||
|
@ -182,13 +210,13 @@ nxtchr: jsr to_upper_ascii
|
||||||
|
|
||||||
check_if_token:
|
check_if_token:
|
||||||
;; Is a PATH set?
|
;; Is a PATH set?
|
||||||
page_num17 := *+2 ; address needing updating
|
reloc_point *+2
|
||||||
lda path_buffer
|
lda path_buffer
|
||||||
beq not_ours
|
beq not_ours
|
||||||
|
|
||||||
page_num10 := *+2 ; address needing updating
|
reloc_point *+2
|
||||||
jsr skip_leading_spaces
|
jsr skip_leading_spaces
|
||||||
page_num7 := *+2 ; address needing updating
|
reloc_point *+2
|
||||||
jsr to_upper_ascii
|
jsr to_upper_ascii
|
||||||
|
|
||||||
cmp #'A'
|
cmp #'A'
|
||||||
|
@ -216,7 +244,7 @@ mloop: iny ; Advance through token table
|
||||||
|
|
||||||
;; Check for match
|
;; Check for match
|
||||||
next_char:
|
next_char:
|
||||||
page_num8 := *+2 ; address needing updating
|
reloc_point *+2
|
||||||
jsr to_upper_ascii ; Next character
|
jsr to_upper_ascii ; Next character
|
||||||
|
|
||||||
;; NOTE: Does not skip over spaces, unlike BASIC tokenizer
|
;; NOTE: Does not skip over spaces, unlike BASIC tokenizer
|
||||||
|
@ -229,7 +257,7 @@ next_char:
|
||||||
|
|
||||||
;; Otherwise, advance to next token
|
;; Otherwise, advance to next token
|
||||||
next_token:
|
next_token:
|
||||||
page_num12 := *+2 ; address needing updating
|
reloc_point *+2
|
||||||
jsr skip_leading_spaces
|
jsr skip_leading_spaces
|
||||||
sloop: lda (tptr),y ; Scan table looking for a high bit set
|
sloop: lda (tptr),y ; Scan table looking for a high bit set
|
||||||
iny
|
iny
|
||||||
|
@ -251,10 +279,10 @@ not_ours:
|
||||||
|
|
||||||
maybe_invoke:
|
maybe_invoke:
|
||||||
;; Compose path
|
;; Compose path
|
||||||
page_num14 := *+2 ; address needing updating
|
reloc_point *+2
|
||||||
ldx path_buffer
|
ldx path_buffer
|
||||||
ldy #1
|
ldy #1
|
||||||
page_num11 := *+2 ; address needing updating
|
reloc_point *+2
|
||||||
: lda path_buffer,y
|
: lda path_buffer,y
|
||||||
sta (ptr),y
|
sta (ptr),y
|
||||||
iny
|
iny
|
||||||
|
@ -265,9 +293,9 @@ maybe_invoke:
|
||||||
sta (ptr),y
|
sta (ptr),y
|
||||||
iny
|
iny
|
||||||
|
|
||||||
page_num15 := *+2 ; address needing updating
|
reloc_point *+2
|
||||||
jsr skip_leading_spaces
|
jsr skip_leading_spaces
|
||||||
page_num16 := *+2 ; address needing updating
|
reloc_point *+2
|
||||||
: jsr to_upper_ascii
|
: jsr to_upper_ascii
|
||||||
cmp #'.'
|
cmp #'.'
|
||||||
beq ok
|
beq ok
|
||||||
|
@ -388,10 +416,10 @@ execute:
|
||||||
;; Show current path
|
;; Show current path
|
||||||
|
|
||||||
ldx #0
|
ldx #0
|
||||||
page_num3 := *+2 ; address needing updating
|
reloc_point *+2
|
||||||
: cpx path_buffer
|
: cpx path_buffer
|
||||||
beq done
|
beq done
|
||||||
page_num4 := *+2 ; address needing updating
|
reloc_point *+2
|
||||||
lda path_buffer+1,x
|
lda path_buffer+1,x
|
||||||
ora #$80
|
ora #$80
|
||||||
jsr COUT
|
jsr COUT
|
||||||
|
@ -409,7 +437,7 @@ set_path:
|
||||||
lda (ptr),y
|
lda (ptr),y
|
||||||
tay
|
tay
|
||||||
: lda (ptr),y
|
: lda (ptr),y
|
||||||
page_num5 := *+2 ; address needing updating
|
reloc_point *+2
|
||||||
sta path_buffer,y
|
sta path_buffer,y
|
||||||
dey
|
dey
|
||||||
bpl :-
|
bpl :-
|
||||||
|
@ -459,29 +487,15 @@ path_buffer:
|
||||||
next_command := handler::next_command
|
next_command := handler::next_command
|
||||||
|
|
||||||
;;; ============================================================
|
;;; ============================================================
|
||||||
;;; Installation Data
|
;;;
|
||||||
|
;;; Relocation Table
|
||||||
new_page:
|
;;;
|
||||||
.byte 0
|
;;; ============================================================
|
||||||
page_delta:
|
|
||||||
.byte 0
|
|
||||||
|
|
||||||
relocation_table:
|
relocation_table:
|
||||||
.byte (table_end - *) / 2
|
.byte ::reloc_counter
|
||||||
.addr handler::page_num1
|
.repeat ::reloc_counter, rc
|
||||||
.addr handler::page_num2
|
.addr ::.ident (.sprintf ("RL%04X", rc))
|
||||||
.addr handler::page_num3
|
.endrepeat
|
||||||
.addr handler::page_num4
|
|
||||||
.addr handler::page_num5
|
;;; ============================================================
|
||||||
.addr handler::page_num6
|
|
||||||
.addr handler::page_num7
|
|
||||||
.addr handler::page_num8
|
|
||||||
.addr handler::page_num9
|
|
||||||
.addr handler::page_num10
|
|
||||||
.addr handler::page_num11
|
|
||||||
.addr handler::page_num12
|
|
||||||
.addr handler::page_num14
|
|
||||||
.addr handler::page_num15
|
|
||||||
.addr handler::page_num16
|
|
||||||
.addr handler::page_num17
|
|
||||||
table_end := *
|
|
||||||
|
|
Loading…
Reference in New Issue