22 lines
476 B
Fennel
22 lines
476 B
Fennel
(local t (require :deps.faith))
|
|
(local {: r : move : branch : branch-link} (require :host.assembler.opcodes))
|
|
(fn hex [n]
|
|
"format a number as 32 bit hexadecimal"
|
|
(string.format :0x%08x n))
|
|
|
|
(fn test-move []
|
|
(t.= 0xe1a05003
|
|
(move (r 5) (r 3)))
|
|
(t.= 0xe3a05003
|
|
(move (r 5) 3)))
|
|
|
|
(fn test-branch []
|
|
(t.= 0xea000021
|
|
(branch 132)))
|
|
|
|
(fn test-branch-link []
|
|
(t.= 0xeb000021
|
|
(branch-link 132)))
|
|
|
|
{: test-move : test-branch : test-branch-link}
|