Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BASIC] Fix 1E39 bug (Issue #247) #357

Merged
merged 7 commits into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 43 additions & 22 deletions basic/code17.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,57 @@ conint jsr posint
bne gofuc
ldx faclo
jmp chrgot
val jsr len1
val_str bne @1

; the "val" function takes a string and turns it into a number by interpreting
; the ascii digits etc. Except for the problem that a terminator must be
; supplied by replacing the character beyond the string, VAL is merely a call
; to floating point input ("finh").
val jsr len1 ;get length
val_str bne @1 ;return 0 if len=0
jmp zerofc
@1: ldx txtptr
@1: ldx txtptr ;save current txtptr
ldy txtptr+1
stx strng2
sty strng2+1
ldx index1
stx txtptr
clc
adc index1
sta index2
ldx index1+1
stx txtptr+1
bcc val2
inx
val2 stx index2+1
lda (index2)
phy
phx
ldx index1 ;save current index1
ldy index1+1
phy
phx
pha
lda #0
sta (index2)
inc
calmsacibis995 marked this conversation as resolved.
Show resolved Hide resolved
beq val_strlong
jsr strspa ;allocate memory for string (this destroys index1, but we saved it to stack)
plx ;restore saved string length
pla
sta index1 ;restore saved index1
pla
sta index1+1
lda dsctmp+1 ;fetch string space pointer
sta txtptr ;update txtptr with dsctmp
lda dsctmp+2
sta txtptr+1
ldy #0 ;initalize Y to begin copying the string
@2: lda (index1),y ;load current byte
sta (txtptr),y ;store it in allocated memory
iny
dex
bne @2 ;loop until string is copied
lda #0 ;load null terminator byte
sta (txtptr),y ;write it to the end of the string
jsr chrgot
jsr finh
pla
sta (index2)
st2txt ldx strng2
plx ;restore saved txtptr
ply
stx txtptr
sty txtptr+1
rts ;done!
st2txt ldx strng2 ;restore text pointer
ldy strng2+1
stx txtptr
sty txtptr+1
valrts rts
valrts rts ;done!
val_strlong ldx #errls
jmp error
getnum jsr frmadr
combyt jsr chkcom
jmp getbyt
Expand Down
Loading