@@ -450,6 +450,9 @@ def to_number(n):
450450 return int ('0x' + n , 0 )
451451 except Exception :
452452 return float (n )
453+ finally :
454+ print ("\n \n Error occured. Invalid number: " ,n )
455+ exit (1 )
453456
454457def parse_arguments ():
455458 """
@@ -1188,18 +1191,22 @@ def findstring(memstart, memend):
11881191# dump_code_array()
11891192
11901193print ("\n Pass 4: Validate labels" )
1194+ """
1195+ This pass is functionally the same as for pass 5, mostly to build the final labels.
1196+ No code is output.
1197+ """
11911198code_snapshot = bytearray (8 )
11921199loc = 0
11931200
11941201# dump_code_array()
1195-
11961202if args .templatefile is not None :
1203+ print (f"Loading template file: { args .templatefile } ..." ,end = "" )
11971204 process_template (args .templatefile )
1205+ print (" Done!" ,end = "" )
1206+ if args .quiet :
1207+ print ("\n " )
11981208
11991209
1200- # This is nearly the final assembly.
1201- # In this pass I'm building the final labels but not outputting code
1202- # dump_code_array()
12031210program_counter = min (code )
12041211print_progress_bar (program_counter - code_org , endaddress , prefix = ' Progress:' , suffix = 'Complete' , length = 50 )
12051212
@@ -1275,23 +1282,12 @@ def findstring(memstart, memend):
12751282 data_addr = handle_data (b )
12761283 if data_addr is None : # So something like LD A,(BC) or LD A,B
12771284 tmp = process_hextype (z80 .disasm (b ))
1278- # code_output(
1279- # program_counter,
1280- # tmp,
1281- # list_address,
1282- # explain.code(z80.disasm(b),explainlevel),
1283- # add_extra_info(decode_buffer),
1284- # )
12851285 program_counter += b .len
12861286 else :
12871287 tmp = z80 .disasm (b ).replace (f'0x{ data_addr :04x} ' ,lookup_label (data_addr ,1 ))
12881288 tmp_data_addr = handle_data (b )
12891289 tmp_addr = hex (handle_data (b ))
1290- # mark_handled(tmp_data_addr, 2, "D")
12911290 if is_in_code (tmp_data_addr ):
1292- # if (tmp_data_addr >= code_org) and (
1293- # tmp_data_addr <= code_org + len(bin_data)
1294- # ):
12951291 ld_label = lookup_label (handle_data (b ))
12961292 # print("---->",hex(program_counter),ld_label,hex(handle_data(b)),code[handle_data(b)][2])
12971293 labelled = tmp .replace (
@@ -1306,54 +1302,8 @@ def findstring(memstart, memend):
13061302 str_for_comment = (
13071303 " - References: " + str_locations [handle_data (b )]
13081304 )
1309- # if commentlevel==0:
1310- # code_output(
1311- # program_counter,
1312- # labelled,
1313- # list_address,
1314- # "", #explain.code(labelled,explainlevel) + " " + str_for_comment,
1315- # add_extra_info(decode_buffer),
1316- # )
1317- # else:
1318- # code_output(
1319- # program_counter,
1320- # labelled,
1321- # list_address,
1322- # explain.code(labelled,explainlevel) + " " + str_for_comment,
1323- # add_extra_info(decode_buffer),
1324- # )
13251305 program_counter += b .len
13261306
1327- # data_addr = handle_data(b)
1328- # if data_addr is None: # So something like LD A,(BC) or LD A,B
1329- # program_counter += b.len
1330- # else:
1331- # tmp = z80.disasm(b)
1332- # tmp_data_addr = handle_data(b)
1333- # tmp_addr = hex(handle_data(b))
1334- # if is_in_code(tmp_data_addr):
1335- # #We only want to mess with strings, ignore all previous instructions
1336- # if code[tmp_data_addr][1]=="S" and is_terminator(code[tmp_data_addr][0]):
1337- # mark_handled(tmp_data_addr, 0, "D")
1338- # #End of fix
1339- # if is_in_code(tmp_data_addr):
1340- # # if (tmp_data_addr >= code_org) and (
1341- # # tmp_data_addr <= code_org + len(bin_data)
1342- # # ):
1343- # # ld_label=f'{identified(handle_data(b))}_{handle_data(b):X}'
1344- # ld_label = lookup_label(handle_data(b))
1345- # labelled = tmp.replace(
1346- # tmp_addr, ld_label
1347- # ) # Convert inline hex to L_xxxx label
1348- # else:
1349- # labelled = tmp
1350- # str_for_comment = ""
1351- # if data_addr in labels:
1352- # if handle_data(b) in str_locations:
1353- # str_for_comment = (
1354- # " - References: " + str_locations[handle_data(b)]
1355- # )
1356- # program_counter += b.len
13571307 else :
13581308 program_counter += b .len
13591309 else :
@@ -1381,8 +1331,13 @@ def findstring(memstart, memend):
13811331 code [loop ][1 ]= "D"
13821332# Print the used external EQUs (with nice formatting)
13831333# First find the longest label
1334+
13841335if args .labelsfile :
1336+ print (f"Loading labels file: { args .labelsfile } ... " ,end = "" )
13851337 load_labels (args .labelsfile )
1338+ print ("Done!" ,end = "" )
1339+ if args .quiet :
1340+ print ("\n " )
13861341
13871342maxlen = 0
13881343for loop in extern_labels :
@@ -1814,7 +1769,7 @@ def findstring(memstart, memend):
18141769print_progress_bar (max (code ), max (code ),prefix = ' Progress:' , suffix = 'Complete' , length = 50 )
18151770print ()
18161771if args .outfile :
1817- print (args .outfile , " created!" )
1772+ print (f" \n { args .outfile } created!" )
18181773
18191774print ()
18201775print ("Lines of code:" ,stats_loc )
0 commit comments