added cbm.RDTIML and cbm.SETTIML wrappers

This commit is contained in:
Irmen de Jong
2025-10-04 02:00:24 +02:00
parent 35b921b062
commit 0e177cb531
7 changed files with 101 additions and 8 deletions

View File

@@ -4256,7 +4256,7 @@ $endLabel""")
} }
} }
} }
else -> throw AssemblyError("expected reg pair or cx16 virtual 16-bit register") else -> throw AssemblyError("expected reg pair or cx16 virtual 16-bit register ${target.position}")
} }
} }
TargetStorageKind.MEMORY -> throw AssemblyError("can't store word into memory byte") TargetStorageKind.MEMORY -> throw AssemblyError("can't store word into memory byte")

View File

@@ -133,6 +133,29 @@ asmsub RDTIM16() clobbers(X) -> uword @AY {
}} }}
} }
asmsub SETTIML(long jiffies @R0R1_32) {
; -- just like SETTIM, but with a single 32 bit (lower 24 bits used) argument.
%asm {{
lda cx16.r0
ldx cx16.r0+1
ldy cx16.r0+2
jmp SETTIM
}}
}
asmsub RDTIML() clobbers(X) -> long @R0R1_32 {
; -- like RDTIM() and returning the timer value as a 32 bit (lower 24 bits used) value.
%asm {{
jsr RDTIM
sta cx16.r0
stx cx16.r0+1
sty cx16.r0+2
lda #0
sta cx16.r0+3
rts
}}
}
sub CLEARST() { sub CLEARST() {
; -- Set the ST status variable back to 0. (there's no direct kernal call for this) ; -- Set the ST status variable back to 0. (there's no direct kernal call for this)
; Note: a drive error state (blinking led) isn't cleared! You can use diskio.status() to clear that. ; Note: a drive error state (blinking led) isn't cleared! You can use diskio.status() to clear that.

View File

@@ -132,6 +132,29 @@ asmsub RDTIM16() clobbers(X) -> uword @AY {
}} }}
} }
asmsub SETTIML(long jiffies @R0R1_32) {
; -- just like SETTIM, but with a single 32 bit (lower 24 bits used) argument.
%asm {{
lda cx16.r0
ldx cx16.r0+1
ldy cx16.r0+2
jmp SETTIM
}}
}
asmsub RDTIML() clobbers(X) -> long @R0R1_32 {
; -- like RDTIM() and returning the timer value as a 32 bit (lower 24 bits used) value.
%asm {{
jsr RDTIM
sta cx16.r0
stx cx16.r0+1
sty cx16.r0+2
lda #0
sta cx16.r0+3
rts
}}
}
sub CLEARST() { sub CLEARST() {
; -- Set the ST status variable back to 0. (there's no direct kernal call for this) ; -- Set the ST status variable back to 0. (there's no direct kernal call for this)
; Note: a drive error state (blinking led) isn't cleared! You can use diskio.status() to clear that. ; Note: a drive error state (blinking led) isn't cleared! You can use diskio.status() to clear that.

View File

@@ -127,6 +127,28 @@ asmsub RDTIM16() clobbers(X) -> uword @AY {
}} }}
} }
asmsub SETTIML(long jiffies @R0R1_32) {
; -- just like SETTIM, but with a single 32 bit (lower 24 bits used) argument.
%asm {{
lda cx16.r0
ldx cx16.r0+1
ldy cx16.r0+2
jmp SETTIM
}}
}
asmsub RDTIML() clobbers(X) -> long @R0R1_32 {
; -- like RDTIM_safe() and returning the timer value as a 32 bit (lower 24 bits used) value.
%asm {{
jsr RDTIM_safe
sta cx16.r0
stx cx16.r0+1
sty cx16.r0+2
stz cx16.r0+3
rts
}}
}
sub CLEARST() { sub CLEARST() {
; -- Set the ST status variable back to 0. (there's no direct kernal call for this) ; -- Set the ST status variable back to 0. (there's no direct kernal call for this)
; Note: a drive error state (blinking led) isn't cleared! You can use diskio.status() to clear that. ; Note: a drive error state (blinking led) isn't cleared! You can use diskio.status() to clear that.

View File

@@ -81,6 +81,29 @@ asmsub RDTIM16() clobbers(X) -> uword @AY {
}} }}
} }
asmsub SETTIML(long jiffies @R0R1_32) {
; -- just like SETTIM, but with a single 32 bit (lower 24 bits used) argument.
%asm {{
lda cx16.r0
ldx cx16.r0+1
ldy cx16.r0+2
jmp SETTIM
}}
}
asmsub RDTIML() clobbers(X) -> long @R0R1_32 {
; -- like RDTIM() and returning the timer value as a 32 bit (lower 24 bits used) value.
%asm {{
jsr RDTIM
sta cx16.r0
stx cx16.r0+1
sty cx16.r0+2
lda #0
sta cx16.r0+3
rts
}}
}
asmsub kbdbuf_clear() { asmsub kbdbuf_clear() {
; -- convenience helper routine to clear the keyboard buffer ; -- convenience helper routine to clear the keyboard buffer
%asm {{ %asm {{

View File

@@ -3,9 +3,10 @@ TODO
LONG TYPE LONG TYPE
--------- ---------
- scan through library routines if there are opportunities to use the long? such as RDTIM = add pushl popl
- document the new long type! and mklong(a,b,c,d) and mklong2(w1,w2) , print_l , print_ulhex (& conv.str_l) and pokel, peekl, and the use of R0:R1 when doing LONG calculations - scan through more library routines if there are opportunities to use the long?
- call convention for asmsubs: asmsubs don't have syntax for passing a long value so use explicit separate msw() and lsw() arguments... Or introduce new syntax for R0+R1 combo's? - document the new long type! and mklong(a,b,c,d) and mklong2(w1,w2) , print_l , print_ulhex (& conv.str_l) and pokel, peekl, cbm.SETTIML/RDTIML, and the use of R0:R1 when doing LONG calculations
- asmsub call convention: @R0R1_32 to specify a 32 bits long combined register R0:R1
- how hard is it to also implement the other comparison operators (<,>,<=,>=) on longs? - how hard is it to also implement the other comparison operators (<,>,<=,>=) on longs?
- implement LONG testcases in testmemory - implement LONG testcases in testmemory

View File

@@ -4,9 +4,10 @@
main { main {
sub start() { sub start() {
long highscore = $50999 cbm.SETTIML($12fe56)
repeat {
highscore = bcd.addl(highscore, 1) txt.home()
txt.print_ulhex(highscore, false) ; prints 00051000, avoiding costly decimal conversion txt.print_ulhex(cbm.RDTIML(), false)
}
} }
} }