mirror of
https://github.com/irmen/prog8.git
synced 2025-02-18 20:30:43 +00:00
txt.get_cursor() now returns the column and row as 2 values, no longer requires 2 pointer arguments
This commit is contained in:
parent
a76b8d66ff
commit
a2be42c5ca
@ -392,9 +392,16 @@ sub plot(ubyte col, ubyte rownum) {
|
||||
row(rownum)
|
||||
}
|
||||
|
||||
sub get_cursor(uword colptr, uword rowptr) {
|
||||
@(colptr) = get_column()
|
||||
@(rowptr) = get_row()
|
||||
asmsub get_cursor() -> ubyte @X, ubyte @Y {
|
||||
%asm {{
|
||||
jsr get_column
|
||||
pha
|
||||
jsr get_row
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub waitkey() -> ubyte @A {
|
||||
|
@ -81,15 +81,15 @@ asmsub get_row() -> ubyte @X {
|
||||
}}
|
||||
}
|
||||
|
||||
sub get_cursor(uword colptr, uword rowptr) {
|
||||
asmsub get_cursor() -> ubyte @X, ubyte @Y {
|
||||
%asm {{
|
||||
sec
|
||||
jsr cbm.PLOT
|
||||
jsr cbm.PLOT
|
||||
stx P8ZP_SCRATCH_REG ; swap X and Y
|
||||
tya
|
||||
ldy #$00
|
||||
sta (colptr),y
|
||||
txa
|
||||
sta (rowptr),y
|
||||
tax
|
||||
ldy P8ZP_SCRATCH_REG
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
|
@ -86,15 +86,15 @@ asmsub get_row() -> ubyte @X {
|
||||
}}
|
||||
}
|
||||
|
||||
sub get_cursor(uword colptr, uword rowptr) {
|
||||
asmsub get_cursor() -> ubyte @X, ubyte @Y {
|
||||
%asm {{
|
||||
sec
|
||||
jsr cbm.PLOT
|
||||
jsr cbm.PLOT
|
||||
stx P8ZP_SCRATCH_REG ; swap X and Y
|
||||
tya
|
||||
ldy #$00
|
||||
sta (colptr),y
|
||||
txa
|
||||
sta (rowptr),y
|
||||
tax
|
||||
ldy P8ZP_SCRATCH_REG
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
|
@ -81,15 +81,15 @@ asmsub get_row() -> ubyte @X {
|
||||
}}
|
||||
}
|
||||
|
||||
sub get_cursor(uword colptr, uword rowptr) {
|
||||
asmsub get_cursor() -> ubyte @X, ubyte @Y {
|
||||
%asm {{
|
||||
sec
|
||||
jsr cbm.PLOT
|
||||
tya
|
||||
ldy #$00
|
||||
sta (colptr),y
|
||||
txa
|
||||
sta (rowptr),y
|
||||
jsr cbm.PLOT
|
||||
phx ; swap X and Y
|
||||
phy
|
||||
plx
|
||||
ply
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
- textio.get_cursor() should just return 2 bytes (rewrite it as asmsub...)
|
||||
|
||||
- add paypal donation button as well?
|
||||
- announce prog8 on the 6502.org site?
|
||||
|
||||
@ -48,7 +46,9 @@ Future Things and Ideas
|
||||
IR/VM
|
||||
-----
|
||||
- getting it in shape for code generation...: the IR file should be able to encode every detail about a prog8 program (the VM doesn't have to actually be able to run all of it though!)
|
||||
- add BZ and BNZ instructions? To replace CMPI #0 + Branch?
|
||||
- split word arrays, both _msb and _lsb arrays are tagged with an alignment. This is not what's intended; only the one put in memory first should be aligned (the other one should follow straight after it)
|
||||
- fix call() return value handling
|
||||
- proper code gen for the CALLI instruction and that it (optionally) returns a word value that needs to be assigned to a reg
|
||||
- implement fast code paths for TODO("inplace split....
|
||||
- implement more TODOs in AssignmentGen
|
||||
- sometimes source lines end up missing in the output p8ir, for example the first assignment is gone in:
|
||||
@ -56,17 +56,12 @@ IR/VM
|
||||
cx16.r0L = cx16.r1 as ubyte
|
||||
cx16.r0sL = cx16.r1s as byte
|
||||
}
|
||||
- implement missing operators in AssignmentGen (array shifts etc)
|
||||
- fix call() return value handling
|
||||
- try to get rid of LSIG opcode again (but this will introduce byte reads from word typed registers...)
|
||||
- proper code gen for the CALLI instruction and that it (optionally) returns a word value that needs to be assigned to a reg
|
||||
- add more optimizations in IRPeepholeOptimizer
|
||||
- idea: (but LLVM IR simply keeps the variables, so not a good idea then?...): replace all scalar variables by an allocated register. Keep a table of the variable to register mapping (including the datatype)
|
||||
global initialization values are simply a list of LOAD instructions.
|
||||
Variables replaced include all subroutine parameters! So the only variables that remain as variables are arrays and strings.
|
||||
- add more optimizations in IRPeepholeOptimizer
|
||||
- the @split arrays are currently also split in _lsb/_msb arrays in the IR, and operations take multiple (byte) instructions that may lead to verbose and slow operation and machine code generation down the line.
|
||||
maybe another representation is needed once actual codegeneration is done from the IR...?
|
||||
- split word arrays, both _msb and _lsb arrays are tagged with an alignment. This is not what's intended; only the one put in memory first should be aligned (the other one should follow straight after it)
|
||||
- ExpressionCodeResult: get rid of the separation between single result register and multiple result registers? maybe not, this requires hundreds of lines to change
|
||||
|
||||
|
||||
|
101
examples/test.p8
101
examples/test.p8
@ -4,102 +4,19 @@
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
uword[] @nosplit arr = [ %01000010_01000010 , %01000010_01000010, %01000010_01000010 ]
|
||||
uword[] @split arrsplit = [ %01000010_01000010 , %01000010_01000010, %01000010_01000010 ]
|
||||
txt.print("\n\n\n\n\n\n !")
|
||||
|
||||
ubyte[] arrb = [ %01000010 , %01000010, %01000010 ]
|
||||
ubyte column, row
|
||||
|
||||
; expected $09
|
||||
arrb[2] = $12
|
||||
arrb[2] >>= 1
|
||||
txt.print_ubhex(arrb[2], true)
|
||||
column, row = txt.get_cursor()
|
||||
txt.nl()
|
||||
txt.print_ub(column)
|
||||
txt.spc()
|
||||
txt.print_ub(row)
|
||||
txt.nl()
|
||||
|
||||
; expected $091a
|
||||
arr[2] = $1234
|
||||
arr[2] >>= 1
|
||||
txt.print_uwhex(arr[2], true)
|
||||
txt.nl()
|
||||
|
||||
; expected $02
|
||||
arrb[2] = $12
|
||||
arrb[2] >>= 3
|
||||
txt.print_ubhex(arrb[2], true)
|
||||
txt.nl()
|
||||
|
||||
; expected $0246
|
||||
arr[2] = $1234
|
||||
arr[2] >>= 3
|
||||
txt.print_uwhex(arr[2], true)
|
||||
txt.nl()
|
||||
|
||||
; arr[2] >>= 1
|
||||
; txt.print_uwhex(arr[2], true)
|
||||
; txt.nl()
|
||||
|
||||
; expected $091a
|
||||
arrsplit[2] = $1234
|
||||
arrsplit[2] >>= 1
|
||||
txt.print_uwhex(arrsplit[2], true)
|
||||
txt.nl()
|
||||
; expected $0246
|
||||
arrsplit[2] = $1234
|
||||
arrsplit[2] >>= 3
|
||||
txt.print_uwhex(arrsplit[2], true)
|
||||
txt.nl()
|
||||
|
||||
; arrsplit[2] >>= 1
|
||||
; txt.print_uwhex(arrsplit[2], true)
|
||||
; txt.nl()
|
||||
|
||||
; uword wv = %01000010_01000010
|
||||
;
|
||||
; ; expected: $8484 $4242
|
||||
; sys.set_carry()
|
||||
; rol(wv)
|
||||
; txt.print_uwhex(wv, true)
|
||||
; sys.set_carry()
|
||||
; ror(wv)
|
||||
; txt.print_uwhex(wv, true)
|
||||
; txt.nl()
|
||||
;
|
||||
; wv = %01000010_01000010
|
||||
; sys.set_carry()
|
||||
; rol2(wv)
|
||||
; txt.print_uwhex(wv, true)
|
||||
; sys.set_carry()
|
||||
; ror2(wv)
|
||||
; txt.print_uwhex(wv, true)
|
||||
; txt.nl()
|
||||
;
|
||||
; sys.set_carry()
|
||||
; rol(arr[2])
|
||||
; txt.print_uwhex(arr[2], true)
|
||||
; sys.set_carry()
|
||||
; ror(arr[2])
|
||||
; txt.print_uwhex(arr[2], true)
|
||||
; txt.nl()
|
||||
; sys.set_carry()
|
||||
; rol2(arr[1])
|
||||
; txt.print_uwhex(arr[1], true)
|
||||
; sys.set_carry()
|
||||
; ror2(arr[1])
|
||||
; txt.print_uwhex(arr[1], true)
|
||||
; txt.nl()
|
||||
;
|
||||
; sys.set_carry()
|
||||
; rol(arrsplit[2])
|
||||
; txt.print_uwhex(arrsplit[2], true)
|
||||
; sys.set_carry()
|
||||
; ror(arrsplit[2])
|
||||
; txt.print_uwhex(arrsplit[2], true)
|
||||
; txt.nl()
|
||||
; sys.set_carry()
|
||||
; rol2(arrsplit[1])
|
||||
; txt.print_uwhex(arrsplit[1], true)
|
||||
; sys.set_carry()
|
||||
; ror2(arrsplit[1])
|
||||
; txt.print_uwhex(arrsplit[1], true)
|
||||
; txt.nl()
|
||||
repeat {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user