prog8/examples/test.p8

132 lines
2.4 KiB
Plaintext
Raw Normal View History

%import textio
%zeropage dontuse
2022-11-29 19:09:10 +00:00
; base level code size: $279
main {
bool[1] expected = [ true ]
uword[1] expectedw = [4242 ]
sub get() -> bool {
2022-11-29 19:09:10 +00:00
ubyte xx
xx = 1
%asm {{
stz P8ZP_SCRATCH_W1
stz P8ZP_SCRATCH_W1+1
stz P8ZP_SCRATCH_W2
stz P8ZP_SCRATCH_W2+1
stz P8ZP_SCRATCH_REG
stz P8ZP_SCRATCH_B1
}}
2022-11-29 19:09:10 +00:00
return xx
}
sub same() -> bool {
2022-11-29 19:09:10 +00:00
ubyte xx
xx = 1
%asm {{
stz P8ZP_SCRATCH_W1
stz P8ZP_SCRATCH_W1+1
stz P8ZP_SCRATCH_W2
stz P8ZP_SCRATCH_W2+1
stz P8ZP_SCRATCH_REG
stz P8ZP_SCRATCH_B1
}}
2022-11-29 19:09:10 +00:00
return xx
}
sub getw() -> uword {
2022-11-29 19:09:10 +00:00
uword xx=4242
%asm {{
stz P8ZP_SCRATCH_W1
stz P8ZP_SCRATCH_W1+1
stz P8ZP_SCRATCH_W2
stz P8ZP_SCRATCH_W2+1
stz P8ZP_SCRATCH_REG
stz P8ZP_SCRATCH_B1
}}
2022-11-29 19:09:10 +00:00
return xx
}
sub samew() -> uword {
2022-11-29 19:09:10 +00:00
uword xx=4242
%asm {{
stz P8ZP_SCRATCH_W1
stz P8ZP_SCRATCH_W1+1
stz P8ZP_SCRATCH_W2
stz P8ZP_SCRATCH_W2+1
stz P8ZP_SCRATCH_REG
stz P8ZP_SCRATCH_B1
}}
return xx
}
sub differentw() -> uword {
uword xx=9999
%asm {{
stz P8ZP_SCRATCH_W1
stz P8ZP_SCRATCH_W1+1
stz P8ZP_SCRATCH_W2
stz P8ZP_SCRATCH_W2+1
stz P8ZP_SCRATCH_REG
stz P8ZP_SCRATCH_B1
}}
2022-11-29 19:09:10 +00:00
return xx
}
sub one() -> ubyte {
2022-11-29 19:09:10 +00:00
ubyte xx=1
%asm {{
stz P8ZP_SCRATCH_W1
stz P8ZP_SCRATCH_W1+1
stz P8ZP_SCRATCH_W2
stz P8ZP_SCRATCH_W2+1
stz P8ZP_SCRATCH_REG
stz P8ZP_SCRATCH_B1
}}
2022-11-29 19:09:10 +00:00
return xx
}
sub start() {
2022-11-29 19:09:10 +00:00
if getw() == samew()
txt.print("ok\n")
else
txt.print("fail\n")
2022-11-29 19:09:10 +00:00
if samew() == getw()
txt.print("ok\n")
else
txt.print("fail\n")
2022-11-29 19:09:10 +00:00
if getw() != samew()
txt.print("fail\n")
else
txt.print("ok\n")
2022-11-29 19:09:10 +00:00
if samew() != getw()
txt.print("fail\n")
else
txt.print("ok\n")
2022-11-29 19:09:10 +00:00
if getw() == differentw()
txt.print("fail\n")
else
txt.print("ok\n")
2022-11-29 19:09:10 +00:00
if differentw() == getw()
txt.print("fail\n")
else
txt.print("ok\n")
2022-11-29 19:09:10 +00:00
if getw() != differentw()
txt.print("ok\n")
else
txt.print("fail\n")
2022-11-29 19:09:10 +00:00
if differentw() != getw()
txt.print("ok\n")
else
txt.print("fail\n")
}
2022-09-18 14:04:49 +00:00
}