aboutsummaryrefslogtreecommitdiffstats
path: root/atk16_schasm/main.scm
blob: b9b1111f24e2284d7bba1a48e08cdb2e6fb34317 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(import (chicken base))

(load "lib.scm")

;; you can just write a raw word
(emit #x1234)

;; compile instructions
(ld SP (u16 0))

;; set the current emit address
(at-addr #x10)

;; set labels
(def-label 'reset-vector
  (emit #xF800)
  (emit #xF801))

(at-addr #x20)
(def-label 'main
  (add R1 R2)
  (add R3 (u16 #xFF)))

;; abs jump
(ld PC (u16 (label 'main)))

;; rel jump
(add PC (i16 10))

(mov R0 R1)

;; compile to a 128KB image file
(write-image-to "out.bin")