mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-27 19:50:10 +00:00
Added fragment for Paul Nelsen.
This commit is contained in:
parent
c7fd528709
commit
899058ce42
@ -0,0 +1,9 @@
|
||||
ldx {c1}
|
||||
stx $fe
|
||||
ldx {c1}+1
|
||||
stx $ff
|
||||
lda ($fe),y
|
||||
sta {z1}
|
||||
iny
|
||||
lda ($fe),y
|
||||
sta {z1}+1
|
@ -638,6 +638,11 @@ public class TestPrograms {
|
||||
}
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testStructPtr26() throws IOException, URISyntaxException {
|
||||
compileAndCompare("struct-ptr-26");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStructPtr25() throws IOException, URISyntaxException {
|
||||
compileAndCompare("struct-ptr-25");
|
||||
|
18
src/test/kc/struct-ptr-26.kc
Normal file
18
src/test/kc/struct-ptr-26.kc
Normal file
@ -0,0 +1,18 @@
|
||||
import "print"
|
||||
typedef unsigned char BYTE;
|
||||
typedef unsigned short WORD;
|
||||
struct fileentry {
|
||||
BYTE *bufEdit;
|
||||
BYTE bFlag;
|
||||
BYTE bError;
|
||||
};
|
||||
typedef struct fileentry ENTRY;
|
||||
void main(){
|
||||
ENTRY *file;
|
||||
WORD uSize;
|
||||
file = 0x4000;
|
||||
file->bufEdit = 4;
|
||||
word* ptrw = (WORD *)(file->bufEdit + 30);
|
||||
uSize = *ptrw;
|
||||
print_word(uSize);
|
||||
}
|
69
src/test/ref/struct-ptr-26.asm
Normal file
69
src/test/ref/struct-ptr-26.asm
Normal file
@ -0,0 +1,69 @@
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
.label print_char_cursor = 2
|
||||
main: {
|
||||
.label file = $4000
|
||||
.label uSize = 4
|
||||
lda #<4
|
||||
sta file
|
||||
lda #>4
|
||||
sta file+1
|
||||
ldy #$1e
|
||||
ldx file
|
||||
stx.z $fe
|
||||
tax
|
||||
stx.z $ff
|
||||
lda ($fe),y
|
||||
sta.z uSize
|
||||
iny
|
||||
lda ($fe),y
|
||||
sta.z uSize+1
|
||||
jsr print_word
|
||||
rts
|
||||
}
|
||||
// Print a word as HEX
|
||||
// print_word(word zeropage(4) w)
|
||||
print_word: {
|
||||
.label w = 4
|
||||
lda.z w+1
|
||||
tax
|
||||
lda #<$400
|
||||
sta.z print_char_cursor
|
||||
lda #>$400
|
||||
sta.z print_char_cursor+1
|
||||
jsr print_byte
|
||||
lda.z w
|
||||
tax
|
||||
jsr print_byte
|
||||
rts
|
||||
}
|
||||
// Print a byte as HEX
|
||||
// print_byte(byte register(X) b)
|
||||
print_byte: {
|
||||
txa
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
tay
|
||||
lda print_hextab,y
|
||||
jsr print_char
|
||||
lda #$f
|
||||
axs #0
|
||||
lda print_hextab,x
|
||||
jsr print_char
|
||||
rts
|
||||
}
|
||||
// Print a single char
|
||||
// print_char(byte register(A) ch)
|
||||
print_char: {
|
||||
ldy #0
|
||||
sta (print_char_cursor),y
|
||||
inc.z print_char_cursor
|
||||
bne !+
|
||||
inc.z print_char_cursor+1
|
||||
!:
|
||||
rts
|
||||
}
|
||||
print_hextab: .text "0123456789abcdef"
|
53
src/test/ref/struct-ptr-26.cfg
Normal file
53
src/test/ref/struct-ptr-26.cfg
Normal file
@ -0,0 +1,53 @@
|
||||
@begin: scope:[] from
|
||||
[0] phi()
|
||||
to:@1
|
||||
@1: scope:[] from @begin
|
||||
[1] phi()
|
||||
[2] call main
|
||||
to:@end
|
||||
@end: scope:[] from @1
|
||||
[3] phi()
|
||||
main: scope:[main] from @1
|
||||
[4] *((byte**)(const struct fileentry*) main::file#1) ← (byte*) 4
|
||||
[5] (word) main::uSize#1 ← *((word*)*((byte**)(const struct fileentry*) main::file#1) + (byte) $1e)
|
||||
[6] (word) print_word::w#0 ← (word) main::uSize#1
|
||||
[7] call print_word
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main
|
||||
[8] return
|
||||
to:@return
|
||||
print_word: scope:[print_word] from main
|
||||
[9] (byte) print_byte::b#0 ← > (word) print_word::w#0
|
||||
[10] call print_byte
|
||||
to:print_word::@1
|
||||
print_word::@1: scope:[print_word] from print_word
|
||||
[11] (byte) print_byte::b#1 ← < (word) print_word::w#0
|
||||
[12] call print_byte
|
||||
to:print_word::@return
|
||||
print_word::@return: scope:[print_word] from print_word::@1
|
||||
[13] return
|
||||
to:@return
|
||||
print_byte: scope:[print_byte] from print_word print_word::@1
|
||||
[14] (byte*) print_char_cursor#24 ← phi( print_word/(byte*) 1024 print_word::@1/(byte*) print_char_cursor#19 )
|
||||
[14] (byte) print_byte::b#2 ← phi( print_word/(byte) print_byte::b#0 print_word::@1/(byte) print_byte::b#1 )
|
||||
[15] (byte~) print_byte::$0 ← (byte) print_byte::b#2 >> (byte) 4
|
||||
[16] (byte) print_char::ch#0 ← *((const byte[]) print_hextab#0 + (byte~) print_byte::$0)
|
||||
[17] call print_char
|
||||
to:print_byte::@1
|
||||
print_byte::@1: scope:[print_byte] from print_byte
|
||||
[18] (byte~) print_byte::$2 ← (byte) print_byte::b#2 & (byte) $f
|
||||
[19] (byte) print_char::ch#1 ← *((const byte[]) print_hextab#0 + (byte~) print_byte::$2)
|
||||
[20] call print_char
|
||||
to:print_byte::@return
|
||||
print_byte::@return: scope:[print_byte] from print_byte::@1
|
||||
[21] return
|
||||
to:@return
|
||||
print_char: scope:[print_char] from print_byte print_byte::@1
|
||||
[22] (byte*) print_char_cursor#18 ← phi( print_byte/(byte*) print_char_cursor#24 print_byte::@1/(byte*) print_char_cursor#19 )
|
||||
[22] (byte) print_char::ch#2 ← phi( print_byte/(byte) print_char::ch#0 print_byte::@1/(byte) print_char::ch#1 )
|
||||
[23] *((byte*) print_char_cursor#18) ← (byte) print_char::ch#2
|
||||
[24] (byte*) print_char_cursor#19 ← ++ (byte*) print_char_cursor#18
|
||||
to:print_char::@return
|
||||
print_char::@return: scope:[print_char] from print_char
|
||||
[25] return
|
||||
to:@return
|
1057
src/test/ref/struct-ptr-26.log
Normal file
1057
src/test/ref/struct-ptr-26.log
Normal file
File diff suppressed because it is too large
Load Diff
52
src/test/ref/struct-ptr-26.sym
Normal file
52
src/test/ref/struct-ptr-26.sym
Normal file
@ -0,0 +1,52 @@
|
||||
(label) @1
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(const byte) RADIX::BINARY BINARY = (number) 2
|
||||
(const byte) RADIX::DECIMAL DECIMAL = (number) $a
|
||||
(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (number) $10
|
||||
(const byte) RADIX::OCTAL OCTAL = (number) 8
|
||||
(byte) fileentry::bError
|
||||
(byte) fileentry::bFlag
|
||||
(byte*) fileentry::bufEdit
|
||||
(void()) main()
|
||||
(label) main::@return
|
||||
(struct fileentry*) main::file
|
||||
(const struct fileentry*) main::file#1 file = (struct fileentry*) 16384
|
||||
(word*) main::ptrw
|
||||
(word) main::uSize
|
||||
(word) main::uSize#1 uSize zp ZP_WORD:4 4.0
|
||||
(void()) print_byte((byte) print_byte::b)
|
||||
(byte~) print_byte::$0 reg byte a 4.0
|
||||
(byte~) print_byte::$2 reg byte x 4.0
|
||||
(label) print_byte::@1
|
||||
(label) print_byte::@return
|
||||
(byte) print_byte::b
|
||||
(byte) print_byte::b#0 reg byte x 4.0
|
||||
(byte) print_byte::b#1 reg byte x 4.0
|
||||
(byte) print_byte::b#2 reg byte x 2.0
|
||||
(void()) print_char((byte) print_char::ch)
|
||||
(label) print_char::@return
|
||||
(byte) print_char::ch
|
||||
(byte) print_char::ch#0 reg byte a 4.0
|
||||
(byte) print_char::ch#1 reg byte a 4.0
|
||||
(byte) print_char::ch#2 reg byte a 6.0
|
||||
(byte*) print_char_cursor
|
||||
(byte*) print_char_cursor#18 print_char_cursor zp ZP_WORD:2 4.0
|
||||
(byte*) print_char_cursor#19 print_char_cursor zp ZP_WORD:2 0.6666666666666666
|
||||
(byte*) print_char_cursor#24 print_char_cursor zp ZP_WORD:2 1.3333333333333333
|
||||
(byte[]) print_hextab
|
||||
(const byte[]) print_hextab#0 print_hextab = (string) "0123456789abcdef"z
|
||||
(byte*) print_line_cursor
|
||||
(byte*) print_screen
|
||||
(void()) print_word((word) print_word::w)
|
||||
(label) print_word::@1
|
||||
(label) print_word::@return
|
||||
(word) print_word::w
|
||||
(word) print_word::w#0 w zp ZP_WORD:4 2.0
|
||||
|
||||
reg byte x [ print_byte::b#2 print_byte::b#0 print_byte::b#1 ]
|
||||
reg byte a [ print_char::ch#2 print_char::ch#0 print_char::ch#1 ]
|
||||
zp ZP_WORD:2 [ print_char_cursor#18 print_char_cursor#24 print_char_cursor#19 ]
|
||||
zp ZP_WORD:4 [ main::uSize#1 print_word::w#0 ]
|
||||
reg byte a [ print_byte::$0 ]
|
||||
reg byte x [ print_byte::$2 ]
|
Loading…
Reference in New Issue
Block a user