mirror of
https://github.com/irmen/prog8.git
synced 2025-02-21 10:29:03 +00:00
more split array fixes
This commit is contained in:
parent
1e85f7812f
commit
8644a4ae91
@ -136,10 +136,7 @@ class SymbolTableMaker(private val program: PtProgram, private val options: Comp
|
|||||||
is PtAddressOf -> {
|
is PtAddressOf -> {
|
||||||
if(it.isFromArrayElement)
|
if(it.isFromArrayElement)
|
||||||
TODO("address-of array element $it in initial array value")
|
TODO("address-of array element $it in initial array value")
|
||||||
if(it.identifier.type.isSplitWordArray)
|
StArrayElement(null, it.identifier.name, null)
|
||||||
StArrayElement(null, it.identifier.name + "_lsb", null) // the _lsb split array comes first in memory
|
|
||||||
else
|
|
||||||
StArrayElement(null, it.identifier.name, null)
|
|
||||||
}
|
}
|
||||||
is PtNumber -> StArrayElement(it.number, null, null)
|
is PtNumber -> StArrayElement(it.number, null, null)
|
||||||
is PtBool -> StArrayElement(null, null, it.value)
|
is PtBool -> StArrayElement(null, null, it.value)
|
||||||
|
@ -843,7 +843,12 @@ internal class ProgramAndVarsGen(
|
|||||||
"$" + it.number!!.toInt().toString(16).padStart(4, '0')
|
"$" + it.number!!.toInt().toString(16).padStart(4, '0')
|
||||||
}
|
}
|
||||||
else if(it.addressOfSymbol!=null) {
|
else if(it.addressOfSymbol!=null) {
|
||||||
asmgen.asmSymbolName(it.addressOfSymbol!!)
|
val addrOfSymbol = it.addressOfSymbol!!
|
||||||
|
val symbol = symboltable.lookup(addrOfSymbol)!!
|
||||||
|
if(symbol is StStaticVariable && symbol.dt.isSplitWordArray)
|
||||||
|
asmgen.asmSymbolName(addrOfSymbol+"_lsb") // the _lsb split array comes first in memory
|
||||||
|
else
|
||||||
|
asmgen.asmSymbolName(addrOfSymbol)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw AssemblyError("weird array elt")
|
throw AssemblyError("weird array elt")
|
||||||
|
@ -67,9 +67,11 @@ internal class ExpressionGen(private val codeGen: IRCodeGen) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// for strings and arrays etc., load the *address* of the value instead
|
// for strings and arrays etc., load the *address* of the value instead
|
||||||
|
// for arrays this could mean a split word array, in which case we take the address of the _lsb array which comes first
|
||||||
val vmDt = if(expr.type.isUndefined) IRDataType.WORD else irType(expr.type)
|
val vmDt = if(expr.type.isUndefined) IRDataType.WORD else irType(expr.type)
|
||||||
val resultRegister = codeGen.registers.nextFree()
|
val resultRegister = codeGen.registers.nextFree()
|
||||||
code += IRInstruction(Opcode.LOAD, vmDt, reg1 = resultRegister, labelSymbol = expr.name)
|
val labelsymbol = if(expr.type.isSplitWordArray) expr.name+"_lsb" else expr.name
|
||||||
|
code += IRInstruction(Opcode.LOAD, vmDt, reg1 = resultRegister, labelSymbol = labelsymbol)
|
||||||
ExpressionCodeResult(code, vmDt, resultRegister, -1)
|
ExpressionCodeResult(code, vmDt, resultRegister, -1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,27 @@ sprites {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub pos_batch(ubyte first_spritenum, ubyte num_sprites, uword xpositions_ptr, uword ypositions_ptr) {
|
sub pos_batch(ubyte first_spritenum, ubyte num_sprites, uword xpositions_ptr, uword ypositions_ptr) {
|
||||||
; -- note: the x and y positions word arrays must be regular arrays, they cannot be split arrays! TODO FIX THIS
|
; -- note: the x and y positions word arrays must both be split word arrays in this version of the routine! (the default)
|
||||||
|
sprite_reg = VERA_SPRITEREGS + 2 + first_spritenum*$0008
|
||||||
|
cx16.vaddr_autoincr(1, sprite_reg, 0, 8)
|
||||||
|
cx16.vaddr_autoincr(1, sprite_reg+1, 1, 8)
|
||||||
|
repeat num_sprites {
|
||||||
|
cx16.VERA_DATA0 = @(xpositions_ptr)
|
||||||
|
cx16.VERA_DATA1 = @(xpositions_ptr+num_sprites)
|
||||||
|
xpositions_ptr ++
|
||||||
|
}
|
||||||
|
sprite_reg += 2
|
||||||
|
cx16.vaddr_autoincr(1, sprite_reg, 0, 8)
|
||||||
|
cx16.vaddr_autoincr(1, sprite_reg+1, 1, 8)
|
||||||
|
repeat num_sprites {
|
||||||
|
cx16.VERA_DATA0 = @(ypositions_ptr)
|
||||||
|
cx16.VERA_DATA1 = @(ypositions_ptr+num_sprites)
|
||||||
|
ypositions_ptr ++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub pos_batch_nosplit(ubyte first_spritenum, ubyte num_sprites, uword xpositions_ptr, uword ypositions_ptr) {
|
||||||
|
; -- note: the x and y positions word arrays must both be regular linear arrays in this version of the routine!
|
||||||
sprite_reg = VERA_SPRITEREGS + 2 + first_spritenum*$0008
|
sprite_reg = VERA_SPRITEREGS + 2 + first_spritenum*$0008
|
||||||
cx16.vaddr_autoincr(1, sprite_reg, 0, 8)
|
cx16.vaddr_autoincr(1, sprite_reg, 0, 8)
|
||||||
cx16.vaddr_autoincr(1, sprite_reg+1, 1, 8)
|
cx16.vaddr_autoincr(1, sprite_reg+1, 1, 8)
|
||||||
|
@ -61,6 +61,7 @@ Subroutines
|
|||||||
- Subroutines can be nested. Inner subroutines can directly access variables from their parent.
|
- Subroutines can be nested. Inner subroutines can directly access variables from their parent.
|
||||||
- Subroutine parameters are just local variables in the subroutine. (you can access them directly as such via their scoped name, if you want)
|
- Subroutine parameters are just local variables in the subroutine. (you can access them directly as such via their scoped name, if you want)
|
||||||
- There is no call stack. So subroutine parameters are overwritten when called again. Thus recursion is not easily possible, but you can do it with manual stack manipulations.
|
- There is no call stack. So subroutine parameters are overwritten when called again. Thus recursion is not easily possible, but you can do it with manual stack manipulations.
|
||||||
|
There are a couple of example programs that show how to solve this in different ways, among which are fractal-tree.p8, maze.p8 and queens.p8
|
||||||
- There is no function overloading (except for a couple of builtin functions).
|
- There is no function overloading (except for a couple of builtin functions).
|
||||||
- Some subroutine types can return multiple return values, and you can multi-assign those in a single statement.
|
- Some subroutine types can return multiple return values, and you can multi-assign those in a single statement.
|
||||||
- Because every declared variable allocates some memory, it might be beneficial to share the same variables over different subroutines
|
- Because every declared variable allocates some memory, it might be beneficial to share the same variables over different subroutines
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
- DONE: make word arrays split by default (remove @split tag) and use new @nosplit tag to make an array use the old storage format? Also invert -splitarrays command line option.
|
- DONE: make word arrays split by default (remove @split tag) and use new @nosplit tag to make an array use the old storage format?
|
||||||
|
- DONE: invert -splitarrays command line option to -dontsplitarrays
|
||||||
- DONE: remove "splitarrays" %option switch
|
- DONE: remove "splitarrays" %option switch
|
||||||
- fix IR compilation errors
|
- DONE: added sprites.pos_batch_nosplit when the x/y arrays are linear instead of split word arrays
|
||||||
- Regular & will just return the start of the split array in memory whatever byte comes first. Search TODO("address of split word array")
|
|
||||||
- check this for 6502 codegen: split word arrays, both _msb and _lsb arrays are tagged with an alignment. This is not what's intended; only the one put in memory first should be aligned (the other one should follow straight after it)
|
|
||||||
- add &< and &> operators to get the address of the lsb-array and msb-array, respectively.
|
|
||||||
- fix sprites.pos_batch
|
|
||||||
- update Syntax files + Document all of this (also that word arrays can then have length 256 by default as well, and that @linear will reduce it to half.)
|
- update Syntax files + Document all of this (also that word arrays can then have length 256 by default as well, and that @linear will reduce it to half.)
|
||||||
- test all examples and projects (paint has wrong palette colors)
|
- test all examples and projects
|
||||||
|
- (paint has wrong palette colors)
|
||||||
|
- cx16/balloonflight is black
|
||||||
|
- cx16/bubbleunivers,kefrenbars has wrong colors
|
||||||
|
- cx16 stream-wav has broken playback?
|
||||||
- benchmark program became slower!? (did get smaller, just slower????)
|
- benchmark program became slower!? (did get smaller, just slower????)
|
||||||
|
- showbmx example has wrong colors and doesn't center the picture correctly (robocat4.bmx) (imageviewer is fine?)
|
||||||
|
- cx16/tehtriz should be better centered vertically
|
||||||
|
- add &< and &> operators to get the address of the lsb-array and msb-array, respectively.
|
||||||
|
|
||||||
|
|
||||||
...
|
...
|
||||||
@ -19,6 +23,7 @@ TODO
|
|||||||
Future Things and Ideas
|
Future Things and Ideas
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
- Fix missing cases where regular & has to return the start of the split array in memory whatever byte comes first. Search TODO("address of split word array")
|
||||||
- a syntax to access specific bits in a variable, to avoid manually shifts&ands, something like variable[4:8] ? (or something else this may be too similar to regular array indexing)
|
- a syntax to access specific bits in a variable, to avoid manually shifts&ands, something like variable[4:8] ? (or something else this may be too similar to regular array indexing)
|
||||||
- something to reduce the need to use fully qualified names all the time. 'with' ? Or 'using <prefix>'?
|
- something to reduce the need to use fully qualified names all the time. 'with' ? Or 'using <prefix>'?
|
||||||
- Libraries: improve ability to create library files in prog8; for instance there's still stuff injected into the start of the start() routine AND there is separate setup logic going on before calling it.
|
- Libraries: improve ability to create library files in prog8; for instance there's still stuff injected into the start of the start() routine AND there is separate setup logic going on before calling it.
|
||||||
@ -69,6 +74,7 @@ IR/VM
|
|||||||
|
|
||||||
Libraries
|
Libraries
|
||||||
---------
|
---------
|
||||||
|
- monogfx: flood fill should be able to fill stippled
|
||||||
- pet32 target: make syslib more complete (missing kernal routines)?
|
- pet32 target: make syslib more complete (missing kernal routines)?
|
||||||
- need help with: PET disk routines (OPEN, SETLFS etc are not exposed as kernal calls)
|
- need help with: PET disk routines (OPEN, SETLFS etc are not exposed as kernal calls)
|
||||||
- fix the problems in atari target, and flesh out its libraries.
|
- fix the problems in atari target, and flesh out its libraries.
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
all: PROGRAM.PRG
|
all: PROGRAM.PRG
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f program.asm program.vice* program.prg PROGRAM.PRG
|
||||||
|
|
||||||
PROGRAM.PRG: library1.asm library2.asm program.p8
|
PROGRAM.PRG: library1.asm library2.asm program.p8
|
||||||
64tass --case-sensitive --ascii --long-branch library1.asm -o LIBRARY1.PRG
|
64tass --case-sensitive --ascii --long-branch library1.asm -o LIBRARY1.PRG
|
||||||
64tass --case-sensitive --ascii --long-branch library2.asm -o LIBRARY2.PRG
|
64tass --case-sensitive --ascii --long-branch library2.asm -o LIBRARY2.PRG
|
||||||
|
@ -60,22 +60,19 @@ main {
|
|||||||
|
|
||||||
; palette.set_color(0, $f00) ; debug rastertime
|
; palette.set_color(0, $f00) ; debug rastertime
|
||||||
|
|
||||||
; draw 2 bobs per frame to speed up bob count
|
; draw 4 bobs per frame to speed up bob count
|
||||||
ubyte vmembase = blitbuffer*4 ; 2048 * 4 per backbuffer
|
repeat 4 {
|
||||||
blit(vmembase)
|
ubyte vmembase = blitbuffer*4 ; 2048 * 4 per backbuffer
|
||||||
blitbuffer++
|
blit(vmembase)
|
||||||
if blitbuffer==num_backbuffers
|
blitbuffer++
|
||||||
blitbuffer=0
|
if blitbuffer==num_backbuffers
|
||||||
vmembase = blitbuffer*4 ; 2048 * 4 per backbuffer
|
blitbuffer=0
|
||||||
blit(vmembase)
|
}
|
||||||
blitbuffer++
|
|
||||||
if blitbuffer==num_backbuffers
|
|
||||||
blitbuffer=0
|
|
||||||
|
|
||||||
backbuffer++
|
backbuffer++
|
||||||
if backbuffer==num_backbuffers {
|
if backbuffer==num_backbuffers {
|
||||||
backbuffer=0
|
backbuffer=0
|
||||||
num_bobs+=2
|
num_bobs+=4
|
||||||
}
|
}
|
||||||
|
|
||||||
vmembase = backbuffer*4 ; 2048 * 4 per backbuffer
|
vmembase = backbuffer*4 ; 2048 * 4 per backbuffer
|
||||||
|
@ -2,8 +2,13 @@
|
|||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
uword[] addresses = [scores2, start]
|
||||||
|
uword[] scores1 = [10, 25, 50, 100]
|
||||||
|
uword[] scores2 = [100, 250, 500, 1000]
|
||||||
|
|
||||||
|
cx16.r0 = &scores1
|
||||||
|
cx16.r1 = &scores2
|
||||||
|
cx16.r2 = &addresses
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ main {
|
|||||||
txt.print("calculating...\n")
|
txt.print("calculating...\n")
|
||||||
|
|
||||||
sys.memset(flags_ptr, SIZEPL, 1)
|
sys.memset(flags_ptr, SIZEPL, 1)
|
||||||
count = 0
|
count = 1
|
||||||
for i in 0 to SIZEPL-1 {
|
for i in 0 to SIZEPL-1 {
|
||||||
if flags_ptr[i]!=0 {
|
if flags_ptr[i]!=0 {
|
||||||
prime = i + i + 3
|
prime = i + i + 3
|
||||||
@ -34,7 +34,10 @@ main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
txt.nl()
|
txt.nl()
|
||||||
|
txt.print("last prime: ")
|
||||||
|
txt.print_uw(prime)
|
||||||
|
txt.print("\nnumber of primes: ")
|
||||||
txt.print_uw(count)
|
txt.print_uw(count)
|
||||||
txt.print(" primes\n")
|
txt.nl()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user