Index . 블로그창고 . Any comments?

\cat software

Stacki
Examples
Alphabet
Summation
Recursive factorial

Stacki

Since May 2, 2003 by Huidae Cho

stacki/stacki.tar.gz

Stacki is a stack-based interpreter that borrows all opcodes from Whitespace. It's not another assembler for Whitespace but has an analogous syntax to that of it; each opcode and operand can be directly translated into a corresponding one of Whitespace.

OpcodeOperandDescriptionSymbol
Stack Manupulationpushsigned-numberPush a number onto the stack(
dupPush top of stack into the stack again=
swapSwap two topmost numbers on stack@
discardPop & discard number on top of stack)
ArithmeticaddPop two numbers, add, push result+
subPop two numbers, subtract, push result-
mulPop two numbers, multiply, push result*
divPop two numbers, integer divide, push result/
modPop two numbers, modulo, push result%
Heap AccessstorePop value and address; store value on heap at that address[
retrievePop address; push onto stack the heap value at that address]
Flow Controllabelunsigned-numberTarget for other flow-control ops:
callunsigned-numberCall subroutine&
jumpunsigned-numberUnconditional jump^
jzunsigned-numberPop top of stack; jump if it's zero!
jnunsigned-numberPop top of stack; jump if it's negative~
retReturn from subroutine|
exitExit interpreter.
I/OoutcharPop top of stack; print it as ascii character$
outnumPop top of stack; print it as decimal number#
readcharRead character from stdin & push it onto stack"
readnumRead integer from stdin & push it onto stack'

Examples

Alphabet

Input:
(65:1=$(1+=(91-~1&123(69$.:123(65(66(67(68$$$$|
Output:

Input:
(65
:1
=
$
(1
+
=
(91
-
~1 ; comment
; comment
&123
(69
$
. ; comment
:123
(65(66(67(68
$$$$
|
Output:


Summation

Input:
(100=(0@[:1(1-=(0]+(0@[=(-1*~1(0]#
Output:


Recursive factorial

Input:
(10&1#.
:1=!10=(1-&1*|:10)(1|
Output:



All the works in this site except software and copyrighted materials by others (e.g., 문학) are licensed under a Creative Commons License. 소프트웨어 및 문학과 같이 다른 이에게 저작권이 있는 작품을 제외하고 모두 크리에이티브 커먼즈 라이센스를 따른다.
Tue Oct 13 15:16:55 2020 . XHTML . CSS (lightbox.css is not part of Uniqki. ;-) . Powered by Uniqki!
refresh . edit . loginout . index