diff options
author | exegete <nikitf-97@mail.ru> | 2020-10-17 03:33:08 +0300 |
---|---|---|
committer | exegete <nikitf-97@mail.ru> | 2020-10-17 03:33:08 +0300 |
commit | b6b9e29c1484c9c8b8af2b382d3a9d796c310217 (patch) | |
tree | 531c498be57a6ed4c61035e33dade9d6a18ae755 /ia32 | |
parent | 808a161313e0a03ead45f843fee3d9c40bec02bd (diff) | |
download | cryptrobber-b6b9e29c1484c9c8b8af2b382d3a9d796c310217.tar cryptrobber-b6b9e29c1484c9c8b8af2b382d3a9d796c310217.tar.xz cryptrobber-b6b9e29c1484c9c8b8af2b382d3a9d796c310217.zip |
Common dir added, stderr output, minor changes
Diffstat (limited to 'ia32')
-rw-r--r-- | ia32/bitwise.sts | 8 | ||||
-rw-r--r-- | ia32/branch.sts | 12 | ||||
-rw-r--r-- | ia32/const.sts | 3 | ||||
-rw-r--r-- | ia32/core.sts | 20 | ||||
-rw-r--r-- | ia32/elf/begin.sts | 1 | ||||
-rw-r--r-- | ia32/ia32.sts | 1 | ||||
-rw-r--r-- | ia32/macro.sts | 20 | ||||
-rw-r--r-- | ia32/math.sts | 97 | ||||
-rw-r--r-- | ia32/memory.sts | 10 | ||||
-rw-r--r-- | ia32/syscall.sts | 48 |
10 files changed, 107 insertions, 113 deletions
diff --git a/ia32/bitwise.sts b/ia32/bitwise.sts index 6d376e4..b86e6c6 100644 --- a/ia32/bitwise.sts +++ b/ia32/bitwise.sts @@ -1,6 +1,6 @@ defasm xor - # 5b ?' ; pop ebx - # 58 ?' ; pop eax - # 31 ?' # d8 ?' ; xor eax, ebx - # 50 ?' ; push eax + # 5b ?' ; pop ebx + # 58 ?' ; pop eax + # 31 ?' # d8 ?' ; xor eax, ebx + # 50 ?' ; push eax next diff --git a/ia32/branch.sts b/ia32/branch.sts index 9c71217..35177f6 100644 --- a/ia32/branch.sts +++ b/ia32/branch.sts @@ -1,11 +1,11 @@ defasm branch - # 8b ?' # 36 ?' ; mov esi, [esi] + # 8b ?' # 36 ?' ; mov esi, [esi] next defasm 0branch - # 58 ?' ; pop eax - # 83 ?' # c6 ?' # 4 ?' ; add esi, 4 - # 83 ?' # f8 ?' # 00 ?' ; cmp eax, 0 - # 75 ?' # 3 ?' ; jne +3 - # 8b ?' # 76 ?' # fc ?' ; mov esi, [esi - 4] + # 58 ?' ; pop eax + # 83 ?' # c6 ?' # 4 ?' ; add esi, 4 + # 83 ?' # f8 ?' # 0 ?' ; cmp eax, 0 + # 75 ?' # 3 ?' ; jne +3 + # 8b ?' # 76 ?' # fc ?' ; mov esi, [esi - 4] next diff --git a/ia32/const.sts b/ia32/const.sts new file mode 100644 index 0000000..31f8041 --- /dev/null +++ b/ia32/const.sts @@ -0,0 +1,3 @@ +defconst word_size 4 +defconst word_max ffffffff +defconst word_endianness 0 diff --git a/ia32/core.sts b/ia32/core.sts index 17b7d89..4a5e692 100644 --- a/ia32/core.sts +++ b/ia32/core.sts @@ -1,19 +1,17 @@ defasm docol - # 83 ?' # ed ?' # 4 ?' ; sub ebp, 4 - # 89 ?' # 75 ?' # 0 ?' ; mov [ebp], esi - # 83 ?' # c0 ?' # 4 ?' ; add eax, 4 - # 89 ?' # c6 ?' ; mov esi, eax - # ad ?' # ff ?' # 20 ?' ; go next + # 83 ?' # ed ?' # 4 ?' ; sub ebp, 4 + # 89 ?' # 75 ?' # 0 ?' ; mov [ebp], esi + # 83 ?' # c0 ?' # 4 ?' ; add eax, 4 + # 89 ?' # c6 ?' ; mov esi, eax + # ad ?' # ff ?' # 20 ?' ; go next next defasm exit - # 8b ?' # 75 ?' # 0 ?' ; mov esi, [ebp] - # 83 ?' # c5 ?' # 4 ?' ; add ebp, 4 + # 8b ?' # 75 ?' # 0 ?' ; mov esi, [ebp] + # 83 ?' # c5 ?' # 4 ?' ; add ebp, 4 next defasm lit - # ad ?' ; lodsd - # 50 ?' ; push eax + # ad ?' ; lodsd + # 50 ?' ; push eax next - -defconst word_size 4 diff --git a/ia32/elf/begin.sts b/ia32/elf/begin.sts index 41c1efc..27b4714 100644 --- a/ia32/elf/begin.sts +++ b/ia32/elf/begin.sts @@ -125,3 +125,4 @@ _return_stack ?. # ff ?' # 20 ?' module ia32/ia32.sts +module common/common.sts diff --git a/ia32/ia32.sts b/ia32/ia32.sts index a667ebf..0d8a9f5 100644 --- a/ia32/ia32.sts +++ b/ia32/ia32.sts @@ -1,4 +1,5 @@ module ia32/macro.sts +module ia32/const.sts module ia32/core.sts module ia32/stack.sts module ia32/branch.sts diff --git a/ia32/macro.sts b/ia32/macro.sts index 9335176..fa9510b 100644 --- a/ia32/macro.sts +++ b/ia32/macro.sts @@ -20,7 +20,7 @@ [ defconst 2 defasm %1% - # 68 ?' # %2% ?. ; push %2% + # 68 ?' # %2% ?. ; push %2% next ] @@ -30,7 +30,7 @@ # %2% # 4 ?* ?res _code_segment ?choose defasm %1% - # 68 ?' _%1%_arr ?. ; push _%1%_arr + # 68 ?' _%1%_arr ?. ; push _%1%_arr next ] @@ -40,17 +40,13 @@ [ as 1 _data_segment ?choose - defword %1% - lit ?$ # 0 ?. - exit + defword %1% + lit ?$ # 0 ?. + exit _code_segment ?choose lit ?. ! ] -[ local 1 - top as %1% -] - [ literal 0 lit # %1% ?. ] @@ -88,9 +84,3 @@ branch ?swap ?. ?$ ?swap ?! ] - -[ change 0 - dup get - swap 2 get swap 2 + set - swap drop -] diff --git a/ia32/math.sts b/ia32/math.sts index 95ca5f7..fefe1d4 100644 --- a/ia32/math.sts +++ b/ia32/math.sts @@ -1,79 +1,70 @@ defasm + - # 58 ?' ; pop eax - # 01 ?' # 04 ?' # 24 ?' ; add [esp], eax + # 58 ?' ; pop eax + # 01 ?' # 04 ?' # 24 ?' ; add [esp], eax next defasm - - # 58 ?' ; pop eax - # 29 ?' # 04 ?' # 24 ?' ; sub [esp], eax + # 58 ?' ; pop eax + # 29 ?' # 04 ?' # 24 ?' ; sub [esp], eax next defasm / - # 5b ?' ; pop ebx - # 58 ?' ; pop eax - # 31 ?' # d2 ?' ; xor edx, edx - # f7 ?' # f3 ?' ; div ebx - # 52 ?' ; push edx - # 50 ?' ; push eax + # 5b ?' ; pop ebx + # 58 ?' ; pop eax + # 31 ?' # d2 ?' ; xor edx, edx + # f7 ?' # f3 ?' ; div ebx + # 52 ?' ; push edx + # 50 ?' ; push eax next defasm mod - # 5b ?' ; pop ebx - # 58 ?' ; pop eax - # 31 ?' # d2 ?' ; xor edx, edx - # f7 ?' # f3 ?' ; div ebx - # 52 ?' ; push edx + # 5b ?' ; pop ebx + # 58 ?' ; pop eax + # 31 ?' # d2 ?' ; xor edx, edx + # f7 ?' # f3 ?' ; div ebx + # 52 ?' ; push edx next defasm div - # 5b ?' ; pop ebx - # 58 ?' ; pop eax - # 31 ?' # d2 ?' ; xor edx, edx - # f7 ?' # f3 ?' ; div ebx - # 50 ?' ; push eax + # 5b ?' ; pop ebx + # 58 ?' ; pop eax + # 31 ?' # d2 ?' ; xor edx, edx + # f7 ?' # f3 ?' ; div ebx + # 50 ?' ; push eax next defasm = - # 5b ?' ; pop ebx - # 58 ?' ; pop eax - # 39 ?' # d8 ?' ; cmp eax, ebx - # 0f ?' # 94 ?' # c0 ?' ; sete al - # 0f ?' # b6 ?' # c0 ?' ; movzx eax, al - # 50 ?' ; push eax + # 5b ?' ; pop ebx + # 58 ?' ; pop eax + # 39 ?' # d8 ?' ; cmp eax, ebx + # 0f ?' # 94 ?' # c0 ?' ; sete al + # 0f ?' # b6 ?' # c0 ?' ; movzx eax, al + # 50 ?' ; push eax next defasm != - # 5b ?' ; pop ebx - # 58 ?' ; pop eax - # 39 ?' # d8 ?' ; cmp eax, ebx - # 0f ?' # 95 ?' # c0 ?' ; sete al - # 0f ?' # b6 ?' # c0 ?' ; movzx eax, al - # 50 ?' ; push eax -next - -defasm != - # 5b ?' ; pop ebx - # 58 ?' ; pop eax - # 39 ?' # d8 ?' ; cmp eax, ebx - # 0f ?' # 95 ?' # c0 ?' ; sete al - # 0f ?' # b6 ?' # c0 ?' ; movzx eax, al - # 50 ?' ; push eax + # 5b ?' ; pop ebx + # 58 ?' ; pop eax + # 39 ?' # d8 ?' ; cmp eax, ebx + # 0f ?' # 95 ?' # c0 ?' ; setne al + # 0f ?' # b6 ?' # c0 ?' ; movzx eax, al + # 50 ?' ; push eax next defasm < - # 5b ?' ; pop ebx - # 58 ?' ; pop eax - # 39 ?' # d8 ?' ; cmp eax, ebx - # 0f ?' # 92 ?' # c0 ?' ; setb al - # 0f ?' # b6 ?' # c0 ?' ; movzx eax, al - # 50 ?' ; push eax + # 5b ?' ; pop ebx + # 58 ?' ; pop eax + # 39 ?' # d8 ?' ; cmp eax, ebx + # 0f ?' # 92 ?' # c0 ?' ; setb al + # 0f ?' # b6 ?' # c0 ?' ; movzx eax, al + # 50 ?' ; push eax next defasm > - # 5b ?' ; pop ebx - # 58 ?' ; pop eax - # 39 ?' # d8 ?' ; cmp eax, ebx - # 0f ?' # 97 ?' # c0 ?' ; seta al - # 0f ?' # b6 ?' # c0 ?' ; movzx eax, al - # 50 ?' ; push eax + # 5b ?' ; pop ebx + # 58 ?' ; pop eax + # 39 ?' # d8 ?' ; cmp eax, ebx + # 0f ?' # 97 ?' # c0 ?' ; seta al + # 0f ?' # b6 ?' # c0 ?' ; movzx eax, al + # 50 ?' ; push eax next diff --git a/ia32/memory.sts b/ia32/memory.sts index 891fab0..240c598 100644 --- a/ia32/memory.sts +++ b/ia32/memory.sts @@ -1,10 +1,10 @@ defasm @ - # 58 ?' ; pop eax - # ff ?' # 30 ?' ; push dword [eax] + # 58 ?' ; pop eax + # ff ?' # 30 ?' ; push dword [eax] next defasm ! - # 5b ?' ; pop ebx - # 58 ?' ; pop eax - # 89 ?' # 03 ?' ; mov [ebx], eax + # 5b ?' ; pop ebx + # 58 ?' ; pop eax + # 89 ?' # 03 ?' ; mov [ebx], eax next diff --git a/ia32/syscall.sts b/ia32/syscall.sts index 92d4d3a..3acfef2 100644 --- a/ia32/syscall.sts +++ b/ia32/syscall.sts @@ -1,7 +1,7 @@ defasm sys_exit - # b8 ?' # 1 ?. ; mov eax, 1 - # 31 ?' # db ?' ; xor ebx, ebx - # cd ?' # 80 ?' ; int 0x80 + # 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 @@ -9,23 +9,33 @@ _data_segment ?choose _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 + # 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 + # 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 |