diff options
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | ia32/core.sts | 2 | ||||
-rw-r--r-- | ia32/macro.sts | 18 | ||||
-rw-r--r-- | ia32/stack.sts | 4 | ||||
-rw-r--r-- | ia32/syscall.sts | 2 | ||||
-rw-r--r-- | test.sts | 11 |
6 files changed, 40 insertions, 5 deletions
@@ -1,5 +1,5 @@ -all: cryptrobber encrypt -.PHONY: all clean encrypt cryptrobber +all: cryptrobber encrypt test +.PHONY: all clean cryptrobber encrypt test cryptrobber: smack strans ./smack main.sts | ./strans > $@ @@ -9,6 +9,10 @@ encrypt: smack strans ./smack encrypt.sts | ./strans > $@ chmod 0755 $@ +test: smack strans + ./smack test.sts | ./strans > $@ + chmod 0755 $@ + smack: smack.c gcc $< -o $@ diff --git a/ia32/core.sts b/ia32/core.sts index fcb62ae..17b7d89 100644 --- a/ia32/core.sts +++ b/ia32/core.sts @@ -15,3 +15,5 @@ defasm lit # ad ?' ; lodsd # 50 ?' ; push eax next + +defconst word_size 4 diff --git a/ia32/macro.sts b/ia32/macro.sts index 3842a5c..5aa3b35 100644 --- a/ia32/macro.sts +++ b/ia32/macro.sts @@ -18,14 +18,19 @@ _docol # 4 ?+ ?. ] +[ defconst 2 + defasm %1% + # 68 ?' # %2% ?. ; push %2% + next +] + [ defarr 2 _data_segment ?choose ?$ ?? _%1%_arr # %2% # 4 ?* ?res _code_segment ?choose defasm %1% - ; push _%1%_arr - # 68 ?' _%1%_arr ?. + # 68 ?' _%1%_arr ?. ; push _%1%_arr next ] @@ -33,6 +38,15 @@ defarr %1% 1 ] +[ as 1 + _data_segment ?choose + defword %1% + lit ?$ # 0 ?. + exit + _code_segment ?choose + lit ?. ! +] + [ literal 0 lit # %1% ?. ] diff --git a/ia32/stack.sts b/ia32/stack.sts index 7756706..f3c8bab 100644 --- a/ia32/stack.sts +++ b/ia32/stack.sts @@ -1,3 +1,7 @@ +defasm top + # 54 ?' ; push esp +next + defasm get # 58 ?' ; pop eax # 8b ?' # 4 ?' # 84 ?' ; mov eax, [esp + 4 * eax] diff --git a/ia32/syscall.sts b/ia32/syscall.sts index 7ff7480..92d4d3a 100644 --- a/ia32/syscall.sts +++ b/ia32/syscall.sts @@ -5,7 +5,7 @@ defasm sys_exit ; no need in next since this is the last instruction _data_segment ?choose - ?$ ?? _iobuf # 0 ?' + ?$ ?? _iobuf # 0 ?. _code_segment ?choose defasm sys_read diff --git a/test.sts b/test.sts new file mode 100644 index 0000000..a1216ac --- /dev/null +++ b/test.sts @@ -0,0 +1,11 @@ +module ia32/elf/begin.sts + +set_entry +32 +31 +top as what +what @ sys_write +what word_size + @ sys_write +sys_exit + +module ia32/elf/end.sts |