Merge branch 'master' of git.sr.ht:~h3rald/xyw
jump to
@@ -13,7 +13,7 @@ .include "lib/putd.xyw"
.include "lib/puts.xyw" ; Register keypress and timer handlers, start 1-second timer -; -- +; -> .label setup-handlers on-keypress terminal.on_keypress STW on-timer clock.on_timer STW@@ -21,14 +21,14 @@ $0100 clock.timer STW
RTS ; Timer handler: redraw the prompt line with updated clock -; -- +; -> .label on-timer redraw-line JSRw $0100 clock.timer STW RTS ; Keypress handler -; -- +; -> .label on-keypress terminal.input LDB ; Enter@@ -50,11 +50,12 @@ ; Echo the character
PUTC RTS +; a8 -> .label on-ignore POP RTS ; Enter: echo back the line -; -- +; a8 -> .label on-enter POP NL@@ -68,7 +69,7 @@ print-prompt JSRw
RTS ; Backspace: remove last character -; -- +; a8 -> .label on-backspace POP buf-len LDBw $00 EQU on-backspace.done JCNw@@ -78,7 +79,7 @@ .label on-backspace.done
RTS ; Print the clock prompt: [HH:MM:SS] > -; -- +; -> .label print-prompt $5B PUTC clock.hour LDB ZEROPADx JSRw@@ -90,7 +91,7 @@ $5D PUTC SP $3E PUTC SP
RTS ; Redraw current line in-place: CR + prompt + buffer + clear-to-EOL -; -- +; -> .label redraw-line $0D PUTC print-prompt JSRw@@ -100,7 +101,7 @@ $1B PUTC $5B PUTC $4B PUTC
RTS ; Print buffer contents (buf[0..len-1]) -; -[xw, y]- +; -> .label print-buffer buf POPxw buf-len LDBw POPy@@ -113,7 +114,7 @@ .label print-buffer.done
RTS ; Print 8-bit value with leading zero if < 10 -; a8 -[x]- +; a8 -> .label ZEROPADx POPx PSHx $0A LTH zeropad.zero JCNw .label zeropad.digit
@@ -7,7 +7,7 @@ NL
HLT ; Factorial subroutine -; a16 -[xy]- +; a16 -> .label fact ; Save argument to both registers POPxyw
@@ -7,7 +7,7 @@ NL
HLT ; Factorial subroutine -; a8 -[xy]- +; a8 -> .label fact ; Save argument to both registers POPxy
@@ -2,8 +2,8 @@ ; main program
hello print JSRw HLT -; a16 -- ; printing subroutine +; a16 -> .label print ; store top of stack to register XW POPxw
@@ -12,7 +12,7 @@ ; Store address of start song in xw
start-song POPxw ; Process <length> <pitch> pairs until end-song -; a16 b16 -[xw]- +; a16 b16 -> .label play ; Set length LDWxw beeper.length STW
@@ -2,7 +2,7 @@ ; <str> <fragment> contains -> $00|$01
; xw -> index of string ; yw -> index of fragment ; y -> internal index within fragment -; a16 b16 -[xxwyw]- a8 +; a16 b16 -> a8 .label contains POPyw POPxw ; save both addresses to xw and yw $00 POPy ; set y to zero
@@ -1,7 +1,5 @@
-; .include "lib/macros.xyw" - ; Check if two strings are equal -; a16 b16 -- a8 +; a16 b16 -> a8 .label equals ; save addresses to registers POPyw POPxw
@@ -1,7 +1,5 @@
-; .include "lib/macros.xyw" - ; returns the length of a string (max: 255) -; a16 -[xxw]- a8 +; a16 -> a8 .label length POPxw ; store start address $00 POPx ; counter
@@ -1,5 +1,5 @@
-; returns the length of a string (max: 255) -; a16 -[xwyw]- b16 +; returns the length of a string +; a16 -> b16 .label lengthw POPxw ; store start address $0000 POPyw ; counter
@@ -1,7 +1,5 @@
-;.include "lib/macros.xyw" - ; Convert a string to lowercase -; a16 -[xw]- +; a16 -> .label lowcase ; store index POPxw
@@ -1,7 +1,5 @@
-; .include "lib/macros.xyw" - ; Checks if char a16 is one of chars in b16 (string) -; a16 b16 -[xwyw]- a8 +; a16 b16 -> a8 .label oneof POPyw POPxw
@@ -1,10 +1,9 @@
-; UNTESTED ; .include "lib/macros.xyw" ; .include "lib/lowcase.xyw" ; .include "lib/contains.xyw" ; Pushes address to OS identifier -; -- a16 +; -> a16 .label osdetect ; Set command to execute osdetect.cmd file.path STW
@@ -1,7 +1,5 @@
-; .include "lib/macros.xyw" - ; Print an 8bit integer as decimal -; a8 -[x]- +; a8 -> .label putd POPx ; If value is less than 10, print single digit
@@ -1,7 +1,7 @@
; .include "lib/macros.xyw" ; Print a 16bit integer as decimal -; a16 -[x]- +; a16 -> .label putdw POPxw ; If value is less than 10, print single digit
@@ -1,7 +1,7 @@
; .include "lib/macros.xyw" ; Print a string starting at address -; a16 -[xw]- +; a16 -> .label puts POPxw .label puts.loop
@@ -1,7 +1,5 @@
-;.include "lib/macros.xyw" - ; Convert a string to uppercase -; a16 -[xw]- +; a16 -> .label upcase ; store index POPxw
@@ -8,7 +8,7 @@ $10 $00 DIV
HLT ; on_error handler -; -- +; -> .label on_error system.error LDB $01 EQU on_error.div-by-zero.print JCNw unknown-error puts JSRw
@@ -6,7 +6,7 @@ ; End program
HLT ; on_argument event handler -; -[x]- +; -> .label print-args terminal.input POPx ; If end of argument, print new line and end
@@ -6,7 +6,7 @@ ; End program
HLT ; on_keypress event handler -; -- +; -> .label print-key ; Print typed character terminal.input LDB PUTC
@@ -8,7 +8,7 @@
.include "lib/putd.xyw" ; Print current time every second -; -- +; -> .label on-timer CR ; print current time@@ -18,7 +18,7 @@ set-timer JSRw
RTS ; Set on_timer handler and start timer for 1 second -; -- +; -> .label set-timer ; reset on_timer handler on-timer clock.on_timer STW@@ -27,7 +27,7 @@ $0100 clock.timer STW
RTS ; Print current time in HH:MM:SS format -; -- +; -> .label print-clock clock.hour LDB ZEROPADx JSRw@@ -40,7 +40,7 @@ ZEROPADx JSRw
RTS ; Print an 8bit integer as decimal, with leading zero if less than 10 -; a8 -[x]- +; a8 -> .label ZEROPADx POPx PSHx $0A LTH put-zero JCNw .label put-digit