-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01-early-math.lsp
52 lines (45 loc) · 1015 Bytes
/
01-early-math.lsp
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
; create native machine instructions for critical math operations
; these are not nice to use as they are but it allows us to at least do
; some math, until we define the proper operator procs later
; addition, a0 + a1
(define +$ (allocate 8 4))
(poke.w +$
0x00b50533 ; add a0, a0, a1
0x00008067 ; ret
)
; subtraction, a0 - a1
(define -$ (allocate 8 4))
(poke.w -$
0x40b50533 ; sub a0, a0, a1
0x00008067 ; ret
)
; left shift, a0 << a1
(define <<$ (allocate 8 4))
(poke.w <<$
0x00b51533 ; sll a0, a0, a1
0x00008067 ; ret
)
; right arithmetic (sign extend) shift, a0 >> a1
(define >>$ (allocate 8 4))
(poke.w >>$
0x40b55533 ; sra a0, a0, a1
0x00008067 ; ret
)
; logical and, a0 & a1
(define &$ (allocate 8 4))
(poke.w &$
0x00b57533 ; and a0, a0, a1
0x00008067 ; ret
)
; logical or, a0 | a1
(define |$ (allocate 8 4))
(poke.w |$
0x00b56533 ; or a0, a0, a1
0x00008067 ; ret
)
; logical xor, a0 ^ a1
(define ^$ (allocate 8 4))
(poke.w ^$
0x00b54533 ; xor a0, a0, a1
0x00008067 ; ret
)