1
0
mirror of https://github.com/irmen/prog8.git synced 2025-01-12 19:29:50 +00:00

tweak diskio to not always include unused subroutine internal_f_tell() in resulting program

This commit is contained in:
Irmen de Jong 2024-09-11 19:51:53 +02:00
parent d34015eec5
commit 6be6eb2227
2 changed files with 36 additions and 12 deletions
compiler/res/prog8lib/cx16
docs/source

@ -935,15 +935,14 @@ io_error:
return
cx16.r0 = cx16.r1 = cx16.r2 = cx16.r3 = 0
sub read4hex() -> uword {
str hex = "0000"
hex[0] = cbm.CHRIN()
hex[1] = cbm.CHRIN()
hex[2] = cbm.CHRIN()
hex[3] = cbm.CHRIN()
return conv.hex2uword(hex)
}
}
sub read4hex() -> uword {
ubyte[5] hex = 0
hex[0] = cbm.CHRIN()
hex[1] = cbm.CHRIN()
hex[2] = cbm.CHRIN()
hex[3] = cbm.CHRIN()
return conv.hex2uword(hex)
}
}

@ -2,11 +2,36 @@ TODO
====
IR: add codegen for containmentcheck literal + test that it actually works (positive and negative)
diskio.internal_f_tell gets included in the assembly even though f_tell is never called ??? (when using another routine from diskio...)
IR: Improve codegen for for loops downto 0. (BPL if <=127 etc like 6502 codegen?)
callgraph issue? : if a sub contains another sub and it calls that, the outer sub is never removed even if it doesn't get called?
callgraph issue? : there's an odd case that keeps unused subroutines marked as used , they don't get removed. Has to do with declaring string var. ::
%import conv
%option no_sysinit
main {
sub start() {
cx16.r0++
}
}
stuff {
asmsub shim() {
%asm {{
jmp p8s_read4hex
}}
}
sub read4hex() -> uword {
;ubyte[5] hex = 0
str hex = "0000" ; TODO causes everything to be included , if declared as a byte array, nothing is included
return conv.hex2uword(hex)
}
}
Improve register load order in subroutine call args assignments:
in certain situations, the "wrong" order of evaluation of function call arguments is done which results
in overwriting registers that already got their value, which requires a lot of stack juggling (especially on plain 6502 cpu!)