From 64a98f6add8613680ed4c2fa55568660979a169c Mon Sep 17 00:00:00 2001 From: Auios Date: Fri, 16 Feb 2024 17:00:38 -0500 Subject: [PATCH] Examples --- .gitignore | 3 ++- examples/clear_screen.asm | 30 +++++++++++++++++++++++ examples/functions.asm | 50 +++++++++++++++++++++++++++++++++++++++ examples/helloworld.asm | 4 ++-- 4 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 examples/clear_screen.asm create mode 100644 examples/functions.asm diff --git a/.gitignore b/.gitignore index 600d2d3..da66e67 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.vscode \ No newline at end of file +.vscode +programs \ No newline at end of file diff --git a/examples/clear_screen.asm b/examples/clear_screen.asm new file mode 100644 index 0000000..1d63917 --- /dev/null +++ b/examples/clear_screen.asm @@ -0,0 +1,30 @@ +.include _hwdefs.asm +.include _clrdefs.asm + +;; Variables +.org SYSRAM +stack: byte[128] + +;; Main +.org SYSROM +lds stack +jss cls + +hlt + +;; Clear the screen +FUNC cls: + ldp screen.char + ldc $00 ;; Blank + ldq screen.color + ldb CLR_BLACK ;; Black + .cls_loop: { + stc *p++ + stb *q++ + lda pl + cmp (lo(COLOR)) + jnz .cls_loop + lda ph + cmp (hi(COLOR)) + jnz } +rts diff --git a/examples/functions.asm b/examples/functions.asm new file mode 100644 index 0000000..e52cfc1 --- /dev/null +++ b/examples/functions.asm @@ -0,0 +1,50 @@ +.include _hwdefs.asm +.include _clrdefs.asm + +;; Defines +.define VARS $0100 + +;; Variables +.org SYSRAM +stack: byte[128] + +.org VARS +hello_str: "Hello world!\0" + +;; Main +.org SYSROM +lds stack + +jss cls + +ldp screen.char +ldq hello_str +jss print + +hlt + +;; Clear the screen +FUNC cls: + ldp screen.char + ldc $00 ;; Blank + ldq screen.color + ldb CLR_BLACK ;; Black + .cls_loop: { + stc *p++ + stb *q++ + lda pl + cmp (lo(COLOR)) + jnz .cls_loop + lda ph + cmp (hi(COLOR)) + jnz } +rts + +;; Print string (Q) to the current screen cursor (P) +FUNC print: + lda *q++ + jpz .print_end + sta *p++ + jmp print + .print_end: +rts diff --git a/examples/helloworld.asm b/examples/helloworld.asm index baf2b0b..d33bc46 100644 --- a/examples/helloworld.asm +++ b/examples/helloworld.asm @@ -10,7 +10,7 @@ print: lda *q++ jpz print_end sta *p++ -jmp print: +jmp print print_end: -hlt \ No newline at end of file +hlt