OpenCores
URL https://opencores.org/ocsvn/s80186/s80186/trunk

Subversion Repositories s80186

[/] [s80186/] [trunk/] [scripts/] [load-program] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jamieiles
#!/usr/bin/env python
2
 
3
# Copyright Jamie Iles, 2017
4
#
5
# This file is part of s80x86.
6
#
7
# s80x86 is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# s80x86 is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with s80x86.  If not, see .
19
 
20
import argparse
21
import sys
22
 
23
from py8086sim.Cpu import GPR
24
 
25
 
26
def load(cpu, program, cs, ip):
27
    cpu.reset()
28
 
29
    cpu.write_reg(GPR.CS, cs)
30
    with open(program) as b:
31
        bytevec = [ord(v) for v in b.read()]
32
        if len(bytevec) % 2 == 1:
33
            bytevec.append(0)
34
        wordvec = []
35
        for a, b in zip(bytevec[::2], bytevec[1::2]):
36
            wordvec.append(a | (b << 8))
37
        cpu.write_vector16(cs, ip, wordvec)
38
 
39
    cpu.write_reg(GPR.IP, ip)
40
 
41
if __name__ == '__main__':
42
    parser = argparse.ArgumentParser()
43
    parser.add_argument('backend')
44
    parser.add_argument('program')
45
    parser.add_argument('cs')
46
    parser.add_argument('ip')
47
    args = parser.parse_args()
48
 
49
    cpu = getattr(sys.modules['py8086sim.Cpu'], args.backend)(args.program)
50
 
51
    load(cpu, args.program, int(args.cs, 0), int(args.ip, 0))

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.