1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-03 12:07:26 +00:00
kickc/src/test/ref/condition-integer-4.asm

81 lines
1.2 KiB
NASM
Raw Normal View History

// Tests using integer conditions in && and || operator
// This should produce '01010101', '00110011', '00010001', '01110111' at the top of the screen
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.label SCREEN = $400
main: {
.label __4 = 2
.label __5 = 3
.label __8 = 4
.label __9 = 5
ldx #0
ldy #0
__b1:
2020-02-23 08:44:36 +00:00
// i&1
tya
and #1
2020-02-23 08:44:36 +00:00
// if(i&1)
cmp #0
beq __b2
2020-02-23 08:44:36 +00:00
// (SCREEN+40*0)[idx] = '+'
lda #'+'
sta SCREEN,x
__b2:
2020-02-23 08:44:36 +00:00
// i&2
tya
and #2
2020-02-23 08:44:36 +00:00
// if(i&2)
cmp #0
beq __b3
2020-02-23 08:44:36 +00:00
// (SCREEN+40*1)[idx] = '+'
lda #'+'
sta SCREEN+$28*1,x
__b3:
2020-02-23 08:44:36 +00:00
// i&1
tya
and #1
sta.z __4
2020-02-23 08:44:36 +00:00
// i&2
tya
and #2
sta.z __5
2020-02-23 08:44:36 +00:00
// if(i&1 && i&2)
lda #0
cmp.z __4
beq __b4
cmp.z __5
beq __b4
2020-02-23 08:44:36 +00:00
// (SCREEN+40*2)[idx] = '+'
lda #'+'
sta SCREEN+$28*2,x
__b4:
2020-02-23 08:44:36 +00:00
// i&1
tya
and #1
sta.z __8
2020-02-23 08:44:36 +00:00
// i&2
tya
and #2
sta.z __9
2020-02-23 08:44:36 +00:00
// if(i&1 || i&2)
lda #0
cmp.z __8
bne __b9
cmp.z __9
beq __b5
__b9:
2020-02-23 08:44:36 +00:00
// (SCREEN+40*3)[idx] = '+'
lda #'+'
sta SCREEN+$28*3,x
__b5:
2020-02-23 08:44:36 +00:00
// idx++;
inx
2020-02-23 08:44:36 +00:00
// for( byte i:0..7)
iny
cpy #8
bne __b1
2020-02-23 08:44:36 +00:00
// }
rts
}