Examples
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1 +1,2 @@ | |||||||
| .vscode | .vscode | ||||||
|  | programs | ||||||
							
								
								
									
										30
									
								
								examples/clear_screen.asm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								examples/clear_screen.asm
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||||
							
								
								
									
										50
									
								
								examples/functions.asm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								examples/functions.asm
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | ||||||
| @@ -10,7 +10,7 @@ print: | |||||||
| lda *q++ | lda *q++ | ||||||
| jpz print_end | jpz print_end | ||||||
| sta *p++ | sta *p++ | ||||||
| jmp print: | jmp print | ||||||
|  |  | ||||||
| print_end: | print_end: | ||||||
| hlt | hlt | ||||||
		Reference in New Issue
	
	Block a user