From 65c54a8986b3519c1949d280e58f46af2eceff85 Mon Sep 17 00:00:00 2001 From: exegete Date: Sat, 17 Oct 2020 16:40:23 +0300 Subject: float, constants, ets --- ia32/elf/begin.sts | 1 + ia32/elf/syscall.sts | 41 +++++++++++++++++++++++++++++++++++++++++ ia32/float/float.sts | 37 +++++++++++++++++++++++++++++++++++++ ia32/ia32.sts | 1 - ia32/math.sts | 6 ++---- ia32/syscall.sts | 41 ----------------------------------------- 6 files changed, 81 insertions(+), 46 deletions(-) create mode 100644 ia32/elf/syscall.sts create mode 100644 ia32/float/float.sts delete mode 100644 ia32/syscall.sts (limited to 'ia32') 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/elf/syscall.sts b/ia32/elf/syscall.sts new file mode 100644 index 0000000..3acfef2 --- /dev/null +++ b/ia32/elf/syscall.sts @@ -0,0 +1,41 @@ +defasm sys_exit + # b8 ?' # 1 ?. ; mov eax, 1 + # 31 ?' # db ?' ; xor ebx, ebx + # cd ?' # 80 ?' ; int 0x80 +; no need in next since this is the last instruction + +_data_segment ?choose + ?$ ?? _iobuf # 0 ?. +_code_segment ?choose + +defasm sys_read + # b8 ?' # 3 ?. ; mov eax, 3 + # 31 ?' # db ?' ; xor ebx, ebx + # b9 ?' _iobuf ?. ; mov ecx, _iobuf + # ba ?' # 1 ?. ; mov edx, 1 + # cd ?' # 80 ?' ; int 0x80 + # 31 ?' # db ?' ; xor ebx, ebx + # 8a ?' # 1d ?' _iobuf ?. ; mov bl, [_iobuf] + # 53 ?' ; push ebx + # 50 ?' ; push eax +next + +defasm sys_write + # 58 ?' ; pop eax + # a2 ?' _iobuf ?. ; mov [_iobuf], al + # b8 ?' # 4 ?. ; mov eax, 4 + # bb ?' # 1 ?. ; mov ebx, 1 + # b9 ?' _iobuf ?. ; mov ecx, _iobuf + # ba ?' # 1 ?. ; mov edx, 1 + # cd ?' # 80 ?' ; int 0x80 +next + +defasm sys_write_err + # 58 ?' ; pop eax + # a2 ?' _iobuf ?. ; mov [_iobuf], al + # b8 ?' # 4 ?. ; mov eax, 4 + # bb ?' # 2 ?. ; mov ebx, 2 + # b9 ?' _iobuf ?. ; mov ecx, _iobuf + # ba ?' # 1 ?. ; mov edx, 1 + # cd ?' # 80 ?' ; int 0x80 +next 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/ia32/syscall.sts b/ia32/syscall.sts deleted file mode 100644 index 3acfef2..0000000 --- a/ia32/syscall.sts +++ /dev/null @@ -1,41 +0,0 @@ -defasm sys_exit - # b8 ?' # 1 ?. ; mov eax, 1 - # 31 ?' # db ?' ; xor ebx, ebx - # cd ?' # 80 ?' ; int 0x80 -; no need in next since this is the last instruction - -_data_segment ?choose - ?$ ?? _iobuf # 0 ?. -_code_segment ?choose - -defasm sys_read - # b8 ?' # 3 ?. ; mov eax, 3 - # 31 ?' # db ?' ; xor ebx, ebx - # b9 ?' _iobuf ?. ; mov ecx, _iobuf - # ba ?' # 1 ?. ; mov edx, 1 - # cd ?' # 80 ?' ; int 0x80 - # 31 ?' # db ?' ; xor ebx, ebx - # 8a ?' # 1d ?' _iobuf ?. ; mov bl, [_iobuf] - # 53 ?' ; push ebx - # 50 ?' ; push eax -next - -defasm sys_write - # 58 ?' ; pop eax - # a2 ?' _iobuf ?. ; mov [_iobuf], al - # b8 ?' # 4 ?. ; mov eax, 4 - # bb ?' # 1 ?. ; mov ebx, 1 - # b9 ?' _iobuf ?. ; mov ecx, _iobuf - # ba ?' # 1 ?. ; mov edx, 1 - # cd ?' # 80 ?' ; int 0x80 -next - -defasm sys_write_err - # 58 ?' ; pop eax - # a2 ?' _iobuf ?. ; mov [_iobuf], al - # b8 ?' # 4 ?. ; mov eax, 4 - # bb ?' # 2 ?. ; mov ebx, 2 - # b9 ?' _iobuf ?. ; mov ecx, _iobuf - # ba ?' # 1 ?. ; mov edx, 1 - # cd ?' # 80 ?' ; int 0x80 -next -- cgit v1.2.3