Created
April 28, 2017 19:33
-
-
Save crcx/ed6e3e035a90a54ec7814d51a8c87428 to your computer and use it in GitHub Desktop.
s:to-number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: next | |
i lica.... | |
r fetch-next | |
i zr...... | |
i lisuswpu | |
d 48 | |
i swlimuad | |
d 10 | |
i poliju.. | |
r next | |
: check | |
i dufelieq | |
d 45 | |
i zr...... | |
i drswdrli | |
d -1 | |
i swliadre | |
d 1 | |
: s:to-number | |
i liswlica | |
d 1 | |
r check | |
i liswlica | |
d 0 | |
r next | |
i drmure.. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:next | |
lit &fetch-next | |
call | |
zret | |
lit 48 | |
sub | |
swap | |
push | |
swap | |
lit 10 | |
mul | |
add | |
pop | |
lit &next | |
jump | |
:check | |
dup | |
fetch | |
lit 1 | |
eq? | |
zret | |
drop | |
swap | |
drop | |
lit -1 | |
swap | |
lit 1 | |
add | |
ret | |
:s:to-number | |
lit 1 | |
swap | |
lit &check | |
call | |
lit 0 | |
swap | |
lit &next | |
call | |
drop | |
mul | |
ret |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:to-number:Mod | |
.data 0 | |
:to-number:Acc | |
.data 0 | |
:to-number:char>digit | |
lit 48 | |
sub | |
ret | |
:to-number:scale | |
lit &to-number:Acc | |
fetch | |
lit 10 | |
mul | |
ret | |
:to-number:convert | |
lit &fetch-next | |
call | |
zret | |
lit &to-number:char>digit | |
call | |
lit &to-number:scale | |
call | |
add | |
lit &to-number:Acc | |
store | |
lit &to-number:convert | |
jump | |
:to-number:prepare | |
lit 1 | |
lit &to-number:Mod | |
store | |
lit 0 | |
lit &to-number:Acc | |
store | |
dup | |
fetch | |
lit 45 | |
eq? | |
zret | |
drop | |
lit -1 | |
lit &to-number:Mod | |
store | |
lit 1 | |
add | |
ret | |
:s:to-number | |
lit &to-number:prepare | |
call | |
lit &to-number:convert | |
call | |
drop | |
lit &to-number:Acc | |
fetch | |
lit &to-number:Mod | |
fetch | |
mul | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
new.muri is the new implementation for the new muri assembler
new.naje is the new implementation for the older naje assembler
old.naje is the previous implementation for the older naje assembler
Muri is a new assembler I wrote yesterday. It allows me to interact closer to the actual instruction set level (as I have to manually pack the instructions and sequence the data elements). Though this is more complex to use, it's a much simpler implementation.
Reading it:
The first column tells Muri what follows.
Instructions are packed up to four per location, with the standard caveat that instructions modifying IP must be followed only by nop (the two ..). Instructions are named using the first two characters of their descriptive names from the table below..
A li (literal) is followed by the value to push in the following cell.
At a higher level: