[Wisp-cvs] wisp/users/dig mz.py,NONE,1.1 make-pe-exe.py,1.58,1.59
Status: Alpha
Brought to you by:
digg
From: <di...@us...> - 2003-05-16 13:52:10
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv32233 Modified Files: make-pe-exe.py Added Files: mz.py Log Message: extracted make_mz_header from make_mz_prefix --- NEW FILE: mz.py --- #### mz.py - MZ-EXE generation # # 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: mz.py,v 1.1 2003/05/16 13:52:02 digg Exp $ from linkie import Linkie def make_mz_header (): h = Linkie('<') h[::1] = 0x4d, 0x5a # magic h[::2] = '#mz/bytes-in-last-block', '#mz/blocks-in-file' h[::2] = '#mz/reloc-count' h[::2] = '#mz/header-size' h[::2] = '#mz/low-memory-limit', '#mz/high-memory-limit' h[::2] = '#mz/ss', '#mz/sp' h[::2] = '#mz/checksum' h[::2] = '#mz/ip', '#mz/cs' h[::2] = '!mz/reloc' h[::2] = '#mz/overlay' return h Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- make-pe-exe.py 16 May 2003 13:34:55 -0000 1.58 +++ make-pe-exe.py 16 May 2003 13:52:01 -0000 1.59 @@ -9,6 +9,7 @@ #### @(#) $Id$ from linkie import Linkie +from mz import * import time # This file is *very* incomplete @@ -22,18 +23,18 @@ raise 'MZ message may not contain dollar signs', message if message.find('\r') == -1: # if no CRs, insert them message = '\r\n'.join(message.split('\n')) - b = Linkie('<') - b[::1] = 0x4d, 0x5a # 'MZ' - b[::2] = '#mz/bytes-in-last-block', '#mz/blocks-in-file' - b[::2] = 0 # no relocation - b[::2] = 0 # empty MZ header--load it all into memory - b[::2] = 0x40, 0x40 # low and high memory limits in paragraphs - b[::2] = -0x10, 0x100 # initial SS, SP - b[::2] = 0 # no checksum - b[::2] = '&mz/_start', -0x10 # initial IP, CS - b[::2] = 0 # relocation table offset - b[::2] = 0 # not an overlay - b.place_symbol('&mz/_start') + 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 |