Parse options properly

This commit is contained in:
Byron Lathi
2023-08-25 21:26:28 -07:00
parent a971e7a717
commit 4b2b1a425e
2 changed files with 27 additions and 3 deletions

View File

@@ -205,10 +205,12 @@ _start:
stx dlen + 1 stx dlen + 1
ldy #O65_OPT_START ldy #O65_OPT_START
phy
@opt_len: @opt_len:
lda #<opt_str lda #<opt_str
ldx #>opt_str ldx #>opt_str
jsr pushax jsr pushax
ply
lda filebuf,y lda filebuf,y
beq @opt_end beq @opt_end
sta olen sta olen
@@ -220,12 +222,30 @@ _start:
sta otype sta otype
phy phy
jsr pusha0 jsr pusha0
ply
ldy #$6 ldy #$6
jsr _cprintf jsr _cprintf
lda #<word_str
ldx #>word_str
jsr pushax
pla
adc olen
dec
dec
pha
bra @opt_len
@opt_end: @opt_end:
; do something iny ; account for reading size
phy
lda #<opt_done
ldx #>opt_done
jsr pushax
pla
jsr pusha0
ldy #$4
jsr _cprintf
@end: bra @end @end: bra @end
@@ -236,4 +256,5 @@ kernel_str: .asciiz "KERNEL O65"
_good: .asciiz "Found KERNEL\r\n" _good: .asciiz "Found KERNEL\r\n"
word_str: .asciiz "Word Value: %x\r\n" word_str: .asciiz "Word Value: %x\r\n"
opt_str: .asciiz "Opt Len: %x, Opt Type: %x\r\n" opt_str: .asciiz "Opt Len: %x, Opt Type: %x\r\n"
opt_done: .asciiz "Options done. total option length: %x\r\n"

View File

@@ -37,6 +37,9 @@ class O65():
self.options.append((olen, otype, obytes)) self.options.append((olen, otype, obytes))
olen = int.from_bytes(_file.read(1)) olen = int.from_bytes(_file.read(1))
text_offs = _file.tell()
print(f"Text offset: {text_offs}")
self.text = _file.read(self.header["tlen"]) self.text = _file.read(self.header["tlen"])
self.data = _file.read(self.header["dlen"]) self.data = _file.read(self.header["dlen"])