SAP6502 Microcode Part 3: First Instruction
HTML-код
- Опубликовано: 6 фев 2025
- The emulator is fleshed out and the microcode for the TXS instruction is written.
github.com/Tur...
AppleWin can be found here:
github.com/App...
Initial video in the series
• SAP6502 Microcode Engi...
really nice technique of representing active signals as 1s and then adjusting them at programming time :)
that flag selector 151 is also very interesting!
Yeah, i'm surprised Ben Eater used this bank of invertors.
Your channel is AWESOME
Glad you think so! Enjoy.
Anyone hows interested in CPUs should, or must see your series on microcode. Effectively, microcode is often poorly explained or lack of detailed information. You are doing an amazing job👏
Thanks for that. Yep, the microcode is often forgotten about, but there’s quite a bit of detail there.
Just catching up on your videos. But leaving a comment to show audience engagement to the algorithm.
Thanks Martin. It does help! What do you think of the series?
@@DrMattRegan It's interesting, especially learning how much area the microcode took up on the early graphics chip. I also liked how you tied that back to the pop culture references.
Amazing content! Keep it up!
Appreciate it!
Amazing content😍
Glad you think so!
Function pointers aren't special, static function declarations are implicitly function pointers when you reference them by name.
What's magical is that there's not really a function reference or value type, so when you dereference a function pointer you just get the function pointer again. GCC will let you write (*******foo)() and it's the same as foo()..
The converse isn't true, "pointer to function pointer" is totally a type. There's a slight amount of magic in that you're allowed to ask for &foo and it gives you foo: so it elides the first level of indirection. But it's not quite as bad as Christopher makes it out.
Very interesting and mind blowing at the same time theres a lot to take in here 🤐. So the microcode is a sequence of so called instructions on every clock pulse to implement the loading or passing of data being manipulated. Its sort off like the CPU has its own software to run or emulate as well to function? Love the reference to terminator to see if we are all still awake. So you've given me an idea and at the sametime one massive curve im going to try my C6510 written in BlitzmaxNG in the Win Apple II emulator like you've done for you're CPU.cpp/ SAP microcode. Which means trying to learn C# as well as VScode 🤨.
From someone who has written there own Emulator from scratch this is a mamouth undertaking just in its self.
So Did you make any table or spread sheet from a software point of view in reference to the microcode? I mean from an emulation point of view for example. The TXS instruction we get the data from the X register and pass it to the stack pointer which is 2 Cycles long. So first clock cycle was get X register on the internal register storage/bus. Then on the next second Clock cycle the data is then loaded to the SP and the PC++ is incremented by one byte ready for the next fetch.
Microcode is so under looked or explained anywhere. But it seems to be the software that operates the chips to function as a CPU it's self. Design level stuff. I have many videos to watch. Thankyou for your time and effort in explaining these concepts.
I didn't use a spread sheet, but it won't be cycle accurate. I only have the one internal bus in keeping with the SAP architecture. Enjoy! If you use a different version of AppleWin than the one i use, you might need to contact me for details.
Hi and Thanks! Can you add this video and the next one to your "SAP 6502 Microcode" playlist? Thank you very much!
Done, thanks for that. Hope you're enjoying it. I plan to put up the whole process of writing the microcode.
@@DrMattRegan Thanks! I just found you out but I will enjoy your 6502 playlist. You have amazing content. Thanks for documenting the whole process. Congrats for Hackaday as well!
My very thoughts and feelings, too..
And I've subscribed too.
Long ago, I programmed in Assembler of a similar microprocessor. I didn't know the things that make the 6502 different. The Break instruction, for instance. Well, I really don't know what it does. The State register is a bit (pun intended) different: only the Z, C, N, V, and I conditions are present in both. Here, half carry H (nibble carry) is absent. The X, Y register set is different, too: only X in the similar microprocessor, but it was a word wide pointer, and the stack pointer could be transfered to it for addressing data in the stack without popping. Little Endian here, Big there. More addressing modes here (seen next video too), but mostly orthogonal instruction set there, registers and accumulators always implied in the instruction's opcode. No Out instruction needed there, I/O dataspace was directly addressable if provided.
In the years I programmed in Assembler, I never figured out microcode was doing the fine work, I thought it was all logic gates. The first Assembler I programmed with was the first that used named (instead of just address numbers) labels: ProSA-300, Siemens. That was back in 1968. It had only 53 instructions, and the bare essential addressing modes. But I still remember the instruction that made multiplication possible: VSEE, Verschieben und Suchen Erste Eins, shift and find the first 1.
7:10 "Hopefully I can remember..."
So a better design would be to take two control words, rather than a flag. That way you must always specify the control words for both flag states, and you don't have the `if` statements -- the two-flag form looks almost the same as the first function, except the two "set"s use different flag parameters.
Doesn't that use just as much memory? except now the control word it needs to twice as wide. That's OK in silicon, but it's a lot more wiring on perf board.
7:16 Don't write counted for-loops when you can avoid it. This should be: for (auto& x : g_controlROM) x = 0;
But, don't do that either! There is a standard algorithm for this. Look in .
OK, but it's not meant to be a C++ tutorial. I want it to be understood by the broadest audience.