2019-05-06 22:59:54 +00:00
|
|
|
// Tests conversion of numbers to correct int types
|
|
|
|
// See https://gitlab.com/camelot/kickc/issues/181
|
2020-12-21 07:57:41 +00:00
|
|
|
// Commodore 64 PRG executable file
|
|
|
|
.file [name="number-conversion.prg", type="prg", segments="Program"]
|
|
|
|
.segmentdef Program [segments="Basic, Code, Data"]
|
|
|
|
.segmentdef Basic [start=$0801]
|
|
|
|
.segmentdef Code [start=$80d]
|
|
|
|
.segmentdef Data [startAfter="Code"]
|
|
|
|
.segment Basic
|
2019-05-06 22:59:54 +00:00
|
|
|
:BasicUpstart(main)
|
|
|
|
.const TYPEID_SIGNED_BYTE = 2
|
|
|
|
.const TYPEID_SIGNED_WORD = 4
|
|
|
|
.const TYPEID_SIGNED_DWORD = 6
|
|
|
|
.const TYPEID_BYTE = 1
|
|
|
|
.const TYPEID_WORD = 3
|
|
|
|
.const TYPEID_DWORD = 5
|
|
|
|
.const RED = 2
|
|
|
|
.const GREEN = 5
|
2019-05-18 19:37:34 +00:00
|
|
|
.label SCREEN = $400
|
|
|
|
.label COLS = $d800
|
2020-12-21 07:57:41 +00:00
|
|
|
.segment Code
|
2019-05-06 22:59:54 +00:00
|
|
|
main: {
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12sb+12), typeid(signed byte))
|
2019-05-06 22:59:54 +00:00
|
|
|
ldx #0
|
|
|
|
lda #TYPEID_SIGNED_BYTE
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12sb+130), typeid(signed word))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_SIGNED_WORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12sb+33000), typeid(signed dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_SIGNED_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12sw+12), typeid(signed word))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_SIGNED_WORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12sw+130), typeid(signed word))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_SIGNED_WORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12sw+100000), typeid(signed dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_SIGNED_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12sd+12), typeid(signed dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_SIGNED_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12sd+130), typeid(signed dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_SIGNED_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12sd+100000), typeid(signed dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_SIGNED_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ub+12), typeid(unsigned byte))
|
2019-05-06 22:59:54 +00:00
|
|
|
ldx #$28
|
|
|
|
lda #TYPEID_BYTE
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ub+250), typeid(unsigned byte))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_BYTE
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ub+300), typeid(unsigned word))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_WORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ub+65534), typeid(unsigned word))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_WORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ub+66000), typeid(unsigned dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12uw+12), typeid(unsigned word))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_WORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12uw+130), typeid(unsigned word))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_WORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12uw+66000), typeid(unsigned dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ud+12), typeid(unsigned dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ud+130), typeid(unsigned dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ud+66000), typeid(unsigned dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ub+3000000000), typeid(unsigned dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ub+-12), typeid(unsigned byte))
|
2019-05-06 22:59:54 +00:00
|
|
|
ldx #$50
|
|
|
|
lda #TYPEID_BYTE
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ub+-120), typeid(unsigned byte))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_BYTE
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ub+-250), typeid(unsigned byte))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_BYTE
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ub+-260), typeid(unsigned word))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_WORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ub+-65000), typeid(unsigned word))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_WORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ub+-66000), typeid(unsigned dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12uw+-12), typeid(unsigned word))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_WORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12uw+-130), typeid(unsigned word))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_WORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12uw+-65000), typeid(unsigned word))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_WORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12uw+-66000), typeid(unsigned dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ud+-12), typeid(unsigned dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ud+-130), typeid(unsigned dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12ud+-66000), typeid(unsigned dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
tay
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// assertType(typeid(12sb+-2100000000), typeid(unsigned dword))
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #TYPEID_DWORD
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z assertType.t2
|
2019-05-06 22:59:54 +00:00
|
|
|
ldy #TYPEID_SIGNED_DWORD
|
|
|
|
jsr assertType
|
2020-02-23 08:44:36 +00:00
|
|
|
// }
|
2019-05-06 22:59:54 +00:00
|
|
|
rts
|
|
|
|
}
|
|
|
|
// Check that the two passed type IDs are equal.
|
|
|
|
// Shows a letter symbolizing t1
|
|
|
|
// If they are equal the letter is green - if not it is red.
|
2019-12-26 08:51:41 +00:00
|
|
|
// assertType(byte register(Y) t1, byte zp(2) t2)
|
2019-05-06 22:59:54 +00:00
|
|
|
assertType: {
|
|
|
|
.label t2 = 2
|
2020-02-23 08:44:36 +00:00
|
|
|
// if(t1==t2)
|
2019-05-06 22:59:54 +00:00
|
|
|
tya
|
2019-08-07 19:00:19 +00:00
|
|
|
cmp.z t2
|
2019-09-29 21:13:37 +00:00
|
|
|
beq __b1
|
2020-02-23 08:44:36 +00:00
|
|
|
// COLS[idx] = RED
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #RED
|
2019-05-18 19:37:34 +00:00
|
|
|
sta COLS,x
|
2019-09-29 21:13:37 +00:00
|
|
|
__b2:
|
2020-02-23 08:44:36 +00:00
|
|
|
// SCREEN[idx++] = t1
|
2019-05-06 22:59:54 +00:00
|
|
|
tya
|
2019-05-18 19:37:34 +00:00
|
|
|
sta SCREEN,x
|
2020-02-23 08:44:36 +00:00
|
|
|
// SCREEN[idx++] = t1;
|
2019-05-06 22:59:54 +00:00
|
|
|
inx
|
2020-02-23 08:44:36 +00:00
|
|
|
// }
|
2019-05-06 22:59:54 +00:00
|
|
|
rts
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2020-02-23 08:44:36 +00:00
|
|
|
// COLS[idx] = GREEN
|
2019-05-06 22:59:54 +00:00
|
|
|
lda #GREEN
|
2019-05-18 19:37:34 +00:00
|
|
|
sta COLS,x
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b2
|
2019-05-06 22:59:54 +00:00
|
|
|
}
|