Page 2 of 5
Re: 6502 with a serial port - a minimal monitor?
Posted: Tue Jul 09, 2013 12:33 am
by 8BIT
Here's the package. Assembles into $F700-$FFFF (2303 bytes).
There's a readme file included. Just fix the ACIA1.asm code for your terminal, and assemble.
Daryl
Re: 6502 with a serial port - a minimal monitor?
Posted: Tue Jul 09, 2013 12:38 pm
by 8BIT
I just realized that I had the CRC tables in the upload.asm files. I can save another 512 bytes of ROM by generating the tables in RAM, as long as there's enough RAM in the target. The new code is < 2k (1792 bytes). The tables need to be placed in RAM where they won't get overwritten by the files being downloaded.
The new file is attached with added directions in the readme.
Daryl
Re: 6502 with a serial port - a minimal monitor?
Posted: Tue Jul 09, 2013 3:29 pm
by enso
...I can save another 512 bytes of ROM by generating the tables in RAM, as long as there's enough RAM in the target. The new code is < 2k (1792 bytes)...
That is great! I was about to ask you if it's possible to bring the size under 2K as I am having a really hard time loading multiple 2K BRAMs...
Thanks again! I will try to integrate your code today.
Re: 6502 with a serial port - a minimal monitor?
Posted: Tue Jul 09, 2013 4:17 pm
by Arlet
Instead of using CRC tables, you could also update the CRC by code. It'll be slower, but with a 50/100MHz core, it's probably fast enough for practical purposes.
Re: 6502 with a serial port - a minimal monitor?
Posted: Tue Jul 09, 2013 5:33 pm
by enso
I presume CRC is for XModem... personally I haven't had any issues just sending binaries across the serial port, assuming the handshaking works...
Re: 6502 with a serial port - a minimal monitor?
Posted: Tue Jul 09, 2013 10:48 pm
by enso
Oy! I didn't realize the monitor is full of 65C02 instructions... Arlet's core does 6502 only. Why isn't anything easy?
Re: 6502 with a serial port - a minimal monitor?
Posted: Tue Jul 09, 2013 10:52 pm
by 8BIT
I presume CRC is for XModem... personally I haven't had any issues just sending binaries across the serial port, assuming the handshaking works...
Yes, xmodem uses it for error detection. When sending binaries, do you have to give your receiver code the start address and file length, or is it embedded in the binary. Also, from the terminal side, how do you send a raw binary file? I tried that a long time ago but the only way to send a raw file was a text file. The programs seemed to skip sending 0x00 and sometimes 0x1b (Esc). That's when I resorted to writing the xmodem code.
Daryl
Re: 6502 with a serial port - a minimal monitor?
Posted: Tue Jul 09, 2013 10:54 pm
by 8BIT
Oy! I didn't realize the monitor is full of 65C02 instructions... Arlet's core does 6502 only. Why isn't anything easy?
Easy would be nice.... I can take a look and fix the code - should not be too hard. I can switch Tass to only assemble 6502 opcodes.
Daryl
Re: 6502 with a serial port - a minimal monitor?
Posted: Tue Jul 09, 2013 11:07 pm
by GARTHWILSON
I presume CRC is for XModem... personally I haven't had any issues just sending binaries across the serial port, assuming the handshaking works...
Yes, xmodem uses it for error detection. When sending binaries, do you have to give your receiver code the start address and file length, or is it embedded in the binary. Also, from the terminal side, how do you send a raw binary file? I tried that a long time ago but the only way to send a raw file was a text file. The programs seemed to skip sending 0x00 and sometimes 0x1b (Esc). That's when I resorted to writing the xmodem code.
Intel hex (or other hex output, like Mot S19) works, since assemblers generally produce these anyway for EPROM programmers. I've used it sometimes, and in fact my PIC programmer (using the workbench computer) uses it, as if the PC were printing the Intel hex file to a serial (RS-232) printer but really the workbench computer takes it and puts it in RAM to program into the PIC.
Re: 6502 with a serial port - a minimal monitor?
Posted: Wed Jul 10, 2013 2:34 am
by BigDumbDinosaur
I presume CRC is for XModem... personally I haven't had any issues just sending binaries across the serial port, assuming the handshaking works...
Yes, xmodem uses it for error detection. When sending binaries, do you have to give your receiver code the start address and file length, or is it embedded in the binary. Also, from the terminal side, how do you send a raw binary file? I tried that a long time ago but the only way to send a raw file was a text file. The programs seemed to skip sending 0x00 and sometimes 0x1b (Esc). That's when I resorted to writing the xmodem code.
Daryl
I use Motorola S-records for transmitting code to POC. No need for something as convoluted as Xmodem on a short-range (under 50 meters) serial link, as long as a reliable form of handshaking is in place. Motorola S-record (or Intel hex) has a built-in error checking regime that is adequate for such usage, and is faster.
Xmodem and its progeny are primarily of value when data goes through modems. Even then, Xmodem is of questionable value, since all modern modems are capable of error checking in hardware.
Re: 6502 with a serial port - a minimal monitor?
Posted: Wed Jul 10, 2013 5:17 am
by Arlet
Also, from the terminal side, how do you send a raw binary file?
Use
TeraTerm. Not only does it have an option to send binary files, but it also supports a scripting language, so you can write complete upload scripts.
Re: 6502 with a serial port - a minimal monitor?
Posted: Wed Jul 10, 2013 5:20 am
by enso
... I can take a look and fix the code - should not be too hard...
That would be great. There are only a few places but I am worried about side effects as I am not familiar with your flag and register usage.
I've been using GtkTerm - it lets you send a binary. It doesn't have scripting, but allows you to see and send hex bytes and twiddle handshaking lines, which is nice for debugging the serial port.
EDIT: in Linux you can also
. Some terminals don't lock the serial port so you can copy while the terminal is open. You can do a similar copy in windows, although I can't remember the exact syntax for the serial port.
Re: 6502 with a serial port - a minimal monitor?
Posted: Wed Jul 10, 2013 1:27 pm
by 8BIT
If the consensus is that xmodem is of no value, then it can be removed - reducing the Monitor to <1k. It would be about 1.5k with the Intel-hex downloader still on board. Those two are combined in one file but could be split apart if desired. It's pretty easy to modify the Monitor code to support more or less commands.
Enso, you can remove the xmodem code and replace with your own binary file transfer code if that is your preference. I can show you how to integrate it into the Monitor.
Will try to work on the 65C02-> 6502 code tonight.
Daryl
Re: 6502 with a serial port - a minimal monitor?
Posted: Wed Jul 10, 2013 3:10 pm
by enso
...I can show you how to integrate it into the Monitor....
I would appreciate any help you can offer. I will be happy to add binary transfer commands (it should be a couple lines of code).
BTW, having the monitor well under 2K is great as it allows us to use the same 2K BRAM for both hight ROM/vector/monitor ROM and page 0 and 1 RAM.
Thank you again for all the help

