aboutsummaryrefslogtreecommitdiffstats
path: root/encoding-test.csc
blob: a7f4ace0ede33399a31e5804c462da37e12036b6 (plain) (blame)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
(import (scheme base)
        (only (csc testing) test assert-equal)
        (csc encoding))


(test encode-const
  (assert-equal
    '(#xf2 #x3 0 0 0 0 0 0 #xf6 #xff #xff #xff #xff #xff #xff #xff)
    (encode '((const -10)))))


(test encode-add
  (assert-equal
    '(#xfc #x3 0 0 0 0 0 0)
    (encode '(add))))


(test encode-sub
  (assert-equal
    '(#x6 #x4 0 0 0 0 0 0)
    (encode '(sub))))


(test encode-mul
  (assert-equal
    '(#x10 #x4 0 0 0 0 0 0)
    (encode '(mul))))


(test encode-div
  (assert-equal
    '(#x1a #x4 0 0 0 0 0 0)
    (encode '(div))))


(test encode-mod
  (assert-equal
    '(#x24 #x4 0 0 0 0 0 0)
    (encode '(mod))))


(test encode-alloc
  (assert-equal
    '(#xda #x7 0 0 0 0 0 0)
    (encode '(alloc))))


(test encode-peek
  (assert-equal
    '(#xe4 #x7 0 0 0 0 0 0 #xa)
    (encode '((peek 10)))))


(test encode-poke
  (assert-equal
    '(#xee #x7 0 0 0 0 0 0 #xa)
    (encode '((poke 10)))))


(test encode-peekbyte
  (assert-equal
    '(#xf8 #x7 0 0 0 0 0 0)
    (encode '(peekbyte))))


(test encode-pokebyte
  (assert-equal
    '(#x2 #x8 0 0 0 0 0 0)
    (encode '(pokebyte))))


(test encode-pop
  (assert-equal
    '(#xc2 #xb 0 0 0 0 0 0)
    (encode '(pop))))


(test encode-local
  (assert-equal
    '(#xcc #xb 0 0 0 0 0 0 #xa)
    (encode '((local 10)))))


(test encode-if
  (assert-equal
    '(#xaa #xf 0 0 0 0 0 0 #xf6 #xff #xff #xff #xff #xff #xff #xff)
    (encode '((if -10)))))


(test encode-call
  (assert-equal
    '(#xb4 #xf 0 0 0 0 0 0 #xa)
    (encode '((call 10)))))


(test encode-ret
  (assert-equal
    '(#xbe #xf 0 0 0 0 0 0)
    (encode '(ret))))


(test encode-exit
  (assert-equal
    '(#xc8 #xf 0 0 0 0 0 0)
    (encode '(exit))))


(test encode-putc
  (assert-equal
    '(#x92 #x13 0 0 0 0 0 0)
    (encode '(putc))))


(test encode-getc
  (assert-equal
    '(#x9c #x13 0 0 0 0 0 0)
    (encode '(getc))))