mirror of
https://github.com/maride/mexico.git
synced 2026-06-16 02:42:06 +00:00
Init commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// Fibonacci program written in mexico - calculating all results below 1337
|
||||
|
||||
// Set up tape
|
||||
push 1
|
||||
pop
|
||||
right
|
||||
push 1
|
||||
pop
|
||||
left
|
||||
|
||||
// Fibonnacci loop
|
||||
MAINLOOP:
|
||||
// Calculate i + j
|
||||
pusht
|
||||
right
|
||||
pusht
|
||||
add
|
||||
|
||||
// Print out result
|
||||
dup
|
||||
print
|
||||
|
||||
// Overwrite i with j
|
||||
pusht
|
||||
left
|
||||
pop
|
||||
|
||||
// Write result of calculation to j, and duplicate it for further usage
|
||||
dup
|
||||
right
|
||||
pop
|
||||
|
||||
// Move head for a clean loop
|
||||
left
|
||||
|
||||
// Check if we should already stop
|
||||
push 1337
|
||||
lt
|
||||
not
|
||||
push MAINLOOP
|
||||
jmpc
|
||||
// MAINLOOP END
|
||||
|
||||
// Calculated all fibonacci numbers below 1337 :) yay!
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// A simple Hello World program, only working with the stack
|
||||
|
||||
// Push "Hello World\0" in reverse order
|
||||
push 0
|
||||
push 100
|
||||
push 108
|
||||
push 114
|
||||
push 111
|
||||
push 87
|
||||
push 32
|
||||
push 111
|
||||
push 108
|
||||
push 108
|
||||
push 101
|
||||
push 72
|
||||
|
||||
PRINTLOOP:
|
||||
// Print until encountering null byte
|
||||
dup
|
||||
print
|
||||
push 0
|
||||
eq
|
||||
not
|
||||
push PRINTLOOP
|
||||
jmpc
|
||||
// Done
|
||||
Reference in New Issue
Block a user