I think your minimal monitor/loader will be a great asset to our community. I know I personally could have used it a few times in the last few years.
Re: 6502 with a serial port - a minimal monitor?
Posted: Wed Jul 10, 2013 6:48 pm
by enso
I wrote a little parser that reads tass files and with the intention of writing out Kingswood-compatible files. Right now it just dumps the lines to the output file, fields separated by |
It splits each assembly line into 4 fields (label,opcode,operand,comment) and gives you a chance to process it and write it out. It is very easy to adapt to output any kind of code (and possibly turn into an assembler...)
I wrote it in python as I always wanted to learn it, and it seems like a pretty good language for text manipulation. Until today I haven't written a line of python - it is pretty easy (I am sure my code is terrible for those who know the language - suggestions welcome)
Code: Select all
#!/usr/bin/env python3
import sys
fileIn = open(sys.argv[1], "r")
fileOut = open("out.txt","w")
line = fileIn.readline()
lineno=0
while line:
label=''
opcode=''
operand=''
comment=''
lineno=lineno+1
#Comment lines must be skipped
if not line.strip().startswith(';'): #first character is ;
#split off the label
x = line.partition(' ')
if x[1]==' ': #split successful
label=x[0].strip()
l=x[2].strip()
#now split off the comment
x = l.partition(';')
if x[1]==';':
comment=';'+x[2].strip()
l=x[0].strip()
#now separate opcode and operand
x=l.partition(' ')
opcode=x[0].strip()
if x[1]==' ':
operand=x[2].strip()
#unchanged line write on empty (which happens for comment-only lines too)
if not label and not opcode and not comment:
fileOut.write(line)
line = fileIn.readline()
continue
# pad the columns
label = label.ljust(16,' ') #pad label column
opcode = opcode.ljust(6,' ')
operand = operand.ljust(18,' ')
#-----------------------------------------------
# write line
fileOut.write ('%s\n' % '|'.join(map(str, [label,opcode,operand,comment]) ))
line = fileIn.readline()
EDIT: fixed errors.
Strategy:
- -skip lines containing only comments
-separate the label (must begin in first column and end with whitespace)
-separate the comment (anything after ; )
-split the remaining part into opcode and operand at the first whitespace
Output looks like:
Code: Select all
|bne |Asm_txt9 ; no, closing, so done
|bra |Asm_txt1 ; yes, get first text chr
Asm_txt3 |cpy |#$ff ; already found opening "?
|beq |Asm_txt4
|sta |(AddrPtr),y ; yes, save chr