Minor bug in your print routine: you test the length after decrementing it, so a zero-length string wil print 256 bytes of garbage.
@rhysbaker2595Ай бұрын
Sounds fun
@PrebleStreetRecordsАй бұрын
Heartbleed 6502 edition
@TrollingAroundАй бұрын
yes, tax, beq lcd_print_exit
@EVPaddyАй бұрын
but probably 0 byte strings will produce an error before ever getting there
@boretrkАй бұрын
@@EVPaddy How? That would require FRMEVL to abort the function that is calling it.
@MizuFelix12 күн бұрын
I love this series/course! I live in Germany and bought the 6502 Kit + the Clock Kit, and I did pay the 50 bucks shipping extra to buy from your website, instead of just ordering each individual part elsewhere, because I wanted to support you. Keep up the great work, Ben, I'm looking forward to finally be able to build this computer myself!
@manlyhallresearch97859 күн бұрын
I need to buy it, too. It looks like a great way to learn.
@moshly64Ай бұрын
In Commodore MS Basic, the output of the print command was controlled by a variable, the screen was device 3 but this could be changed to any device (0 Keyboard, 1 Tape, 2 Serial, 3 Screen, 4-7 Printer, 8-15 Disk). If you implement the LCD as a device then the system print/input/get commands can be redirected to any device.
@drobotkАй бұрын
That sounds like the best approach to do this
@SIDCIAVICАй бұрын
There are basic vectors to redirect for adding new i/o devices.
@melkiorwiseman5234Ай бұрын
That was something which came to my mind, too. Maybe Ben could set up the LCD as device #7. I'd think that it would also be possible to make the LCDPRINT command automatically set up the device to print to as #7 and then call the "PRINT" routine to handle the rest, which would save on RAM space since commands such as LCDPRINT condense to a single byte whereas "PRINT#7," would require at least 4 bytes. Ben would still need to set up some kind of subroutine to handle the nonprinting characters (perhaps making CHR$(26) which is the Form Feed character act like a LCDCMD 1 to clear the screen, for example), but I'm sure that MBASIC has the appropriate "hooks" already provided to allow that kind of control.
@amartini5129 күн бұрын
So that’s where the 8 in LOAD ‘*’,8 comes from! Used to play games on a C64 at my grandparents’ when I was growing up, and we just copied the loading instructions from a scrap of paper by the computer.
@bcarlisle2575Ай бұрын
Yeah…just bought the full 6502 kit and have been watching for a couple years…can’t wait to watch all of these again and follow along this time with my own kit.
@sirnukesalot24Ай бұрын
Yes, floating point video please
@akaHarvesteRАй бұрын
YES YES YES pretty please
@PaulaBeanАй бұрын
+1. Not only the floating point as it was imlplemented in MS Basic, but also the standard IEEE format ;-)
@kilianhekhuisАй бұрын
@@PaulaBeanit's not that different, al FP numbers work largely the same.
@AresydatchАй бұрын
In memory of Thomas Kurtz, inventor of BASIC 1928-2024
10 FOR I=1 TO 2 20 PRINT "The horror!" 30 NEXT I ...but seriously, RIP :(
@RetroRynАй бұрын
Co-Inventor with John G Kemeny who also passed away some year ago. But yes very sad, was one of my heroes who made computing accessible to so many more..
@frankowalker4662Ай бұрын
@@RetroRyn I still program in BASIC on my ZX81 now and then.
@RetroRynАй бұрын
@@frankowalker4662 Nice I started on a Sinclair ZX80, with 1K of ram, was fun..
@euromicelli5970Ай бұрын
2:27 yes, PRINT in MS Basic supports a SPC(n) and TAB(n) pseudo-functions. SPC(n) outputs ‘n’ spaces (you can get the same result by outputting SPACE$(n) of course but that’s more verbose and allocates an additional string). TAB(n) outputs enough spaces to reach column ‘n’; if you’re past the ‘n-th’ column in the output already, it outputs a new line and then enough spaces to get to ‘n’ on the next line. These are not real functions but output-control/formatting operators; they only exist within PRINT.
@jeromethiel4323Ай бұрын
Zero page memory is absolutely critical for 6502. Not only is memory access faster in zero page, it's the only way to do indirect addressing. So if you want pointers, which you definitely do, you need 2 bytes in zero page to hold the address. When i was coding in machine code on the Apple ][, i never put simple variables in zero page, that was always just reserved for pointers. Mainly, because i was using basic for the majority of most programs, and only using machine code for the fast bits. So i could not use zero page that was used by basic. When i was writing my one and only 6502 "game," i could use the entire space, and that was amazing!
@Lemonator321Ай бұрын
Intel has been real quiet since this dropped
@En-Pea-SeaАй бұрын
Bill Gates hates this one trick!
@MichaelWillemsАй бұрын
😂
@rhysbaker2595Ай бұрын
MOS Technologies has been raking it in
@zirizeАй бұрын
I was shocked to find that there was a buffer in the zero page. I've always considered the zero page to be a kind of register. It's such a precious memory that I've always believed it should be used sparingly.
@safiireАй бұрын
this
@paulabraham2550Ай бұрын
MS Basic even has a subroutine in zero page to pick up the next character from the prog - wild. And I've just realised I've picked that out of a more than 40 year old memory from when I was doing my own reverse engineering on it!
@gcewingАй бұрын
Putting the buffer in zero page is probably so that the zero-page indexed addressing modes can be used to access it.
@gcewingАй бұрын
@@paulabraham2550 Not sure why you would put a subroutine in zero page on a 6502, there is no zero page JSR instruction. Are you thinking of the Z80? The Z80 doesn't have zero-page addressing modes, but it does have 8 special one-byte instructions that perform subroutine calls to locations in page zero. I think the Z80 version of MS Basic used them to save code space and speed up calls to very frequently used operations.
@paulabraham2550Ай бұрын
@@gcewing Ha! I guess you weren't about in the day if you think people would have got confused between the two ;-). No - definitely 6502, and definitely the "character get" routine was in zero page. I don't think I ever worked out why they did that myself - I was certainly confused about that myself when I found it. Perhaps the annotated source code explains it - I only had disassembled code, of course.
@dbingamon27 күн бұрын
It brings back a lot of memories from working on Commodore BASIC mods. Your strings are stored in a string heap, it's similar to a stack only software generated and every time you manipulate a string it takes up space on the heap. Eventually heap grows to much and a garbage collection takes place to clean up the no longer needed strings or temporary strings. This would cause BASIC to periodically freeze up while this garbage collection is happening. Programmers would perform a command that checks available memory FRE(0) in Commodore BASIC and mem in some others, they would strategically put these commands in certain places to put the delay where it would have less noticeable impact on operation. BTW - We used add extra commands to Commodore basic without changing the ROM by intercepting the CHRGET subroutine, which is a piece of code in zero page.
@clonkexАй бұрын
0:33 I bought one of your breadboard CPU kits! It makes for a fantastic conversation starter. Maybe one day I'll even assemble it.
@naso_gАй бұрын
That was interesting thank you! It's pretty crazy how you can read HEX like another language, pretty cool.
@klafbangАй бұрын
It becomes quite easy after a bit as it has been structured for being semi-readable. 0 is 0x30, A is 0x41, a is 0x61. You just read digits as "whats after 0x3" and letters as "what's after 0x4, 0x5 or equivalently 0x6, 0x7". Space and the most common punctuation you easily pick up as "before the numbers or between numbers and letters" with space = 0x20.
@blazernitrox6329Ай бұрын
Seconding (thirding? fourthing?) the floating point video. I think I've got a pretty good grasp of how floating point numbers are represented at a high level, but actually getting into the weeds on how the representation is generated would be really cool, especially in a pure-software environment like on the 6502.
@SsekiddeEdrine16 күн бұрын
Ben u are my cyber motivator
@mohammedanwarsayeedАй бұрын
I don’t know why, but everything Ben does is always amazing, and I really like it.
@gregorymccoy6797Ай бұрын
This is the content I need from KZbin. Thanks so much for bringing us along.
@krzysztofhennigАй бұрын
Hi, if you are looking for a really cheap soundcard, you can use a 555 timer with few resistors connected via their respective mosfets to pin 7 to control the PWM cycle time. Each resistor/mosfet pair gives us 2 new frequency combinations. With 4 resistors/mosfets pairs you will get 16 frequencies. That would sound like a buzzers from 80s :) If you wish, you can even use PCF8574 to control the cycle time via I2C. Good luck!
@solcloud26 күн бұрын
Thank you for video Ben
@certifiedskillissuesАй бұрын
it's a beautiful morning when you post Ben!
@chrissachs7713Ай бұрын
Please do a video on floating point numbers! Your videos and kits (I've built the 6502) have satisfied so many lifelong curiosities of mine. I have a working programmer's knowledge of floating point, NaNs, ULPs, etc. But I feel like I'm missing the intuitive/historical/fundamental picture-why they are the way they are, how they got that way, and why it makes sense-that your videos always satisfyingly provide. Please keep it up!
@mikefochtman7164Ай бұрын
Hmmm "82C00000" is NOT modern IEEE-754 flt point for 3.0. That would be 0x40400000 I remember using another system that also represented floating point in an odd way called "Excess-64". I suppose before floating point machine instructions were standardized, vendors were free to come up with each unique format.
@nikkiofthevalleyАй бұрын
Yeah, that confused me there. It is still the same basic (pun very much intended) idea, just done slightly differently.
@dkosmariАй бұрын
That's exactly how the history of floating-point formats played out. Each vendor had their own format and conventions, some even had design bugs. Some engineers even went as far as saying "you don't need floating-point, any mathematician worth their salt will know where the point is supposed to be." Some threatened to boycott the standard unless it matched the hardware they themselves were already selling to clients (such as government, military, banks, etc.) It was one of the biggest dramas in the computer industry up to that point. Needless to say, IEEE-754 left a lot of vendors unhappy, we almost didn't get a floating-point standard at all.
@phirenzАй бұрын
Microsoft's floating point is actually really close to IEEE-754, especially for single-precision. Bias is 128 instead of 127, and the sign bit is moved from bit 31 to bit 23. Moving the sign bit means the 8-bit exponent is now aligned with the first byte. The IEEE-754 format would require some awkward bitshifting.
@foo0815Ай бұрын
Note that MS Basic floating point numbers actually are 5 bytes long, first byte is biased exponent, next 4 bytes is mantissa in BIG endian format, leading 1 bit explicit. Also IEEE special formats like inf, nan and subnormals are not supported.
@MonochromeWenchАй бұрын
MS Basic uses the MBF floating point system created by Monte Davidoff in 1975. It predates IEEE754 by 10 years
@DesincarnageАй бұрын
A new Ben Eater video! What a wonderful day :D
@manlyhallresearch97859 күн бұрын
Yes, do a separate video about floating point numbers.
@RegisMichelLeclercАй бұрын
I confirm the space before a positive number is for the sign, I think you passed on that code in the string construction. There was also a test for the comma that simulates a tab. However, later versions of basic also had a "print using" command (Amstrad) similar to C's "printf()" or "print@" (Oric) that included cursor positioning in the same command.
@mikefochtman7164Ай бұрын
Agree. space vs minus sign was common in FORTRAN as well (another old language lol). FORTRAN had options where you could force a "+" sign instead of space.
@MadScientist267Ай бұрын
That used to drive me nuts formatting the screen.. less so of course as the workarounds became habit. It always made for gaps next to numbers unless you went back over the screen with whatever got overwritten. Not really a thing in "productivity" but say in games or anything with graphics, you had to account for it being there haha
@tekk3213Ай бұрын
What a nice day this is getting new Ben Eater video!
@lefteriseleftheriades7381Ай бұрын
Mad respect, you are one of the best on youtube
@gcewingАй бұрын
I think you're right about FRM standing for "formula". If I remember rightly, in Applesoft, if you wrote a deeply-nested expression that overflowed the evaluation stack, the error message you got was "FORMULA TOO COMPLEX".
@zac917629 күн бұрын
Hey Ben! I've been loving your content since your first releases of the 8-bit CPU you made. I'd love to see a dive into more RISC architectures, whenever you start to finish up the 6502 series. I've developed a few RISC CPUs myself, with some great help of your explanations, and would love to see my favorite Comp-Sci creator touch a few topics a bit closer to my knowledge!
@jatinkrumkar7689Ай бұрын
when bad times hit this guy posts a video and then the time is no longer bad you just amazing!!
@akaHarvesteRАй бұрын
This was jaw droppingly amazing 🤯 Mind that if you followed along since the beginning of the b breadboard computer series, We've watched Ben basically reinvent modern computing, from bits of wire and transistors, to evaluating formatted strings in software. We need an international holiday to celebrate this man!
@smallduck1001001Ай бұрын
Ben starts at a big step up though, with a 6502 processor. There are few people making videos chronicling creation of custom CPUs on breadboards out of simple logic chips. My current favorite is @fabianschuiki www.youtube.com/@fabianschuiki/videos he's now replacing components he's done on breadboards with custom circuit boards (with some tiny surface mounted components he solders himself), cleaning it up in preparation for some more fancy instruction decoding to come which I personally can't wait to see.
@akaHarvesteRАй бұрын
@smallduck1001001 that's why I mentioned the breadboard computer series. The 6502 CPU only makes sense after you watch that.
@RoSi4YouАй бұрын
I will never follow or understand any of this, but I am fascinated, how clever you are. Hats off.
@MadScientist267Ай бұрын
I grew up on the 8088 which is different but close enough to this to call it... I remember thinking everything happening inside that box was just pure magic... and before it was over had basic and qbasic doing handstands lol... seeing the infrastructure under the hood and what made all of it tick is a wild blast from the past. I still have trouble following along with some of the assembly but still wild to watch as each block of this thing lays the foundation for the ones to follow. I'm strongly considering getting one of the kits just to play around with. Certainly *waaay* cheaper than the box I'd have otherwise needed to modify to really get my head around the hardware.
@chrisdixon5241Ай бұрын
FAC is definitely standing for Floating point ACcumulator. If I remember correctly, the C64 has both FAC and FAC2, but I had no idea they were "repurposed" for printing strings! Excellent video!
@adriansnow5087Ай бұрын
Superb - really enjoyed watching that.
@chriswalker2753Ай бұрын
Brilliant! Takes me back to my early days on a 6502 machine. IIRC the comma and semicolon are used to modify formatting. Comma allows printing a separated list of things. Semicolon at the end prevents a newline. I think you can also use semicolon to suppress the space prepended to positive numbers.
@melkiorwiseman5234Ай бұрын
Comma is used to say "advance to the next tab stop before printing the next thing" while semicolon is used to say "print the next thing immediately after the previous thing". Without either, it advances to the start of the next line before printing the next thing.
@MadScientist267Ай бұрын
Semicolon did a few things in basic... I learned it as "(prepare to) append", preventing CRLF from running at the end of a print statement... similar to concatenate strings.. and in GW/Quick (at least) it would also dump the question mark at an input prompt, allowing you to change it to whatever you wanted within the prompt instead. Long time ago haha might be more uses but that's all that comes to mind at the moment. Edit: I've never heard of it dumping the leading space for a number, or I've forgotten lol, but that would have been nice to know many many years ago 🤣
@HipsterBaby747Ай бұрын
Ben eater’s original videos nerd sniped me so hard I got a masters in computer engineering. I still love these videos and learn something every upload
@ExpressoMechanicTVАй бұрын
Fascinating stuff - many thanks for doing this!
@der.SchtefanАй бұрын
8-bit show and tell has a lot of explanations how the C64, which uses a modified version of Microsoft Basic, works internally, especially with stuff like this. It is fascinating to see. It also applies very well if you want to modify Microsoft Basic on this project.
@alaksiej5913Ай бұрын
This is Microsoft Binary Format (MBF). Ask Mr. Google for more info. HEX 82 C0 00 00 00 = BIN 1000 0010 (exponent) 0 (sign) 110 0000 0000 0000 (mantissa) => BIN +0.11 * (10 pow (1000 0010 - 1000 0000)) = DEC 0.75 * (2 pow 2) = DEC 3
@chromosundriftАй бұрын
Yes Ben I found that interesting. As usual!
@DocM221Ай бұрын
I think you should natively support keyboards and text to LCD to make the whole computer self contained!!
@hamzawali2893Ай бұрын
HES BACK 🎉🎉🎉
@DavidLatham-productiondaveАй бұрын
Oh man. A video on floating point in 6502 would be awesome!
@jeffreyholtmyer5012Ай бұрын
An I2C interface to a serial flash rom for storage would be an awesome next video.
@Keys_991427 күн бұрын
I am glade to see another video ! Sometimes I get worried that it may be the last time you upload .... 😅😂
@patric-z2i17 күн бұрын
wouldn't it be cool if the breadboard-computer had circuitry for a video generator wich can produce text aswell, so this device could be an actual computer
@mrbrianparkerАй бұрын
Fascinating as always. I would also be interested if you do a floating point video.
@BrainSlugs83Ай бұрын
Those edge cases of semicolon and comma are important for printing multiple variables and literals together, and whether or not to put a carriage return, nothing, or a tab at the end of the string.
@DavidLindesАй бұрын
Wild. Fun stuff; thank you for sharing your explorations!
@jeffreyholtmyer5012Ай бұрын
Very interesting, I very much like seeing how to work with assembly code. Your videos are Bothe entertaining and educational. Thank you very much.
@DW-indeedАй бұрын
Any day with a Ben Eater video is a good day... Though it reminds me again that I haven't done anything on my Acorn Electron build for a lot of months now... life, man 🙄
@hotrodhunk7389Ай бұрын
What a great Saturday! Great morning with my family. Now a Ben eater video?
@StevenHokins15 күн бұрын
❤
@msmith2961Ай бұрын
Ben Eater videos are why i bought a clicky keyboard 😂
@adrianocamargo3193Ай бұрын
A big yes to floating point numbers video!
@CraftMine1000Ай бұрын
Always a good day when Ben posts
@saultube4429 күн бұрын
Oh it was, thank you. Always happy to look under the skirt, ehem hood, at Assembly level of Software. Now I see why Quick Basic and later Visual basic, were the improvement over Basic
@globalfarkndalk454029 күн бұрын
wunderbar
@MissNoringtonАй бұрын
Please, do floating point numbers video: I think you would be able to explain it in a different (better) way compared to others on KZbin
@Lord-SméagolАй бұрын
It's easy 'reverse engineering' BASIC when you have the source code :) I had to first make my own source code for Nascom ROM BASIC by disassembling it in 1981! I can't remember finding any serious Microsoft bugs, except that they assembled it for 8080 and not Z80. There were some bugs in the routines that Nascom added, but nothing that broke it when using the T4 or NAS-SYS monitor ROMs. There was a bug in LIST where it would expand characters 80-FF to reserved words when they were string literals. This was funny when I let Computer & Video Games magazine include my Nimbot game as a type-in listing. I was using DATA and PRINT statements with block graphic characters in quotes. They didn't even contact me to fix it before publishing, they just printed the listing, which would have been a real pain for people to get working properly!
@Lord-SméagolАй бұрын
Another problem I found with Nascom BASIC was with strings. When a large number of strings was active, such as a string array with many elements, and many changes have been made to those strings, this would trigger a 'garbage collection' which shifted all the active string data down to leave a single region of free memory. The algorithm was very inefficient; It searched all string variables to find the string in the lowest address in memory that needed to be moved down to release the unused memory. For each of N strings, it would have to search through those N strings to find the lowest one to move. This would need N*N checks, which could stall your program for a very long time ... I managed to get > 1 hour!!!
@DanHowardMtlАй бұрын
I would LOVE a video on floating point. I never understood how they could get even basic floating point math to work in 8 bits.
@yazidkeraichia2858Ай бұрын
Great thanks ❤❤❤
@simonepernice8059Ай бұрын
Great content, thank you very much!!! Could you make a video on floating point, please?
@MangoJones139Ай бұрын
20:55 Isn't the range from $0100 to $01FF the stack area? This feels like a bug in the BASIC interpreter that could cause corruption if the stack is almost full, but probably rare to actually cause problems.
@smallduck1001001Ай бұрын
Maybe those bytes got there by being pushed onto the stack?
@gsittly5 күн бұрын
I looked into eval.s and there you can see that the intermediate steps of each numerical operation are stored onto the stack. It leaves the result there to get fetched for display or storing.
@mxljeАй бұрын
„Hopefully you found that interesting“ - oh yes, most definitely.
@boretrkАй бұрын
OK, but you don't check for 0-length strings so what happens if you do LCDPRINT "" ?
@tsuomАй бұрын
this is so cool
@bobvines00Ай бұрын
Here's another vote for a video on floating point programming(?). Thumbs up!
@luckyizzacАй бұрын
Benny is back❤
@staswisniewski4101Ай бұрын
Babe, wake up, new Ben Eater's video just dropped
@ET_gamer13ytАй бұрын
the king is alive
@ovalteen4404Ай бұрын
The string format in MS BASIC is also continued in BASIC for the IBM PC. If you call varptr(s$), the returned pointer is that 3-byte structure with the length and the pointer to the string data. So apparently you can still learn a lot about older MS BASIC by looking at the appendix of the IBM BASIC manual from the PC/XT days.
@MonochromeWenchАй бұрын
Microsoft used a shared codebase for all versions of Microsoft BASIC. So the basic data structures are the same for all of them regardless of platform. The open sourced GW Basic source has extensive comments explaining how things work but other than the more detailed comments the x86 assembly of GW Basic wont really be any easier to understand than the 6502 code here.
@ovalteen4404Ай бұрын
@@MonochromeWench I was speaking of the IBM BASIC users manual though. The appendix has a lot of info about internals, such as memory organization and variable formats.
@TheStickCollectorАй бұрын
It would be cool to make a programming language that can run basic commands (or is built around basic) would be a good way to get into programming.
@badstateАй бұрын
BASIC is a programming language that can run BASIC commands. I guess I'm missing your point.
@dacomputernerd4096Ай бұрын
Ooo new video If you're still doing videos on communication protocols, I'd love to see one on I2C
@billyhart3299Ай бұрын
Yes please do a video on floating point numbers
@KryllyxOfficialАй бұрын
15:42 I can't speak for other people, but that'd be an awesome video!
@GameBacardiАй бұрын
Good video, thank you again
@northcoast7184Ай бұрын
Thank you Ben.
@mikesz-_-Ай бұрын
Bro u made my life danke schön
@MattyEnglandАй бұрын
Eater Alert 👍
@willembeltmanАй бұрын
I just love your videos
@rick_.Ай бұрын
Q: FOUT calls a different string print routine that includes FREEFAC. You are always calling FREEFAC. FAC isn't loaded for strings, so won't calling FREEFAC unnecessarily result in bad things happening?
@somethinggeekyАй бұрын
Hot swapping ROMs, wild man 👍😎
@markramsell454Ай бұрын
Just look at the linker output to see what is built for your conditional stuff.
@MrMassarakshАй бұрын
Thank you!
@DmitryKandinerАй бұрын
15:45 Looks much more like a fixed point number for me.
@OscarSommerboАй бұрын
Your guess is correct FAC is indeed the floatingpoint accumulator. Or at least it is on the C64
@gabrielsrokaАй бұрын
yes, C64 also uses Microsoft BASIC.
@ed_halleyАй бұрын
A whole video on IEEE 754 would be cool. I think the FAC would be the F from FRMEVL, or Formula.
@artefox0Ай бұрын
I would love a video on floating point numbers
@SpaceMyNameАй бұрын
BASIC mentioned! 🥳
@YaroKasearАй бұрын
I'd like both a floating point video, and maybe a transition into using the C functionality of cc65.
@talmeron6593Ай бұрын
i would love to see a floating point video!
@miniropАй бұрын
first time I see one of Ben's video with fewer than 1,000 views :O
@Chems7308Ай бұрын
Very awesome
@stevetodd7383Ай бұрын
From memory, FAC is the floating point accumulator.
@gabrielsrokaАй бұрын
correct. a quick Google would've confirmed it for Ben. eg, the C64 Wiki has a short entry about it.
@hisarharyana840Ай бұрын
Love you sir ❤
@morlaniusАй бұрын
I would be interested to see how it is reserving and freeing memory works there.
@bluegrass5425 күн бұрын
I would low to see a sound card built!!! Please do a video on that.