prog8/testsource/conditionals.ill
Irmen de Jong 0e785fcfb3 new docs
2018-08-06 03:35:43 +02:00

142 lines
3.4 KiB
Plaintext

%output basic
%import c64lib
~ main {
var word value
memory word memvalue = $8000
start:
A = 100
; conditional if, without conditional expression. needs explicit if status.
if_not goto label
if_true goto label
if_zero goto label
if_cc goto label
if_lt goto label
if_le goto label
if_ge goto label
if_gt goto label
if_cc goto value
;if_cc goto memvalue
;if_cc goto #memvalue
if_cc goto [value]
;if_cc goto [memvalue]
;if_cc goto $c000
;if_cc goto [$c000.word]
label:
; conditional if with a single 'truth' value (register)
if_true A goto label2
if_not A goto label2
if_zero A goto label2
if A goto label2
if_true X goto label2
if_not X goto label2
if_zero X goto label2
if X goto label2
if_true Y goto label2
if_not Y goto label2
if_zero Y goto label2
if Y goto label2
if_true XY goto label2
if_not XY goto label2
if_zero XY goto label2
if XY goto label2
label2:
; conditional if with a single 'truth' value (variable)
if_true value goto label3
if_not value goto label3
if_zero value goto label3
if value goto label3
if_true memvalue goto label3
if_not memvalue goto label3
if_zero memvalue goto label3
if memvalue goto label3
label3:
; conditional if with a single 'truth' value (indirect address)
if_true [$c000] goto label4
if_not [$c000] goto label4
if_zero [$c000] goto label4
if [$c000] goto label4
if_true [XY] goto label4
if_true [AY] goto label4
if_true [AX] goto label4
label4:
return
}
~ conditionals {
var bytevar = 22 + 23
var str name = "?"*80
var bytevar2 = 23
var word wordvar = 22345
start:
c64.init_system()
A = 0
printloop:
c64scr.print_byte_decimal(A)
c64.CHROUT('\n')
A++
if A <20 goto printloop
return
label1:
if_true A==123 goto label1
if_true A == 123 goto label1
if_true A!=0 goto label1
if_not X!=0 goto label1
if_true A <= 1 goto label1
if_true A==1 goto label1
if_true A!=1 goto label1
if_not X < 1 goto label1
if_not Y>1 goto label1
if_not X!=1 goto label1
if_true 22<=Y goto label1
if_true A<=22 goto label1
if_true A<X goto label1
if_true X>Y goto label1
if_true X>A goto label1
if A<=22 goto label1
if A <= 22 goto label1
if_zero A goto label1
if_zero X goto label1
if Y goto label1
if_true XY goto label1
if_not XY goto label1
if A goto label1
if_not goto label1
if_true bytevar<=A goto label2
if_true bytevar<=22 goto label2
if bytevar<=22 goto label2
if bytevar<=22 goto label2
if bytevar goto label2
if bytevar>bytevar2 goto label2
if_zero bytevar goto label2
if_not wordvar goto label2
if_zero wordvar goto label2
if_true wordvar goto label2
label2:
return
}