2024-01-21 22:05:51 +00:00
|
|
|
%import textio
|
2024-02-21 22:10:04 +00:00
|
|
|
%zeropage dontuse
|
2024-01-22 23:56:06 +00:00
|
|
|
%option no_sysinit
|
2023-12-31 00:02:33 +00:00
|
|
|
|
2024-01-07 17:48:18 +00:00
|
|
|
main {
|
2024-02-10 02:07:49 +00:00
|
|
|
sub start() {
|
2024-02-21 22:10:04 +00:00
|
|
|
uword @shared pointer
|
2024-02-22 10:35:54 +00:00
|
|
|
cx16.r0L = 10
|
2024-02-21 22:10:04 +00:00
|
|
|
pointer = &label2
|
2024-02-22 10:35:54 +00:00
|
|
|
if cx16.r0L!=0
|
|
|
|
goto pointer
|
2024-02-21 22:10:04 +00:00
|
|
|
|
|
|
|
label1:
|
|
|
|
txt.print("fail\n")
|
|
|
|
return
|
|
|
|
|
|
|
|
label2:
|
|
|
|
txt.print("indirect jump ok\n")
|
|
|
|
return
|
|
|
|
|
2024-02-21 16:35:37 +00:00
|
|
|
|
2024-02-10 02:07:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-21 22:10:04 +00:00
|
|
|
;%import textio
|
|
|
|
;%import floats
|
|
|
|
;%zeropage dontuse
|
|
|
|
;%option no_sysinit
|
|
|
|
;
|
|
|
|
;main {
|
|
|
|
; sub start() {
|
|
|
|
; test_bool()
|
|
|
|
;; test_byte()
|
|
|
|
;; test_ubyte()
|
|
|
|
;; test_word()
|
|
|
|
;; test_uword()
|
|
|
|
;; test_float()
|
|
|
|
; }
|
|
|
|
;
|
|
|
|
; /*
|
|
|
|
; tests:
|
|
|
|
; - if with only a single goto, direct
|
|
|
|
; - if with only a single indirect goto
|
|
|
|
; - if without an else block
|
|
|
|
; - if with both if and else blocks
|
|
|
|
; carthesian product with:
|
|
|
|
; - comparison with const zero
|
|
|
|
; - comparison with const values
|
|
|
|
; - comparison with variable
|
|
|
|
; - comparison with array
|
|
|
|
; - comparison with expression
|
|
|
|
; */
|
|
|
|
;
|
|
|
|
; sub fail(uword test) {
|
|
|
|
; txt.print("failed ")
|
|
|
|
; txt.print_uw(test)
|
|
|
|
; txt.nl()
|
|
|
|
; }
|
|
|
|
;
|
|
|
|
; sub test_bool() {
|
|
|
|
; bool @shared var1, var2
|
|
|
|
; uword success = 0
|
|
|
|
;
|
|
|
|
; single_goto()
|
|
|
|
; single_goto_indirect()
|
|
|
|
; no_else()
|
|
|
|
; ifelse()
|
|
|
|
;
|
|
|
|
; sub single_goto() {
|
|
|
|
; txt.print("bool single_goto\n")
|
|
|
|
;test1:
|
|
|
|
; var1 = false
|
|
|
|
; if var1
|
|
|
|
; goto lbl1
|
|
|
|
; success++
|
|
|
|
; goto test2
|
|
|
|
;lbl1:
|
|
|
|
; fail(1)
|
|
|
|
;
|
|
|
|
;test2:
|
|
|
|
; var1 = true
|
|
|
|
; if var1
|
|
|
|
; goto lbl2
|
|
|
|
; fail(1)
|
|
|
|
; goto test3
|
|
|
|
;lbl2: success++
|
|
|
|
;
|
|
|
|
;test3:
|
|
|
|
; if success==2
|
|
|
|
; txt.print(" ok\n")
|
|
|
|
; else
|
|
|
|
; txt.print(" failed\n")
|
|
|
|
; }
|
|
|
|
;
|
|
|
|
; sub single_goto_indirect() {
|
|
|
|
; uword pointer
|
|
|
|
; txt.print("bool single_goto_indirect\n")
|
|
|
|
;test1:
|
|
|
|
; var1 = false
|
|
|
|
; pointer = &lbl1
|
|
|
|
; if var1
|
|
|
|
; goto pointer
|
|
|
|
; success++
|
|
|
|
; goto test2
|
|
|
|
;lbl1:
|
|
|
|
; fail(1)
|
|
|
|
;
|
|
|
|
;test2:
|
|
|
|
; var1 = true
|
|
|
|
; pointer = &lbl2
|
|
|
|
; if var1
|
|
|
|
; goto pointer
|
|
|
|
; fail(1)
|
|
|
|
; goto test3
|
|
|
|
;lbl2: success++
|
|
|
|
;
|
|
|
|
;test3:
|
|
|
|
; if success==2
|
|
|
|
; txt.print(" ok\n")
|
|
|
|
; else
|
|
|
|
; txt.print(" failed\n")
|
|
|
|
; }
|
|
|
|
;
|
|
|
|
; sub no_else() {
|
|
|
|
; }
|
|
|
|
;
|
|
|
|
; sub ifelse() {
|
|
|
|
; }
|
|
|
|
; }
|
|
|
|
;
|
|
|
|
;}
|