wisp-cvs Mailing List for Wisp interpreter (Page 4)
Status: Alpha
Brought to you by:
digg
You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(30) |
Sep
(312) |
Oct
|
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(5) |
Feb
(131) |
Mar
(17) |
Apr
(184) |
May
(252) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
|
From: <di...@us...> - 2003-05-18 21:28:26
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv4068
Modified Files:
tran.py
Log Message:
made the parser chop up string literals
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -d -r1.118 -r1.119
--- tran.py 18 May 2003 18:00:09 -0000 1.118
+++ tran.py 18 May 2003 21:28:22 -0000 1.119
@@ -110,13 +110,30 @@
this.commenters = '\\'
this.quotes = '"'
this.wordchars += '!#$%&()*+,-./:;<=>?@[]'
+ this.waiting = []
def get_token (this):
+ if this.waiting: return this.waiting.pop(0)
tok = shlex.get_token(this)
if tok == '': tok = None
elif tok[:2] == '#o': tok = Integer_Literal(long(tok[2:], 8))
elif tok[:2] == '#x': tok = Integer_Literal(long(tok[2:], 16))
elif tok[:2] == '#/' and len(tok) == 3:
tok = Integer_Literal(ord(tok[2]))
+ elif tok[0] == tok[-1] == '"':
+ s = []; esc = 0
+ for c in tok[1:-1]:
+ if esc:
+ esc = 0
+ try: c = {'n': '\n', 'r': '\r'}[c]
+ except: pass
+ elif c == '\\':
+ esc = 1
+ continue
+ s.insert(0, Integer_Literal(ord(c)))
+ if esc == 1: raise 'trailing escape', tok
+ s.append(Integer_Literal(len(s)))
+ this.waiting = s
+ return this.waiting.pop(0)
else:
try: tok = Integer_Literal(long(tok, 10))
except: pass
|
|
From: <di...@us...> - 2003-05-18 18:04:17
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv1186
Modified Files:
pe.py
Log Message:
tranified some more of make_pe_aout_header via Interpreter.do
Index: pe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/pe.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- pe.py 18 May 2003 18:00:09 -0000 1.15
+++ pe.py 18 May 2003 18:04:14 -0000 1.16
@@ -54,6 +54,14 @@
interp = Interpreter(h)
# #aout/image-base must be multiple of 64ki
# #aout/file-align must be a power of 2 in range of [512 ... 64Ki]
+ # &aout/image-end must be a multiple of #aout/memory-align
+ # !aout/header-end must be a multiple of #aout/file-align
+ # Known flags for #aout/dll-flags
+ # 0x0001 - per-process library initialization
+ # 0x0002 - per-process library termination
+ # 0x0004 - per-thread library initialization
+ # 0x0008 - per-thread library termination
+ # All others must be zero.
interp.do("""
4 align
' #aout/magic w, 0x10B =: #?aout/magic
@@ -76,23 +84,16 @@
' #aout/subsys-version-major w,
' #aout/subsys-version-minor w,
0 t,
+ ' &aout/image-end ' #rva + t,
+ ' !aout/header-end t,
+ ' #aout/checksum (opt) t,
+ ' #aout/subsys w,
+ ' #aout/dll-flags w,
+ ' #aout/stack-reserve-size t,
+ ' #aout/stack-commit-size t,
+ ' #aout/heap-reserve-size t,
+ ' #aout/heap-commit-size t,
""")
- # &aout/image-end must be a multiple of #aout/memory-align
- h.emit_tetra_sum(['&aout/image-end', '#rva'])
- # !aout/header-end must be a multiple of #aout/file-align
- h.emit_tetra_sum(['!aout/header-end'])
- h[::4] = 0 # checksum
- h[::2] = '#aout/subsys', '#aout/dll-flags'
- # Known flags for #aout/dll-flags
- # 0x0001 - per-process library initialization
- # 0x0002 - per-process library termination
- # 0x0004 - per-thread library initialization
- # 0x0008 - per-thread library termination
- # All others must be zero.
- h.emit_tetra_sum(['#aout/stack-reserve-size'])
- h.emit_tetra_sum(['#aout/stack-commit-size'])
- h.emit_tetra_sum(['#aout/heap-reserve-size'])
- h.emit_tetra_sum(['#aout/heap-commit-size'])
h.emit_tetra(0) # loader flags - obsolete
h.emit_tetra_sum(['#aout/dict-entry-count'])
h.emit_tetra_sum(['&export-table', '#rva'])
|
|
From: <di...@us...> - 2003-05-18 18:00:13
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv32513
Modified Files:
pe.py tran.py
Log Message:
tranified some of make_pe_aout_header via Interpreter.do
Index: pe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/pe.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- pe.py 18 May 2003 15:56:30 -0000 1.14
+++ pe.py 18 May 2003 18:00:09 -0000 1.15
@@ -8,7 +8,7 @@
from coff import *
import time
-from tran import interpret_single
+from tran import Interpreter, interpret_single
def roundup (value, boundary):
return (value + boundary - 1) & ~(boundary - 1)
@@ -51,25 +51,32 @@
def make_pe_aout_header ():
h = Linkie('<')
- h.align(4)
- # #aout/magic = 0x10B
- h[::2] = '#aout/magic'
- h[::1] = '#aout/linker-version-major', '#aout/linker-version-minor'
- h[::4] = '#aout/text-size', '#aout/data-size', '#aout/bss-size'
- h[::4] = '&_start #rva', '&.text #rva',
- h[::4] = '&.data #rva' # not present in PE32+ (?)
+ interp = Interpreter(h)
# #aout/image-base must be multiple of 64ki
- h[::4] = '#aout/image-base'
- h[::4] = '#aout/memory-align'
# #aout/file-align must be a power of 2 in range of [512 ... 64Ki]
- h[::4] = '#aout/file-align'
- h[::2] = '#aout/os-version-major'
- h[::2] = '#aout/os-version-minor'
- h[::2] = '#aout/image-version-major'
- h[::2] = '#aout/image-version-minor'
- h[::2] = '#aout/subsys-version-major'
- h[::2] = '#aout/subsys-version-minor'
- h[::4] = 0
+ interp.do("""
+ 4 align
+ ' #aout/magic w, 0x10B =: #?aout/magic
+ ' #aout/linker-version-major (opt) b,
+ ' #aout/linker-version-minor (opt) b,
+ ' #aout/text-size t,
+ ' #aout/data-size t,
+ ' #aout/bss-size t,
+ ' &_start ' #rva + t,
+ ' &.text ' #rva + t,
+ ' &.data ' #rva + t,""" + # not present in PE32+ (?)
+ """
+ ' #aout/image-base t,
+ ' #aout/memory-align t,
+ ' #aout/file-align t,
+ ' #aout/os-version-major w,
+ ' #aout/os-version-minor w,
+ ' #aout/image-version-major (opt) w,
+ ' #aout/image-version-minor (opt) w,
+ ' #aout/subsys-version-major w,
+ ' #aout/subsys-version-minor w,
+ 0 t,
+ """)
# &aout/image-end must be a multiple of #aout/memory-align
h.emit_tetra_sum(['&aout/image-end', '#rva'])
# !aout/header-end must be a multiple of #aout/file-align
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- tran.py 18 May 2003 17:43:27 -0000 1.117
+++ tran.py 18 May 2003 18:00:09 -0000 1.118
@@ -309,7 +309,7 @@
def do (this, phrase): # Note that parsing is only partial
l = phrase.split()
for i in range(len(l)):
- try: l[i] = Integer_Literal(long(l[i]))
+ try: l[i] = Integer_Literal(long(l[i], 0))
except: pass
this.run(Macro_Cursor(l))
def run (this, toksrc, verbose = 0):
|
|
From: <di...@us...> - 2003-05-18 17:47:43
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv28556
Modified Files:
hello.tran i80386.tran i80486.tran mswhello.tran pe.tran
pentium.tran
Log Message:
use |needs| instead of |include| in *.tran
Index: hello.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/hello.tran,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- hello.tran 17 May 2003 15:05:17 -0000 1.5
+++ hello.tran 18 May 2003 17:47:38 -0000 1.6
@@ -8,8 +8,8 @@
\ This file is intended to be processed using tran.py
-include i80386
-include ia32
+needs i80386
+needs ia32
\ main entry point
Index: i80386.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/i80386.tran,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- i80386.tran 18 May 2003 11:40:45 -0000 1.4
+++ i80386.tran 18 May 2003 17:47:38 -0000 1.5
@@ -6,7 +6,7 @@
\
\\\\ @(#) $Id$
-include i8086
+needs i8086
\ registers
:regs reg16/32
Index: i80486.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/i80486.tran,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- i80486.tran 18 May 2003 14:37:03 -0000 1.1
+++ i80486.tran 18 May 2003 17:47:38 -0000 1.2
@@ -6,7 +6,7 @@
\
\\\\ @(#) $Id$
-include i80386
+needs i80386
\ i80486 doesn't add many instructions.
\ This file is still incomplete, however.
Index: mswhello.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/mswhello.tran,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- mswhello.tran 17 May 2003 15:05:17 -0000 1.14
+++ mswhello.tran 18 May 2003 17:47:38 -0000 1.15
@@ -8,9 +8,9 @@
\ Don't forget to translate with -fpe
-include i80386
-include ia32
-include winapi
+needs i80386
+needs ia32
+needs winapi
\ main entry point
@@ -27,4 +27,4 @@
label rckeep
1 tetras reserve
-\ vim: ft=forth
+\ vim: ft=tran
Index: pe.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/pe.tran,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- pe.tran 18 May 2003 16:14:37 -0000 1.7
+++ pe.tran 18 May 2003 17:47:38 -0000 1.8
@@ -6,7 +6,7 @@
\
\\\\ @(#) $Id$
-include mz
+needs mz
\ The result's assumed origin address is 0x100.
:[ ] make-pe-mz-stub-structure \ ( -- ) no message itself
Index: pentium.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/pentium.tran,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- pentium.tran 18 May 2003 14:37:03 -0000 1.1
+++ pentium.tran 18 May 2003 17:47:38 -0000 1.2
@@ -6,7 +6,7 @@
\
\\\\ @(#) $Id$
-include i80486
+needs i80486
:regs mmxreg %mm0 %mm1 %mm2 %mm3 %mm4 %mm5 %mm6 %mm7 ;
|
|
From: <di...@us...> - 2003-05-18 17:43:30
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv27270
Modified Files:
tran-builtins tran.py
Log Message:
implemented |needs|
Index: tran-builtins
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran-builtins,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- tran-builtins 18 May 2003 17:22:55 -0000 1.36
+++ tran-builtins 18 May 2003 17:43:27 -0000 1.37
@@ -135,6 +135,12 @@
include|name
interpreter.toksrc.push(Lexer(str(name) + '.tran'))
+ interpreter.included[name] = 1
+
+needs|name
+ if not interpreter.included.has_key(name):
+ interpreter.toksrc.push(Lexer(str(name) + '.tran'))
+ interpreter.included[name] = 1
'|name
if not name[0] in '&#!': name = '&' + name
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- tran.py 18 May 2003 17:36:44 -0000 1.116
+++ tran.py 18 May 2003 17:43:27 -0000 1.117
@@ -228,7 +228,7 @@
return um
class Interpreter (object):
- __slots__ = 'sections current recordee regpaths hanging regstack state meaning register_names toksrc'.split()
+ __slots__ = 'sections current recordee regpaths hanging regstack state meaning register_names toksrc included'.split()
universal_meaning = make_universal_meaning('tran-builtins')
def make_section_switcher (this, name):
@@ -259,6 +259,7 @@
this.state = this.outer_state
this.toksrc = None # only used during interpretation
this.run('builtin.tran')
+ this.included = {}
def match_generator (this, root):
yield root
if len(this.regstack) < 1: yield None # want more registers
|
|
From: <di...@us...> - 2003-05-18 17:36:49
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv24666
Modified Files:
tran.py
Log Message:
wrote Interpreter.do
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -d -r1.115 -r1.116
--- tran.py 18 May 2003 17:22:55 -0000 1.115
+++ tran.py 18 May 2003 17:36:44 -0000 1.116
@@ -305,6 +305,12 @@
else: raise 'Unknown meaning type in', `this.meaning[tok]`
else: raise 'Unknown meaning format for', tok
else: raise 'bad token', tok
+ def do (this, phrase): # Note that parsing is only partial
+ l = phrase.split()
+ for i in range(len(l)):
+ try: l[i] = Integer_Literal(long(l[i]))
+ except: pass
+ this.run(Macro_Cursor(l))
def run (this, toksrc, verbose = 0):
if isinstance(toksrc, str): toksrc = Lexer(toksrc)
this.toksrc = Preprocessor(toksrc)
|
|
From: <di...@us...> - 2003-05-18 17:25:31
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv20438
Modified Files:
winapi.tran
Log Message:
minor cleanup
Index: winapi.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/winapi.tran,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- winapi.tran 17 May 2003 15:05:17 -0000 1.3
+++ winapi.tran 18 May 2003 17:25:28 -0000 1.4
@@ -6,13 +6,13 @@
\
\\\\ @(#) $Id$
-:[ ] GetStdHandle \ (handle-number -- handle)
+:[ ] GetStdHandle \ ( handle-number -- handle )
commit 'GetStdHandle@kernel32 $call %eax ;
-:[ ] WriteFile \ (file buffer count result* overlapped* -- result)
+:[ ] WriteFile \ ( file buffer count result* overlapped* -- result )
5rev commit 'WriteFile@kernel32 $call %eax ;
-:[ ] ExitProcess \ (code --)
+:[ ] ExitProcess \ ( code -- )
commit 'ExitProcess@kernel32 $call ;
\ vim: ft=tran
|
|
From: <di...@us...> - 2003-05-18 17:22:58
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv19751
Modified Files:
Makefile.am tran-builtins tran.py
Added Files:
tran-emitters
Log Message:
extracted tran-emitters from tran-builtins
--- NEW FILE: tran-emitters ---
#### tran-emitters - see tran.py for details
#
# Copyleft © 2003 by Andres Soolo (di...@us...)
# This file is licensed under the GNU GPL v2. If you
# don't know what that means, please do read the GPL.
#
#### @(#) $Id: tran-emitters,v 1.1 2003/05/18 17:22:55 digg Exp $
$-t, sum
s = interpreter.regstack.pop()
scalar = long(s[0])
symbols = map(str, s[1:])
interpreter.current.emit_tetra_sum(symbols, delta = scalar % 0x100000000L, relative = 1)
$-t, sym
interpreter.current.emit_tetra_sum([str(interpreter.regstack.pop())], relative = 1)
$-w, sum
s = interpreter.regstack.pop()
scalar = long(s[0])
symbols = map(str, s[1:])
interpreter.current.emit_wyde_sum(symbols, delta = scalar % 0x10000L, relative = 1)
$-w, sym
interpreter.current.emit_wyde_sum([str(interpreter.regstack.pop())], relative = 1)
=: int|name
if not name[0] in '&#!': name = '&' + name
value = interpreter.regstack.pop()
interpreter.current.place_symbol(name, value)
align int
interpreter.current.align(long(interpreter.regstack.pop()))
b, int
interpreter.current[::1] = long(interpreter.regstack.pop())
b, sum
sum = interpreter.regstack.pop()
interpreter.current.emit_byte_sum(map(str, sum.get_symbols()),
delta = sum.get_scalar())
b, sym
interpreter.current[::1] = str(interpreter.regstack.pop())
bind int sym
symbol = interpreter.regstack.pop()
value = interpreter.regstack.pop()
interpreter.current.place_symbol(symbol, value)
current-offset
interpreter.regstack.append(Integer_Literal(interpreter.current.memsz()))
label|name
if not name[0] in '&#!': name = '&' + name
interpreter.current.place_symbol(name)
padded-symbol, sym int
# takes a symbol S and an integer N. Emits S, character-wise,
# padded by zero bytes to N and cut as needed.
# The symbol prefix will not be emitted.
n = interpreter.regstack.pop()
s = interpreter.regstack.pop()
s = (str(s) + '\0' * n)[1:n + 1]
interpreter.current.emit_string(s)
reserve int
interpreter.current.skip(interpreter.regstack.pop())
t, int
interpreter.current[::4] = long(interpreter.regstack.pop())
t, sum
sum = interpreter.regstack.pop()
interpreter.current.emit_tetra_sum(map(str, sum.get_symbols()),
delta = sum.get_scalar())
t, sym
interpreter.current[::4] = str(interpreter.regstack.pop())
w, int
interpreter.current[::2] = long(interpreter.regstack.pop())
w, sum
sum = interpreter.regstack.pop()
interpreter.current.emit_wyde_sum(map(str, sum.get_symbols()),
delta = sum.get_scalar())
w, sym
interpreter.current[::2] = str(interpreter.regstack.pop())
# vim: ft=python
Index: Makefile.am
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/Makefile.am,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- Makefile.am 18 May 2003 16:01:14 -0000 1.24
+++ Makefile.am 18 May 2003 17:22:55 -0000 1.25
@@ -8,7 +8,7 @@
EXTRA_DIST = .cvsignore .pycheckrc struburn.wisp bits.py linkie.py \
coff.py elf.py pe.py \
- builtin.tran \
+ tran.py tran-builtins tran-emitters builtin.tran \
i8086.tran i80386.tran i80486.tran pentium.tran ia16.tran ia32.tran \
coff.tran elf.tran mz.tran pe.tran \
winapi.tran \
Index: tran-builtins
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran-builtins,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- tran-builtins 18 May 2003 15:56:30 -0000 1.35
+++ tran-builtins 18 May 2003 17:22:55 -0000 1.36
@@ -6,24 +6,6 @@
#
#### @(#) $Id$
-$-t, sum
- s = interpreter.regstack.pop()
- scalar = long(s[0])
- symbols = map(str, s[1:])
- interpreter.current.emit_tetra_sum(symbols, delta = scalar % 0x100000000L, relative = 1)
-
-$-t, sym
- interpreter.current.emit_tetra_sum([str(interpreter.regstack.pop())], relative = 1)
-
-$-w, sum
- s = interpreter.regstack.pop()
- scalar = long(s[0])
- symbols = map(str, s[1:])
- interpreter.current.emit_wyde_sum(symbols, delta = scalar % 0x10000L, relative = 1)
-
-$-w, sym
- interpreter.current.emit_wyde_sum([str(interpreter.regstack.pop())], relative = 1)
-
+ int int
n = interpreter.regstack.pop(); m = interpreter.regstack.pop()
interpreter.regstack.append(m + n)
@@ -122,37 +104,10 @@
interpreter.register_names[r] = tok
regs_state0(family)
-=: int|name
- if not name[0] in '&#!': name = '&' + name
- value = interpreter.regstack.pop()
- interpreter.current.place_symbol(name, value)
-
-align int
- interpreter.current.align(long(interpreter.regstack.pop()))
-
-b, int
- interpreter.current[::1] = long(interpreter.regstack.pop())
-
-b, sum
- sum = interpreter.regstack.pop()
- interpreter.current.emit_byte_sum(map(str, sum.get_symbols()),
- delta = sum.get_scalar())
-
-b, sym
- interpreter.current[::1] = str(interpreter.regstack.pop())
-
-bind int sym
- symbol = interpreter.regstack.pop()
- value = interpreter.regstack.pop()
- interpreter.current.place_symbol(symbol, value)
-
commit
interpreter.regstack.reverse()
interpreter.toksrc.push(Macro_Cursor(['$push'] * len(interpreter.regstack)))
-current-offset
- interpreter.regstack.append(Integer_Literal(interpreter.current.memsz()))
-
drop any
interpreter.regstack.pop()
@@ -175,10 +130,6 @@
interpreter.regstack.append(Symbol_Literal(before + core1 + \
middle + core2 + after))
-label|name
- if not name[0] in '&#!': name = '&' + name
- interpreter.current.place_symbol(name)
-
minor reg
interpreter.regstack.append(Integer_Literal(interpreter.regstack.pop()[-1]))
@@ -189,18 +140,6 @@
if not name[0] in '&#!': name = '&' + name
interpreter.regstack.append(Symbol_Literal(name))
-padded-symbol, sym int
- # takes a symbol S and an integer N. Emits S, character-wise,
- # padded by zero bytes to N and cut as needed.
- # The symbol prefix will not be emitted.
- n = interpreter.regstack.pop()
- s = interpreter.regstack.pop()
- s = (str(s) + '\0' * n)[1:n + 1]
- interpreter.current.emit_string(s)
-
-reserve int
- interpreter.current.skip(interpreter.regstack.pop())
-
swap any any
y = interpreter.regstack.pop(); x = interpreter.regstack.pop()
interpreter.regstack.append(y); interpreter.regstack.append(x)
@@ -212,31 +151,9 @@
interpreter.regstack.extend(chars)
interpreter.regstack.append(len(chars))
-t, int
- interpreter.current[::4] = long(interpreter.regstack.pop())
-
-t, sum
- sum = interpreter.regstack.pop()
- interpreter.current.emit_tetra_sum(map(str, sum.get_symbols()),
- delta = sum.get_scalar())
-
-t, sym
- interpreter.current[::4] = str(interpreter.regstack.pop())
-
times int|word
multiplier = interpreter.regstack.pop()
interpreter.toksrc.push(Macro_Cursor([word] * multiplier))
-
-w, int
- interpreter.current[::2] = long(interpreter.regstack.pop())
-
-w, sum
- sum = interpreter.regstack.pop()
- interpreter.current.emit_wyde_sum(map(str, sum.get_symbols()),
- delta = sum.get_scalar())
-
-w, sym
- interpreter.current[::2] = str(interpreter.regstack.pop())
weaker sym
sym = str(interpreter.regstack.pop())
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- tran.py 18 May 2003 16:55:48 -0000 1.114
+++ tran.py 18 May 2003 17:22:55 -0000 1.115
@@ -224,6 +224,7 @@
um = {'...': Unique('...')}
for m in 'any const int lit sum sym'.split(' '): um[m] = Class_Marker(m)
load_primitives(um, 'tran-builtins')
+ load_primitives(um, 'tran-emitters')
return um
class Interpreter (object):
|
|
From: <di...@us...> - 2003-05-18 16:55:54
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv10986
Modified Files:
tran.py
Log Message:
extracted load_primitives from make_universal_meaning
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -d -r1.113 -r1.114
--- tran.py 18 May 2003 16:17:06 -0000 1.113
+++ tran.py 18 May 2003 16:55:48 -0000 1.114
@@ -205,15 +205,10 @@
MA_PREFIX = 1
-def make_universal_meaning (fn):
- um = {'...': Unique('...')}
- for m in 'any const int lit sum sym'.split(' '): um[m] = Class_Marker(m)
-
- # load builtin primitives
+def load_primitives (d, fn):
bf = open(fn, 'r')
builtins = bf.read()
bf.close()
-
for b in builtins.split('\n\n'):
if b[0] != '#':
name, code = b.split('\n', 1)
@@ -223,7 +218,12 @@
exec 'def _p (interpreter, %s):\n%s\n' % (pa, code)
flags = 0
if pa: flags |= MA_PREFIX
- um[name] = 'builtin', _p, flags
+ d[name] = 'builtin', _p, flags
+
+def make_universal_meaning (fn):
+ um = {'...': Unique('...')}
+ for m in 'any const int lit sum sym'.split(' '): um[m] = Class_Marker(m)
+ load_primitives(um, 'tran-builtins')
return um
class Interpreter (object):
|
|
From: <di...@us...> - 2003-05-18 16:50:28
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv9259
Modified Files:
elf.py elf.tran
Log Message:
merged make_ELF32_phtable into make_ELF32_object
Index: elf.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/elf.py,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- elf.py 18 May 2003 16:46:02 -0000 1.62
+++ elf.py 18 May 2003 16:50:25 -0000 1.63
@@ -333,11 +333,6 @@
if reloc: h.place_symbol('&_start', 0); h.place_symbol('!elf/proghdr', 0)
return h
-def make_ELF32_phtable (byte_order, names):
- input = [Integer_Literal(len(names)), 'make-elf32-phtable']
- for name in names: input = ["'", name] + input # reversed
- return interpret_single(input, byte_order, include = 'elf')
-
def make_ELF32_shtable (byte_order, names, zero_addresses = 0):
t = Linkie(byte_order)
t.align(4)
@@ -515,8 +510,9 @@
for name in shentnames:
if guess_ELF32_pflags(name) <> 0:
phentnames.append(name)
- binary.align(4)
- binary.glue(binary.memsz(), make_ELF32_phtable('<', phentnames), None)
+ input = [Integer_Literal(len(phentnames)), 'make-elf32-phtable']
+ for name in phentnames: input = ["'", name] + input # reversed
+ interpret_single(input, binary, include = 'elf')
for name in shentnames:
sections['.shstrtab'].emit_entry(name, '#.shstrtab/strings/' + name)
Index: elf.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/elf.tran,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- elf.tran 18 May 2003 16:46:02 -0000 1.3
+++ elf.tran 18 May 2003 16:50:25 -0000 1.4
@@ -33,7 +33,6 @@
;
:[ ] make-elf32-phentry \ ( section-name -- )
- 4 align
dup mingle #*/p_type t,
dup mingle !* t, \ offset
dup mingle &* t, \ p_vaddr
|
|
From: <di...@us...> - 2003-05-18 16:46:06
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv7613
Modified Files:
elf.py elf.tran
Log Message:
converted the body of make_ELF32_header into the |make-elf32-header| tran macro
Index: elf.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/elf.py,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- elf.py 18 May 2003 16:29:37 -0000 1.61
+++ elf.py 18 May 2003 16:46:02 -0000 1.62
@@ -326,26 +326,11 @@
def make_ELF32_header (byte_order, reloc = 0):
h = Linkie(byte_order)
- h.align(4)
- h[::1] = 0x7F, 0x45, 0x4C, 0x46 # magic
- h[::1] = ELFCLASS.TETRA
- if byte_order == '<':
- h[::1] = ELFDATA.TWOLSB
- elif byte_order == '>':
- h[::1] = ELFDATA.TWOMSB
- else:
- raise 'Invalid byte order', byte_order
- h[::1] = EV.CURRENT
- h[::1] = (0,) * 9
- h[::2] = '#elf/type', '#elf/machine'
- h[::4] = EV.CURRENT
- if not reloc: h[::4] = '&_start', '!elf/proghdr'
- else: h[::4] = 0, 0
- h[::4] = '!elf/secthdr', '#elf/flags'
- h[::2] = 0x34, 32 # e_ehsize, e_phentsize
- h[::2] = '#elf/phnum'
- h[::2] = 40 # e_shentsize
- h[::2] = '#elf/shnum', '#elf/shstrndx'
+ interpret_single('make-elf32-header', h, include = 'elf')
+ if byte_order == '<': h.place_symbol('#elf/byte-order', ELFDATA.TWOLSB)
+ elif byte_order == '>': h.place_symbol('#elf/byte-order', ELFDATA.TWOMSB)
+ else: raise 'Invalid byte order', byte_order
+ if reloc: h.place_symbol('&_start', 0); h.place_symbol('!elf/proghdr', 0)
return h
def make_ELF32_phtable (byte_order, names):
Index: elf.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/elf.tran,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- elf.tran 18 May 2003 16:29:37 -0000 1.2
+++ elf.tran 18 May 2003 16:46:02 -0000 1.3
@@ -6,6 +6,32 @@
\
\\\\ @(#) $Id$
+:[ ] ELF-CLASS-NONE 0 ;
+:[ ] ELF-CLASS-TETRA 1 ;
+:[ ] ELF-CLASS-OCTA 2 ;
+:[ ] ELF-CLASS-NUM 3 ;
+
+:[ ] ELF-EV-NONE 0 ;
+:[ ] ELF-EV-CURRENT 1 ;
+:[ ] ELF-EV-NUM 2 ;
+
+:[ ] make-elf32-header \ ( -- )
+ 16 align \ well ...
+ #x7F b, #x45 b, #x4C b, #x46 b, \ magic
+ ELF-CLASS-TETRA b,
+ '#elf/byte-order b,
+ ELF-EV-CURRENT b,
+ 16 align \ padding
+ '#elf/type w, '#elf/machine w,
+ ELF-EV-CURRENT t,
+ '&_start t, '!elf/proghdr t,
+ '!elf/secthdr t, '#elf/flags t,
+ #x34 w, 32 w, \ e_ehsize, e_phentsize
+ '#elf/phnum w,
+ 40 w, \ e_shentsize
+ '#elf/shnum w, '#elf/shstrndx w,
+;
+
:[ ] make-elf32-phentry \ ( section-name -- )
4 align
dup mingle #*/p_type t,
|
|
From: <di...@us...> - 2003-05-18 16:29:43
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv848
Modified Files:
elf.py elf.tran
Log Message:
extracted the body of make_ELF32_phtable as |make-elf32-phtable|
Index: elf.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/elf.py,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- elf.py 17 May 2003 15:05:17 -0000 1.60
+++ elf.py 18 May 2003 16:29:37 -0000 1.61
@@ -322,7 +322,7 @@
NUM = 11
from linkie import Linkie
-from tran import interpret_single
+from tran import interpret_single, Integer_Literal
def make_ELF32_header (byte_order, reloc = 0):
h = Linkie(byte_order)
@@ -349,14 +349,9 @@
return h
def make_ELF32_phtable (byte_order, names):
- t = Linkie(byte_order)
- t.align(4)
- t |= '!elf/proghdr'
- for name in names:
- interpret_single(["'", name, 'make-elf32-phentry'],
- t, include = 'elf')
- t.place_symbol('#elf/phnum', len(names))
- return t
+ input = [Integer_Literal(len(names)), 'make-elf32-phtable']
+ for name in names: input = ["'", name] + input # reversed
+ return interpret_single(input, byte_order, include = 'elf')
def make_ELF32_shtable (byte_order, names, zero_addresses = 0):
t = Linkie(byte_order)
Index: elf.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/elf.tran,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- elf.tran 17 May 2003 14:16:24 -0000 1.1
+++ elf.tran 18 May 2003 16:29:37 -0000 1.2
@@ -6,7 +6,7 @@
\
\\\\ @(#) $Id$
-:[ ] make-elf32-phentry
+:[ ] make-elf32-phentry \ ( section-name -- )
4 align
dup mingle #*/p_type t,
dup mingle !* t, \ offset
@@ -16,6 +16,13 @@
dup mingle #*/memsz t,
dup mingle #*/p_flags t,
mingle #*/p_align t,
+;
+
+:[ ] make-elf32-phtable \ ( ... section-name count -- )
+ dup =: #elf/phnum
+ 4 align
+ label !elf/proghdr
+ times make-elf32-phentry
;
\ vim: ft=tran
|
|
From: <di...@us...> - 2003-05-18 16:17:58
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv28531
Modified Files:
coff.tran
Log Message:
made #coff/timdat default to 0
Index: coff.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/coff.tran,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- coff.tran 17 May 2003 15:05:16 -0000 1.2
+++ coff.tran 18 May 2003 16:17:55 -0000 1.3
@@ -30,7 +30,7 @@
\ 0x0366 Mips with FPU
\ 0x0466 Mips 16 with FPU
'#coff/nscns w,
- '#coff/timdat t,
+ '#coff/timdat (opt) t,
'!coff/symptr t,
'#coff/nsyms t,
'#coff/opthdr w,
|
|
From: <di...@us...> - 2003-05-18 16:17:09
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv28186
Modified Files:
tran.py
Log Message:
minor cleanup
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -d -r1.112 -r1.113
--- tran.py 18 May 2003 16:14:37 -0000 1.112
+++ tran.py 18 May 2003 16:17:06 -0000 1.113
@@ -206,9 +206,7 @@
MA_PREFIX = 1
def make_universal_meaning (fn):
- um = {
- '...': Unique('...'),
- }
+ um = {'...': Unique('...')}
for m in 'any const int lit sum sym'.split(' '): um[m] = Class_Marker(m)
# load builtin primitives
|
|
From: <di...@us...> - 2003-05-18 16:15:13
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv27436
Modified Files:
builtin.tran
Log Message:
fixed a comment in builtin.tran
Index: builtin.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/builtin.tran,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- builtin.tran 18 May 2003 16:03:57 -0000 1.2
+++ builtin.tran 18 May 2003 16:15:10 -0000 1.3
@@ -10,6 +10,6 @@
dup weaker 0 swap bind
;
-:[ ] tetras dup + dup + ; # FIXME
+:[ ] tetras dup + dup + ; \ FIXME
\ vim: ft=tran
|
|
From: <di...@us...> - 2003-05-18 16:14:40
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv27076
Modified Files:
mz.tran pe.tran tran.py
Log Message:
made #mz/reloc-count, !mz/reloc, and #mz/overlay default to 0
Index: mz.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/mz.tran,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mz.tran 17 May 2003 15:05:17 -0000 1.2
+++ mz.tran 18 May 2003 16:14:37 -0000 1.3
@@ -9,14 +9,14 @@
:[ ] make-mz-header
#x4D b, #x5A b, \ magic
'#mz/bytes-in-last-block w, '#mz/blocks-in-file w,
- '#mz/reloc-count w,
+ '#mz/reloc-count (opt) w,
'#mz/header-size w,
'#mz/low-memory-limit w, '#mz/high-memory-limit w,
'#mz/ss w, '#mz/sp w,
'#mz/checksum w,
'#mz/ip w, '#mz/cs w,
- '!mz/reloc w,
- '#mz/overlay w,
+ '!mz/reloc (opt) w,
+ '#mz/overlay (opt) w,
;
\ vim: ft=tran
Index: pe.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/pe.tran,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- pe.tran 18 May 2003 16:01:14 -0000 1.6
+++ pe.tran 18 May 2003 16:14:37 -0000 1.7
@@ -11,7 +11,6 @@
\ The result's assumed origin address is 0x100.
:[ ] make-pe-mz-stub-structure \ ( -- ) no message itself
make-mz-header
- 0 =: #mz/reloc-count \ no relocation
0 =: #mz/header-size \ empty MZ header--load it all
#x40 dup =: #mz/low-memory-limit =: #mz/high-memory-limit
#x-10 =: #mz/ss
@@ -19,8 +18,6 @@
0 =: #mz/checksum
#x100 current-offset + =: #mz/ip
#x-10 =: #mz/cs
- 0 =: !mz/reloc
- 0 =: #mz/overlay
#x8C b, #xc8 b, \ mov %ax, %cs
#x8E b, #xD8 b, \ mov %ds, %ax
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -d -r1.111 -r1.112
--- tran.py 18 May 2003 16:03:57 -0000 1.111
+++ tran.py 18 May 2003 16:14:37 -0000 1.112
@@ -211,7 +211,7 @@
}
for m in 'any const int lit sum sym'.split(' '): um[m] = Class_Marker(m)
- # load builtins
+ # load builtin primitives
bf = open(fn, 'r')
builtins = bf.read()
bf.close()
|
|
From: <di...@us...> - 2003-05-18 16:03:59
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv22703
Modified Files:
builtin.tran tran.py
Log Message:
moved the definition of |tetras| from tran.py to builtin.tran
Index: builtin.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/builtin.tran,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- builtin.tran 18 May 2003 16:01:14 -0000 1.1
+++ builtin.tran 18 May 2003 16:03:57 -0000 1.2
@@ -10,4 +10,6 @@
dup weaker 0 swap bind
;
+:[ ] tetras dup + dup + ; # FIXME
+
\ vim: ft=tran
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- tran.py 18 May 2003 16:01:14 -0000 1.110
+++ tran.py 18 May 2003 16:03:57 -0000 1.111
@@ -208,7 +208,6 @@
def make_universal_meaning (fn):
um = {
'...': Unique('...'),
- 'tetras': ['dup', '+', 'dup', '+'], # FIXME
}
for m in 'any const int lit sum sym'.split(' '): um[m] = Class_Marker(m)
|
|
From: <di...@us...> - 2003-05-18 16:01:18
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv21401
Modified Files:
Makefile.am pe.tran tran.py
Added Files:
builtin.tran
Log Message:
moved |(opt)| to the new builtin.tran module
--- NEW FILE: builtin.tran ---
\\\\ builtin.tran - builtin macros
\
\ Copyleft © 2003 by Andres Soolo (di...@us...)
\ This file is licensed under the GNU GPL v2. If you
\ don't know what that means, please do read the GPL.
\
\\\\ @(#) $Id: builtin.tran,v 1.1 2003/05/18 16:01:14 digg Exp $
:[ sym ] (opt) \ ( symbol -- symbol )
dup weaker 0 swap bind
;
\ vim: ft=tran
Index: Makefile.am
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/Makefile.am,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- Makefile.am 18 May 2003 14:37:03 -0000 1.23
+++ Makefile.am 18 May 2003 16:01:14 -0000 1.24
@@ -8,6 +8,7 @@
EXTRA_DIST = .cvsignore .pycheckrc struburn.wisp bits.py linkie.py \
coff.py elf.py pe.py \
+ builtin.tran \
i8086.tran i80386.tran i80486.tran pentium.tran ia16.tran ia32.tran \
coff.tran elf.tran mz.tran pe.tran \
winapi.tran \
Index: pe.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/pe.tran,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- pe.tran 18 May 2003 15:56:30 -0000 1.5
+++ pe.tran 18 May 2003 16:01:14 -0000 1.6
@@ -31,10 +31,6 @@
#xCD b, #x21 b, \ int 0x21
;
-:[ sym ] (opt) \ ( symbol -- symbol )
- dup weaker 0 swap bind
-;
-
:[ ] make-pe-section-header \ ( name -- )
4 align
dup 8 padded-symbol,
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -d -r1.109 -r1.110
--- tran.py 18 May 2003 15:56:30 -0000 1.109
+++ tran.py 18 May 2003 16:01:14 -0000 1.110
@@ -260,6 +260,7 @@
this.regstack = []
this.state = this.outer_state
this.toksrc = None # only used during interpretation
+ this.run('builtin.tran')
def match_generator (this, root):
yield root
if len(this.regstack) < 1: yield None # want more registers
|
|
From: <di...@us...> - 2003-05-18 15:56:34
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv18747
Modified Files:
pe.py pe.tran tran-builtins tran.py
Log Message:
employed weak symbols in |make-pe-section-header|
Index: pe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/pe.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- pe.py 18 May 2003 15:36:28 -0000 1.13
+++ pe.py 18 May 2003 15:56:30 -0000 1.14
@@ -159,10 +159,6 @@
sections = {'.text': text, '.data': data, '.bss': bss, '.imports': imports}
for s in sectnames:
interpret_single(["'", s, 'make-pe-section-header'], e, include = 'pe')
- e.place_symbol('!' + s + '/reloc', 0)
- e.place_symbol('!' + s + '/lineno', 0)
- e.place_symbol('#' + s + '/reloc', 0)
- e.place_symbol('#' + s + '/lineno', 0)
e.place_symbol('#.text/flags', 0x60000020)
e.place_symbol('#.data/flags', 0xc0000040)
e.place_symbol('#.bss/flags', 0xc0000080)
Index: pe.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/pe.tran,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- pe.tran 18 May 2003 15:36:28 -0000 1.4
+++ pe.tran 18 May 2003 15:56:30 -0000 1.5
@@ -31,6 +31,10 @@
#xCD b, #x21 b, \ int 0x21
;
+:[ sym ] (opt) \ ( symbol -- symbol )
+ dup weaker 0 swap bind
+;
+
:[ ] make-pe-section-header \ ( name -- )
4 align
dup 8 padded-symbol,
@@ -38,10 +42,10 @@
dup mingle &* '#rva + t, \ IOW, it's a RVA
dup mingle #*/filesz t,
dup mingle !* t,
- dup mingle !*/reloc t,
- dup mingle !*/lineno t,
- dup mingle #*/reloc w,
- dup mingle #*/lineno w,
+ dup mingle !*/reloc (opt) t,
+ dup mingle !*/lineno (opt) t,
+ dup mingle #*/reloc (opt) w,
+ dup mingle #*/lineno (opt) w,
mingle #*/flags t,
;
Index: tran-builtins
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran-builtins,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- tran-builtins 18 May 2003 15:45:53 -0000 1.34
+++ tran-builtins 18 May 2003 15:56:30 -0000 1.35
@@ -238,4 +238,8 @@
w, sym
interpreter.current[::2] = str(interpreter.regstack.pop())
+weaker sym
+ sym = str(interpreter.regstack.pop())
+ interpreter.regstack.append(Symbol_Literal(sym[0] + '?' + sym[1:]))
+
# vim: ft=python
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -d -r1.108 -r1.109
--- tran.py 17 May 2003 16:19:42 -0000 1.108
+++ tran.py 18 May 2003 15:56:30 -0000 1.109
@@ -109,7 +109,7 @@
shlex.__init__(this, instream = open(filename, 'r'), infile = filename)
this.commenters = '\\'
this.quotes = '"'
- this.wordchars += '!#$%&*+,-./:;<=>?@[]'
+ this.wordchars += '!#$%&()*+,-./:;<=>?@[]'
def get_token (this):
tok = shlex.get_token(this)
if tok == '': tok = None
|
|
From: <di...@us...> - 2003-05-18 15:45:56
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv12875
Modified Files:
tran-builtins
Log Message:
added |bind int sym|
Index: tran-builtins
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran-builtins,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- tran-builtins 18 May 2003 15:19:57 -0000 1.33
+++ tran-builtins 18 May 2003 15:45:53 -0000 1.34
@@ -141,6 +141,11 @@
b, sym
interpreter.current[::1] = str(interpreter.regstack.pop())
+bind int sym
+ symbol = interpreter.regstack.pop()
+ value = interpreter.regstack.pop()
+ interpreter.current.place_symbol(symbol, value)
+
commit
interpreter.regstack.reverse()
interpreter.toksrc.push(Macro_Cursor(['$push'] * len(interpreter.regstack)))
|
|
From: <di...@us...> - 2003-05-18 15:42:11
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv10833
Modified Files:
linkie.py
Log Message:
added a symbol defaulting mechanism
Index: linkie.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- linkie.py 17 May 2003 05:48:12 -0000 1.62
+++ linkie.py 18 May 2003 15:42:06 -0000 1.63
@@ -245,13 +245,16 @@
while i > 0:
i = i - 1
offset, type, arg = this._linker_notes[i]
- if symbols.has_key(arg):
- if type in (1, 2, 4):
- this[offset::type] += symbols[arg]
- elif type in (-1, -2, -4):
- this[offset::-type] += symbols[arg] - offset
- else: raise 'Invalid linker note type', (offset, type, arg)
- del this._linker_notes[i]
+ try: value = symbols[arg]
+ except KeyError:
+ try: value = symbols[arg[0] + '?' + arg[1:]]
+ except KeyError: continue
+ if type in (1, 2, 4):
+ this[offset::type] += value
+ elif type in (-1, -2, -4):
+ this[offset::-type] += value - offset
+ else: raise 'Invalid linker note type', (offset, type, arg)
+ del this._linker_notes[i]
return len(this._linker_notes)
def dump (this, title = 'some-linkie'):
|
|
From: <di...@us...> - 2003-05-18 15:36:31
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv7974
Modified Files:
pe.py pe.tran
Log Message:
replaced make_pe_section_header by the |make-pe-section-header| tran macro
Index: pe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/pe.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- pe.py 17 May 2003 16:49:13 -0000 1.12
+++ pe.py 18 May 2003 15:36:28 -0000 1.13
@@ -121,21 +121,6 @@
h.emit_tetra(0); h.emit_tetra(0) # reserved
return h
-def make_pe_section_header (name):
- t = Linkie('<')
- t.align(4)
- t.emit_string((name + '\0' * 8)[:8])
- t[::4] = '#%s/memsz' % name
- t[::4] = '&%s #rva' % name
- t[::4] = '#%s/filesz' % name
- t[::4] = '!%s' % name
- t[::4] = '!%s/reloc' % name
- t[::4] = '!%s/lineno' % name
- t[::2] = '#%s/reloc' % name
- t[::2] = '#%s/lineno' % name
- t[::4] = '#%s/flags' % name
- return t
-
def populate_pe_directories (linkie, base, **given):
defaults = {
'&export-table': base, '#export-table/size': 0,
@@ -154,8 +139,8 @@
'&COM+-runtime-header': base, '#COM+-runtime-header/size': 0,
}
for sym, defval in defaults.items():
- if given.has_key(s): linkie.place_symbol(s, given[s])
- else: linkie.place_symbol(s, defval)
+ if given.has_key(sym): linkie.place_symbol(sym, given[sym])
+ else: linkie.place_symbol(sym, defval)
def make_pe_executable (text = None, data = None, bss = None,
base_address = 0x00400000):
@@ -173,7 +158,7 @@
sectnames = ['.text', '.data', '.bss', '.imports']
sections = {'.text': text, '.data': data, '.bss': bss, '.imports': imports}
for s in sectnames:
- e.glue(e.memsz(), make_pe_section_header(s), None)
+ interpret_single(["'", s, 'make-pe-section-header'], e, include = 'pe')
e.place_symbol('!' + s + '/reloc', 0)
e.place_symbol('!' + s + '/lineno', 0)
e.place_symbol('#' + s + '/reloc', 0)
Index: pe.tran
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/pe.tran,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- pe.tran 17 May 2003 15:05:17 -0000 1.3
+++ pe.tran 18 May 2003 15:36:28 -0000 1.4
@@ -9,7 +9,7 @@
include mz
\ The result's assumed origin address is 0x100.
-:[ ] make-pe-mz-stub-structure \ no message itself
+:[ ] make-pe-mz-stub-structure \ ( -- ) no message itself
make-mz-header
0 =: #mz/reloc-count \ no relocation
0 =: #mz/header-size \ empty MZ header--load it all
@@ -29,6 +29,20 @@
#xCD b, #x21 b, \ int 0x21
#xB8 b, #x4CFF w, \ mov %ax, 0x4CFF
#xCD b, #x21 b, \ int 0x21
+;
+
+:[ ] make-pe-section-header \ ( name -- )
+ 4 align
+ dup 8 padded-symbol,
+ dup mingle #*/memsz t,
+ dup mingle &* '#rva + t, \ IOW, it's a RVA
+ dup mingle #*/filesz t,
+ dup mingle !* t,
+ dup mingle !*/reloc t,
+ dup mingle !*/lineno t,
+ dup mingle #*/reloc w,
+ dup mingle #*/lineno w,
+ mingle #*/flags t,
;
\ vim: ft=tran
|
|
From: <di...@us...> - 2003-05-18 15:20:03
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv32459
Modified Files:
tran-builtins
Log Message:
wrote |padded-symbol, sym int|
Index: tran-builtins
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran-builtins,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- tran-builtins 18 May 2003 13:15:04 -0000 1.32
+++ tran-builtins 18 May 2003 15:19:57 -0000 1.33
@@ -184,6 +184,15 @@
if not name[0] in '&#!': name = '&' + name
interpreter.regstack.append(Symbol_Literal(name))
+padded-symbol, sym int
+ # takes a symbol S and an integer N. Emits S, character-wise,
+ # padded by zero bytes to N and cut as needed.
+ # The symbol prefix will not be emitted.
+ n = interpreter.regstack.pop()
+ s = interpreter.regstack.pop()
+ s = (str(s) + '\0' * n)[1:n + 1]
+ interpreter.current.emit_string(s)
+
reserve int
interpreter.current.skip(interpreter.regstack.pop())
|
|
From: <di...@us...> - 2003-05-18 14:37:07
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv14274
Modified Files:
Makefile.am
Added Files:
i80486.tran pentium.tran
Log Message:
introduced i80486.tran and pentium.tran
--- NEW FILE: i80486.tran ---
\\\\ i80486 - Intel's 80486 instructions
\
\ Copyleft © 2003 by Andres Soolo (di...@us...)
\ This file is licensed under the GNU GPL v2. If you
\ don't know what that means, please do read the GPL.
\
\\\\ @(#) $Id: i80486.tran,v 1.1 2003/05/18 14:37:03 digg Exp $
include i80386
\ i80486 doesn't add many instructions.
\ This file is still incomplete, however.
:[ reg32 ] $bswap $o32 #x0F b, minor #xC8 + b, ;
:[ ] $invd #x0F b, #x08 b, ;
\ vim: ft=tran
--- NEW FILE: pentium.tran ---
\\\\ pentium.tran - Intel Pentium instructions
\
\ Copyleft © 2003 by Andres Soolo (di...@us...)
\ This file is licensed under the GNU GPL v2. If you
\ don't know what that means, please do read the GPL.
\
\\\\ @(#) $Id: pentium.tran,v 1.1 2003/05/18 14:37:03 digg Exp $
include i80486
:regs mmxreg %mm0 %mm1 %mm2 %mm3 %mm4 %mm5 %mm6 %mm7 ;
:[ ] $cpuid #x0F b, #xA2 b, ;
\ vim: ft=tran
Index: Makefile.am
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/Makefile.am,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- Makefile.am 17 May 2003 14:54:41 -0000 1.22
+++ Makefile.am 18 May 2003 14:37:03 -0000 1.23
@@ -8,7 +8,7 @@
EXTRA_DIST = .cvsignore .pycheckrc struburn.wisp bits.py linkie.py \
coff.py elf.py pe.py \
- i8086.tran i80386.tran ia16.tran ia32.tran \
+ i8086.tran i80386.tran i80486.tran pentium.tran ia16.tran ia32.tran \
coff.tran elf.tran mz.tran pe.tran \
winapi.tran \
hello.tran mswhello.tran \
|
|
From: <di...@us...> - 2003-05-18 13:15:08
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv13777
Modified Files:
tran-builtins
Log Message:
implemented |symchop|
Index: tran-builtins
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran-builtins,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- tran-builtins 18 May 2003 11:20:51 -0000 1.31
+++ tran-builtins 18 May 2003 13:15:04 -0000 1.32
@@ -191,6 +191,13 @@
y = interpreter.regstack.pop(); x = interpreter.regstack.pop()
interpreter.regstack.append(y); interpreter.regstack.append(x)
+symchop sym
+ sym = interpreter.regstack.pop()
+ chars = map(Integer_Literal, map(ord, sym))
+ chars.reverse() # so the first char gets on top of stack
+ interpreter.regstack.extend(chars)
+ interpreter.regstack.append(len(chars))
+
t, int
interpreter.current[::4] = long(interpreter.regstack.pop())
|