This commit is contained in:
J.B. Langston
2017-02-03 23:16:34 -05:00
parent f4fae979ac
commit 33c258c553
9 changed files with 11 additions and 1417 deletions
+8 -5
View File
@@ -40,23 +40,26 @@ if len(mon1) != len(mon2):
print("input files are not the same length")
sys.exit()
if len(mon1) > 38911:
print("input files too large")
sys.exit()
# get end of first program from header
end1 = struct.unpack('H', mon1[0:2])[0] + len(mon1) - 2
origin = struct.unpack('H', mon1[0:2])[0]
# strip origin from both programs
mon1 = mon1[2:]
mon2 = mon2[2:]
with open(sys.argv[4], 'wb') as out:
# prepend relocator stub
out.write(stub)
# separate from supermon code with $36 twice
out.write(b'\x36\x36')
i = 0
while i < len(mon1):
if len(mon1) > i+1 and mon1[i+1] != mon2[i+1]:
addr = struct.unpack('H', mon1[i:i+2])[0]
offset = struct.pack('h', addr - origin - len(mon1))
# calculate offset to address
offset = struct.pack('h', addr - end1)
out.write(offset)
# mark address to be adjusted with $36
out.write(b'\x36')
i += 2
else:
+3 -21
View File
@@ -1,22 +1,5 @@
; Relocatable code stub for Supermon 64 by Jim Butterfield
; Jim Butterfield described the post-processing of Supermon 64 binaries
; in a posting to comp.sys.cbm on Dec 20, 2003:
; I should note that, since Supermon+64 is relocatable code, the source
; does not assemble into the final binary file. It may seem crude, but
; I follow this procedure: (1) The source is carefully structured so
; that there are no "dispersed addresses" such as might be created with
; something like LDA #>VECTOR .. LDY #<VECTOR - every relocatable
; address is two adjacent bytes; (2) I assemble the source TWICE, to
; two different page addresses; the only difference in the binaries will
; be the high-order bytes of the relocatable addresses; (3) a small
; post-processing program blends the two binaries into a relocatable
; package, adding a Basic driver to complete the bundle.
; Source: https://groups.google.com/forum/#!searchin/comp.sys.cbm/supermon$2064%7Csort:relevance/comp.sys.cbm/5owItyf5qjk/50_UQlwVnPcJ
; This code was disassembled from the original Supermon+64 V1.2 binary.
; The relocation stub starts at the Start of Variables pointer (VARTAB) and
@@ -29,9 +12,8 @@
; adding the top of memory to them will yield the absolute address of the
; jump target in the relocated code.
; The next step will be to build a Python script that will take Supermon64
; binaries assembled to two different addresses and output relocatable code
; with the relative addresses and $36 address markers.
; build.py will build a relocatable Supermon64 binary from this stub plus
; standard Supermon64 binaries assembled to two different pages.
; ----------------------------------------------------------------------------
; variables
@@ -118,4 +100,4 @@ DONE LDA TARGET ; fix pointer to string storage
STA FRETOP
LDA TARGET+1
STA FRETOP+1
JMP (TARGET) ; jump to the beginning of the relocated code
JMP (TARGET) ; jump to the beginning of the relocated code
BIN
View File
Binary file not shown.
View File
BIN
View File
Binary file not shown.
File diff suppressed because one or more lines are too long
-285
View File
@@ -1,285 +0,0 @@
S U P E R M O N + 64
In the following discussion, keyboard
input in designated by brackets.
<this is what you type>
SUPERMON+ is a new version of
'SUPERMON' the reason for the new
version is to provide identical
commands to those of the built-in
monitor of the commodore 128.
The most visible changes from earlier
versions of SUPERMON are:
--decimal or binary input allowed;
--disk status and commands (@);
--looser (easier) syntax.
NUMBER CONVERSION
<$2000>
$2000
+8192
&20000
%10000000000000
In the above example the user
has asked for the numeric
equivalents to hexadecimal 2000.
The reply shows the value in hex
($), in decimal (+), in octal (&)
and in binary (%).
The user could ask for a number
to be converted from any of these
bases by giving the appropriate
prefix.
IMPORTANT NOTE --
At any time in the following text,
you may enter any number in any
base and conversion will be done
for you.
Example:
<m +4096>
Will cause a memory display from
decimal address 4096. In the
display, the hex address ($1000)
will be shown. Similarly,
<+2048 lda#%10000000>
Will be converted to assemble:
"a $0400 lda #$80"
If you don't give a prefix, the
monitor will assume hexadecimal.
REGISTER DISPLAY
<r>
pc sr ac xr yr sp
; 0000 01 02 03 04 05
Displays the register values
saved when SUPERMON+ was entered.
Values may be changed by typing
over the display followed by a
return character.
pc - program counter
sr - status register
ac, xr, yr - a, x, and y
registers
sp - stack pointer
<m 200 209>
>0200 4d 20 32 30 30 20 32 30: m 200 20
>0208 39 00 00 04 00 04 00 04: 9.......
Display memory from 0200 hex to
0209 hex. Display is in lines of
8, so addresses $200 to $20f are
shown. If only one address is
used then 12 lines (96 locations)
will be shown. If no address is
given display will go from the
last address. Equivalent ASCII
characters are shown in reverse
at the right. Values are changed
by typing over the display
followed by a return character.
EXIT TO BASIC
<x>
Return to BASIC READY mode. When
you wish to return to SUPERMON+,
command "SYS 8".
SIMPLE ASSEMBLER
<a 2000 lda #+18>
(changes to:)
a 2000 a9 12 lda #$12
a 2002 ..next instruction
In the above example the user
started assembly at 2000 hex. The
first instruction was load a
register with immediate 18
decimal. In following lines the
user need not type the "a" and
address. The simple assembler
prompts with the next address. To
exit the assembler type a return
after the the address prompt.
Previous lines may be changed by
typing over the right hand part.
<d 2000 2004>
. 2000 a9 12 lda #$12
. 2002 9d 00 80 sta $8000,x
Disassembles instructions from
2000 to 2004 hex. If one address
is given, 20 bytes will be
disassembled. If no address,
start from the last used address.
Code may be reassembled by moving
the cursor back and typing over
the right hand part.
FILL MEMORY
<f 1000 1100 ff>
fills the memory from 1000 hex to
1100 hex with the byte ff hex.
GO (RUN)
<g 1000>
Go to address 1000 hex and begin
running code. If no address is
given, the address from the <pc>
register is used.
JUMP (SUBROUTINE)
<j 1000>
Call address 1000 hex and begin
running code. Return to the
monitor.
HUNT MEMORY
<h c000 d000 'read>
Hunt thru memory from c000 hex to
d000 hex for the ascii string
"read" and print the address
where it is found. A maximum of
32 characters may be used.
<h c000 d000 20 d2 ff>
Hunt memory from c000 hex to d000
hex for the sequence of bytes
20 d2 ff and print the address. A
maximum of 32 bytes may be used.
FILE HANDLING
LOAD
<l>
Load any program from cassette #1.
<l "ram test">
Load from cassette #1 the program
named "ram test".
<l "ram test",08>
Load from disk (device 8) the
program named "ram test". This
command leaves basic pointers
unchanged.
SAVE
<s "program name",01,0800,0c80>
Save to cassette #1 memory from
0800 hex up to but not including
0c80 hex and name it
"program name".
<s "0:program name",08,1200,1f50>
Save to disk drive #0 memory from
1200 hex up to but not including
1f50 hex and name it
"program name".
TRANSFER MEMORY
<t 1000 1100 5000>
Transfer memory in the range 1000
hex to 1100 hex and start storing
it at address 5000 hex.
COMPARE MEMORY
<c 1000 1100 5000>
Compare memory in the range 1000
hex to 1100 hex with memory
starting at address 5000 hex.
DISK OPERATIONS
CHECK DISK
<@>
Get disk status message
<@9>
Get disk unit 9 status message
<@,$0>
Get drive 0 directory
<@,s0:temp>
Scratch file 'temp' from disk
OUTPUT TO PRINTER
Call SUPERMON+ from basic with:
<open 4,4:cmd 4:sys 8>
All commands will go the printer.
When complete, return to basic
with "x" and command:
<print#4:close 4>
SUMMARY
$ , + , & , % number conversion
g go (run)
j jump (subroutine)
l load from tape or disk
m memory display
r register display
s save to tape or disk
x exit to basic
a simple assembler
d disassembler
f fill memory
h hunt memory
t transfer memory
c compare memory
@ disk status/command
Supermon will load itself into the top
of memory...wherever that happens to
be on your machine. Be sure to note
the SYS command which links SUPERMON
to the Commodore. It may be used to
reconnect the monitor if it is
accidentally disconnected by use of
the run-stop/restore keys.
File diff suppressed because one or more lines are too long
-1104
View File
File diff suppressed because it is too large Load Diff