txt.get_cursor() now returns the column and row as 2 values, no longer requires 2 pointer arguments

This commit is contained in:
Irmen de Jong 2025-01-04 01:36:47 +01:00
parent a76b8d66ff
commit a2be42c5ca
6 changed files with 42 additions and 123 deletions

View File

@ -392,9 +392,16 @@ sub plot(ubyte col, ubyte rownum) {
row(rownum) row(rownum)
} }
sub get_cursor(uword colptr, uword rowptr) { asmsub get_cursor() -> ubyte @X, ubyte @Y {
@(colptr) = get_column() %asm {{
@(rowptr) = get_row() jsr get_column
pha
jsr get_row
tay
pla
tax
rts
}}
} }
asmsub waitkey() -> ubyte @A { asmsub waitkey() -> ubyte @A {

View File

@ -81,15 +81,15 @@ asmsub get_row() -> ubyte @X {
}} }}
} }
sub get_cursor(uword colptr, uword rowptr) { asmsub get_cursor() -> ubyte @X, ubyte @Y {
%asm {{ %asm {{
sec sec
jsr cbm.PLOT jsr cbm.PLOT
stx P8ZP_SCRATCH_REG ; swap X and Y
tya tya
ldy #$00 tax
sta (colptr),y ldy P8ZP_SCRATCH_REG
txa rts
sta (rowptr),y
}} }}
} }

View File

@ -86,15 +86,15 @@ asmsub get_row() -> ubyte @X {
}} }}
} }
sub get_cursor(uword colptr, uword rowptr) { asmsub get_cursor() -> ubyte @X, ubyte @Y {
%asm {{ %asm {{
sec sec
jsr cbm.PLOT jsr cbm.PLOT
stx P8ZP_SCRATCH_REG ; swap X and Y
tya tya
ldy #$00 tax
sta (colptr),y ldy P8ZP_SCRATCH_REG
txa rts
sta (rowptr),y
}} }}
} }

View File

@ -81,15 +81,15 @@ asmsub get_row() -> ubyte @X {
}} }}
} }
sub get_cursor(uword colptr, uword rowptr) { asmsub get_cursor() -> ubyte @X, ubyte @Y {
%asm {{ %asm {{
sec sec
jsr cbm.PLOT jsr cbm.PLOT
tya phx ; swap X and Y
ldy #$00 phy
sta (colptr),y plx
txa ply
sta (rowptr),y rts
}} }}
} }

View File

@ -1,8 +1,6 @@
TODO TODO
==== ====
- textio.get_cursor() should just return 2 bytes (rewrite it as asmsub...)
- add paypal donation button as well? - add paypal donation button as well?
- announce prog8 on the 6502.org site? - announce prog8 on the 6502.org site?
@ -48,7 +46,9 @@ Future Things and Ideas
IR/VM 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!) - 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 fast code paths for TODO("inplace split....
- implement more TODOs in AssignmentGen - implement more TODOs in AssignmentGen
- sometimes source lines end up missing in the output p8ir, for example the first assignment is gone in: - 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.r0L = cx16.r1 as ubyte
cx16.r0sL = cx16.r1s as byte cx16.r0sL = cx16.r1s as byte
} }
- implement missing operators in AssignmentGen (array shifts etc) - add more optimizations in IRPeepholeOptimizer
- 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
- 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) - 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. 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. 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. - 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...? 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 - ExpressionCodeResult: get rid of the separation between single result register and multiple result registers? maybe not, this requires hundreds of lines to change

View File

@ -4,102 +4,19 @@
main { main {
sub start() { sub start() {
uword[] @nosplit arr = [ %01000010_01000010 , %01000010_01000010, %01000010_01000010 ] txt.print("\n\n\n\n\n\n !")
uword[] @split arrsplit = [ %01000010_01000010 , %01000010_01000010, %01000010_01000010 ]
ubyte[] arrb = [ %01000010 , %01000010, %01000010 ] ubyte column, row
; expected $09 column, row = txt.get_cursor()
arrb[2] = $12 txt.nl()
arrb[2] >>= 1 txt.print_ub(column)
txt.print_ubhex(arrb[2], true) txt.spc()
txt.print_ub(row)
txt.nl() txt.nl()
; expected $091a
arr[2] = $1234
arr[2] >>= 1
txt.print_uwhex(arr[2], true)
txt.nl()
; expected $02 repeat {
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()
} }
} }