14:16 The Nintendo 6502 decap and IC photograph show that it uses the exact the same 6502 layout as the Apple and includes all of the BCD logic however a very tiny (few gate) modification has been made to disable the Decimal mode from working. This was to avoid the patent you mentioned as they weren't exactly paying MOS appropriately for the use of the 6502. As mentioned elsewhere, on systems like the 2600 BCD was useful to do decimal scoring in games.
Another 6502 programmer here from Commodore 64 camp Instruction manuals which came with the computers post 8bit continue to lack. So hard to find books back then. Much longer distance than a click away.
I am just starting out. I am building the Ben Eater computer on a breadboard. I am using the ca65 and ld65 (assembler and linker). I am going to be watching your awesome guide lets says many many times, and taking notes. Ty for sharing.
BCD Decimal arithmetic commands we often used in apple][ games in fact! They were used just to increment/display game score in decimal. It saved dozens of bytes.
Atari Basic is slow because it uses a BCD library in the O.S. that was written by someone who didn't know how to write a math package. Years later someone came out with Turbo Basic where they replaced the BCD library with one written to be much faster. It's about 4 times faster than the original Atari Basic.
5:56 There are actually only 3 instruction groups (according to my 1976 650x programming manual). If bit 0 is set it is a group 1 instruction with 16 addressing modes, 8 of which have been defined. These are the Accumulator work horse instructiinsxand every instruction has every one of the 16 address modes. If bit 0 is 0 and bit 1 is 1 it is a group 2 instruction which are the bit shifting, X and INC/DEC instructions - not all instructions can have all 8 of the possible addressing modes. If bits 0 and 1 are both clear then it's the group 3 instructions which are the Y and the rest instructions. These have near enough the same addressing modes as group 1. In group 1 if bit 1 is set it is one of the 8 addressing modes reserved/defined for future expansion, so group 1 can be split into 1A if bit 1 is unset and 1B if it is set. This does allow the split you gave with bits 0&1 the group: 0 - Group 3 1 - Group 1A 2 - Group 2 3 - Group 1B (all future expansion) The 3 address mode bits are consistent in group 1A, and fairly consistent between Groups 2&3 where the moses are defined slightly differently. Using the 3-bit, 3-bit, 2-bit model you suggest shows that some instructions have the wrong OP Code. eg TYA ought to be $88, CLV ought to be $98 (based on how the other instructions in their groups behave with the same addressing modes). DEX, DEY, INX, INY, NOP ought to be elsewhere as well. Missing instructions can be seen where they should be in the instruction set based on the addressing modes available (eg STX Z,Y; CPY Z,X; CPY abs, X). JMP ought to be, say $40 (as that then matches the addressing mode 000 for group 3 instructions which is immediate data, instructions 0-3 use 2 bytes, 4-7 use 1 byte - BRK, RTI and RTS effectively ignore the 2 byte immediate data, and it vaguely explains BRK pushing instruction address + 2 on the stack).
In other 1975 events: Linda Ronstadt had her first and only number 1 single with "You're No Good" (for one week in February 1975). Elton John's Captain Fantastic and the Brown Dirt Cowboy and Rock of the Westies both debuted at number 1 on the Billboard 200.
11:47 The group 2 addressing modes are: 000 - £ (immediate) 001 - ZP 010 - A 011 - absolute 100 - PC relative (not used) * 101 - ZP,X (ZP,Y for X reg instr) 110 - S (stack pointer) 111 - absolute,X (abs,Y for X reg instr) STX A = TXA, LDX A = TAX STX S = TXS, STX A = TXS No other instructions in group 2 use S. DEC A and INC A are replaced by DEX and NOP * This was "guessed" by group 3 addressing modes which are the same, except A and S are implied modes.
Video memory addresses were often arranged in an unintuitive way - although not always as tricky as in the Apple II. The reason for this is that it was Dynamic RAM, that had to be refreshed within a certain time frame to retain its contents. To create the video output signal, the video chip had to read the RAM in a repetitive way anyway, and if the addresses were interwoven in the right manner, this continuous read operation could have been used as the DRAM refresh.
Despite all of its weirdness and limitations, the fact that the Apple ][ had built-in color graphics made it the first personal computer that could be a video game platform. Other 8-bit computers had much better capabilities, but they came later and were able to use custom chips.
Very nice video! ...but at 1:00 "Everything had to go through the accumulator" is not totally true (Ack, watching your entire video, I now see you cover this really well and this comment should probably be deleted!) . Many useful operations do not require the accumulator. For example you can rotate, shift, increment, decrement memory locations. Yes, a read modify write operation is performed by the processor on the data, but it, does not affect the accumulator. Instead an "invisible" data register on the CPU (and actually an "invisible" address register) is used. For example to left shift a 24 bit value located at $1 to $3 in memory. (zero page in this case) the instructions ASL $1, ROL $2, ROL $3 would be executed with no impact on the accumulator. This is a lot nicer than having to write LDA $1, ASL, STA $1, LDA $2, ROL, STA $2, LDA $3, ROL STA $3 which you would have to do without this feature and saves a few machine cycles (9 - I think) and code length (9 bytes shorter). Similarly you can increment and decrement memory locations where zero flag is useful if you have a multi-byte data where branch would be used to skip incrementing higher order byte when the lower order byte is not zero after its increment, e.g. 16 bit counter stored in $0 and $1: INC $0, BNE 1, INC $1 (where BNE is branch if not zero +1 instructions skipping INC $1. Hopefully this is pretty accurate, I wrote a ton of 6502 code 1979 to 1982 and NONE since, except I did kind of check my comment using an Apple II emulator I just downloaded with Integer basic ROM model including WOZ's mini-assembler. One final comment, of course if you wanted to do something like add two values in memory or add a constant to a value, then the accumulator would be needed for that.
I remember struggling trying to write Assembly code in High School with no book to refer to. Was able to do things, but the concept of the interrupt was beyond me at the time. I would have loved to have had those two books you refer to. Alas, the age of the 6502 has passed.
feels like wozniak on LSD when he came up with the graphics scheme. So you can't have 3 pixels blue green purple next to each other horizontally. Talk about limitations!
It's a shame that you can't tag people here. Else I would be tagging Ben Eater, or The 8 Bit Guy on this video, they'd for sure enjoy this just as I did.
The answer is no, the balls did not move fast enough, I built a chip 8 emulator a while back that did the same thing to draw characters, so i wondered about it
I am always baffled when programmers (who ought to know better) don't grasp, fundamentally, what a sprite is. Maybe it's just too exotic a hardware construct for softees to understand? This is the first time however I have ever seen a serious programmer conflate Apple II shape tables with sprites. This is like having a division routine and calling it a "math coprocessor".
I'm baffled how someone managed to make it to 2023 without realizing that the vast majority of people are not talking about hardware sprites when they say "sprite".
I am interested in learning more about 6502 machine language. I have only been working with it on the KIM-1 for about 1 year and I created my own OP Code diagram which included the different addressing modes. That you explained in this video very well. Keep in mind that I am new to studying the 6502 and it's Op Codes, so there may be a mistake or two in my diagram. Please let me know if you find one. drive.google.com/file/d/1stT1klHHyHeuhXuHmm77puHzOgLKEF2Q/view?usp=drive_link I hope this table helps other 6502 enthusiasts like myself. Anyhow, I was interested in the way you were looking at the least significant bits starting with Group One (01) - Which basically repeats everything down columns 1,5,9,D and Group Two (10) - Which repeats everything down columns 2,6,A and E. I could also see how Group Three (11) - Which would include columns 3,7,B,F have nothing in them at all and Group 4 (00) which contains columns 0,4,8,C that do not repeat each other. Now when I look at the most significant bits or the rows across my table. I can see a similar pattern when it applies to addressing modes. Group 0 (0000) and 2 (0010) contain the same addressing modes as you look across each row and down each column. Group 1 (0001) and 3 (0011) also contain the same addressing modes as you look across and down each column.
One of the best videos on RUclips for the retro crowd. Your summation of the 6502 instruction set was excellent.
Superb video. If I had a time machine, I'd go back and show it to my teenage self!
14:16 The Nintendo 6502 decap and IC photograph show that it uses the exact the same 6502 layout as the Apple and includes all of the BCD logic however a very tiny (few gate) modification has been made to disable the Decimal mode from working. This was to avoid the patent you mentioned as they weren't exactly paying MOS appropriately for the use of the 6502.
As mentioned elsewhere, on systems like the 2600 BCD was useful to do decimal scoring in games.
This is very informative, explaining the instructions in logical groups is excellent.
Another 6502 programmer here from Commodore 64 camp
Instruction manuals which came with the computers post 8bit continue to lack.
So hard to find books back then. Much longer distance than a click away.
This video's place is in a museum. Woz would agree.
If I had been born in those times and had known you, I would consider you my best friend. We would have been two nerds doing awesome nerd things!
So well spoken, thank you.
This is a masterpiece!!!!
Such a clear and well done presentation!
I am just starting out. I am building the Ben Eater computer on a breadboard. I am using the ca65 and ld65 (assembler and linker). I am going to be watching your awesome guide lets says many many times, and taking notes. Ty for sharing.
BCD Decimal arithmetic commands we often used in apple][ games in fact! They were used just to increment/display game score in decimal. It saved dozens of bytes.
Atari Basic is slow because it uses a BCD library in the O.S. that was written by someone who didn't know how to write a math package. Years later someone came out with Turbo Basic where they replaced the BCD library with one written to be much faster. It's about 4 times faster than the original Atari Basic.
Great video! Very well explains Assembly! Thank you!
5:56
There are actually only 3 instruction groups (according to my 1976 650x programming manual).
If bit 0 is set it is a group 1 instruction with 16 addressing modes, 8 of which have been defined. These are the Accumulator work horse instructiinsxand every instruction has every one of the 16 address modes.
If bit 0 is 0 and bit 1 is 1 it is a group 2 instruction which are the bit shifting, X and INC/DEC instructions - not all instructions can have all 8 of the possible addressing modes.
If bits 0 and 1 are both clear then it's the group 3 instructions which are the Y and the rest instructions. These have near enough the same addressing modes as group 1.
In group 1 if bit 1 is set it is one of the 8 addressing modes reserved/defined for future expansion, so group 1 can be split into 1A if bit 1 is unset and 1B if it is set. This does allow the split you gave with bits 0&1 the group:
0 - Group 3
1 - Group 1A
2 - Group 2
3 - Group 1B (all future expansion)
The 3 address mode bits are consistent in group 1A, and fairly consistent between Groups 2&3 where the moses are defined slightly differently.
Using the 3-bit, 3-bit, 2-bit model you suggest shows that some instructions have the wrong OP Code. eg TYA ought to be $88, CLV ought to be $98 (based on how the other instructions in their groups behave with the same addressing modes). DEX, DEY, INX, INY, NOP ought to be elsewhere as well.
Missing instructions can be seen where they should be in the instruction set based on the addressing modes available (eg STX Z,Y; CPY Z,X; CPY abs, X). JMP ought to be, say $40 (as that then matches the addressing mode 000 for group 3 instructions which is immediate data, instructions 0-3 use 2 bytes, 4-7 use 1 byte - BRK, RTI and RTS effectively ignore the 2 byte immediate data, and it vaguely explains BRK pushing instruction address + 2 on the stack).
In other 1975 events:
Linda Ronstadt had her first and only number 1 single with "You're No Good" (for one week in February 1975).
Elton John's Captain Fantastic and the Brown Dirt Cowboy and Rock of the Westies both debuted at number 1 on the Billboard 200.
I use BIT to toggle soft switches. I saw it somewhere and started do it.
This video is amazing. I wish I found it sooner.
I took lots of Apple II programming classes when I was a child back in the 80's. Why was I never taught any of this material in any of the classes?
This is such a cool video!! Thank you for sharing
11:47
The group 2 addressing modes are:
000 - £ (immediate)
001 - ZP
010 - A
011 - absolute
100 - PC relative (not used) *
101 - ZP,X (ZP,Y for X reg instr)
110 - S (stack pointer)
111 - absolute,X (abs,Y for X reg instr)
STX A = TXA, LDX A = TAX
STX S = TXS, STX A = TXS
No other instructions in group 2 use S.
DEC A and INC A are replaced by DEX and NOP
* This was "guessed" by group 3 addressing modes which are the same, except A and S are implied modes.
Video memory addresses were often arranged in an unintuitive way - although not always as tricky as in the Apple II. The reason for this is that it was Dynamic RAM, that had to be refreshed within a certain time frame to retain its contents. To create the video output signal, the video chip had to read the RAM in a repetitive way anyway, and if the addresses were interwoven in the right manner, this continuous read operation could have been used as the DRAM refresh.
Amazing.
Despite all of its weirdness and limitations, the fact that the Apple ][ had built-in color graphics made it the first personal computer that could be a video game platform. Other 8-bit computers had much better capabilities, but they came later and were able to use custom chips.
very good!
Very nice video! ...but at 1:00 "Everything had to go through the accumulator" is not totally true (Ack, watching your entire video, I now see you cover this really well and this comment should probably be deleted!) . Many useful operations do not require the accumulator. For example you can rotate, shift, increment, decrement memory locations. Yes, a read modify write operation is performed by the processor on the data, but it, does not affect the accumulator. Instead an "invisible" data register on the CPU (and actually an "invisible" address register) is used. For example to left shift a 24 bit value located at $1 to $3 in memory. (zero page in this case) the instructions ASL $1, ROL $2, ROL $3 would be executed with no impact on the accumulator. This is a lot nicer than having to write LDA $1, ASL, STA $1, LDA $2, ROL, STA $2, LDA $3, ROL STA $3 which you would have to do without this feature and saves a few machine cycles (9 - I think) and code length (9 bytes shorter). Similarly you can increment and decrement memory locations where zero flag is useful if you have a multi-byte data where branch would be used to skip incrementing higher order byte when the lower order byte is not zero after its increment, e.g. 16 bit counter stored in $0 and $1: INC $0, BNE 1, INC $1 (where BNE is branch if not zero +1 instructions skipping INC $1. Hopefully this is pretty accurate, I wrote a ton of 6502 code 1979 to 1982 and NONE since, except I did kind of check my comment using an Apple II emulator I just downloaded with Integer basic ROM model including WOZ's mini-assembler. One final comment, of course if you wanted to do something like add two values in memory or add a constant to a value, then the accumulator would be needed for that.
The NES CPU core acually had the decimal mode circuits still on the chip, just disconnected.
... doesn't mention the z80? Seems deliberate.
In your opinion what is the most notable hires app written for the apple ii?
I remember struggling trying to write Assembly code in High School with no book to refer to. Was able to do things, but the concept of the interrupt was beyond me at the time. I would have loved to have had those two books you refer to. Alas, the age of the 6502 has passed.
I am a bit surprised noone mentioned the STY HGRY, referring to the Steve Jobs speech ending with the phrase "Stay hungry, stay foolish" :)
7:09 good thing it took me 2 weeks 😜
Sorry, what means "DAdj"?
wow 27 free page zero addresses you should try the 8 bit atari range I would have loved 26 page zero addresses
I thew my Apple II Reference manual out in about 1999, :(
Where can I get these slides?
www.cs.columbia.edu/~sedwards/presentations/2022-vcf-6502-programming.pdf
feels like wozniak on LSD when he came up with the graphics scheme. So you can't have 3 pixels blue green purple next to each other horizontally. Talk about limitations!
It's a shame that you can't tag people here. Else I would be tagging Ben Eater, or The 8 Bit Guy on this video, they'd for sure enjoy this just as I did.
The answer is no, the balls did not move fast enough, I built a chip 8 emulator a while back that did the same thing to draw characters, so i wondered about it
I am always baffled when programmers (who ought to know better) don't grasp, fundamentally, what a sprite is. Maybe it's just too exotic a hardware construct for softees to understand? This is the first time however I have ever seen a serious programmer conflate Apple II shape tables with sprites. This is like having a division routine and calling it a "math coprocessor".
The term morphed over time to have a broader meaning than just hardware sprites.
I'm baffled how someone managed to make it to 2023 without realizing that the vast majority of people are not talking about hardware sprites when they say "sprite".
I am interested in learning more about 6502 machine language. I have only been working with it on the KIM-1 for about 1 year and I created my own OP Code diagram which included the different addressing modes. That you explained in this video very well. Keep in mind that I am new to studying the 6502 and it's Op Codes, so there may be a mistake or two in my diagram. Please let me know if you find one. drive.google.com/file/d/1stT1klHHyHeuhXuHmm77puHzOgLKEF2Q/view?usp=drive_link I hope this table helps other 6502 enthusiasts like myself.
Anyhow, I was interested in the way you were looking at the least significant bits starting with Group One (01) - Which basically repeats everything down columns 1,5,9,D and Group Two (10) - Which repeats everything down columns 2,6,A and E. I could also see how Group Three (11) - Which would include columns 3,7,B,F have nothing in them at all and Group 4 (00) which contains columns 0,4,8,C that do not repeat each other.
Now when I look at the most significant bits or the rows across my table. I can see a similar pattern when it applies to addressing modes.
Group 0 (0000) and 2 (0010) contain the same addressing modes as you look across each row and down each column. Group 1 (0001) and 3 (0011) also contain the same addressing modes as you look across and down each column.