Add boot_file
This commit is contained in:
parent
13b227ac22
commit
bc67b65de2
1 changed files with 41 additions and 2 deletions
43
boot.py
43
boot.py
|
@ -1,4 +1,7 @@
|
||||||
def boot_hp(p, addr=0o10000):
|
|
||||||
|
def boot_hp(p, /, *, addr=0o10000):
|
||||||
|
"""Read the first 1KB of drive 0 into location 'addr'."""
|
||||||
|
|
||||||
# this is the sort of thing that would be keyed in from
|
# this is the sort of thing that would be keyed in from
|
||||||
# the console switches (if the machine was not equipped
|
# the console switches (if the machine was not equipped
|
||||||
# with a boot rom option to hold it instead)
|
# with a boot rom option to hold it instead)
|
||||||
|
@ -8,7 +11,7 @@ def boot_hp(p, addr=0o10000):
|
||||||
# at zero is done elsewhere.
|
# at zero is done elsewhere.
|
||||||
#
|
#
|
||||||
# NOTE WELL: THIS ASSUMES THE MACHINE IS IN RESET CONDITION WHICH
|
# NOTE WELL: THIS ASSUMES THE MACHINE IS IN RESET CONDITION WHICH
|
||||||
# MEANS MANY OF THE DEVICE REGISTERS ARE KNOWN TO BE ZERO
|
# MEANS MANY OF THE DEVICE REGISTERS ARE ASSUMED TO BE ZERO
|
||||||
#
|
#
|
||||||
# MOV #176704,R0 -- note how used
|
# MOV #176704,R0 -- note how used
|
||||||
# MOV #177000,-(R0) -- word count - read 1K though boot really 512
|
# MOV #177000,-(R0) -- word count - read 1K though boot really 512
|
||||||
|
@ -29,6 +32,42 @@ def boot_hp(p, addr=0o10000):
|
||||||
return addr
|
return addr
|
||||||
|
|
||||||
|
|
||||||
|
def boot_file(p, fname, /, *, addr=0, little_endian=True, skipwords=8):
|
||||||
|
"""Read a raw binary image of pdp11 data into location 'addr'."""
|
||||||
|
|
||||||
|
with open(fname, 'rb') as f:
|
||||||
|
bb = f.read()
|
||||||
|
|
||||||
|
# Two data format cases:
|
||||||
|
# 1) little_endian (the default)
|
||||||
|
#
|
||||||
|
# The file is truly a binary image of pdp11 format data
|
||||||
|
# and the words (pairs of bytes) in bb are in little endian
|
||||||
|
# order. They will be assembled accordingly and the names
|
||||||
|
# "low" and "hi" make sense.
|
||||||
|
#
|
||||||
|
# 2) not little_endian
|
||||||
|
#
|
||||||
|
# Presumably the file has been byte-swapped already and
|
||||||
|
# the words (pairs of bytes) in it are in big endian order.
|
||||||
|
# They will be assembled accordingly, but the names "low"
|
||||||
|
# and "hi" are backwards.
|
||||||
|
#
|
||||||
|
|
||||||
|
xi = iter(bb)
|
||||||
|
words = []
|
||||||
|
for low in xi:
|
||||||
|
hi = next(xi)
|
||||||
|
if little_endian:
|
||||||
|
words.append((hi << 8) | low)
|
||||||
|
else:
|
||||||
|
words.append((low << 8) | hi) # see case 2) above
|
||||||
|
|
||||||
|
for a, w in enumerate(words[skipwords:]):
|
||||||
|
p.physmem[a] = w
|
||||||
|
return p
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import time
|
import time
|
||||||
from machine import PDP1170
|
from machine import PDP1170
|
||||||
|
|
Loading…
Add table
Reference in a new issue