Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Commit 53cc2e5

Browse files
committed
Update
1 parent 85e3055 commit 53cc2e5

File tree

4 files changed

+47
-37
lines changed

4 files changed

+47
-37
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
msxbios:
2-
python3 msxbios.py > msxbios.as
2+
python3 msxbios.py > msxbios.asm

msxbios.as msxbios.asm

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; MSX BIOS
33
; ========
44
;
5-
; . Symbol table by MSX.BIOS by ASCII Corp., 1983 (v3.44)
5+
; . Symbol table by MSX.BIOS, ASCII Corp., 1983 (v3.44)
66
;
77
; file : BIOHDR.MAC
88
; use : Restart calls and ROM entries table
@@ -16,6 +16,10 @@
1616
; . Disassembled by Ximenes R. Resende ([email protected])
1717
; file : EXPERT10.ROM
1818
;
19+
;
20+
; The following RST's (RST 0 thru RST 5) are reserved for BASIC
21+
; interpreter, RST 6 for inter-slot calls, and RST 7 for
22+
; hardware interrupt
1923

2024

2125
BEGIN: ; MSX System Init

msxbios.py

+25-21
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626

2727
def msxbios_begin(rom, beg, end):
2828
"""."""
29-
rom.add_line_comment(addr=beg, comment=[
29+
rom.add_comment_line(addr=beg, comment=[
3030
'MSX BIOS',
3131
'========',
3232
'',
33-
'. Symbol table by MSX.BIOS by ASCII Corp., 1983 (v3.44)',
33+
'. Symbol table by MSX.BIOS, ASCII Corp., 1983 (v3.44)',
3434
'',
3535
' file : BIOHDR.MAC',
3636
' use : Restart calls and ROM entries table',
@@ -44,18 +44,22 @@ def msxbios_begin(rom, beg, end):
4444
'. Disassembled by Ximenes R. Resende ([email protected])',
4545
' file : EXPERT10.ROM',
4646
'',
47+
'',
48+
'The following RST\'s (RST 0 thru RST 5) are reserved for BASIC',
49+
'interpreter, RST 6 for inter-slot calls, and RST 7 for',
50+
'hardware interrupt',
4751
])
48-
rom.add_line_comment(0x0006, comment=[
52+
rom.add_comment_line(0x0006, comment=[
4953
'** VDP Information **',
5054
'Any program that access the VDP hardware directly',
5155
'should read the I/O port address found here, to be certain',
5256
'the software is compatible with future versions of the VDP',
5357
])
5458

55-
rom.add_ins_comment(addr=0x0000, comment='Fail safe')
56-
rom.add_ins_comment(addr=0x0001, comment='Find all connected RAM')
57-
rom.add_ins_comment(addr=0x0006, comment='Port address for VDP data read')
58-
rom.add_ins_comment(addr=0x0007, comment='Port address for VDP data write')
59+
rom.add_comment_ins(addr=0x0000, comment='Fail safe')
60+
rom.add_comment_ins(addr=0x0001, comment='Find all connected RAM')
61+
rom.add_comment_ins(addr=0x0006, comment='Port address for VDP data read')
62+
rom.add_comment_ins(addr=0x0007, comment='Port address for VDP data write')
5963
rom.add_dw(0x0004)
6064
rom.add_db([
6165
0x0006, 0x0007, 0x000B, 0x000F, 0x0013,
@@ -67,7 +71,7 @@ def msxbios_begin(rom, beg, end):
6771

6872
def msxbios_ioinij(rom, beg, end):
6973

70-
rom.add_line_comment(addr=beg, comment=[
74+
rom.add_comment_line(addr=beg, comment=[
7175
'',
7276
'Following are used for I/O initializations',
7377
'',
@@ -77,7 +81,7 @@ def msxbios_ioinij(rom, beg, end):
7781

7882
def msxbios_vdprmc(rom, beg, end):
7983

80-
rom.add_line_comment(addr=beg, comment=[
84+
rom.add_comment_line(addr=beg, comment=[
8185
'',
8286
'The following entry points provide control of the ',
8387
'VDP\'s registers, screen mode settings, and memory block',
@@ -89,7 +93,7 @@ def msxbios_vdprmc(rom, beg, end):
8993

9094
def msxbios_psgini(rom, beg, end):
9195

92-
rom.add_line_comment(addr=beg, comment=[
96+
rom.add_comment_line(addr=beg, comment=[
9397
'',
9498
'The following entry points are used for PSG initialization, ',
9599
'read and write PSG registers, and PLAY statement execution.',
@@ -99,7 +103,7 @@ def msxbios_psgini(rom, beg, end):
99103

100104
def msxbios_inpprt(rom, beg, end):
101105

102-
rom.add_line_comment(addr=beg, comment=[
106+
rom.add_comment_line(addr=beg, comment=[
103107
'',
104108
'General INPUT and PRINT utilities.',
105109
'',
@@ -109,7 +113,7 @@ def msxbios_inpprt(rom, beg, end):
109113

110114
def msxbios_joystk(rom, beg, end):
111115

112-
rom.add_line_comment(addr=beg, comment=[
116+
rom.add_comment_line(addr=beg, comment=[
113117
'',
114118
'General INPUT and PRINT utilities.',
115119
'',
@@ -119,7 +123,7 @@ def msxbios_joystk(rom, beg, end):
119123

120124
def msxbios_tapect(rom, beg, end):
121125

122-
rom.add_line_comment(addr=beg, comment=[
126+
rom.add_comment_line(addr=beg, comment=[
123127
'',
124128
'Following are used to access the cassette tape, ',
125129
'data read/write, and motor on/off',
@@ -130,7 +134,7 @@ def msxbios_tapect(rom, beg, end):
130134

131135
def msxbios_basicq(rom, beg, end):
132136

133-
rom.add_line_comment(addr=beg, comment=[
137+
rom.add_comment_line(addr=beg, comment=[
134138
'',
135139
'BASIC queues',
136140
'',
@@ -140,20 +144,20 @@ def msxbios_basicq(rom, beg, end):
140144

141145
def msxbios_basgrp(rom, beg, end):
142146

143-
rom.add_line_comment(addr=beg, comment=[
147+
rom.add_comment_line(addr=beg, comment=[
144148
'',
145149
'For BASIC interpreter\'s GENGRP and ADVGRP modules use',
146150
'',
147151
])
148-
rom.add_ins_comment(addr=0x015C, comment='RESERVED FOR EXPANSION - start')
149-
rom.add_ins_comment(addr=0x01B5, comment='RESERVED FOR EXPANSION - end')
152+
rom.add_comment_ins(addr=0x015C, comment='RESERVED FOR EXPANSION - start')
153+
rom.add_comment_ins(addr=0x01B5, comment='RESERVED FOR EXPANSION - end')
150154
rom.add_db(0x015C, 0x01B5)
151155
rom.disassemble(pc=beg, lastpc=end, nrbytes=None, print_addr=True)
152156

153157

154158
def msxbios_slotsm(rom, beg, end):
155159

156-
rom.add_line_comment(addr=beg, comment=[
160+
rom.add_comment_line(addr=beg, comment=[
157161
'',
158162
'SLOTS',
159163
'',
@@ -214,7 +218,7 @@ def msxbios():
214218

215219
# rom.disassemble(pc=0x0000, lastpc=0x008D, nrbytes=None, print_addr=True)
216220

217-
# rom.add_ins_comment(addr=0x01B6, comment='Calculate bit pattern and mask code')
221+
# rom.add_comment_ins(addr=0x01B6, comment='Calculate bit pattern and mask code')
218222

219223
# rom.disassemble(pc='RDSLT', lastpc=0x01C5, nrbytes=None, print_addr=True)
220224
# rom.disassemble(pc='RDESLT', lastpc=0x01CF, nrbytes=None, print_addr=True)
@@ -230,8 +234,8 @@ def msxbios():
230234
# rom.disassemble(pc='SELPRM', lastpc=0x02A2, nrbytes=None, print_addr=True)
231235
# rom.disassemble(pc='SELEXP', lastpc=0x02D6, nrbytes=None, print_addr=True)
232236

233-
# rom.add_skip('0x033B') # avoid replacing 0x0000 <-> _CHKRAM
234-
# rom.add_skip('0x039E') # avoid replacing 0x0000 <-> _CHKRAM
237+
# rom.add_symbol_skip('0x033B') # avoid replacing 0x0000 <-> _CHKRAM
238+
# rom.add_symbol_skip('0x039E') # avoid replacing 0x0000 <-> _CHKRAM
235239
# rom.disassemble(pc='CHKRAM', lastpc=0x03F8, nrbytes=None, print_addr=True)
236240

237241

msxdis.py

+16-14
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,22 @@ def memsize(self):
129129
return len(self._memory)
130130

131131
def add_symbol(self, addr, symbol, comment=None):
132-
"""."""
132+
"""Add an address to symbol convertion."""
133133
addr = MSXDisassembler._conv_pc2addr(addr)
134134
self._symbols[addr] = dict(symbol=symbol, comment=comment)
135135

136136
def add_db_string(self, addr, size=None, terminator=None):
137-
"""."""
137+
"""Add db command at specific address with bytes converted to strings."""
138138
addr = MSXDisassembler._conv_pc2addr(addr)
139139
self._db_string[addr] = dict(size=size, terminator=terminator)
140140

141141
def add_db_bytes(self, addr):
142-
"""Add address from which db gathers bytes until a symbol address is found."""
142+
"""Add db command at specific address that gathers bytes until a symbol address is found."""
143143
addr = MSXDisassembler._conv_pc2addr(addr)
144144
self._db_bytes.append(addr)
145145

146146
def add_db(self, addr_beg, addr_end=None):
147+
"""Add db command at specific address."""
147148
if isinstance(addr_beg, (list, tuple)):
148149
for addr_ in addr_beg:
149150
addr = MSXDisassembler._conv_pc2addr(addr_)
@@ -158,23 +159,27 @@ def add_db(self, addr_beg, addr_end=None):
158159
self._db.append(addr)
159160

160161
def add_dw(self, addr):
162+
"""Add dw command at specific address."""
161163
addr = MSXDisassembler._conv_pc2addr(addr)
162164
self._dw.append(addr)
163165

164-
def add_ins_comment(self, addr, comment):
166+
def add_comment_ins(self, addr, comment):
167+
"""Add instruction comment at specific address."""
165168
addr = MSXDisassembler._conv_pc2addr(addr)
166169
self._ins_comments[addr] = comment
167170

168-
def add_line_comment(self, addr, comment):
171+
def add_comment_line(self, addr, comment):
172+
"""Add line comment at specific address."""
169173
addr = MSXDisassembler._conv_pc2addr(addr)
170174
self._line_comments[addr] = comment
171175

172-
def add_skip(self, addr):
176+
def add_symbol_skip(self, addr):
177+
"""Skip symbol replacement at specific address."""
173178
addr = MSXDisassembler._conv_pc2addr(addr)
174179
self._skip.append(addr)
175180

176181
def print_rom_header(self, print_addr=True):
177-
"""."""
182+
"""Print ROM header."""
178183
text = list()
179184
text.append('; ROM SIZE :' + str(len(self._memory)))
180185
text.append('; ROM ID :' + self._rom_id)
@@ -237,6 +242,7 @@ def print_rom_header(self, print_addr=True):
237242
return text
238243

239244
def load_symbols(self, fname):
245+
"""Load symbols from file."""
240246
self._use_symbols = True
241247
with open(fname, 'r') as fp:
242248
data = fp.readlines()
@@ -255,7 +261,7 @@ def load_symbols(self, fname):
255261
self._symbols.update(symbols)
256262

257263
def disassemble(self, pc=None, lastpc=None, nrbytes=None, print_addr=True):
258-
"""."""
264+
"""Disassemble code."""
259265
text = list()
260266

261267
if isinstance(pc, str):
@@ -400,9 +406,7 @@ def disassemble(self, pc=None, lastpc=None, nrbytes=None, print_addr=True):
400406
text += lines
401407
text.append(line)
402408

403-
# print lines
404-
for line in text:
405-
print(line)
409+
MSXDisassembler.print_code(text)
406410

407411
return text
408412

@@ -423,9 +427,7 @@ def _add_symbols_comments(self, ins, pc, addr, char, tab_flag):
423427
spcs = ' ' * (MSXDisassembler._COMMENTPOS - len(ins_sym) - len(prefix))
424428
if symbol['comment'] is not None and pc_ not in self._skip:
425429
comt = spcs + ' ; ' + symbol['comment']
426-
line = prefix + ins_sym
427-
if True:
428-
line += comt
430+
line = prefix + ins_sym + comt
429431
return line
430432

431433
@staticmethod

0 commit comments

Comments
 (0)