added textio.spc(). assem tweaks.

This commit is contained in:
Irmen de Jong 2021-01-14 22:51:09 +01:00
parent 04e75455c4
commit 7277c08fa6
17 changed files with 193 additions and 134 deletions

View File

@ -19,14 +19,19 @@ sub clear_screen() {
txt.chrout(147)
}
sub home() {
txt.chrout(19)
}
sub nl() {
txt.chrout('\n')
}
sub home() {
txt.chrout(19)
sub spc() {
txt.chrout(' ')
}
asmsub fill_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) {
; ---- fill the character screen with the given fill character and character color.
; (assumes screen and color matrix are at their default addresses)

View File

@ -19,14 +19,19 @@ sub clear_screen() {
txt.chrout(147)
}
sub home() {
txt.chrout(19)
}
sub nl() {
txt.chrout('\n')
}
sub home() {
txt.chrout(19)
sub spc() {
txt.chrout(' ')
}
asmsub fill_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) {
; ---- fill the character screen with the given fill character and character color.
%asm {{

View File

@ -30,7 +30,7 @@ diskio {
ubyte low = c64.CHRIN()
ubyte high = c64.CHRIN()
txt.print_uw(mkword(high, low))
txt.chrout(' ')
txt.spc()
ubyte @zp char
repeat {
char = c64.CHRIN()
@ -295,7 +295,8 @@ _in_buffer sta $ffff
; Routine to read text lines from a text file. Lines must be less than 255 characters.
; Reads characters from the input file UNTIL a newline or return character (or EOF).
; The line read will be 0-terminated in the buffer (and not contain the end of line character).
; The length of the line is returned in Y.
; The length of the line is returned in Y. Note that an empty line is okay and is length 0!
; I/O error status should be checked by the caller itself via READST() routine.
%asm {{
sta P8ZP_SCRATCH_W1
sty P8ZP_SCRATCH_W1+1

View File

@ -482,7 +482,7 @@ galaxy {
txt.chrout('*')
else
txt.chrout('-')
txt.chrout(' ')
txt.spc()
planet.name = make_current_planet_name()
planet.display(true)
txt.print(" (")
@ -853,9 +853,9 @@ planet {
print_name_uppercase()
txt.print(" TL:")
txt.print_ub(techlevel+1)
txt.chrout(' ')
txt.spc()
txt.print(econnames[economy])
txt.chrout(' ')
txt.spc()
txt.print(govnames[govtype])
} else {
txt.print("\n\nSystem: ")
@ -864,7 +864,7 @@ planet {
txt.print_ub(x)
txt.chrout('\'')
txt.print_ub(y)
txt.chrout(' ')
txt.spc()
txt.chrout('#')
txt.print_ub(number)
txt.print("\nEconomy: ")
@ -883,15 +883,15 @@ planet {
if species_is_alien {
if species_size < len(species_sizes) {
txt.print(species_sizes[species_size])
txt.chrout(' ')
txt.spc()
}
if species_color < len(species_colors) {
txt.print(species_colors[species_color])
txt.chrout(' ')
txt.spc()
}
if species_look < len(species_looks) {
txt.print(species_looks[species_look])
txt.chrout(' ')
txt.spc()
}
if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind])
@ -956,7 +956,7 @@ util {
sub print_right(ubyte width, uword st) {
repeat width - string.length(st) {
txt.chrout(' ')
txt.spc()
}
txt.print(st)
}

View File

@ -472,7 +472,7 @@ galaxy10 {
txt.chrout('*')
else
txt.chrout('-')
txt.chrout(' ')
txt.spc()
planet10.name = make_current_planet10_name()
planet10.display(true)
txt.print(" (")
@ -843,9 +843,9 @@ planet10 {
print_name_uppercase()
txt.print(" TL:")
txt.print_ub(techlevel+1)
txt.chrout(' ')
txt.spc()
txt.print(econnames[economy])
txt.chrout(' ')
txt.spc()
txt.print(govnames[govtype])
} else {
txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet10 {
txt.print_ub(x)
txt.chrout('\'')
txt.print_ub(y)
txt.chrout(' ')
txt.spc()
txt.chrout('#')
txt.print_ub(number)
txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet10 {
if species_is_alien {
if species_size < len(species_sizes) {
txt.print(species_sizes[species_size])
txt.chrout(' ')
txt.spc()
}
if species_color < len(species_colors) {
txt.print(species_colors[species_color])
txt.chrout(' ')
txt.spc()
}
if species_look < len(species_looks) {
txt.print(species_looks[species_look])
txt.chrout(' ')
txt.spc()
}
if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util10 {
sub print_right(ubyte width, uword st) {
repeat width - string.length(st) {
txt.chrout(' ')
txt.spc()
}
txt.print(st)
}

View File

@ -472,7 +472,7 @@ galaxy2 {
txt.chrout('*')
else
txt.chrout('-')
txt.chrout(' ')
txt.spc()
planet2.name = make_current_planet2_name()
planet2.display(true)
txt.print(" (")
@ -843,9 +843,9 @@ planet2 {
print_name_uppercase()
txt.print(" TL:")
txt.print_ub(techlevel+1)
txt.chrout(' ')
txt.spc()
txt.print(econnames[economy])
txt.chrout(' ')
txt.spc()
txt.print(govnames[govtype])
} else {
txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet2 {
txt.print_ub(x)
txt.chrout('\'')
txt.print_ub(y)
txt.chrout(' ')
txt.spc()
txt.chrout('#')
txt.print_ub(number)
txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet2 {
if species_is_alien {
if species_size < len(species_sizes) {
txt.print(species_sizes[species_size])
txt.chrout(' ')
txt.spc()
}
if species_color < len(species_colors) {
txt.print(species_colors[species_color])
txt.chrout(' ')
txt.spc()
}
if species_look < len(species_looks) {
txt.print(species_looks[species_look])
txt.chrout(' ')
txt.spc()
}
if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util2 {
sub print_right(ubyte width, uword st) {
repeat width - string.length(st) {
txt.chrout(' ')
txt.spc()
}
txt.print(st)
}

View File

@ -472,7 +472,7 @@ galaxy3 {
txt.chrout('*')
else
txt.chrout('-')
txt.chrout(' ')
txt.spc()
planet3.name = make_current_planet3_name()
planet3.display(true)
txt.print(" (")
@ -843,9 +843,9 @@ planet3 {
print_name_uppercase()
txt.print(" TL:")
txt.print_ub(techlevel+1)
txt.chrout(' ')
txt.spc()
txt.print(econnames[economy])
txt.chrout(' ')
txt.spc()
txt.print(govnames[govtype])
} else {
txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet3 {
txt.print_ub(x)
txt.chrout('\'')
txt.print_ub(y)
txt.chrout(' ')
txt.spc()
txt.chrout('#')
txt.print_ub(number)
txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet3 {
if species_is_alien {
if species_size < len(species_sizes) {
txt.print(species_sizes[species_size])
txt.chrout(' ')
txt.spc()
}
if species_color < len(species_colors) {
txt.print(species_colors[species_color])
txt.chrout(' ')
txt.spc()
}
if species_look < len(species_looks) {
txt.print(species_looks[species_look])
txt.chrout(' ')
txt.spc()
}
if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util3 {
sub print_right(ubyte width, uword st) {
repeat width - string.length(st) {
txt.chrout(' ')
txt.spc()
}
txt.print(st)
}

View File

@ -472,7 +472,7 @@ galaxy4 {
txt.chrout('*')
else
txt.chrout('-')
txt.chrout(' ')
txt.spc()
planet4.name = make_current_planet4_name()
planet4.display(true)
txt.print(" (")
@ -843,9 +843,9 @@ planet4 {
print_name_uppercase()
txt.print(" TL:")
txt.print_ub(techlevel+1)
txt.chrout(' ')
txt.spc()
txt.print(econnames[economy])
txt.chrout(' ')
txt.spc()
txt.print(govnames[govtype])
} else {
txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet4 {
txt.print_ub(x)
txt.chrout('\'')
txt.print_ub(y)
txt.chrout(' ')
txt.spc()
txt.chrout('#')
txt.print_ub(number)
txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet4 {
if species_is_alien {
if species_size < len(species_sizes) {
txt.print(species_sizes[species_size])
txt.chrout(' ')
txt.spc()
}
if species_color < len(species_colors) {
txt.print(species_colors[species_color])
txt.chrout(' ')
txt.spc()
}
if species_look < len(species_looks) {
txt.print(species_looks[species_look])
txt.chrout(' ')
txt.spc()
}
if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util4 {
sub print_right(ubyte width, uword st) {
repeat width - string.length(st) {
txt.chrout(' ')
txt.spc()
}
txt.print(st)
}

View File

@ -472,7 +472,7 @@ galaxy5 {
txt.chrout('*')
else
txt.chrout('-')
txt.chrout(' ')
txt.spc()
planet5.name = make_current_planet5_name()
planet5.display(true)
txt.print(" (")
@ -843,9 +843,9 @@ planet5 {
print_name_uppercase()
txt.print(" TL:")
txt.print_ub(techlevel+1)
txt.chrout(' ')
txt.spc()
txt.print(econnames[economy])
txt.chrout(' ')
txt.spc()
txt.print(govnames[govtype])
} else {
txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet5 {
txt.print_ub(x)
txt.chrout('\'')
txt.print_ub(y)
txt.chrout(' ')
txt.spc()
txt.chrout('#')
txt.print_ub(number)
txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet5 {
if species_is_alien {
if species_size < len(species_sizes) {
txt.print(species_sizes[species_size])
txt.chrout(' ')
txt.spc()
}
if species_color < len(species_colors) {
txt.print(species_colors[species_color])
txt.chrout(' ')
txt.spc()
}
if species_look < len(species_looks) {
txt.print(species_looks[species_look])
txt.chrout(' ')
txt.spc()
}
if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util5 {
sub print_right(ubyte width, uword st) {
repeat width - string.length(st) {
txt.chrout(' ')
txt.spc()
}
txt.print(st)
}

View File

@ -472,7 +472,7 @@ galaxy6 {
txt.chrout('*')
else
txt.chrout('-')
txt.chrout(' ')
txt.spc()
planet6.name = make_current_planet6_name()
planet6.display(true)
txt.print(" (")
@ -843,9 +843,9 @@ planet6 {
print_name_uppercase()
txt.print(" TL:")
txt.print_ub(techlevel+1)
txt.chrout(' ')
txt.spc()
txt.print(econnames[economy])
txt.chrout(' ')
txt.spc()
txt.print(govnames[govtype])
} else {
txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet6 {
txt.print_ub(x)
txt.chrout('\'')
txt.print_ub(y)
txt.chrout(' ')
txt.spc()
txt.chrout('#')
txt.print_ub(number)
txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet6 {
if species_is_alien {
if species_size < len(species_sizes) {
txt.print(species_sizes[species_size])
txt.chrout(' ')
txt.spc()
}
if species_color < len(species_colors) {
txt.print(species_colors[species_color])
txt.chrout(' ')
txt.spc()
}
if species_look < len(species_looks) {
txt.print(species_looks[species_look])
txt.chrout(' ')
txt.spc()
}
if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util6 {
sub print_right(ubyte width, uword st) {
repeat width - string.length(st) {
txt.chrout(' ')
txt.spc()
}
txt.print(st)
}

View File

@ -472,7 +472,7 @@ galaxy7 {
txt.chrout('*')
else
txt.chrout('-')
txt.chrout(' ')
txt.spc()
planet7.name = make_current_planet7_name()
planet7.display(true)
txt.print(" (")
@ -843,9 +843,9 @@ planet7 {
print_name_uppercase()
txt.print(" TL:")
txt.print_ub(techlevel+1)
txt.chrout(' ')
txt.spc()
txt.print(econnames[economy])
txt.chrout(' ')
txt.spc()
txt.print(govnames[govtype])
} else {
txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet7 {
txt.print_ub(x)
txt.chrout('\'')
txt.print_ub(y)
txt.chrout(' ')
txt.spc()
txt.chrout('#')
txt.print_ub(number)
txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet7 {
if species_is_alien {
if species_size < len(species_sizes) {
txt.print(species_sizes[species_size])
txt.chrout(' ')
txt.spc()
}
if species_color < len(species_colors) {
txt.print(species_colors[species_color])
txt.chrout(' ')
txt.spc()
}
if species_look < len(species_looks) {
txt.print(species_looks[species_look])
txt.chrout(' ')
txt.spc()
}
if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util7 {
sub print_right(ubyte width, uword st) {
repeat width - string.length(st) {
txt.chrout(' ')
txt.spc()
}
txt.print(st)
}

View File

@ -472,7 +472,7 @@ galaxy8 {
txt.chrout('*')
else
txt.chrout('-')
txt.chrout(' ')
txt.spc()
planet8.name = make_current_planet8_name()
planet8.display(true)
txt.print(" (")
@ -843,9 +843,9 @@ planet8 {
print_name_uppercase()
txt.print(" TL:")
txt.print_ub(techlevel+1)
txt.chrout(' ')
txt.spc()
txt.print(econnames[economy])
txt.chrout(' ')
txt.spc()
txt.print(govnames[govtype])
} else {
txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet8 {
txt.print_ub(x)
txt.chrout('\'')
txt.print_ub(y)
txt.chrout(' ')
txt.spc()
txt.chrout('#')
txt.print_ub(number)
txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet8 {
if species_is_alien {
if species_size < len(species_sizes) {
txt.print(species_sizes[species_size])
txt.chrout(' ')
txt.spc()
}
if species_color < len(species_colors) {
txt.print(species_colors[species_color])
txt.chrout(' ')
txt.spc()
}
if species_look < len(species_looks) {
txt.print(species_looks[species_look])
txt.chrout(' ')
txt.spc()
}
if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util8 {
sub print_right(ubyte width, uword st) {
repeat width - string.length(st) {
txt.chrout(' ')
txt.spc()
}
txt.print(st)
}

View File

@ -472,7 +472,7 @@ galaxy9 {
txt.chrout('*')
else
txt.chrout('-')
txt.chrout(' ')
txt.spc()
planet9.name = make_current_planet9_name()
planet9.display(true)
txt.print(" (")
@ -843,9 +843,9 @@ planet9 {
print_name_uppercase()
txt.print(" TL:")
txt.print_ub(techlevel+1)
txt.chrout(' ')
txt.spc()
txt.print(econnames[economy])
txt.chrout(' ')
txt.spc()
txt.print(govnames[govtype])
} else {
txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet9 {
txt.print_ub(x)
txt.chrout('\'')
txt.print_ub(y)
txt.chrout(' ')
txt.spc()
txt.chrout('#')
txt.print_ub(number)
txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet9 {
if species_is_alien {
if species_size < len(species_sizes) {
txt.print(species_sizes[species_size])
txt.chrout(' ')
txt.spc()
}
if species_color < len(species_colors) {
txt.print(species_colors[species_color])
txt.chrout(' ')
txt.spc()
}
if species_look < len(species_looks) {
txt.print(species_looks[species_look])
txt.chrout(' ')
txt.spc()
}
if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util9 {
sub print_right(ubyte width, uword st) {
repeat width - string.length(st) {
txt.chrout(' ')
txt.spc()
}
txt.print(st)
}

View File

@ -12,18 +12,22 @@
main {
sub start() {
txt.print("\n65c02 file based assembler.\n")
txt.print("\n65c02 file based assembler.\n\nfilename or enter for interactive: ")
; user_input()
file_input()
str filename = "?" * 20
if txt.input_chars(filename)
file_input(filename)
else
user_input()
; test_stack.test()
test_stack.test()
}
sub user_input() {
txt.lowercase()
parser.print_emit_bytes = true
txt.print("Empty line to stop.\n")
parser.program_counter = $4000
txt.print("\nEmpty line to stop.\n")
repeat {
ubyte input_length = 0
txt.chrout('A')
@ -42,55 +46,67 @@ main {
if not parser.process_line()
break
}
parser.done()
}
sub file_input() {
sub file_input(uword filename) {
parser.print_emit_bytes = false
str filename = "romdis.asm"
ubyte success = false
txt.print("\nread file: ")
txt.print("\nreading ")
txt.print(filename)
txt.nl()
txt.spc()
if diskio.f_open(8, filename) {
c64.SETTIM(0,0,0)
uword line=0
repeat {
if diskio.f_readline(parser.input_line) {
line++
if not lsb(line)
txt.chrout('.')
void diskio.f_readline(parser.input_line)
line++
if not parser.process_line() {
txt.print("\nerror. last line was ")
txt.print_uw(line)
txt.chrout(':')
txt.print(parser.word_addrs[0])
txt.chrout(' ')
if not lsb(line)
txt.chrout('.')
if not parser.process_line() {
txt.print("\nerror. last line was ")
txt.print_uw(line)
txt.print(": ")
txt.print(parser.word_addrs[0])
if parser.word_addrs[1] {
txt.spc()
txt.print(parser.word_addrs[1])
txt.chrout(' ')
}
if parser.word_addrs[2] {
txt.spc()
txt.print(parser.word_addrs[2])
txt.nl()
break
}
if c64.READST()
break
if c64.STOP2() {
txt.print("?break\n")
break
}
} else
txt.nl()
break
}
if c64.READST() {
success = c64.READST()&64==64 ; end of file?
break
}
if c64.STOP2() {
txt.print("?break\n")
break
}
}
diskio.f_close()
parser.done()
print_summary(line)
if success
print_summary(line, parser.pc_min, parser.pc_max)
} else {
txt.print(diskio.status(8))
}
}
sub print_summary(uword lines) {
txt.print("\n\nfinal address: ")
txt.print_uwhex(parser.program_counter, 1)
sub print_summary(uword lines, uword start_address, uword end_address) {
txt.print("\n\nstart address: ")
txt.print_uwhex(start_address, 1)
txt.print("\n end address: ")
txt.print_uwhex(end_address, 1)
txt.print("\n lines: ")
txt.print_uw(lines)
@ -115,8 +131,10 @@ parser {
str input_line = "?" * 160
uword[3] word_addrs
uword program_counter = $4000
ubyte print_emit_bytes = true
uword program_counter = $ffff
ubyte print_emit_bytes
uword pc_min = $ffff
uword pc_max = $0000
sub process_line() -> ubyte {
string.lower(input_line)
@ -131,6 +149,11 @@ parser {
return false
}
sub done() {
if program_counter>pc_max
pc_max = program_counter
}
sub do_assign() -> ubyte {
; target is in word_addrs[0], value is in word_addrs[2] ('=' is in word_addrs[1])
if not word_addrs[2] {
@ -152,6 +175,10 @@ parser {
txt.print("\n* = ")
txt.print_uwhex(program_counter, true)
txt.nl()
if program_counter<pc_min
pc_min = program_counter
if program_counter>pc_max
pc_max = program_counter
} else {
symbols.setvalue(word_addrs[0], cx16.r15)
}
@ -275,7 +302,7 @@ parser {
ubyte num_operand_bytes = operand_size[addr_mode]
if print_emit_bytes {
txt.chrout(' ')
txt.spc()
txt.print_uwhex(program_counter, 1)
txt.print(" ")
}
@ -406,7 +433,7 @@ parser {
return false
}
if print_emit_bytes {
txt.chrout(' ')
txt.spc()
txt.print_uwhex(program_counter, 1)
txt.print(" ")
}
@ -489,7 +516,7 @@ _is_2_entry
if print_emit_bytes {
txt.print_ubhex(value, 0)
txt.chrout(' ')
txt.spc()
}
}

View File

@ -34,7 +34,7 @@ main {
iter++
}
txt.color2(1, max_iter-iter)
txt.chrout(' ')
txt.spc()
}
txt.nl()
}

View File

@ -7,7 +7,28 @@ main {
sub start() {
txt.print("hello\n")
str filename="?"*40
txt.print("> ")
ubyte il = txt.input_chars(filename)
txt.print_ub(il)
txt.nl()
txt.print_ubhex(filename[0],1)
txt.print_ubhex(filename[1],1)
txt.print_ubhex(filename[2],1)
txt.nl()
txt.print(filename)
txt.nl()
txt.print("> ")
il = txt.input_chars(filename)
txt.print_ub(il)
txt.nl()
txt.print_ubhex(filename[0],1)
txt.print_ubhex(filename[1],1)
txt.print_ubhex(filename[2],1)
txt.nl()
txt.print(filename)
txt.nl()
}
}

View File

@ -472,7 +472,7 @@ galaxy {
txt.chrout('*')
else
txt.chrout('-')
txt.chrout(' ')
txt.spc()
planet.name = make_current_planet_name()
planet.display(true)
txt.print(" (")
@ -843,9 +843,9 @@ planet {
print_name_uppercase()
txt.print(" TL:")
txt.print_ub(techlevel+1)
txt.chrout(' ')
txt.spc()
txt.print(econnames[economy])
txt.chrout(' ')
txt.spc()
txt.print(govnames[govtype])
} else {
txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet {
txt.print_ub(x)
txt.chrout('\'')
txt.print_ub(y)
txt.chrout(' ')
txt.spc()
txt.chrout('#')
txt.print_ub(number)
txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet {
if species_is_alien {
if species_size < len(species_sizes) {
txt.print(species_sizes[species_size])
txt.chrout(' ')
txt.spc()
}
if species_color < len(species_colors) {
txt.print(species_colors[species_color])
txt.chrout(' ')
txt.spc()
}
if species_look < len(species_looks) {
txt.print(species_looks[species_look])
txt.chrout(' ')
txt.spc()
}
if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util {
sub print_right(ubyte width, uword s) {
repeat width - string.length(s) {
txt.chrout(' ')
txt.spc()
}
txt.print(s)
}