Assembly language vs. machine code - 6502 part 3

  Рет қаралды 1,052,068

Ben Eater

Ben Eater

Күн бұрын

Schematics, datasheets, kits, and more at eater.net/6502
More on vasm: sun.hasenbraten...
Part 1: • “Hello, world” from sc...
Part 2: • How do CPUs read machi...
Part 3: This video!
Part 4: • Connecting an LCD to o...
Part 5: • What is a stack and ho...
Part 6: • RAM and bus timing - 6...
Part 7: • Subroutine calls, now ...
Support these videos on Patreon: / beneater or eater.net/support for other ways to support.
------------------
Social media:
Website: www.eater.net
Twitter: / ben_eater
Patreon: / beneater
Reddit: / beneater
Special thanks to these supporters for making this video possible:
Adam Lininger
Adrien Friggeri
Alex Catchpole
Andrew R. Whalley
Anthony Cuccia
Armin Brauns
BakerStaunch
Beau-James Erion
Ben Dyson
Ben Kamens
Ben Williams
Bradley Pirtle
Brian Wanda
Bryan Brickman
Carlos Ambrozak
Chad Fertig
Christopher Blackmon
Clayton Parker Coleman
Daniel Tang
Dave Walter
David Boardman
David H. Friedman
David House
David Turner
Dean Winger
Debilu Krastas
Dušan Dželebdžić
Dzevad Trumic
Eric Brummer
Eric Dynowski
Eric Twilegar
Erik Broeders
Eugene Bulkin
Foaly
Gabriel Lafond-Thenaille
HaykH
Ian Tait
Ivan Sorokin
Jackson Warren
JavaXP
Jay Binks
Jayne Gabriele
Jeremy Wise
Jimmy Campbell
Joel Messerli
Joel Miller
Joern Heidenreich
Jordan Scales
Joshua King
Justin Dubs
Justin Duch
Kefen
Kent Collins
Manne Moquist
Marcus Classon
Mats Fredriksson
Michael
Michael Burke
Michael Garland
Michael Tedder
Miguel Ríos
Nathan Wachholz
Nicholas Moresco
Onion Sniffer
Paul Pluzhnikov
Paul Randal
Peter Simard
Philip Hofstetter
Randy True
Richard Wells
Rob Bruno
Robert Blackshaw
Robert Butler
Ross
Sachin Chitale
Sam Rose
Scott
Sergey Ten
Sever Banesiu
SonOfSofaman
Stefan Nesinger
Stefanus Du Toit
Stephen Smithstone
Steve Jones
Steve Gorman
Steven Pequeno
Thomas Ballinger
Tom Burns
Vladimir Kanazir
Warren Miller
fxshlein
hunter wright
xisente
Örn Arnarson

