beginners' 6502 articles in the works
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: beginners' 6502 articles in the works
Yes, maybe later I'll do a follow-up for the '816, but for getting newbies into building and programming, I had to resist the constant urge to tell how much better the '816 is, since it again gets that deer-in-the-headlights look and shoos them away unintentionally.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: beginners' 6502 articles in the works
GARTHWILSON wrote:
Near the bottom of my home page it says,
New (4/27/12): 6502 PRIMER: Building your own 6502 computer
I'll go put the link in the head post of the topic now.
New (4/27/12): 6502 PRIMER: Building your own 6502 computer
I'll go put the link in the head post of the topic now.
I'm still reading your instructions and the only question which I have is how to bootstrap the 6502 and I would probably need help with bootstrapping a 65C816S as well. Maybe I didn't recognise how to do it or maybe you are still working on it?
Re: beginners' 6502 articles in the works
BigEd wrote:
Garth - good work! You've pulled together lots of useful experience and references there.
Dajgoro - Jeff Tranter wrote a couple of articles about cc65 bringup on his replica1 recently which might help you.
Cheers
Ed
Dajgoro - Jeff Tranter wrote a couple of articles about cc65 bringup on his replica1 recently which might help you.
Cheers
Ed
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: beginners' 6502 articles in the works
ChuckT wrote:
This is great. Thank you. I'll leave it up to you if you want to post it on Hackaday because it will bring you a lot of traffic. The do-it-yourself crowd has forums at Sparkfun, Parallax, Hackaday, Dangerousprototypes, Make and Adafruit. I'm sure they would blog about your article which would be good but the traffic part is the board owner's decision because Hackaday's blog alone could bring you over 1,000 visitors in a week.
Quote:
I'm still reading your instructions and the only question which I have is how to bootstrap the 6502 and I would probably need help with bootstrapping a 65C816S as well. Maybe I didn't recognise how to do it or maybe you are still working on it?
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: beginners' 6502 articles in the works
For the 816, I'd restrict yourself, at most, to an appendix pointing out that it's a CPU with a lot of extra features. At power-up it runs in an emulation mode which gives it some extra features which are useful, but otherwise is highly compatible. If you make use of the extra instructions your software is of course no longer able to run on a 65C02. It's a good CPU to choose if you want to address more than 64k of memory with a minimum of effort. Then refer to a fuller document about the '816. (Edit: for a programmer perspective, "A 65816 Primer" is good.)
As you say, if you bring it to the forefront it all becomes too scary. Pacing is important!
(On bootstrapping, I see you have some words here about the vectors and initialising the hardware as the first actions in a ROM. Maybe there could be a section header to make it stand out more.)
(On the HTML: I'm seeing the overbars, on Chrome.)
Cheers
Ed
As you say, if you bring it to the forefront it all becomes too scary. Pacing is important!
(On bootstrapping, I see you have some words here about the vectors and initialising the hardware as the first actions in a ROM. Maybe there could be a section header to make it stand out more.)
(On the HTML: I'm seeing the overbars, on Chrome.)
Cheers
Ed
Last edited by BigEd on Mon Apr 30, 2012 9:40 am, edited 2 times in total.
Re: beginners' 6502 articles in the works
On the subject of the Phi symbols, I used the HTML entity codes Φ and φ to get the upper and lower case phi characters - instead of pasting them directly into the source, as you have them - and the result is like this:
(the processor having the Φ2 output that feeds the φ2 inputs of all the I/O chips)
[That's text, so it will display in a browser as it would for your page.]
See also image attached, which is how it shows in my browser.
For the benefit of readers not familiar with the Greek alphabet, I recommend you spell out that the signal and pin are pronounced Phi2, if you don't already.
Cheers
Ed
(the processor having the Φ2 output that feeds the φ2 inputs of all the I/O chips)
[That's text, so it will display in a browser as it would for your page.]
See also image attached, which is how it shows in my browser.
For the benefit of readers not familiar with the Greek alphabet, I recommend you spell out that the signal and pin are pronounced Phi2, if you don't already.
Cheers
Ed
- Attachments
-
- phi.png (4.36 KiB) Viewed 1672 times
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: beginners' 6502 articles in the works
BigEd wrote:
(Edit: for a programmer perspective, "A 65816 Primer" is good.)
- Additionally, the 65816 offers full 6502 emulation, new addressing modes,
full 16 bit user registers, and dozens of new instructions.
In emulation mode, the W65C816S is approximately a 65C02, not a 6502. I say "approximately" because all 256 opcodes perform valid operations regardless of processor mode, hence all of the illegal opcodes that exist in the NMOS 6502, as well as the 65C02, map to valid '816 instructions. Therefore, emulation mode in the '816 is definitely not like the operation of the NMOS 6502. This mistake is not good when you consider the above statement is right near the beginning of the primer. It conceivably could lead a beginner to erroneously believe that in emulation mode the '816 behaves just like the NMOS 6502.
Here's another one:
- Two other new registers are the Data Bank Register and the Program Bank
register. The Program Bank Register functionally extends the program
counter out to 24 bits, while the Data Bank register allows code flow
control to branch or jump to points outside of the 6502's 64k address
space.
While PB does permit code execution to occur in any of the 256 possible memory banks that can exist in the 16 MB environment, it doesn't "extend" the program counter (PC). If PC is $FFFF and a one byte instruction is executed, PC will wrap to $0000, but PB will not autoincrement. Hence if PB contains $4A the successive execution addresses would be $4AFFFF and $4A0000, limiting the program to a 64K address space, same as the 65(c)02. Only the "long" jump and JSR instructions allow execution to be diverted to a different bank. Relative branches cannot occur outside the current bank. It is possible to manipulate PB via stack acrobatics, but is not something a beginner should be trying.
DB has nothing to do with program flow control at all. DB determines from which bank a load, store or read-modify-write instruction will access data. The instruction itself is retrieved from the bank defined by PB. However, bank boundaries can be crossed by load, store and read-modify-write operations. For example:
Code: Select all
SEP #%00110000 ;8 bit registers
LDX #$00
LDA $FFFF,X
INX
STA $FFFF,XIn a system with more than 64 KB of addressable RAM, understanding the effects of these registers is fundamental to successfully writing '816 code, so the above errors are not good at all.
Yet another:
- Here is a run down of some of the new fun stuff:
* XYA registers can be 16 or 8 bits wide.
* Wow, two actual Block Move Memory instructions.
* New push/pull instructions phx,plx,phy,ply. [Editor: These exist in the 65C02, so they aren't new.]
* New xfer instructions tyx,txy.
* Set or Reset any memory bit without loading the accumulator. [Editor: Wrong. A mask has to be in the accumulator so the '816 knows which bit(s) to twiddle.]
* INC and DEC the accumulator.
* JSR indirect, Branch Always, or Branch Long to 64k. [Editor: Wrong regarding branch long—it's a ±32K branch, not a 64K one.]
* Zero Page has been renamed to Direct Page...
I've thought about writing a "Getting Started with the 65C816" article—I do have more than a little experience with the processor.
Last edited by BigDumbDinosaur on Mon Apr 30, 2012 10:04 pm, edited 1 time in total.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: beginners' 6502 articles in the works
Fair enough(*). I've bookmarked it as good place to find a summary, but I am already familiar. I think the point is well made by your critique (and by Bruce's work in progress) that there are a wealth of devilish details.
Edit: Sorry, I didn't mean "Fair enough" - I meant some variation on "I don't wish to argue with you at this time". An unfortunate word choice, because I can't let it stand - I don't think your critique is altogether fair. I think the document is, broadly, well done. One would use it as a primer, not to replace the datasheet. You are right to point out the error about the Data Bank Register. The author clearly understands the machine, and should have said that the Address Bus is extended to 24 bits, by means of two registers, one for program accesses and one for data accesses. (I've come across this thinko before, to confuse PC with the Address Bus.) As we know, there are also stack and direct page accesses, and vector accesses - the '816 is a wealth of details which defy simple glosses. It is not a beginner's machine unless one allows for some staged introduction of truths.
I can't agree with your opening comment about full 6502 emulation - in the context of the Primer, the author clarifies what he means beyond his opening remarks, as is appropriate. But as I say, I have no appetite for a point-by-point.
(I'll PM you so this after-the-fact edit isn't secret)
Cheers
Ed
Edit: Sorry, I didn't mean "Fair enough" - I meant some variation on "I don't wish to argue with you at this time". An unfortunate word choice, because I can't let it stand - I don't think your critique is altogether fair. I think the document is, broadly, well done. One would use it as a primer, not to replace the datasheet. You are right to point out the error about the Data Bank Register. The author clearly understands the machine, and should have said that the Address Bus is extended to 24 bits, by means of two registers, one for program accesses and one for data accesses. (I've come across this thinko before, to confuse PC with the Address Bus.) As we know, there are also stack and direct page accesses, and vector accesses - the '816 is a wealth of details which defy simple glosses. It is not a beginner's machine unless one allows for some staged introduction of truths.
I can't agree with your opening comment about full 6502 emulation - in the context of the Primer, the author clarifies what he means beyond his opening remarks, as is appropriate. But as I say, I have no appetite for a point-by-point.
(I'll PM you so this after-the-fact edit isn't secret)
Cheers
Ed
Last edited by BigEd on Tue May 01, 2012 4:31 am, edited 1 time in total.
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: beginners' 6502 articles in the works
BigDumbDinosaur wrote:
Full 6502 emulation? Ain't no such a thing!
In emulation mode, the W65C816S is approximately a 65C02, not a 6502. I say "approximately" because all 256 opcodes perform valid operations regardless of processor mode, hence all of the illegal opcodes that exist in the NMOS 6502, as well as the 65C02, map to valid '816 instructions. Therefore, emulation mode in the '816 is definitely not like the operation of the NMOS 6502. This mistake is not good when you consider the above statement is right near the beginning of the primer. It conceivably could lead a beginner to erroneously believe that in emulation mode the '816 behaves just like the NMOS 6502.
In emulation mode, the W65C816S is approximately a 65C02, not a 6502. I say "approximately" because all 256 opcodes perform valid operations regardless of processor mode, hence all of the illegal opcodes that exist in the NMOS 6502, as well as the 65C02, map to valid '816 instructions. Therefore, emulation mode in the '816 is definitely not like the operation of the NMOS 6502. This mistake is not good when you consider the above statement is right near the beginning of the primer. It conceivably could lead a beginner to erroneously believe that in emulation mode the '816 behaves just like the NMOS 6502.
Quote:
* Wow, two actual Block Move Memory instructions.
Quote:
* Set or Reset any memory bit without loading the accumulator. [Editor: Wrong. A mask has to be in the accumulator so the '816 knows which bit(s) to twiddle.]
Quote:
* INC and DEC the accumulator.
Quote:
I've thought about writing a "Getting Started with the 65C816" article—I do have more than a little experience with the processor.
However, as I'm sure Garth would quickly point out, writing beginners' articles in a clear and understandable manner, proof-reading and fact-checking, and then polishing the presentation so one won't later wince when s/he sees it in lights on the Internet is a painstaking and time-consuming process.
A non-trivial part of writing is making it so you get the reader's interest immediately. Otherwise they will probably move on even if your article is full of gems. Even wording a title that attracts the reader can take a lot of time.
In an '816 primer, I would want to point out, up front, that the '816 gives a ton of benefits even if you only use the first 64K of memory map, that you don't have to latch, decode, or use the upper 8 address bits to run it, and that especially if you frequently handle 16-bit values, the '816 is much easier to program.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: beginners' 6502 articles in the works
GARTHWILSON wrote:
Quote:
* Wow, two actual Block Move Memory instructions.
Quote:
Quote:
* Set or Reset any memory bit without loading the accumulator. [Editor: Wrong. A mask has to be in the accumulator so the '816 knows which bit(s) to twiddle.]
Quote:
Quote:
* INC and DEC the accumulator.
Quote:
Quote:
However, as I'm sure Garth would quickly point out, writing beginners' articles in a clear and understandable manner, proof-reading and fact-checking, and then polishing the presentation so one won't later wince when s/he sees it in lights on the Internet is a painstaking and time-consuming process.
Quote:
A non-trivial part of writing is making it so you get the reader's interest immediately. Otherwise they will probably move on even if your article is full of gems. Even wording a title that attracts the reader can take a lot of time.
- The W65C816S is an upgrade of the 6502.
- The W65C816S will enable you to write shorter, faster and more elegant programs than possible with the 6502—and with less difficulty.
Quote:
In an '816 primer, I would want to point out, up front, that the '816 gives a ton of benefits even if you only use the first 64K of memory map, that you don't have to latch, decode, or use the upper 8 address bits to run it, and that especially if you frequently handle 16-bit values, the '816 is much easier to program.
As I developed the POC's BIOS ROM I retained all the old versions, and looking back at them, I can see where I could not have fit the entire BIOS plus the machine language monitor plus the Motorola S-record loader into the 8 KB ROM space had I stuck with "traditional" 6502 coding styles. In particular, the SCSI host adapter device driver (which is full of bit twiddling), along with the code that enumerates the SCSI bus and attempts an ISL from the boot disk, simply wouldn't have fit.
So there are significant advantages to using the '816 in native mode, even without taking advantage of the extended memory addressing. Once one gets over the initial hurdle of understanding the effects of 8 versus 16 bit operation, writing '816 code becomes substantially easier than accomplishing the same tasks solely with 8 bit operations.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: beginners' 6502 articles in the works
GARTHWILSON wrote:
ChuckT wrote:
This is great. Thank you. I'll leave it up to you if you want to post it on Hackaday because it will bring you a lot of traffic. The do-it-yourself crowd has forums at Sparkfun, Parallax, Hackaday, Dangerousprototypes, Make and Adafruit. I'm sure they would blog about your article which would be good but the traffic part is the board owner's decision because Hackaday's blog alone could bring you over 1,000 visitors in a week.
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: beginners' 6502 articles in the works
Chuck (and anyone else), the initial barage of corrections after publication seems to be over, so it would be great if you would tell the other forums you're on about the articles.
Now I'm working on the EPROMs for the big look-up tables for 16-bit math, the multiplication, inversion, log & trig functions, etc.. I can't believe I calculated the Intel Hex files 11 years ago! They've just been collecting dust all this time. It would not be hard to provide EPROMs for anyone who wants them, so I've just ordered some 1Mx8 ones that I think my old programmer can handle, and I'm trying to figure it out again, then I'll build up and actual circuit and check them to make sure I didn't take a left turn into the weeds someplace. Of course as we all know, EPROMs are slow, but the plan is to also put the Intel Hex files on my website (along with the HP-71 programs I used to calculate the numbers and form the files), so the reader can also have a way to load them into RAM from serial flash, or whatever. I will offer the programmed EPROMs too. If you want to do a lot of scaled-integer math, looking up answers, correct to all 16 bits (or in the case of inverses, all 32 bits!), will be extremely fast compared to actually calculating them.
I've kept thinking about how to make an article attract the reader. For some future ones, I want to instantly spark the imagination of what could be done with these techniques/circuits/programs/etc. if the reader were to go for it. I should still try to find at least a good picture or two to put in the introduction to my "Building Your Own 6502" articles. Even the front page of a data sheet is kind of a sales job, trying to grab your attention immediately with "Why you want this IC!" The disclaimers, copyrights, licenses, contact info, errata, etc. go near the end.
Now I'm working on the EPROMs for the big look-up tables for 16-bit math, the multiplication, inversion, log & trig functions, etc.. I can't believe I calculated the Intel Hex files 11 years ago! They've just been collecting dust all this time. It would not be hard to provide EPROMs for anyone who wants them, so I've just ordered some 1Mx8 ones that I think my old programmer can handle, and I'm trying to figure it out again, then I'll build up and actual circuit and check them to make sure I didn't take a left turn into the weeds someplace. Of course as we all know, EPROMs are slow, but the plan is to also put the Intel Hex files on my website (along with the HP-71 programs I used to calculate the numbers and form the files), so the reader can also have a way to load them into RAM from serial flash, or whatever. I will offer the programmed EPROMs too. If you want to do a lot of scaled-integer math, looking up answers, correct to all 16 bits (or in the case of inverses, all 32 bits!), will be extremely fast compared to actually calculating them.
I've kept thinking about how to make an article attract the reader. For some future ones, I want to instantly spark the imagination of what could be done with these techniques/circuits/programs/etc. if the reader were to go for it. I should still try to find at least a good picture or two to put in the introduction to my "Building Your Own 6502" articles. Even the front page of a data sheet is kind of a sales job, trying to grab your attention immediately with "Why you want this IC!" The disclaimers, copyrights, licenses, contact info, errata, etc. go near the end.
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: beginners' 6502 articles in the works
GARTHWILSON wrote:
Chuck (and anyone else), the initial barage of corrections after publication seems to be over, so it would be great if you would tell the other forums you're on about the articles.
You currently have 23 or 24 people viewing the forums here.
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: beginners' 6502 articles in the works
Thanks. I had to resist the urge to answer Mr. nes's comment there and tell why the 65816 is way better than his 6809. 
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
-
ElEctric_EyE
- Posts: 3260
- Joined: 02 Mar 2009
- Location: OH, USA
Re: beginners' 6502 articles in the works
I'm sure he would appreciate the education.