mirror of
https://github.com/nineties/planckforth
synced 2024-12-26 21:58:42 +01:00
Add binary arithmetics
This commit is contained in:
parent
8c9bf0480a
commit
db8cfe07a3
2 changed files with 54 additions and 2 deletions
10
README.md
10
README.md
|
@ -37,3 +37,13 @@ $ cat helloworld.fs | ./plank
|
|||
| e | exit | ( -- ) | Exit current function |
|
||||
| L | lit | ( -- a ) | Load immediate |
|
||||
| S | string | ( -- addr len) | Load string literal |
|
||||
| + | add | ( a b -- c ) | c = (a + b) |
|
||||
| - | sub | ( a b -- c ) | c = (a - b) |
|
||||
| * | mul | ( a b -- c ) | c = (a * b) |
|
||||
| / | div | ( a b -- c ) | c = (a / b) |
|
||||
| % | mod | ( a b -- c ) | c = (a % b) |
|
||||
| & | and | ( a b -- c ) | c = (a & b) |
|
||||
| | | or | ( a b -- c ) | c = (a | b) |
|
||||
| ^ | xor | ( a b -- c ) | c = (a ^ b) |
|
||||
| < | less | ( a b -- c ) | c = (a < b) |
|
||||
| = | equal | ( a b -- c ) | c = (a == b) |
|
||||
|
|
46
planck.xxd
46
planck.xxd
|
@ -6,10 +6,10 @@
|
|||
00000028: 3400 2000 0100 0000 e_ehsize,e_phentsize,e_phnum,e_shentsize
|
||||
00000030: 0000 0000 0100 0000 e_shnum,e_shstrndx,<phdr> PT_LOAD
|
||||
00000038: 0000 0000 0080 0408 p_offset,p_vaddr=0x08048000
|
||||
00000040: 0000 0000 0003 0000 p_paddr,p_filesz
|
||||
00000040: 0000 0000 0004 0000 p_paddr,p_filesz
|
||||
00000048: 0000 0008 0700 0000 p_memsz(128MB),PF_X|PF_W|PF_R
|
||||
00000050: 0010 0000 0200 0000 p_align, <here>
|
||||
00000058: e082 0408 e880 0408 <latest:init="S">, <interpreter>(5c: key)
|
||||
00000058: e082 0408 e880 0408 <latest:init="=">, <interpreter>(5c: key)
|
||||
00000060: 6881 0408 9881 0408 (60: find) (64: execute)
|
||||
00000068: 3881 0408 f0ff ffff (68: jump) (6c: -16)
|
||||
00000070: be5c 8004 08bd 0080 (70: movl $interpreter,%esi) (75: movl $0x10048000,%ebp)
|
||||
|
@ -117,3 +117,45 @@
|
|||
000002e8: ec82 0408 ad56 5001 lodsl; pushl %esi; pushl %eax
|
||||
000002f0: c683 c603 83e6 fcad addl %eax,%esi; addl $3,%esi; andl $~3,%esi;next;
|
||||
000002f8: ff20 0000 0000 0000
|
||||
|
||||
00000300: e082 0408 012b 0000 +: add
|
||||
00000308: 0c83 0408 5801 0424 popl %eax; addl %eax,(%esp)
|
||||
00000310: adff 2000 0000 0000 next;
|
||||
|
||||
00000318: 0083 0408 012d 0000 -: sub
|
||||
00000320: 2483 0408 5829 0424 popl %eax; subl %eax,(%esp)
|
||||
00000328: adff 2000 0000 0000 next;
|
||||
|
||||
00000330: 1883 0408 012a 0000 *: mul
|
||||
00000338: 3c83 0408 585b 0faf popl %eax; popl %ebx; imul %ebx,%eax
|
||||
00000340: c350 adff 2000 0000 pushl %eax; next;
|
||||
|
||||
00000348: 3083 0408 012f 0000 /: div
|
||||
00000350: 5483 0408 31d2 5b58 xorl %edx,%edx; popl %ebx; popl %eax
|
||||
00000358: f7fb 50ad ff20 0000 idiv %ebx; pushl %eax
|
||||
|
||||
00000360: 4883 0408 0125 0000 %: mod
|
||||
00000368: 6c83 0408 31d2 5b58 xorl %edx,%edx; popl %ebx; popl %eax
|
||||
00000370: f7fb 52ad ff20 0000 idiv %ebx; pushl %edx
|
||||
|
||||
00000378: 6083 0408 0126 0000 &: and
|
||||
00000380: 8483 0408 5821 0424 popl %eax; andl %eax,(%esp)
|
||||
00000388: adff 2000 0000 0000 next;
|
||||
|
||||
00000390: 7883 0408 017c 0000 |: or
|
||||
00000398: 9c83 0408 5809 0424 popl %eax; orl %eax,(%esp)
|
||||
000003a0: adff 2000 0000 0000 next;
|
||||
|
||||
000003a8: 9083 0408 015e 0000 ^: xor
|
||||
000003b0: b483 0408 5831 0424 popl %eax; andl %eax,(%esp)
|
||||
000003b8: adff 2000 0000 0000 next;
|
||||
|
||||
000003c0: a883 0408 013c 0000 <: less
|
||||
000003c8: cc83 0408 585b 39c3 popl %eax; popl %ebx; cmpl %eax,%ebx
|
||||
000003d0: 0f9c c00f b6c0 50ad setl %al; movzbl %al, %eax; pushl %eax; next;
|
||||
000003d8: ff20 0000 0000 0000
|
||||
|
||||
000003e0: c083 0408 013d 0000 =: equal
|
||||
000003e8: ec83 0408 585b 39c3 popl %eax; popl %ebx; cmpl %eax,%ebx
|
||||
000003f0: 0f94 c00f b6c0 50ad setl %al; movzbl %al, %eax; pushl %eax; next;
|
||||
000003f8: ff20 0000 0000 0000
|
||||
|
|
Loading…
Reference in a new issue