BillO wrote:
GARTHWILSON wrote:
..., but it's slower than something like a 6522 ...
I had a look at your serial code for the 6522. Excuse my inexperience, but that did not look like any assembler code I cut my teeth on centuries ago. Do you mind my asking what assembler you use?
I'm not sure which serial code you're referring to; maybe http://wilsonminesco.com/6502primer/SPI.ASM ? The comments there include:
Code:
; For SEND_BYT and RCV_BYT below, I use program structures discussed in my web page
; http://wilsonminesco.com/StructureMacros/ . The source code for implementing them on the C32 assembler is at
; http://wilsonminesco.com/StructureMacros/STRUCMAC.ASM , but you can undoubtedly see what they will assemble
; if you want to do it without the macros. I used them here to make it more clear what is happening.
Cross-32 (C32) is a very nice macro assembler originally from Universal Cross Assemblers in Canada, but now is being sold by Data Sync Engineering. [Edit, 2023: It's gone. I'm trying to find out where else we can get it, or if I could distribute it myself.] For $99, you get an assembler that's good for at least about 50 different processors, and they give you the information to make up the tables to assemble even for a processor of your own design, so you don't have to write your own assembler for it. It's an excellent, powerful macro assembler that runs on your PC. It adheres to the manufacturer's recommended notation for 65xx assembly language.
The structure macros however are my own creation—although as soon as I made them, I found that others have done the same kind of thing. As with any macro, they hide the confusing or ugly internals, so that once you have them written and debugged, they do the exact same thing you would do by hand, but now you don't have to look at those innards anymore. Your code becomes more clear and concise; and since you can see what you're doing better, you become more productive and produce fewer bugs. A simple example is this loop where you want to keep looping until the Z flag is set:
Code:
BEGIN
<do stuff>
<do stuff>
<do stuff>
UNTIL_ZERO ; ("UNTIL_EQ" would do the same thing)
The "UNTIL_ZERO" just assembles a BNE (as you would expect), but you don't need a label, because the assembler remembered where to branch back to because of the "BEGIN." You can nest these too, for example having another similar loop inside this one, and each branch will go to the right target address. You can of course still use the normal instructions you're already used to as well, like if you want to use a label and have another routine jump into the middle of this one.
Having the macros never limits you. They only open up more possibilities. See the article at http://wilsonminesco.com/StructureMacros/ which starts with the very basics of macros and works its way up to the program structure macros. It has links to the macro source code and to further explanation in the 6502 stacks treatise for those who want to go further.
OTOH, if you're referring to the I²C code at http://wilsonminesco.com/6502primer/GENRLI2C.ASM, I wrote that before I had the 65c02 structure macros going, and it has several sections, including 65c02 assembly, Forth, and PIC12 assembly. From the file:
Code:
; This file has five sets of source code:
; A. 65c02 source code for running the I2C interface as shown in the 6502
; primer's "potpourri" page. I ran it with the actual circuit just enough
; to have a degree of confidence the I'm not steering you wrong.
; B. a section on changes to make if you use different bit numbers
; C. my working Forth source code for using the 24256 32Kx8 I2C EEPROM. Even if
; you don't know Forth, much of it should be pretty clear as to what order
; things need to happen in to interface to this 8-pin serial EEPROM.
; It is profusely commented.
; D. my working Forth code for operating the MAX520 quad D/A converter.
; E. my working PIC code for running a tiny 24c00 EEPROM that was put as a
; separate die in the PIC12CE673 we used for a product.
I have a list of 65xx assemblers on my links page, at http://wilsonminesco.com/links.html#assem . Most of them are free, and a couple of them were written by our own forum members.