aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile18
-rw-r--r--common/const.sts84
-rw-r--r--enki/smack.c (renamed from smack.c)0
-rw-r--r--enki/strans.c (renamed from strans.c)0
-rw-r--r--ia32/elf/begin.sts1
-rw-r--r--ia32/elf/syscall.sts (renamed from ia32/syscall.sts)0
-rw-r--r--ia32/float/float.sts37
-rw-r--r--ia32/ia32.sts1
-rw-r--r--ia32/math.sts6
-rw-r--r--test.sts15
10 files changed, 143 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index a242d89..823e0f2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,23 +1,23 @@
all: cryptrobber encrypt test
.PHONY: all clean cryptrobber encrypt test
-cryptrobber: smack strans
- ./smack main.sts | ./strans > $@
+cryptrobber: enki/smack enki/strans
+ enki/smack main.sts | enki/strans > $@
chmod 0755 $@
-encrypt: smack strans
- ./smack encrypt.sts | ./strans > $@
+encrypt: enki/smack enki/strans
+ enki/smack encrypt.sts | enki/strans > $@
chmod 0755 $@
-test: smack strans
- ./smack test.sts | ./strans > $@
+test: enki/smack enki/strans
+ enki/smack test.sts | enki/strans > $@
chmod 0755 $@
-smack: smack.c
+enki/smack: enki/smack.c
gcc $< -o $@
-strans: strans.c
+enki/strans: enki/strans.c
gcc $< -o $@
clean:
- rm -f smack strans cryptrobber encrypt test
+ rm -f enki/smack enki/strans cryptrobber encrypt test
diff --git a/common/const.sts b/common/const.sts
index b2e9f31..7b20b4d 100644
--- a/common/const.sts
+++ b/common/const.sts
@@ -1,3 +1,19 @@
+defconst space 20
+defconst '!' 21
+defconst '"' 22
+defconst '#' 23
+defconst '$' 24
+; '%' (25) symbol is reserved by smack
+defconst '&' 26
+defconst ''' 27
+defconst '(' 28
+defconst ')' 29
+defconst '*' 2a
+defconst '+' 2b
+defconst ',' 2c
+defconst '-' 2d
+defconst '.' 2e
+defconst '/' 2f
defconst '0' 30
defconst '1' 31
defconst '2' 32
@@ -8,3 +24,71 @@ defconst '6' 36
defconst '7' 37
defconst '8' 38
defconst '9' 39
+defconst ':' 3a
+defconst '<' 3c
+defconst '=' 3d
+defconst '>' 3e
+defconst '?' 3f
+defconst '@' 40
+defconst 'A' 41
+defconst 'B' 42
+defconst 'C' 43
+defconst 'D' 44
+defconst 'E' 45
+defconst 'F' 46
+defconst 'G' 47
+defconst 'H' 48
+defconst 'I' 49
+defconst 'J' 4a
+defconst 'K' 4b
+defconst 'L' 4c
+defconst 'M' 4d
+defconst 'N' 4e
+defconst 'O' 4f
+defconst 'P' 50
+defconst 'Q' 51
+defconst 'R' 52
+defconst 'S' 53
+defconst 'T' 54
+defconst 'U' 55
+defconst 'V' 56
+defconst 'W' 57
+defconst 'X' 58
+defconst 'Y' 59
+defconst 'Z' 5a
+defconst '[' 5b
+defconst '\' 5c
+defconst ']' 5d
+defconst '^' 5e
+defconst '_' 5f
+defconst '`' 60
+defconst 'a' 61
+defconst 'b' 62
+defconst 'c' 63
+defconst 'd' 64
+defconst 'e' 65
+defconst 'f' 66
+defconst 'g' 67
+defconst 'h' 68
+defconst 'i' 69
+defconst 'j' 6a
+defconst 'k' 6b
+defconst 'l' 6c
+defconst 'm' 6d
+defconst 'n' 6e
+defconst 'o' 6f
+defconst 'p' 70
+defconst 'q' 71
+defconst 'r' 72
+defconst 's' 73
+defconst 't' 74
+defconst 'u' 75
+defconst 'v' 76
+defconst 'w' 77
+defconst 'x' 78
+defconst 'y' 79
+defconst 'z' 7a
+defconst '{' 7b
+defconst '|' 7c
+defconst '}' 7d
+defconst '~' 7e
diff --git a/smack.c b/enki/smack.c
index f6f9f30..f6f9f30 100644
--- a/smack.c
+++ b/enki/smack.c
diff --git a/strans.c b/enki/strans.c
index e3d834d..e3d834d 100644
--- a/strans.c
+++ b/enki/strans.c
diff --git a/ia32/elf/begin.sts b/ia32/elf/begin.sts
index 27b4714..8dab930 100644
--- a/ia32/elf/begin.sts
+++ b/ia32/elf/begin.sts
@@ -125,4 +125,5 @@ _return_stack ?.
# ff ?' # 20 ?'
module ia32/ia32.sts
+module ia32/elf/syscall.sts
module common/common.sts
diff --git a/ia32/syscall.sts b/ia32/elf/syscall.sts
index 3acfef2..3acfef2 100644
--- a/ia32/syscall.sts
+++ b/ia32/elf/syscall.sts
diff --git a/ia32/float/float.sts b/ia32/float/float.sts
new file mode 100644
index 0000000..158781c
--- /dev/null
+++ b/ia32/float/float.sts
@@ -0,0 +1,37 @@
+defasm float_init
+ # 9b ?' ; wait
+ # db ?' # e3 ?' ; fninit
+next
+
+defasm float_fload
+ # d9 ?' # 04 ?' # 24 ?' ; fld dword [esp]
+ # 58 ?' ; pop eax
+next
+
+defasm float_iload
+ # db ?' # 04 ?' # 24 ?' ; fild dword [esp]
+ # 58 ?' ; pop eax
+next
+
+defasm float_fstore
+ # 50 ?' ; push eax
+ # d9 ?' # 1c ?' # 24 ?' ; fstp dword [esp]
+next
+
+defasm float_istore
+ # 50 ?' ; push eax
+ # db ?' # 1c ?' # 24 ?' ; fistp dword [esp]
+next
+
+defasm float_status
+ # de ?' # f9 ?' ; fnstsw ax
+ # 50 ?' ; push eax
+next
+
+defasm float_add
+ # de ?' # c1 ?' ; faddp st1, st0
+next
+
+defasm float_div
+ # de ?' # f9 ?' ; fdivp st1, st0
+next
diff --git a/ia32/ia32.sts b/ia32/ia32.sts
index 0d8a9f5..38b5919 100644
--- a/ia32/ia32.sts
+++ b/ia32/ia32.sts
@@ -6,4 +6,3 @@ module ia32/branch.sts
module ia32/memory.sts
module ia32/math.sts
module ia32/bitwise.sts
-module ia32/syscall.sts
diff --git a/ia32/math.sts b/ia32/math.sts
index fefe1d4..609a21a 100644
--- a/ia32/math.sts
+++ b/ia32/math.sts
@@ -8,12 +8,10 @@ defasm -
# 29 ?' # 04 ?' # 24 ?' ; sub [esp], eax
next
-defasm /
+defasm mul
# 5b ?' ; pop ebx
# 58 ?' ; pop eax
- # 31 ?' # d2 ?' ; xor edx, edx
- # f7 ?' # f3 ?' ; div ebx
- # 52 ?' ; push edx
+ # f7 ?' # e3 ?' ; mul ebx
# 50 ?' ; push eax
next
diff --git a/test.sts b/test.sts
index 950a517..9158c49 100644
--- a/test.sts
+++ b/test.sts
@@ -1,11 +1,16 @@
module ia32/elf/begin.sts
+module ia32/float/float.sts
set_entry
-'2'
-'1'
-top as what
-what @ sys_write
-what word_size + @ sys_write_err
+float_init
+8 float_iload
+3 float_iload
+float_div
+float_istore '0' + sys_write
+21 float_iload
+4 float_iload
+float_div
+float_istore '0' + sys_write
sys_exit
module ia32/elf/end.sts