aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/common.sts1
-rw-r--r--common/print.sts30
-rw-r--r--ia32/bitwise.sts21
-rw-r--r--ia32/float/float.sts20
-rw-r--r--test.sts17
5 files changed, 80 insertions, 9 deletions
diff --git a/common/common.sts b/common/common.sts
index cc5f5ee..8a7f835 100644
--- a/common/common.sts
+++ b/common/common.sts
@@ -1,2 +1,3 @@
module common/macro.sts
module common/const.sts
+module common/print.sts
diff --git a/common/print.sts b/common/print.sts
new file mode 100644
index 0000000..9517307
--- /dev/null
+++ b/common/print.sts
@@ -0,0 +1,30 @@
+defword get_hex
+ f and
+ dup 9 > if
+ a - 'a' +
+ else
+ '0' +
+ fi
+exit
+
+defword print_hex
+ dup 1c shr get_hex sys_write
+ dup 18 shr get_hex sys_write
+ dup 14 shr get_hex sys_write
+ dup 10 shr get_hex sys_write
+ dup c shr get_hex sys_write
+ dup 8 shr get_hex sys_write
+ dup 4 shr get_hex sys_write
+ get_hex sys_write
+ a sys_write
+exit
+
+defword print_stack
+ dup
+ do
+ dup 0 = until
+ over over - 2 + get print_hex
+ 1 -
+ od
+ drop
+exit
diff --git a/ia32/bitwise.sts b/ia32/bitwise.sts
index b86e6c6..205e618 100644
--- a/ia32/bitwise.sts
+++ b/ia32/bitwise.sts
@@ -4,3 +4,24 @@ defasm xor
# 31 ?' # d8 ?' ; xor eax, ebx
# 50 ?' ; push eax
next
+
+defasm and
+ # 5b ?' ; pop ebx
+ # 58 ?' ; pop eax
+ # 21 ?' # d8 ?' ; and eax, ebx
+ # 50 ?' ; push eax
+next
+
+defasm shr
+ # 59 ?' ; pop ecx
+ # 58 ?' ; pop eax
+ # d3 ?' # e8 ?' ; shr eax, cl
+ # 50 ?' ; push eax
+next
+
+defasm shl
+ # 59 ?' ; pop ecx
+ # 58 ?' ; pop eax
+ # d3 ?' # e0 ?' ; shl eax, cl
+ # 50 ?' ; push eax
+next
diff --git a/ia32/float/float.sts b/ia32/float/float.sts
index 158781c..9f3ba52 100644
--- a/ia32/float/float.sts
+++ b/ia32/float/float.sts
@@ -3,6 +3,21 @@ defasm float_init
# db ?' # e3 ?' ; fninit
next
+defasm float_cload
+ # d9 ?' # 2c ?' # 24 ?' ; fldcw [esp]
+ # 58 ?' ; pop eax
+next
+
+defasm float_sstore
+ # 9b ?' # df ?' # e0 ?' ; fstsw ax
+ # 50 ?' ; push eax
+next
+
+defasm float_cstore
+ # 50 ?' ; push eax
+ # d9 ?' # 3c ?' # 24 ?' ; fstcw [esp]
+next
+
defasm float_fload
# d9 ?' # 04 ?' # 24 ?' ; fld dword [esp]
# 58 ?' ; pop eax
@@ -23,11 +38,6 @@ defasm float_istore
# 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
diff --git a/test.sts b/test.sts
index 9158c49..896400e 100644
--- a/test.sts
+++ b/test.sts
@@ -3,14 +3,23 @@ module ia32/float/float.sts
set_entry
float_init
+21 float_iload
+4 float_iload
+21 float_iload
+4 float_iload
8 float_iload
-3 float_iload
-float_div
-float_istore '0' + sys_write
+0 float_iload
21 float_iload
4 float_iload
float_div
-float_istore '0' + sys_write
+float_istore
+float_div
+float_istore
+float_div
+float_istore
+float_div
+float_istore
+7 print_stack
sys_exit
module ia32/elf/end.sts