cx16 registers should come first in subroutine arg list

This commit is contained in:
Irmen de Jong 2020-12-22 00:59:07 +01:00
parent d22df22f7d
commit f1d55c688a
7 changed files with 106 additions and 19 deletions

View File

@ -222,14 +222,15 @@ romsub $ff08 = FB_get_pixels(uword pointer @R0, uword count @R1) clobbers(A,X,Y
romsub $ff0b = FB_set_pixel(ubyte color @A) clobbers(A,X,Y) romsub $ff0b = FB_set_pixel(ubyte color @A) clobbers(A,X,Y)
romsub $ff0e = FB_set_pixels(uword pointer @R0, uword count @R1) clobbers(A,X,Y) romsub $ff0e = FB_set_pixels(uword pointer @R0, uword count @R1) clobbers(A,X,Y)
romsub $ff11 = FB_set_8_pixels(ubyte pattern @A, ubyte color @X) clobbers(A,X,Y) romsub $ff11 = FB_set_8_pixels(ubyte pattern @A, ubyte color @X) clobbers(A,X,Y)
romsub $ff14 = FB_set_8_pixels_opaque(ubyte mask @A, ubyte color1 @X, ubyte color2 @Y, ubyte pattern @R0) clobbers(A,X,Y) romsub $ff14 = FB_set_8_pixels_opaque(ubyte pattern @R0, ubyte mask @A, ubyte color1 @X, ubyte color2 @Y) clobbers(A,X,Y)
romsub $ff17 = FB_fill_pixels(ubyte color @A, uword count @R0, uword pstep @R1) clobbers(A,X,Y) romsub $ff14 = FB_set_8_pixels_opaque_OLD(ubyte mask @A, ubyte color1 @X, ubyte color2 @Y) clobbers(A,X,Y) ; TODO WEG!!!!
romsub $ff17 = FB_fill_pixels(uword count @R0, uword pstep @R1, ubyte color @A) clobbers(A,X,Y)
romsub $ff1a = FB_filter_pixels(uword pointer @ R0, uword count @R1) clobbers(A,X,Y) romsub $ff1a = FB_filter_pixels(uword pointer @ R0, uword count @R1) clobbers(A,X,Y)
romsub $ff1d = FB_move_pixels(uword sx @R0, uword sy @R1, uword tx @R2, uword ty @R3, uword count @R4) clobbers(A,X,Y) romsub $ff1d = FB_move_pixels(uword sx @R0, uword sy @R1, uword tx @R2, uword ty @R3, uword count @R4) clobbers(A,X,Y)
; misc ; misc
romsub $fef0 = sprite_set_image(ubyte number @A, ubyte width @X, ubyte height @Y, uword pixels @R0, uword mask @R1, ubyte bpp @R2, ubyte apply_mask @Pc) clobbers(A,X,Y) -> ubyte @Pc romsub $fef0 = sprite_set_image(uword pixels @R0, uword mask @R1, ubyte bpp @R2, ubyte number @A, ubyte width @X, ubyte height @Y, ubyte apply_mask @Pc) clobbers(A,X,Y) -> ubyte @Pc
romsub $fef3 = sprite_set_position(ubyte number @A, uword x @R0, uword y @R1) clobbers(A,X,Y) romsub $fef3 = sprite_set_position(uword x @R0, uword y @R1, ubyte number @A) clobbers(A,X,Y)
romsub $fee4 = memory_fill(uword address @R0, uword num_bytes @R1, ubyte value @A) clobbers(A,X,Y) romsub $fee4 = memory_fill(uword address @R0, uword num_bytes @R1, ubyte value @A) clobbers(A,X,Y)
romsub $fee7 = memory_copy(uword source @R0, uword target @R1, uword num_bytes @R2) clobbers(A,X,Y) romsub $fee7 = memory_copy(uword source @R0, uword target @R1, uword num_bytes @R2) clobbers(A,X,Y)
romsub $feea = memory_crc(uword address @R0, uword num_bytes @R1) clobbers(A,X,Y) -> uword @R2 romsub $feea = memory_crc(uword address @R0, uword num_bytes @R1) clobbers(A,X,Y) -> uword @R2

View File

@ -151,6 +151,11 @@ val ElementArrayTypes = mapOf(
DataType.UWORD to DataType.ARRAY_UW, DataType.UWORD to DataType.ARRAY_UW,
DataType.FLOAT to DataType.ARRAY_F DataType.FLOAT to DataType.ARRAY_F
) )
val Cx16VirtualRegisters = setOf(RegisterOrPair.R0, RegisterOrPair.R1, RegisterOrPair.R2, RegisterOrPair.R3,
RegisterOrPair.R4, RegisterOrPair.R5, RegisterOrPair.R6, RegisterOrPair.R7,
RegisterOrPair.R8, RegisterOrPair.R9, RegisterOrPair.R10, RegisterOrPair.R11,
RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, RegisterOrPair.R15)
// find the parent node of a specific type or interface // find the parent node of a specific type or interface
// (useful to figure out in what namespace/block something is defined, etc) // (useful to figure out in what namespace/block something is defined, etc)

View File

