1
0
mirror of https://github.com/irmen/prog8.git synced 2025-04-27 12:59:42 +00:00

Also romable warning for inline variables. Added TODO: Romable in library files where applicable

This commit is contained in:
Irmen de Jong 2025-02-21 21:00:26 +01:00
parent e55ce5504e
commit 5c56267662
14 changed files with 34 additions and 2 deletions

@ -1716,7 +1716,7 @@ $repeatLabel""")
if(options.romable) {
// until the code generation can provide an alternative, we have to report about code generated that is incompatible with ROMable code mode...
errors.warn("problem for ROMable code: $problem", pos)
out(" .warn \"ROMable code selected but incompatible code was generated: $problem\"")
out(" .error \"ROMable code selected but incompatible code was generated: $problem\"")
}
}
}

@ -652,6 +652,7 @@ internal class ProgramAndVarsGen(
it.initializationStringValue!!.second,
it.initializationStringValue!!.first
)
asmgen.romableWarning("inlined variable (${it.dt}, ${it.name})", Position.DUMMY) // TODO
}
alignedStrings.sortedBy { it.align }.forEach {
outputStringvar(
@ -660,13 +661,16 @@ internal class ProgramAndVarsGen(
it.initializationStringValue!!.second,
it.initializationStringValue!!.first
)
asmgen.romableWarning("inlined variable (${it.dt}, ${it.name})", Position.DUMMY) // TODO
}
notAlignedOther.sortedBy { it.type }.forEach {
staticVariable2asm(it)
asmgen.romableWarning("inlined variable (${it.dt}, ${it.name})", Position.DUMMY) // TODO
}
alignedOther.sortedBy { it.align }.sortedBy { it.type }.forEach {
staticVariable2asm(it)
asmgen.romableWarning("inlined variable (${it.dt}, ${it.name})", Position.DUMMY) // TODO
}
}
}

@ -445,6 +445,7 @@ sys {
}
asmsub save_prog8_internals() {
; TODO: Romable
%asm {{
lda P8ZP_SCRATCH_B1
sta save_SCRATCH_ZPB1
@ -1056,6 +1057,7 @@ cx16 {
&byte r15sH = $1bff
asmsub save_virtual_registers() clobbers(A,Y) {
; TODO: Romable
%asm {{
ldy #31
- lda cx16.r0,y

@ -460,6 +460,7 @@ sys {
}
asmsub save_prog8_internals() {
; TODO: Romable
%asm {{
lda P8ZP_SCRATCH_B1
sta save_SCRATCH_ZPB1
@ -1072,6 +1073,7 @@ cx16 {
&byte r15sH = $cfff
asmsub save_virtual_registers() clobbers(A,Y) {
; TODO: Romable
%asm {{
ldy #31
- lda cx16.r0,y

@ -352,6 +352,7 @@ asmsub str2word(str string @AY) -> word @AY {
; the number may be preceded by a + or - sign but may NOT contain spaces
; (any non-digit character will terminate the number string that is parsed)
; result in AY, number of characters processed also remains in cx16.r15 if you want to use it!! (0 = error)
; TODO: Romable
%asm {{
_result = P8ZP_SCRATCH_W1
sta P8ZP_SCRATCH_W2
@ -539,6 +540,7 @@ asmsub internal_uword2decimal (uword value @AY) -> ubyte @Y, ubyte @A, ubyte @
; output in internal_uword2decimal.decTenThousands, decThousands, decHundreds, decTens, decOnes
; (these are terminated by a zero byte so they can be easily printed)
; also returns Y = 100's, A = 10's, X = 1's
; TODO: Romable
%asm {{

@ -981,6 +981,7 @@ asmsub vpoke_mask(ubyte bank @A, uword address @R0, ubyte mask @X, ubyte value @
}
asmsub save_virtual_registers() clobbers(A,Y) {
; TODO: Romable
%asm {{
ldy #31
- lda cx16.r0,y
@ -1010,6 +1011,7 @@ asmsub restore_virtual_registers() clobbers(A,Y) {
asmsub save_vera_context() clobbers(A) {
; -- use this at the start of your IRQ handler if it uses Vera registers, to save the state
; TODO: Romable
%asm {{
; note cannot store this on cpu hardware stack because this gets called as a subroutine
lda cx16.VERA_ADDR_L
@ -1448,6 +1450,7 @@ _modified
}
asmsub restore_irq() clobbers(A) {
; TODO: Romable
%asm {{
sei
lda _orig_irqvec
@ -1770,6 +1773,7 @@ _no_msb_size
}
asmsub save_prog8_internals() {
; TODO: Romable
%asm {{
lda P8ZP_SCRATCH_B1
sta save_SCRATCH_ZPB1

@ -64,6 +64,8 @@ multiply_words .proc
; The routine also works for NEGATIVE (signed) word values, but ONLY the lower 16 bits of the result are correct then!
; Prog8 only uses those so that's not an issue, but math.mul16_last_upper() no longer gives the correct result here.
; TODO: Romable
; mult62.a
; from: https://github.com/TobyLobster/multiply_test/blob/main/tests/mult62.a
; based on Dr Jefyll, http://forum.6502.org/viewtopic.php?f=9&t=689&start=0#p19958
@ -187,6 +189,7 @@ result .byte 0,0,0,0 ; routine could be faster if this were in Zeropage.
divmod_b_asm .proc
; signed byte division: make everything positive and fix sign afterwards
; TODO: Romable
sta P8ZP_SCRATCH_B1
tya
eor P8ZP_SCRATCH_B1
@ -286,6 +289,7 @@ divmod_uw_asm .proc
; input: P8ZP_SCRATCH_W1 in ZP: 16 bit number, A/Y: 16 bit divisor
; output: P8ZP_SCRATCH_W2 in ZP: 16 bit remainder, A/Y: 16 bit division result
; division by zero will result in quotient = 65535 and remainder = divident
; TODO: Romable
dividend = P8ZP_SCRATCH_W1
@ -329,6 +333,7 @@ randword .proc
; -- 16 bit pseudo random number generator into AY
; default seed = $00c2 $1137
; routine from https://codebase64.org/doku.php?id=base:x_abc_random_number_generator_8_16_bit
; TODO: Romable
inc x1
clc
x1=*+1

@ -360,6 +360,7 @@ _no_msb_size
}
asmsub save_prog8_internals() {
; TODO: Romable
%asm {{
lda P8ZP_SCRATCH_B1
sta save_SCRATCH_ZPB1
@ -603,6 +604,7 @@ cx16 {
&byte r15sH = $7fff
asmsub save_virtual_registers() clobbers(A,Y) {
; TODO: Romable
%asm {{
ldy #31
- lda cx16.r0,y

@ -184,6 +184,7 @@ func_sort_uw .proc
; sorting subroutine coded by mats rosengren (mats.rosengren@esa.int)
; input: address of array to sort in P8ZP_SCRATCH_W1, length in A
; first: subtract 2 of the pointer
; TODO: Romable
asl a
sta P8ZP_SCRATCH_B1
lda P8ZP_SCRATCH_W1
@ -246,6 +247,7 @@ func_sort_w .proc
; sorting subroutine coded by mats rosengren (mats.rosengren@esa.int)
; input: address of array to sort in P8ZP_SCRATCH_W1, length in A
; first: subtract 2 of the pointer
; TODO: Romable
asl a
sta P8ZP_SCRATCH_B1
lda P8ZP_SCRATCH_W1

@ -146,6 +146,7 @@ memcopy16_up .proc
memset .proc
; -- fill memory from (P8ZP_SCRATCH_W1), length XY, with value in A.
; clobbers X, Y
; TODO: Romable
stx P8ZP_SCRATCH_B1
sty _save_reg
ldy #0
@ -268,6 +269,7 @@ strcpy .proc
strcmp_expression .proc
; -- compare strings, result in A
; TODO: Romable
lda _arg_s2
ldy _arg_s2+1
sta P8ZP_SCRATCH_W2

@ -140,6 +140,7 @@ compression {
; -- Decodes "ByteRun1" (aka PackBits) RLE compressed data. Control byte value 128 ends the decoding.
; Also stops decompressing when the maxsize has been reached. Returns the size of the decompressed data.
; Instead of a source buffer, you provide a callback function that must return the next byte to compress in A.
; TODO: Romable
%asm {{
sta _cb_mod1+1
sty _cb_mod1+2

@ -154,6 +154,7 @@ _found tya
asmsub rfind(uword string @AY, ubyte character @X) -> ubyte @A, bool @Pc {
; Locates the first position of the given character in the string, starting from the right.
; returns Carry set if found + index in A, or Carry clear if not found (and A will be 255, an invalid index).
; TODO: Romable
%asm {{
stx P8ZP_SCRATCH_B1
sta _str

@ -1,13 +1,15 @@
TODO
====
- disable floating point support for %option romable ? (because if it's your code that is running in the rom bank you can't have the floating point routines available there)
...
Future Things and Ideas
^^^^^^^^^^^^^^^^^^^^^^^
- Look at github PR for improved romability (see github issue 149)
- Look at github PR for improved romability (see github issue 149) Also search for "TODO: Romable"
- const values should always either be of type long or float, this is how they were usually treated in const expression evaluation already anyway
- Kotlin: can we use inline value classes in certain spots?
- add float support to the configurable compiler targets

@ -2,6 +2,9 @@
%option no_sysinit, romable
main {
ubyte[100] @shared array1
ubyte[100] @shared array2 = [42] *100
sub start() {
uword @shared pointer = $4000
ubyte @shared size = 42