-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix subroutine calling convention for @rx parameters: don't pass them…
… via cpu registers
- Loading branch information
Showing
4 changed files
with
56 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,53 @@ | ||
%import floats | ||
%import sprites | ||
%import textio | ||
%option no_sysinit | ||
%zeropage basicsafe | ||
|
||
|
||
main { | ||
sub start() { | ||
|
||
cx16.mouse_config2(1) | ||
|
||
sprites.init(1, 0, 0, sprites.SIZE_64, sprites.SIZE_64, sprites.COLORS_16, 0) | ||
|
||
sprites.pos(1, 100, 100) | ||
|
||
repeat { | ||
word x,y | ||
x,y = sprites.getxy(0) | ||
sprites.pos(1, x, y) | ||
} | ||
|
||
float fz | ||
cx16.r0L = single() | ||
cx16.r0L, fz = multi() | ||
} | ||
|
||
sub single() -> ubyte { | ||
return xx | ||
; uword @shared uw1 = 1001 | ||
; uword @shared uw2 = 1001 | ||
; ubyte @shared ub = 42 | ||
; ubyte @shared index = 2 | ||
; | ||
; uword[] array1 = [999,1000,1001] | ||
; uword[] @nosplit array2 = [999,1000,1001] | ||
|
||
; func2(array1[index], ub) ; args via subroutine variables (R1, R2) | ||
; func2(uw2, ub) ; args via subroutine variables (R1, R2) | ||
; func1(1001) ; arg via AY? or R1? | ||
; func1(array1[index]) ; arg via AY? or R1? | ||
; func1(array2[index]) ; arg via AY? or R1? | ||
|
||
main.func1.arg1 = 9999 | ||
%asm {{ | ||
lda #0 | ||
ldy #0 | ||
jsr p8s_func1 | ||
}} | ||
cx16.r3 = 8888 | ||
%asm {{ | ||
lda #0 | ||
ldy #0 | ||
jsr p8s_func1 | ||
}} | ||
} | ||
|
||
sub multi() -> ubyte, float { | ||
return xx, 3.33 | ||
; sub func2(uword arg1 @R1, ubyte arg2 @R2) { ; expected args via variables R1+R2 | ||
; txt.print_uw(arg1) | ||
; txt.chrout('=') | ||
; txt.print_uw(cx16.r1) | ||
; txt.spc() | ||
; txt.print_ub(arg2) | ||
; txt.chrout('=') | ||
; txt.print_ub(cx16.r2L) | ||
; txt.nl() | ||
; } | ||
|
||
sub func1(uword arg1 @R3) { ; expected arg1 via R3, not via cpu regs AY | ||
txt.print_uw(arg1) | ||
txt.chrout('=') | ||
txt.print_uw(cx16.r3) | ||
txt.nl() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters