diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-02-28 11:00:05 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-02-28 11:00:05 +0200 |
| commit | e18c789aebccecd7510a53110276a47e09ca0623 (patch) | |
| tree | 90c2023fe04fc76ca77e7b6f65bf4d076cfbfe37 /atk16_schasm/main.scm | |
| parent | 3db2fadbfbefc03395bff5d3fafe1abddf01c393 (diff) | |
Implement all basic features in new assembler
Diffstat (limited to 'atk16_schasm/main.scm')
| -rw-r--r-- | atk16_schasm/main.scm | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/atk16_schasm/main.scm b/atk16_schasm/main.scm index 79f7686..b9b1111 100644 --- a/atk16_schasm/main.scm +++ b/atk16_schasm/main.scm @@ -2,26 +2,32 @@ (load "lib.scm") -(define FL (reg 13)) -(define PC (reg 14)) -(define SP (reg 15)) +;; you can just write a raw word +(emit #x1234) -(ld SP (imm 0)) +;; compile instructions +(ld SP (u16 0)) +;; set the current emit address (at-addr #x10) -(def-label 'reset-vector) -(emit #xF800) -(emit #xF801) + +;; set labels +(def-label 'reset-vector + (emit #xF800) + (emit #xF801)) (at-addr #x20) -(def-label 'main) -(add (reg 1) (reg 2)) -(add (reg 3) (imm #xFF)) +(def-label 'main + (add R1 R2) + (add R3 (u16 #xFF))) ;; abs jump -(ld PC (imm (label 'main))) +(ld PC (u16 (label 'main))) ;; rel jump -(add PC (imm 10)) +(add PC (i16 10)) + +(mov R0 R1) -(mov (reg 0) (reg 1)) +;; compile to a 128KB image file +(write-image-to "out.bin") |
