mirror of
https://github.com/nineties/planckforth
synced 2024-12-27 21:58:35 +01:00
Add "V"
This commit is contained in:
parent
98e62c63be
commit
c6fdc53d21
3 changed files with 22 additions and 3 deletions
|
@ -13,6 +13,8 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define VERSION "C implementation"
|
||||||
|
|
||||||
typedef uintptr_t cell;
|
typedef uintptr_t cell;
|
||||||
typedef void (**cfa)();
|
typedef void (**cfa)();
|
||||||
|
|
||||||
|
@ -141,6 +143,7 @@ defcode("t", type) { putchar(pop()); next(); }
|
||||||
defcode("x", exec) { (*(ip = (cfa) pop()))(); }
|
defcode("x", exec) { (*(ip = (cfa) pop()))(); }
|
||||||
defcode("f", find_) { push((cell) find(pop())); next(); }
|
defcode("f", find_) { push((cell) find(pop())); next(); }
|
||||||
defcode("v", argv_) { push((cell) saved_argv); push(saved_argc); next(); }
|
defcode("v", argv_) { push((cell) saved_argv); push(saved_argc); next(); }
|
||||||
|
defcode("V", version) { push((cell) VERSION); next(); }
|
||||||
#define defbinary(name, label, op, ty) \
|
#define defbinary(name, label, op, ty) \
|
||||||
defcode(name, label) { \
|
defcode(name, label) { \
|
||||||
ty b = (ty) pop(); \
|
ty b = (ty) pop(); \
|
||||||
|
|
|
@ -7,6 +7,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import operator
|
import operator
|
||||||
|
|
||||||
|
VERSION = "Python 3.x implementation"
|
||||||
MEMORY_SIZE = 0x20000
|
MEMORY_SIZE = 0x20000
|
||||||
STACK_SIZE = 0x400
|
STACK_SIZE = 0x400
|
||||||
RSTACK_SIZE = 0x400
|
RSTACK_SIZE = 0x400
|
||||||
|
@ -156,6 +157,11 @@ ARGV_ADDR = read(HERE_CELL)
|
||||||
for addr in argv_addrs:
|
for addr in argv_addrs:
|
||||||
comma(addr)
|
comma(addr)
|
||||||
|
|
||||||
|
# Version String
|
||||||
|
VERSION_ADDR = read(HERE_CELL)
|
||||||
|
comma_string(VERSION)
|
||||||
|
align()
|
||||||
|
|
||||||
def docol(ip, np):
|
def docol(ip, np):
|
||||||
rpush(np)
|
rpush(np)
|
||||||
return next(ip + 4)
|
return next(ip + 4)
|
||||||
|
@ -217,6 +223,7 @@ def argv():
|
||||||
push(ARGV_ADDR)
|
push(ARGV_ADDR)
|
||||||
push(len(sys.argv))
|
push(len(sys.argv))
|
||||||
add_simple_operator('v', argv)
|
add_simple_operator('v', argv)
|
||||||
|
add_simple_operator('V', lambda: push(VERSION_ADDR))
|
||||||
|
|
||||||
SUCCESS = 0
|
SUCCESS = 0
|
||||||
ALLOCATE_ERROR = -59
|
ALLOCATE_ERROR = -59
|
||||||
|
|
15
planck.xxd
15
planck.xxd
|
@ -6,10 +6,10 @@
|
||||||
00000028: 3400 2000 0100 0000 e_ehsize,e_phentsize,e_phnum,e_shentsize
|
00000028: 3400 2000 0100 0000 e_ehsize,e_phentsize,e_phnum,e_shentsize
|
||||||
00000030: 0000 0000 0100 0000 e_shnum,e_shstrndx,<phdr>p_type=PT_LOAD
|
00000030: 0000 0000 0100 0000 e_shnum,e_shstrndx,<phdr>p_type=PT_LOAD
|
||||||
00000038: 0000 0000 0080 0408 p_offset,p_vaddr=0x08048000
|
00000038: 0000 0000 0080 0408 p_offset,p_vaddr=0x08048000
|
||||||
00000040: 0000 0000 9403 0000 p_paddr,p_filesz
|
00000040: 0000 0000 d003 0000 p_paddr,p_filesz
|
||||||
00000048: 0000 2000 0700 0000 p_memsz(128KB),p_flags=PF_X|PF_W|PF_R
|
00000048: 0000 2000 0700 0000 p_memsz(128KB),p_flags=PF_X|PF_W|PF_R
|
||||||
00000050: 0010 0000 9483 0408 p_align, <here>
|
00000050: 0010 0000 d083 0408 p_align, <here>
|
||||||
00000058: 7483 0408 0000 0000 <latest:init="v">, <sp0>
|
00000058: 9483 0408 0000 0000 <latest:init="V">, <sp0>
|
||||||
00000060: e480 0408 5c81 0408 <interpreter>key, find
|
00000060: e480 0408 5c81 0408 <interpreter>key, find
|
||||||
00000068: 8881 0408 3081 0408 execute, jump
|
00000068: 8881 0408 3081 0408 execute, jump
|
||||||
00000070: f0ff ffff be60 8004 -16, movl $interpreter, %esi
|
00000070: f0ff ffff be60 8004 -16, movl $interpreter, %esi
|
||||||
|
@ -156,3 +156,12 @@
|
||||||
0000037c: 8083 0408 8b05 5c80 movl sp0,%eax;
|
0000037c: 8083 0408 8b05 5c80 movl sp0,%eax;
|
||||||
00000384: 0408 89c3 83c3 0453 movl %eax,%ebx; addl $4,%ebx; pushl %ebx
|
00000384: 0408 89c3 83c3 0453 movl %eax,%ebx; addl $4,%ebx; pushl %ebx
|
||||||
0000038c: ff30 adff 2000 0000 pushl (%eax); next;
|
0000038c: ff30 adff 2000 0000 pushl (%eax); next;
|
||||||
|
|
||||||
|
00000394: 7483 0408 0156 0000 V: version
|
||||||
|
0000039c: 8083 0408 68a8 8304 pushl $version
|
||||||
|
000003a4: 08ad ff20 6861 6e64 next; <version>hand
|
||||||
|
000003ac: 2d77 7269 7474 656e -written
|
||||||
|
000003b4: 2069 3338 362d 6c69 i386-li
|
||||||
|
000003bc: 6e75 7820 696d 706c nux impl
|
||||||
|
000003c4: 656d 656e 7461 7469 ementati
|
||||||
|
000003cc: 6f6e 0000 on
|
||||||
|
|
Loading…
Reference in a new issue