@ -336,6 +336,14 @@ internal class AstChecker(private val program: Program,
if(carryParameter!=null && carryParameter !== subroutine.asmParameterRegisters.last()) if(carryParameter!=null && carryParameter !== subroutine.asmParameterRegisters.last())
err("carry parameter has to come last") err("carry parameter has to come last")
val cx16virtualRegParameters = subroutine.asmParameterRegisters.withIndex().filter { it.value.registerOrPair in Cx16VirtualRegisters }
if(cx16virtualRegParameters.isNotEmpty()) {
for(elt in cx16virtualRegParameters.withIndex()) {
if(elt.index != elt.value.index)
err("cx16 virtual register parameters have to be specified first")
}
}
} else { } else {
// Pass-by-reference datatypes can not occur as parameters to a subroutine directly // Pass-by-reference datatypes can not occur as parameters to a subroutine directly
// Instead, their reference (address) should be passed (as an UWORD). // Instead, their reference (address) should be passed (as an UWORD).

View File

@ -113,8 +113,7 @@ internal class FunctionCallAsmGen(private val program: Program, private val asmg
argi.value.second.registerOrPair == RegisterOrPair.Y -> { argi.value.second.registerOrPair == RegisterOrPair.Y -> {
asmgen.out(" ldy P8ESTACK_LO+${argi.index},x") asmgen.out(" ldy P8ESTACK_LO+${argi.index},x")
} }
argi.value.second.registerOrPair in setOf(RegisterOrPair.R0, RegisterOrPair.R1, RegisterOrPair.R2, RegisterOrPair.R3, RegisterOrPair.R4, RegisterOrPair.R5, RegisterOrPair.R6, RegisterOrPair.R7, argi.value.second.registerOrPair in Cx16VirtualRegisters -> {
RegisterOrPair.R8, RegisterOrPair.R9, RegisterOrPair.R10, RegisterOrPair.R11, RegisterOrPair.R12, RegisterOrPair.R13, RegisterOrPair.R14, RegisterOrPair.R15) -> {
asmgen.out(""" asmgen.out("""
lda P8ESTACK_LO+${argi.index},x lda P8ESTACK_LO+${argi.index},x
sta cx16.${argi.value.second.registerOrPair.toString().toLowerCase()} sta cx16.${argi.value.second.registerOrPair.toString().toLowerCase()}

View File

@ -104,8 +104,10 @@ bmp_module {
} }
} }
1 -> { 1 -> {
for x in 0 to width-1 step 8 for x in 0 to width-1 step 8 {
cx16.FB_set_8_pixels_opaque(255, 255, 0, c64.CHRIN()) cx16.r0 = c64.CHRIN()
cx16.FB_set_8_pixels_opaque_OLD(255, 255, 0) ; TODO update
}
} }
} }

View File

@ -100,13 +100,17 @@ bitmap {
b &= %00111111 b &= %00111111
ubyte dat = c64.CHRIN() ubyte dat = c64.CHRIN()
repeat b { repeat b {
if y_ok if y_ok {
cx16.FB_set_8_pixels_opaque(255, 255, 0, dat) cx16.r0 = dat
cx16.FB_set_8_pixels_opaque_OLD(255, 255, 0) ; TODO update
}
px += 8 px += 8
} }
} else { } else {
if y_ok if y_ok {
cx16.FB_set_8_pixels_opaque(255, 255, 0, b) cx16.r0 = b
cx16.FB_set_8_pixels_opaque_OLD(255, 255, 0) ; TODO update
}
px += 8 px += 8
} }
if px==width if px==width

View File

@ -1,16 +1,84 @@
%import textio %import textio
%import diskio ;%import diskio
%import floats ;%import floats
%import graphics ;%import graphics
%zeropage basicsafe %zeropage basicsafe
%import test_stack %import test_stack
%option no_sysinit %option no_sysinit
main { main {
sub start () {
float fl
fl = log2(10) ;romsub $ff14 = FB_set_8_pixels_opaque(ubyte pattern @R0, ubyte mask @A, ubyte color1 @X, ubyte color2 @Y) clobbers(A,X,Y)
floats.print_f(fl) ;romsub $ff14 = FB_set_8_pixels_opaque_OLD(ubyte mask @A, ubyte color1 @X, ubyte color2 @Y) clobbers(A,X,Y)
asmsub set_8_pixels_opaque(ubyte pattern @R0, ubyte mask @A, ubyte color1 @X, ubyte color2 @Y) clobbers(A,X,Y) {
%asm {{
sta _a
stx _x
sty _y
lda _a
jsr txt.print_ub
lda #13
jsr c64.CHROUT
lda _x
jsr txt.print_ub
lda #13
jsr c64.CHROUT
lda _y
jsr txt.print_ub
lda #13
jsr c64.CHROUT
lda cx16.r0
ldy cx16.r0+1
jsr txt.print_uw
lda #13
jsr c64.CHROUT
rts
_a .byte 0
_x .byte 0
_y .byte 0
}}
}
asmsub set_8_pixels_opaque_OLD(ubyte mask @A, ubyte color1 @X, ubyte color2 @Y) clobbers(A,X,Y) {
%asm {{
sta _a
stx _x
sty _y
lda _a
jsr txt.print_ub
lda #13
jsr c64.CHROUT
lda _x
jsr txt.print_ub
lda #13
jsr c64.CHROUT
lda _y
jsr txt.print_ub
lda #13
jsr c64.CHROUT
rts
_a .byte 0
_x .byte 0
_y .byte 0
}}
}
sub start () {
; cx16.r0 = 65535
; set_8_pixels_opaque_OLD(111,222,33)
; txt.chrout('\n')
ubyte bb = 44
set_8_pixels_opaque(bb,111,222,33)
txt.chrout('\n')
set_8_pixels_opaque(c64.CHRIN(),111,222,33)
txt.chrout('\n')
test_stack.test()
} }
} }