Пікірлер: 851
@CZghost
@CZghost 4 жыл бұрын
Nice little shoutout to you for Mac and Windows version :D 2:37
@rty1955
@rty1955 4 жыл бұрын
Should make an open source for Linux. I spoke too soon. It is ooen source....
@dentjoener
@dentjoener 4 жыл бұрын
@@rty1955 It is open source... These are just prebuilt binaries
@rty1955
@rty1955 4 жыл бұрын
@@dentjoener awesome. I left M$ decades ago... Its shareware at best
@sdspivey
@sdspivey 4 жыл бұрын
I don't think windows or Mac will run on a 6502.
@cokeforever
@cokeforever 4 жыл бұрын
@@rty1955 Why?? He should eventually do Eatix ;) that's the point of building your own computing system )
@Khobalt664
@Khobalt664 4 жыл бұрын
2:35 lol Glossing over the "Thanks to Ben Eater for providing the Mac and Windows versions." You're really a gem.
@georgethornburg9259
@georgethornburg9259 8 ай бұрын
Ha! No joke!
@bubba_brandon
@bubba_brandon 3 жыл бұрын
Graduated with a degree in Computer Engineering a few years ago and I WISH I had an instructor like this guy because I've understood more from these videos than all of my Computer Architecture classes combined!!
@RajKumar-he3dv
@RajKumar-he3dv 3 жыл бұрын
So true man
@timsanders9111
@timsanders9111 3 жыл бұрын
Agreed. Same situation for me in 1987. Too bad Ben was not my instructor.
@deang5622
@deang5622 2 жыл бұрын
So your computer engineering degree must be worthless then? Which college was this?
@ckannan90
@ckannan90 Жыл бұрын
@@deang5622I mean, it’s one class out of dozens you take in college. I have the same degree (different college probably) and loved my computer architecture class, but there are other classes which had poor instruction. All college courses are hit or miss, because they’re taught mostly by researchers who just happen to be teachers. They are good researchers. There is a chance that they are good teachers. And they keep their job by doing good research, not by teaching well.
@deang5622
@deang5622 Жыл бұрын
@@ckannan90 I learnt more about computer architecture than I did in my university degree by self study.
@justincobb5853
@justincobb5853 4 жыл бұрын
I have learned more about practical digital electronics from your videos than two semesters of dedicated digital electronics labs. Thanks for all your hard work!
@uliun2344
@uliun2344 4 жыл бұрын
pyropulse >plays minecraft I bet you’re a subhuman with a double digit IQ that wants to look smart.
@anders5611
@anders5611 4 жыл бұрын
Bad labs then
@justincobb5853
@justincobb5853 4 жыл бұрын
@pyropulse Excuse me?
@chrissesock4245
@chrissesock4245 4 жыл бұрын
You are the only reason I'm passing my embedded systems class in college. I love you.
@idjles
@idjles 4 жыл бұрын
Back in 1985 that’s how I coded, with 6502 instruction set and paper and pencil and then typed the bytes. I had to count the bytes for the jumps by hand and if I had to jump more than 256 bytes I coded smaller jumps by hand. We had no compiler to do that.
@MrSapps
@MrSapps 4 жыл бұрын
Did they not have assemblers back then?
@QuintarFarenor
@QuintarFarenor 4 жыл бұрын
@@MrSapps probably did but they were also expensive
@jarisipilainen3875
@jarisipilainen3875 4 жыл бұрын
@@MrSapps yes there was,but nobody know it was stone age. people do their own assembler or becouse they were so good on machine code they not need
@idjles
@idjles 4 жыл бұрын
PaulsMagicVideos I had the Print-out of the Apple 2 OS in the back of the Apple Manual, so I knew Assemblers existed, but we didn’t have that at school. yes, 6502 programming was a school topic in 1985! It was awesome. I met and thanked my science teacher for it 36 years later! The 6502 had a clock speed of about 961 kHz, not even 1 MHz!! We entered the bytes with a poke statement for each byte.
@YourUNKus
@YourUNKus 4 жыл бұрын
You want pain? Had to toggle in addresses and instructions individually on the high school's brand new PDP-11 circa '72. Big hoorays when they later that year 'upgraded' with a punched papertape reader/writer. Ah the good ol days. LOL.
@robcumberland8089
@robcumberland8089 4 ай бұрын
Four years on and these Videos are still being found and much appreciated by the likes of me. Thank you very much, Ben. Your Videos are THE BEST ones, to cover this topic.
@skillfulfighter23
@skillfulfighter23 4 жыл бұрын
Man I love this 6502 series. I'm currently almost finished with the 8 bit cpu (I've made some upgrades). Money definitely well spent. Thanks for all you do Ben, from your semiconductor video to this video.
@skillfulfighter23
@skillfulfighter23 4 жыл бұрын
Not yet, I want to finish first so I don't post anything that's broken and could mislead others
@LeonardoCamposBR
@LeonardoCamposBR 4 жыл бұрын
Please keep doing video like this. I'm sure everyone is learning a lot and at this speed no beginners are left behind.
@michelles.3835
@michelles.3835 3 жыл бұрын
This video series is weirdly relaxing and I appreciate it immensely.
@badstate
@badstate 4 жыл бұрын
I should have learned this stuff thirty years ago. Thanks, Ben, for making it so accessible.
@JamesPotts
@JamesPotts 4 жыл бұрын
I'm not here to learn (I write embedded software for a living), but I still enjoy watching your videos. Good stuff.
@satibel
@satibel 4 жыл бұрын
I don't do it for a living, but I've written some asm and took applied electonics classes, so I pretty much know everything he talks about, still, pretty good entertainement.
@endofourlives
@endofourlives 4 жыл бұрын
This is my new favorite channel.
@kdog3908
@kdog3908 Жыл бұрын
This highlights both the beauty and the frustration (for me, anyway) of programming. I started out self teaching on all this at 12-13 yrs of age. This all made sense, was intensely fascinating but remembering and recalling all of the "fiddly" little quirks like the carry bit, "little" vs "big" endian etc, is what caused the frustration.....which caused me to give up programming almost before I started it. Unbeknownst to my 12-13 yr old self and parents and teachers, I had ADHD. A fact I didn't learn until I was diagnosed at age 38. Looking at this now, knowing what I know now, considering my own neurocognitive "quirks", i'm getting tempted to dive back in. The fascination and the fact it makes perfect sense is all still alive but now I can include workarounds for the working and processing memory deficiencies (meat, not silicon) I have. Thanks for rekindling the memory of being an enthralled kid!
@Piano_Board
@Piano_Board 9 ай бұрын
I'm autistic 😅
@jc_from_tx9229
@jc_from_tx9229 2 жыл бұрын
I had an entire semester of 6500 training back in 1989, we built and interfaced circuits just like this. I wrote an assembler program in a relational database that was called Paradox and downloaded programs from my PC through a serial link to the processor. This brings me right back to the great times I had !
@bob-007
@bob-007 4 жыл бұрын
I think the shorter but more frequent videos are better than waiting 2 months for a long one. thx :)
@henrypostulart
@henrypostulart 2 жыл бұрын
I remember when these details were much more ‘bleeding edge’ than a walk down memory lane. I’m glad someone young is still paying attention to these details…
@sailor67duilio27
@sailor67duilio27 2 жыл бұрын
boy oh boy this brought me back in the early 70's, thank you
@ottobass9193
@ottobass9193 4 жыл бұрын
Wow, you made the mac and Windows versions of vasm! Well done!
@jamesmnguyen
@jamesmnguyen 4 жыл бұрын
@@tau8550 My personal question is, can Vasm be compiled without using make?
@baileyharrison1030
@baileyharrison1030 4 жыл бұрын
Otto Bass he just compiled the code and then uploaded the binaries.
@baileyharrison1030
@baileyharrison1030 4 жыл бұрын
James Nguyen Yeah. You could just execute the commands in the makefile by hand
8 ай бұрын
Congratulations teacher for this brilliant series! I have learned a lot from your videos! The Lord has my best salute!
@frivolas
@frivolas 3 жыл бұрын
I've been wondering for years how the bridge between software and hardware works, and here it is, and in such an easy to follow way! Thanks so much!
@MrTridac
@MrTridac 4 жыл бұрын
Even though I'm neck deep in C64 assembly programming, I still enjoy your explanation. Low level is just great.
@peneloperafael8800
@peneloperafael8800 2 жыл бұрын
It seems sooo incredible today that we had learned all these stuff in the 80s without internet, without youtube... Wish I had a teacher like you when I learned assembly!
@drivers99
@drivers99 Жыл бұрын
For my machine language program I wanted to increment A from 00 to FF and send it to the LEDs. That worked, but in plain 6502 assembly there’s no INcrement A mnemonic (op code 1A). After doing a little googling I see 65C02 added a few really useful instructions beyond the MOS 6502 and vasm supports them if you add the -c02 option on the command line! Actually for this chip there’s the -wdc02 option which includes even more instructions added by WDC.
@Sypaka
@Sypaka Жыл бұрын
so without "INC A", you would have to write extra code? How would that look like? Just 3 lines of code?
@Veliki-k3i
@Veliki-k3i Жыл бұрын
​@@SypakaADD A, 1
@Sypaka
@Sypaka Жыл бұрын
@@Veliki-k3i Why ask for something complex, if the solution is actually simple. I seriously forgot increasing is adding by 1..
@picoplanetdev
@picoplanetdev 9 ай бұрын
​@@SypakaAdding one to A is a good idea as has already been mentioned but depending on the scenario you might also use the X or Y register with INX and then store it with STX for example. Those registers are made specifically to be counters/indexes to increment, but if you need to do other things with that value it'll take an extra transfer.
@gingeral253
@gingeral253 Жыл бұрын
I would have never though I would be learning assembly. It’s crazy how much our compilers do for us.
@pawagnathom
@pawagnathom 2 жыл бұрын
It is so complex, with some explanations so logical yet so ground level and hard to learn. Amazing work.
@markell1172
@markell1172 Жыл бұрын
What a fun way to show assembly instructions background without passing through pages of deep down content.
@n2n8sda
@n2n8sda 4 жыл бұрын
lol as others have already pointed out, I also smiled when I saw the thanks to you on the download link. I use vasm myself from time to time as I have a homebuilt 6502 from the late 90's that does various automation tasks that I built to replace a pic based system when it became too limiting... it used to do quite a bit from lighting to door locking and things but now it just mainly keeps plants watered... of course these days you can do plenty more and a lot quicker on a $2 arduino uno clone but back then I used to repair arcade boards when there were still plenty of arcades about I often had donor boards about and 6502s, z80s and eeproms were pretty abdundent, as well as an unbelievable amount of ttl glue logic. Kind of funny that now the technology is more available and easier to build and use the less I do :P
@pugcookie8739
@pugcookie8739 3 жыл бұрын
Hello! I am trying to do this project and vasm isn't working for me, I can't find anywhere online about how to fix this, so you are my last resort. I'm trying to compile a file but it says no input specified, I've tried everything, I am using Cygwin for windows 10 64bit, I put in the command: "./vasm6502_oldstyle -Fbin -dotdir blink.s" am I doing something wrong?
@1gogo76
@1gogo76 2 жыл бұрын
This guys was born with a breadboard in hand, never seen someone going to much into machine level details
@soviut
@soviut 4 жыл бұрын
"it looks like it's actively maintained" [shows vasm website that hasn't changed since 1998]
@TheKetsa
@TheKetsa 4 жыл бұрын
"04-Oct-2019: vasm 1.8g." ...
@soviut
@soviut 4 жыл бұрын
@@TheKetsa The release dates were off screen. Besides, I'm laughing about the dated appearance of the site itself and "HTML4.1 compliant" badge.
@Gidaio
@Gidaio 4 жыл бұрын
@@soviut It's pretty funny how older-tech developers kind of do the minimum-required for higher-level things. If it ain't broke, don't fix it.
@Pretagonist
@Pretagonist 4 жыл бұрын
Well people who write assembler compilers usually aren't the kind of people that care about being up to date with the latest html/Javascript frameworks.
@Gidaio
@Gidaio 4 жыл бұрын
@@Pretagonist Exactly my point. It's just funny, because in my line of programming (backend JS dev), you _have_ to keep up with all the latest techs.
@danbance5799
@danbance5799 4 жыл бұрын
Next, can you make a time machine and send these videos back to 1986? I could have really used them about that time. Still fascinating to watch.
@nihushu8748
@nihushu8748 4 жыл бұрын
I want to build 6502 computer for a competition in my school and you fell from heaven for me :D
@Umski
@Umski 4 жыл бұрын
Learnt more here in 15 minutes than I did in an entire term's module on Microprocessor programming at university 20 odd years ago ( I was probably hungover most of the time back then mind :D)
@ShimaKiyoshi
@ShimaKiyoshi 4 жыл бұрын
In my first job, I wrote 680x assembly programs, and by wrote, I mean I had to write them down on lined paper, then write the machine code next to each line in the margin, then type all the bytes into a BBC micro which had a ROM burner attached. My biggest program was almost 8k which, for reference, is a full ring-binder worth. You guys have it so easy these days, with your fancy assemblers!
@craftsmanwoodturner
@craftsmanwoodturner 4 жыл бұрын
It was a very long time ago, so I could be mistaken, but I seem to remember that BBC Basic had built-in 6502 assembler support?
@ShimaKiyoshi
@ShimaKiyoshi 4 жыл бұрын
@@craftsmanwoodturner - well, long answer is that we also used the (awsome) Dataman S3 programmers, and to do software updates we would call out any changed bytes on the telephone to our customer, who would be typing them into their Dataman. In order to make this work, each page of code was divided into 4 line groups, and when your code got to the end of a page (only one page allowed per subroutine!) the remaining bytes in the final group of 4 were left blank - to allow for pudent modification of that page of code without affecting any other page. An assembler *might* rearrange a whole load of other code after an update. While a similar approach could probably have been forced with an assembler, my Boss was an eccentric PDP owner/operator, and insisted it was done this way. As a 'rookie' it certainly was a good way to learn the careful writing of code. It's a process that younger generations might find hard to imagine!
@asemabuelhija4501
@asemabuelhija4501 4 жыл бұрын
I'm so assembling this computer some time soon! Thank you sir!
@Hettilo
@Hettilo 4 жыл бұрын
While i would lie if i sad i would pass my computer technology class only with your videos, but those are by far the best ilustrationon of what the hell is going on:) keep up the good work i really helps me to understand it
@myhobbies5965
@myhobbies5965 Жыл бұрын
Excellent way of teaching, please sir make some video tutorials for AVR microcontrollers in assembly. Thank for providing us such a great knowledge.
@OneAndOnlyMe
@OneAndOnlyMe 4 жыл бұрын
Opcodes were how we did do it back in the day! Literally by writing DATA statements in BASIC, and reading those and POKE'ing the values into memory addresses. Back then we used to be able to memorize the decimal values for the opcdes (there weren't that many to memorize for the 6502).
@melkiorwiseman5234
@melkiorwiseman5234 4 жыл бұрын
These videos remind me of when I built a Z80 based computer from a kit (a complete computer with a proper video display - B&W of course - and cassette tape storage) and then entered Microsoft BASIC for the TRS-80 into it, one hexadecimal instruction at a time, saving it on tape between sessions, and finally altered it so it would run on the kit computer. That was fun. The kit computer had a display half the size of the TRS-80 and used a different method for saving and loading on tapes and accessed the keyboard differently, so I had to alter all three of those sections of the code. Yes, I made it work. I used it for quite a while until computers which used disk drives became affordable.
@AiOinc1
@AiOinc1 4 жыл бұрын
8-Bit guy has a great video on how those LCDs work
@mysock351C
@mysock351C 4 жыл бұрын
Brings back memories of programming in assembly on old GM 6800 series car/truck ECMs from the early 80's. Kind of fun to program on since they did not require a bootable operating system like the later ones, which meant you could use them for simple control projects.
@r00tyschannel52
@r00tyschannel52 4 жыл бұрын
This was how us poor people, in the 1980s wrote our Z80 machine code. I was too young to afford devpac, and the ZX Spectrum +3 manual had the z80 mnemonics listed. So, I needed to do it manually. I wrote it out machine code style on paper, then put the opcode numbers next to the commands on the right and in the margin popped in the address (for jumps). Then pop them all in a data statement with a poke loop and boom. Instant program (that would often crash, but still). Yeah, it was a pain for anything remotely complicated. But, I was young so not doing anything THAT complex. I did manage a track by track disk copier though. That needed to be in machine code, because you had to swap out the basic rom, and swap in the +3DOS rom, which if you tried to do from basic, for obvious reasons would cause a pretty instantaneous crash.
@zaberfluten8978
@zaberfluten8978 4 жыл бұрын
It satisfies me so much so see your circuits. It is also the main reason why I watch your videos tbh😂😂
@xanderplayz3446
@xanderplayz3446 2 жыл бұрын
Thanks for teaching me about computers! You make everything easy to understand. Thank you.
@synshenron798
@synshenron798 Жыл бұрын
I literally just messaged a buddy of mine about this guys channel. We were in a microprocessors class where we were not learning SHIT. We did the best we could, we r3ad the text book, we asked questions, we wrote down ever note the prof gave us and then some. Everyone in that class was lost as hell. After seeing this guys series om Assembly code I actually want to take a second shot at it. I want a round two cause I came to college wanting to learn, low and behold I am almost done and all I want is that stupid piece of paper
@CybAtSteam
@CybAtSteam 2 жыл бұрын
My first paid software was a 6502 assembly user port device driver for a custom piece of industrial hardware for the c64. One of the guys i worked with wrote all his programs in machine code. Just straight typing in the hex numbers. We all thought he was nuts, even back then.
@pentachronic
@pentachronic 4 жыл бұрын
This takes me back. Damn do I miss those old days. This is a lot of fun.
@JustinSBarrett
@JustinSBarrett 4 жыл бұрын
Really fun stuff! This reminds me of my one-and-only assembly language program that I wrote for our family's Commodore VIC-20, back when I was in my teens. It just put a little Pac Man character on the screen and made his mouth open and close. Nothing thrilling, but I was stoked to have figured it out. I'm kinda wishing I'd stuck with assembly language stuff beyond that one program, but I've been coding in other languages over the years, so at least the programming vibe is still alive and well.
@sjpwarren
@sjpwarren 4 жыл бұрын
Wow as a Kid wanted to understand assembly etc. Over time it made sense but it was always something I never fully understood. Thanks for making it clear. I wish I knew how to do Assembly programming back in the Z80 days!
@spongerobert
@spongerobert 4 жыл бұрын
I won't lie. A large amount of what you do on your channel is way over my head but I find the content both fascinating and somewhat philosophical. I always say that computers turn stupid electricity either from a wall socket or battery into smart electricity that can dazzle our senses and create worlds and realities beyond most of our imaginations. I often draw parallels between things that happen in everyday life like the predictable nature of my dog when I give it basic commands like sit or roll over to the pure logic nature of computers and sometimes wonder where is the 6502 chip(s) controlling my dog. It's just interesting seeing the "magic" happen bit by bit and realizing it's not magic at all but just a crap ton of very basic commands. It's really quite enlightening.
@carecavoador
@carecavoador 4 жыл бұрын
Oh my gosh, Ben. What a cliffhanger! Your videos are simply awesome. Thank you so much.
@kirbymia6209
@kirbymia6209 4 жыл бұрын
Another Ben Eater video! I'm really excited for this series of videos. I look up to your skill and ability to teach others and hope to be like you one day.
@chitlitlah
@chitlitlah 2 жыл бұрын
One thing that became obvious to me when programming a Z80 processor emulator in x86 assembly language is that there are patterns to these opcodes. For instance, if you look at the adc instruction (add with carry) for the 6502, there are eight different opcodes depending on if what you're adding is an immediate value, an absolute memory reference, etc. All the opcodes begin (in hexadecimal) with 6 or 7 and end with 1, 5, 9, or D. When you convert that to binary, the adc instruction is 011xxx01 with the x bits changing depending on where the value is. The processor uses five bits to determine it's an adc instruction and the other three to figure out what to add. If you look at the opcodes for the sbc (subtract with carry) instruction, they're the same except they begin with E or F instead of 6 or 7. That means the binary changes by only one bit from adc to become 111xxx01 and you fill in the x bits the same way as with adc. Not all instructions fit into this same pattern, but many do if they involve taking some value from somewhere in memory and moving it into the accumulator or combining it via some operation with what's already in the accumulator. That gives you a hint as to how the processor works at the hardware level. Even the sta instruction fits into this pattern even though the direction is the opposite. There's just no opcode for when it's an immediate value because it doesn't make sense to do so. It does make me wonder what would happen if you send it an $89 opcode though, if the processor would fault out for invalid instruction, actually overwrite the next value in memory and keep going, or something in between. I may have to try that as an experiment.
@chitlitlah
@chitlitlah 2 жыл бұрын
I found out what the $89 opcode does. It apparently does nothing, like the nop instruction, but with an 8-byte operand that it ignores. There are apparently a lot of these amongst the undocumented opcodes, as well as some that crash the processor and some that have interesting but inconsistent results.
@ZedaZ80
@ZedaZ80 4 жыл бұрын
I used to program primarily in machine code on my TI-84+ because you can type the code in hexadecimal on-calc and I didn't have a computer. I got really, really good at memorizing the addresses of all my routines. I still code this way, too, because it's just so convenient when I need to quickly test something. No compiling, no typing out so many characters to spell out one instruction, and I don't have to set up sending a binary from my computer to my calculator.
@atsugi2210able
@atsugi2210able Жыл бұрын
Wow, I remember writing 6502 Machine language back during my middle school in the 80s on a Commodore.
@brendasaurusrex
@brendasaurusrex 3 жыл бұрын
Thanks Ben Eater for those binaries. 2:32
@johnscarfone
@johnscarfone 4 жыл бұрын
One little detail... you might throw a CLC in there before the ROR unless you want to be surprised by three lit LEDs once in a while. 🙂
@BenEater
@BenEater 4 жыл бұрын
Hah! Good point.
@mcg6762
@mcg6762 4 жыл бұрын
The original 6502 from MOS actually does not clear the carry flag on reset, confirmed with Visual6502, so you have a good point! This might be different on the CMOS version though.
@NoNameAtAll2
@NoNameAtAll2 4 жыл бұрын
Explain please?
@johnscarfone
@johnscarfone 4 жыл бұрын
NoName If the carry flag is already set when the program is run, you’ll see three LEDs lit as the ROR rotates the bits around. From the datasheet, “All Registers are initialized by software except the Decimal and Interrupt disable mode select bits of the Processor Status Register (P) are initialized by hardware.” So the state of the carry bit is undefined when the program starts and has to be cleared explicitly if you want to make sure it’s off. Personally, I don’t mind being surprised in this example.
@ChiDraconis
@ChiDraconis 4 жыл бұрын
@@NoNameAtAll2 Even more exotic stuff can be done such as reading inaccessible control registers with an XOR mask that otherwise cannot be read; Other issues involve setting no-interrupts which is a difficult issue for me to think about; Here from the comment of John Scarfone we have rotate right which brings us to does it use what sometimes is a sign bit *{ + / - }* or does it even look to see what the value is? Study Ariane Rocket disaster and you can find adherents of a multi-volume work I forgot the name of saying that it was not them and many other situations which deify sanity and bend the notion of what is right; This is known as sanity checks when you drop into a loop; Clean programming will run an initialization which sets some things and does not bother with others → for example you do not clear memory for testing usually; Poor work results in midnight phone calls which are notorious for pitting you challenging vast empires that do not care in the slightest;
@johnorozco7580
@johnorozco7580 4 жыл бұрын
Hola Ben Excelente canal que has creado, no se si lees español, pero lo que haces me ha sorprendido mucho he recordado mis clases de electronica y cuando empeze a armar los circuitos electronicos, es la base de la electronica explicada a un nivel excepcional, gracias por las explicaciones me gradue en el año 1999, pudieras hacer un video con el microcontrolador C8051
@robby3467
@robby3467 2 жыл бұрын
The language brings back memories of my programming the C64 (which used a variant of the 6502). I used to program everything in hex.
@gypsyjr1371
@gypsyjr1371 4 жыл бұрын
I toggled machine code into a Dec PDP-8 long before the 6502. And wrote tons of BAL (assembly language). Things are a *lot* easier now.
@halamkajohn
@halamkajohn 2 жыл бұрын
Overview : " what is needed in a BASIC computer design to mass produce " things i was thinking about. 1) commodore video characters that make pictures with automatic program. 2) number input from a printed list 3) slideshow program 4) well ebay is kinda supposed to be "by hook and crook" with a bit of persistance needed.
@hatsjie2
@hatsjie2 4 жыл бұрын
When someone calls Assembly language "easier"...
@AshtonSnapp
@AshtonSnapp 4 жыл бұрын
It’s easier than messing with raw machine code.
@ggldmrd5583
@ggldmrd5583 4 жыл бұрын
@@AshtonSnapp Creating our own 8bits turing machine, then creating the assembly language and the assembler for it, then creating compiler programms for it, then creating programs for it, is way easier than programing a x64 intel processor with pre-built libraries for a langage made from an other one made from an other one made from x64 assembly that we have to learn and that have no other issue than just getting the work done. Well, im a fan of homemade tech.
@mhballa5866
@mhballa5866 4 жыл бұрын
@@ggldmrd5583 it is like walking a road yourself from beginning to end , instead of using a map by someone else . the understanding is deeper and fuller .
@tratbagd4500
@tratbagd4500 4 жыл бұрын
My favorite channel and content on KZbin.
@kilinnet
@kilinnet 4 ай бұрын
In the good old times we had to erase the EPROM using the sun rays or using the UV eraser, before programming the EPROM with new data.
@vuurniacsquarewave5091
@vuurniacsquarewave5091 3 жыл бұрын
One thing about the ROR and ROL instructions is that if you look one of the "on" leds seems to disappear for one rotation before reappearing on the other side. That's because ROR and ROL run the bits through the Carry 'C' flag in the processor status, acting as a "9th bit" for additions/subtractions and moving bits around. This makes it easier to chain bytes together and interpret them as a variable larger than 8 bits. If you want to leave the carry out, on the 6502 it's easy to put a CMP #$80 before the ROL instruction because this will essentially copy the highest bit to C before you rotate it back into the lowest bit.
@darwinvinci7744
@darwinvinci7744 4 жыл бұрын
Can't wait to start earning and be your patron. Thank you for everything!
@eldanielo0001
@eldanielo0001 4 жыл бұрын
This is ingeniously brilliant! Thank you for this series!
@Leuel48Fan
@Leuel48Fan 4 жыл бұрын
Super cool, keep up the good work! I'd love this series to continue all the way to high level languages maybe mock C(++) style language, similar to the *Nand2Tetris* program series. Hardware -> Binary -> Assembly -> C style code -> Object oriented
@jarisipilainen3875
@jarisipilainen3875 4 жыл бұрын
cc65.org you get assembler and c
@simsanutiy
@simsanutiy 4 жыл бұрын
2:32 >thanks to Ben Eater for providing the Mac and Windows versions Yep, thanks, when my 6502AD arrives I'll use the windows one a lot
@andrewlankford9634
@andrewlankford9634 3 жыл бұрын
Programming in assembly on the Sym 1 (6502 single board computer) was hand asembly. Instead of an assembler, you had a photocopied worksheet to write down your assembly language and hand-encode into machine language and then input into the computer via the monitor program. Of course, with 6502, that's pretty straightforward.
@chuckthebull
@chuckthebull 2 жыл бұрын
I used to do alot of assembly for Pic micro,,,I miss it but dont miss it.
@benbowyang
@benbowyang 4 жыл бұрын
You're a great teacher! Thanks, and well done!
@toby9999
@toby9999 2 жыл бұрын
This brings back memories of writing software for the C64 back in the 80's in hex like that. There was no assembler available.
@kannanrkarthikr9541
@kannanrkarthikr9541 4 жыл бұрын
I am an electrical engineering student. I am fully satisfied with your whole series of videos. Would you please make videos about how machine code is translated by assembly language and multilevel language at very base level, something like you did programmed machine code to eeprom by push button... I want to make a mini computer in breadboard which demonstrate machine code assembly language and multilevel language...
@will5948
@will5948 3 жыл бұрын
Things I normally do over Christmas/New year holidays: drink, eat, sleep. Things I've done this year: write C code, compile to assembly, read every line with the instruction datasheet next to me.
@Wanttoknowabout
@Wanttoknowabout 4 жыл бұрын
If there was a Nobel prize for just being awesome, you would easily get it!
@Vermilicious
@Vermilicious 4 жыл бұрын
It's all pretty simple, but many find it hard to grasp. Kudos to Ben for making the knowledge so accessible and easy to follow. And who would've thought the 6502 would teach people how computers work so long after it was conceived? Modern processors work in much the same way, so it's still relevant. Using Arduinos and whatnot seems like overkill, and quite wasteful to me, for small hobby projects.
@leoscarano1136
@leoscarano1136 4 жыл бұрын
I hated low level classes because my professors just spewed out assembly info at us, some directly from the x86 manual. I wonder how many career paths would have changed if more practical goal-oriented assembly programming was done like this.
@DIPper352
@DIPper352 7 ай бұрын
Thanx U really sparked my interest in assembly I was thinking of making the same series on 8051 in assembly coz there aren't much videos covering it in assembly, majority is in C
@SciHeartJourney
@SciHeartJourney 3 жыл бұрын
Here's a cool project for an engineer to build: ROM emulator using Flash technology. One can use surface mount parts on a PCB that has the same large DIP package format as the ROM. You can put a switch to address different address spaces without removing the module and put a USB port on it to reprogram it. I'll bet someone has already done this though. But if not, there is legacy equipment (like old console video games) that you can benefit from this.
@Jamesthe1
@Jamesthe1 3 жыл бұрын
I'm really enjoying this series. It's been making me want to look into how this is done to make my own program, maybe a 6502 emulator on an arduino for myself.
@seanrodgers1839
@seanrodgers1839 3 жыл бұрын
This is so meaningful to me. In the 80s I taught myself how to program in 6502 (6510) machine code. I still remember the A9 command. What I want to do now is see how to add some ram chips, with a framebuffer that is output to a video device, put some bootstrap and useful code in the eeprom and add a keyboard. Can that I/O chip be used with a keyboard that signals in a row, column wire arrangement? There's probably a keyboard chip that outputs on an 8 bit output.
@AzureLazuline
@AzureLazuline Жыл бұрын
thank you for this series! I did 65c816 programming as a kid (for SNES), which built off the 6502 instruction set. It's really fun to go back to this! I'm very slightly annoyed at using JMP instead of BRA (branch always) for a nearby address, since BRA is one cycle faster and one byte smaller, since i used to have to actually care about that stuff for the program to run well... but this is on breadboards, who cares about efficiency 😆
@andrewtitcombe8378
@andrewtitcombe8378 2 жыл бұрын
Reminds me of the old Z80 days .Good that you had the clock speed right down. Else you would have needed delay loops. Could have saved 2 bytes of emprom by removing the first LDA $6000. and putting ROR after the LDA$600 in the loop. Makes me want to drag the old boxes out the loft and go back to using the PIC chips.
@joosepeliastoru6021
@joosepeliastoru6021 3 жыл бұрын
This video made Assembly look high level
@MrSapps
@MrSapps 4 жыл бұрын
Could you do a final part where its even higher level? Using a C compiler to generate asm for the LED blinks or something?
@doctorrzepa
@doctorrzepa 4 жыл бұрын
I think C is overkill for that task. It would take longer to prepare enviroment and include 6502 libraries than type 10 lines in assembly.
@jamesmnguyen
@jamesmnguyen 4 жыл бұрын
C is actually too high level in some ways. For example, how to tell C to write to register 0x6002, without special compiler builtins? If you had a C compiler/library, then it'll be easier, but the comment above me address that.
@MrSapps
@MrSapps 4 жыл бұрын
@@jamesmnguyen Its a memory mapped register, so #define REG_6002 (unsigned char*)0x6002 *REG_6002 = 0xFF; I know its overkill for this example, but for doing more things with this computer its quite nice to use C for most of the logic. You can still mix C and asm.
@lsfornells
@lsfornells 4 жыл бұрын
James Nguyen You can write to any raw memory location in C by just using a simple integer to pointer cast. There’s no need for libraries to do that.
@jamesmnguyen
@jamesmnguyen 4 жыл бұрын
@@lsfornells ok
@runrin_
@runrin_ 4 жыл бұрын
error 1011 in line 1 of "blink.s": identifier expected >lda #$ff i had to add a tab at the start of each line to get vasm to assemble my code. in case anyone else gets confused. ben actually mentions it at 6:20 ish. >.
@vibrion121
@vibrion121 4 жыл бұрын
This is quite common to most assemblers. Last column used to write comments (tought semicolon preceded)
@melkiorwiseman5234
@melkiorwiseman5234 4 жыл бұрын
Many older assemblers did not care about column position at all. 8080 and Z80 assemblers used the colon following the label to denote it as a label and would throw an error out if the symbol could not be identified as a mnemonic and did not have the following colon to identify it as a label. In other words, it would check the first thing on the line to see if it was an opcode mnemonic such as LDA and if it wasn't an opcode it would check for a following colon to see if it was a label, otherwise you'd get an error message. At least, that's my understanding of how it worked. I may be wrong since I used to offset my assembly code instructions anyway just out of habit so it was easier to see where the labels were in the code.
@fathomisticfantasy2681
@fathomisticfantasy2681 4 жыл бұрын
Some how I made this mistake and about panicked. Then found your comment. Glad you said something. Although now I feel kind of dumb.
@ServitorSkull
@ServitorSkull 4 жыл бұрын
@@fathomisticfantasy2681 You're learning. You're not dumb. Good luck with your build!
@Tikorous
@Tikorous 4 жыл бұрын
@@ServitorSkull they might be dumb you don't know
@Kuzyapso
@Kuzyapso 4 жыл бұрын
I understand nothing but I still watch the whole video
@BenKickert
@BenKickert 3 жыл бұрын
Subtle flex at 2:30... "You can find his binary files here... " on the same page that give a shout out to the creator for making the mac and windows version. Nice.
@zquall
@zquall 2 жыл бұрын
Man love this videos. I found gold! Thanks!
@cassolmedia
@cassolmedia 3 жыл бұрын
ugh.... I started down this road at 1 am and now I can't stop! lol
@davidconnelly
@davidconnelly 4 жыл бұрын
I'm having nothing to do with that. Holy moly! Run for your life!
@MikeBramm
@MikeBramm 4 жыл бұрын
My first applications were written in Assembly for the Atari 1200XL back in the early 1980's. Programming languages sure have come a long way since then.
@absf6502
@absf6502 4 жыл бұрын
Thanks for teaching me how to use an Arduino to function like a debugger/logic analyzer. Never know this technique till now. Have most of the chips for this video, but no at28c256 only 27c256. I also have a eprom programmer on 8 bit ISA card and a professional UV eraser with timer. My apple II eprom programmer can only program 2708-2764 and it is under repair at the moment. Thank for the efforts for making this video and I expect more to come in the future. Cheers.
@kimbring2727
@kimbring2727 2 жыл бұрын
Thank you for nice instructions. I can understand how CPU works with memory 😊😊
@SIGJNF
@SIGJNF 4 жыл бұрын
You made more progress in making a computer single-handedly without a plan and money in a few months than 8-Bit Guy in over a year with a plan, people and money
@gg5115
@gg5115 4 жыл бұрын
Easy there. 8 bit guy is an enthusiast, and is a student of this guy. I've never heard him claim to be on Ben's level, which is what we used to call 'elite.'
@jeremiahbaker985
@jeremiahbaker985 4 жыл бұрын
Not exactly accurate. 8-bit has a computer that interfaces with monitor, sound, keyboard etc. They really are attempting two different projects.
@googleboughtmee
@googleboughtmee 4 жыл бұрын
What did he do to you?
@Colaholiker
@Colaholiker 4 жыл бұрын
Wow, comparing this to apples and oranges is like comparing apples and oranges. Apart from being 8 bit platforms (maybe even with the same CPU?) both projects are as similar as they can be. This is a minimalistic "bare bones" project to show how computers work. Excellent to understand how these machines tick inside, but of limited practical use besides the educational purpose. The 8-bit guy's project is something that can be practically used like the old days' home computers. Probably good for learning how to program, but less so to understand how these machines work on their lowest programmable level. Both have their reason to be, both are very interesting and fulfill (or will so) what they are made for. But it's a different complexity involved, so a direct comparison is simply not fair.
@melkiorwiseman5234
@melkiorwiseman5234 4 жыл бұрын
That's not a fair comparison. Ben is only trying to make a very simple education video to show people the basics of how computers work. What Ben will end up with won't be really useful in and of itself apart from the educational value involved in making it. The 8-bit Guy is trying to make a full, working computer which will actually be useful. That's a lot more complicated and naturally requires a lot more time and planning as well as a lot more expense to create and build.
@sdlion7287
@sdlion7287 4 жыл бұрын
Such a beautiful series
@monad_tcp
@monad_tcp 4 жыл бұрын
2:14 old style C code compiled in modern Clang/LLVM. Don't we love it !
@TheGuyThatEveryoneIgnores
@TheGuyThatEveryoneIgnores 4 жыл бұрын
Using assignment statements within expressions is considered a poor practice and should have never have been allowed in the first place. The accidental assignment bug has cursed me on many occasions. Some compilers give me a warning when I do it, but not always. Personally, I think embedded assignment statements is one of the dumber things ever created for a language.
@michaelbruce5415
@michaelbruce5415 4 жыл бұрын
BTW, Ultra Edit is a very cool editor for many lannguages, includng 6502 assembler language which is supported for syntax highlighting
@AriKath
@AriKath Жыл бұрын
Thank you! I am really grateful
Connecting an LCD to our computer - 6502 part 4
28:10
Ben Eater
Рет қаралды 1,1 МЛН
Running Apple 1 software on a breadboard computer (Wozmon)
14:23
Nastya and balloon challenge
00:23
Nastya
Рет қаралды 64 МЛН
iPhone or Chocolate??
00:16
Hungry FAM
Рет қаралды 37 МЛН
HAH Chaos in the Bathroom 🚽✨ Smart Tools for the Throne 😜
00:49
123 GO! Kevin
Рет қаралды 15 МЛН
The RS-232 protocol
26:10
Ben Eater
Рет қаралды 841 М.
EEPROM Traps! (Combinational logic / TTL Computer microcoding)
8:26
Machine Code Explained - Computerphile
20:32
Computerphile
Рет қаралды 118 М.
A simple BIOS for my breadboard computer
21:53
Ben Eater
Рет қаралды 343 М.
When you Accidentally Compromise every CPU on Earth
15:59
Daniel Boctor
Рет қаралды 827 М.
I built my own 16-Bit CPU in Excel
15:45
Inkbox
Рет қаралды 1,4 МЛН
I Made a Working Computer with just Redstone!
15:37
mattbatwings
Рет қаралды 834 М.
Signals. I spent 2 years to understand this part.
21:24
kimylamp
Рет қаралды 233 М.
The world's worst video card?
32:47
Ben Eater
Рет қаралды 6 МЛН
Nastya and balloon challenge
00:23
Nastya
Рет қаралды 64 МЛН