fix a const long value hex asm mistake, fix conv.str_l(0) empty output

This commit is contained in:
Irmen de Jong
2025-10-12 01:44:16 +02:00
parent 13f6efc1d1
commit fc38be6376
4 changed files with 22 additions and 11 deletions

View File

@@ -870,13 +870,13 @@ class AsmGen6502Internal (
when(target.kind) { when(target.kind) {
TargetStorageKind.VARIABLE -> { TargetStorageKind.VARIABLE -> {
out(""" out("""
lda #${hex.substring(6,8)} lda #$${hex.substring(6,8)}
sta ${target.asmVarname} sta ${target.asmVarname}
lda #${hex.substring(4, 6)} lda #$${hex.substring(4, 6)}
sta ${target.asmVarname}+1 sta ${target.asmVarname}+1
lda #${hex.substring(2, 4)} lda #$${hex.substring(2, 4)}
sta ${target.asmVarname}+2 sta ${target.asmVarname}+2
lda #${hex.take(2)} lda #$${hex.take(2)}
sta ${target.asmVarname}+3""") sta ${target.asmVarname}+3""")
} }
TargetStorageKind.ARRAY -> TODO("assign long to array ${target.position}") TargetStorageKind.ARRAY -> TODO("assign long to array ${target.position}")

View File

@@ -269,6 +269,10 @@ sub str_l (long value) -> str {
bne + bne +
inx inx
bne - bne -
+ cpx #10 ; just all 0? keep one
bne +
dex
+ ; x points at the rightmost leading 0 + ; x points at the rightmost leading 0
lda negative lda negative
beq + beq +

View File

@@ -1,6 +1,8 @@
TODO TODO
==== ====
fix crash for txt.print_l(conv.str_l(0))
STRUCTS and TYPED POINTERS STRUCTS and TYPED POINTERS
-------------------------- --------------------------

View File

@@ -3,12 +3,17 @@
main { main {
sub start() { sub start() {
long lv1, lv2, lv3 txt.print_l(0)
txt.nl()
lv1 = 999999 txt.print(conv.str_l(0))
lv2 = 555555 ; long lv1, lv2, lv3
lv3 = 222222 ;
lv1 = lv2-(lv3*2) ; lv1 = 999999
txt.print_l(lv1) ; lv2 = 555555
; lv3 = 222222
; lv1 = lv2-(lv3 | $2222)
; txt.print_l(lv1)
; txt.spc()
; txt.print_ulhex(lv1, true)
} }
} }