prog8/examples/test.p8
Irmen de Jong 928611eb20 Got rid of problematic attempts to save status register after function calls. If you really need it (for instance for if_XX instructions) it's probably better to use a short asmsub wrapper.
For function calls, register saves go via stack (to allow nested saves) for simpler cases, registers are saved in a local variable.
Fixed too agressive removal of sta-lda sequence if the lda is followed by a branching instruction.
Insert missing cmp #0 after functioncall if the value of the A register is needed in a comparison expression (could otherwise test wrong status flag)
2020-12-22 03:35:00 +01:00

95 lines
2.2 KiB
Lua

%import textio
%import diskio
;%import floats
;%import graphics
%zeropage basicsafe
%import test_stack
%option no_sysinit
main {
;romsub $ff14 = FB_set_8_pixels_opaque(ubyte pattern @R0, ubyte mask @A, ubyte color1 @X, ubyte color2 @Y) 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)
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 () {
while c64.CHRIN() {
; read the rest of the entry until the end
}
; cx16.r0 = 65535
; set_8_pixels_opaque_OLD(111,222,33)
; txt.chrout('\n')
; ;ubyte qq=c64.CHKIN(3) ;; TODO fix compiler crash "can't translate zero return values in assignment"
;
; test_stack.test()
; ubyte bb = 44
; set_8_pixels_opaque(bb,111,222,33)
; txt.chrout('\n')
; test_stack.test()
;
; set_8_pixels_opaque(c64.CHRIN(),111,222,33)
; txt.chrout('\n')
test_stack.test()
}
}