aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--ia32/stack.sts28
-rw-r--r--ia32/syscall.sts6
-rw-r--r--main.sts23
4 files changed, 33 insertions, 32 deletions
diff --git a/Makefile b/Makefile
index fc94f79..581241b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,14 @@
-cryptrobber: main.sts strans smack
- ./smack $< | ./strans > $@
+.PHONY: cryptrobber clean
+
+cryptrobber:
+ ./smack main.sts | ./strans > $@
chmod 0755 $@
smack: smack.c
gcc $< -o $@
+
strans: strans.c
gcc $< -o $@
-.PHONY: clean
clean:
rm -f smack strans cryptrobber
diff --git a/ia32/stack.sts b/ia32/stack.sts
index 56f4f07..cf1bd21 100644
--- a/ia32/stack.sts
+++ b/ia32/stack.sts
@@ -1,18 +1,30 @@
-defasm drop
- # 58 ?' ; pop eax
+defasm get
+ # 58 ?' ; pop eax
+ # 8b ?' # 4 ?' # 84 ?' ; mov eax, [esp + 4 * eax]
+ # 50 ?' ; push eax
+next
+
+defasm set
+ # 5b ?' ; pop ebx
+ # 58 ?' ; pop eax
+ # 89 ?' # 04 ?' # 9c ?' ; mov [esp + 4 * ebx], eax
next
+defasm drop
+ # 58 ?' ; pop eax
+next
+
defasm dup
- # ff ?' # 34 ?' # 24 ?' ; push dword [esp]
+ # ff ?' # 34 ?' # 24 ?' ; push dword [esp]
next
defasm over
- # ff ?' # 74 ?' # 24 ?' # 4 ?' ; push dword [esp + 4]
+ # ff ?' # 74 ?' # 24 ?' # 4 ?' ; push dword [esp + 4]
next
defasm swap
- # 58 ?' ; pop eax
- # 5b ?' ; pop ebx
- # 50 ?' ; push eax
- # 53 ?' ; push ebx
+ # 58 ?' ; pop eax
+ # 5b ?' ; pop ebx
+ # 50 ?' ; push eax
+ # 53 ?' ; push ebx
next
diff --git a/ia32/syscall.sts b/ia32/syscall.sts
index 3bce0ff..7ff7480 100644
--- a/ia32/syscall.sts
+++ b/ia32/syscall.sts
@@ -1,4 +1,4 @@
-defasm quit
+defasm sys_exit
# b8 ?' # 1 ?. ; mov eax, 1
# 31 ?' # db ?' ; xor ebx, ebx
# cd ?' # 80 ?' ; int 0x80
@@ -8,7 +8,7 @@ _data_segment ?choose
?$ ?? _iobuf # 0 ?'
_code_segment ?choose
-defasm key
+defasm sys_read
# b8 ?' # 3 ?. ; mov eax, 3
# 31 ?' # db ?' ; xor ebx, ebx
# b9 ?' _iobuf ?. ; mov ecx, _iobuf
@@ -20,7 +20,7 @@ defasm key
# 50 ?' ; push eax
next
-defasm emit
+defasm sys_write
# 58 ?' ; pop eax
# a2 ?' _iobuf ?. ; mov [_iobuf], al
# b8 ?' # 4 ?. ; mov eax, 4
diff --git a/main.sts b/main.sts
index 89b8697..45010ec 100644
--- a/main.sts
+++ b/main.sts
@@ -1,24 +1,11 @@
module ia32/elf/begin.sts
-defword keyecho
- key if emit fi
- drop
-exit
-
-defarr numstr 3
-defvar char
-
set_entry
- 31 char !
- char @ emit
- 32 numstr !
- 33 numstr 1 + !
- 34 numstr 2 + !
- numstr @ emit
- numstr 1 + @ emit
- numstr 2 + @ emit
- 35 36 swap emit emit
- keyecho
+ 30 31 32
+ 33 0 set 34 1 set 35 2 set
+ emit
+ emit
+ emit
quit
module ia32/elf/end.sts