[Wisp-cvs] wisp/users/dig pe.tran,NONE,1.1 Makefile.am,1.20,1.21 pe.py,1.7,1.8 tran-builtins,1.25,1.
Status: Alpha
Brought to you by:
digg
|
From: <di...@us...> - 2003-05-17 14:46:40
|
Update of /cvsroot/wisp/wisp/users/dig
In directory sc8-pr-cvs1:/tmp/cvs-serv28158
Modified Files:
Makefile.am pe.py tran-builtins tran.py
Added Files:
pe.tran
Log Message:
converted the body of make_pe_mz_stub into the |make-pe-mz-stub-structure| tran macro
--- NEW FILE: pe.tran ---
\\\\ pe.tran - PE generation routines
\
\ 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: pe.tran,v 1.1 2003/05/17 14:46:34 digg Exp $
:[ ] make-pe-mz-stub-structure \ no message itself
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
#x100 =: #mz/sp
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
#xB4 b, 9 b, \ mov %ah, 9
#xBA b, ref mz/message t, \ mov %dx, message
#xCD b, #x21 b, \ int 0x21
#xB8 b, #x4CFF t, \ mov %ax, 0x4CFF
#xCD b, #x21 b, \ int 0x21
;
\ vim: ft=tran
Index: Makefile.am
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/Makefile.am,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- Makefile.am 17 May 2003 14:16:23 -0000 1.20
+++ Makefile.am 17 May 2003 14:46:34 -0000 1.21
@@ -9,7 +9,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 \
- coff.tran elf.tran \
+ coff.tran elf.tran pe.tran \
winapi.tran \
hello.tran mswhello.tran \
makehello.py elfdump.py
Index: pe.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/pe.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- pe.py 17 May 2003 10:16:53 -0000 1.7
+++ pe.py 17 May 2003 14:46:34 -0000 1.8
@@ -9,6 +9,7 @@
from mz import *
from coff import *
import time
+from tran import interpret_single
def roundup (value, boundary):
return (value + boundary - 1) & ~(boundary - 1)
@@ -30,22 +31,7 @@
if message.find('\r') == -1: # if no CRs, insert them
message = '\r\n'.join(message.split('\n'))
b = make_mz_header()
- b.place_symbol('#mz/reloc-count', 0) # no relocation
- b.place_symbol('#mz/header-size', 0) # empty MZ header--load it all
- b.place_symbol('#mz/low-memory-limit', 0x40)
- b.place_symbol('#mz/high-memory-limit', 0x40)
- b.place_symbol('#mz/ss', -0x10)
- b.place_symbol('#mz/sp', 0x100)
- b.place_symbol('#mz/checksum', 0)
- b.place_symbol('#mz/ip', 0x100 + b.memsz())
- b.place_symbol('#mz/cs', -0x10)
- b.place_symbol('!mz/reloc', 0)
- b.place_symbol('#mz/overlay', 0)
- b[::1] = 0x8C, 0xC8, 0x8E, 0xD8 # mov %ax, %cs; mov %ds, mov %ax
- b[::1] = 0xB4, 0x09 # mov %ah, 0x09
- b[::1] = 0xBA; b[::2] = '&mz/message' # mov %dx, message
- b[::1] = 0xCD, 0x21 # int 0x21
- b[::1] = 0xB8, 0xFF, 0x4C, 0xCD, 0x21 # mov %ax, 0x4CFF; int 0x21
+ interpret_single('make-pe-mz-stub-structure', b, include = 'pe')
message += '$' # Dollar the Terminator
# a pointer to the PE signature must appear at the offset 0x003C
Index: tran-builtins
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran-builtins,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- tran-builtins 17 May 2003 14:16:24 -0000 1.25
+++ tran-builtins 17 May 2003 14:46:34 -0000 1.26
@@ -118,6 +118,11 @@
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()))
@@ -131,6 +136,9 @@
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()
@@ -145,7 +153,8 @@
interpreter.regstack.append(Symbol_Literal(before + core + after))
label|name
- interpreter.current.place_symbol('&' + name)
+ if not name[0] in '&#!': name = '&' + name
+ interpreter.current.place_symbol(name)
minor reg
interpreter.regstack.append(Integer_Literal(interpreter.regstack.pop()[-1]))
Index: tran.py
===================================================================
RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- tran.py 17 May 2003 14:16:24 -0000 1.104
+++ tran.py 17 May 2003 14:46:34 -0000 1.105
@@ -173,6 +173,10 @@
class Class_Marker (object, Stackable):
def __init__ (this, id):
this.id = id
+ def __str__ (this):
+ return this.id
+ def __repr__ (this):
+ return `this.id`
def matchers (object):
if isinstance(object, Class_Marker):
@@ -279,9 +283,9 @@
while not this.meaning.has_key(tok):
tok = mg.next()
if tok == None:
- raise 'stack too empty or meaningless word', root
+ raise 'stack too empty or meaningless word', (root, ' '.join(map(str, this.regstack)))
except StopIteration:
- raise 'meaningless word', root
+ raise 'meaningless word', (root, ' '.join(map(str, this.regstack)))
m = this.meaning[tok]
if isinstance(m, list): this.toksrc.push(Macro_Cursor(m))
elif isinstance(m, Stackable): this.regstack.append(m)
|