Buttherahmonlyneeds 15 addresslinesbecauseitcanonlyhold 32 K ofdata.
Sowekindofhave a choicehere.
Ifwejusttook a zerothrough a 14 directlyfromthemicroprocessortotherahm, justlikewehavehere.
ThenwhenthemicroprocessorReed's addresszerothroughseven f f f oryouknow 7 32,067 Thenit's gonnareadAddresszerothroughseven f f f for 7 32,067 fromtheprom, whichmeansit's gonnabeabletoreadfromanywhereintheroom, whichiswhichisgreat.
Butthen, iftheprocessortriestoreadfromaddress 8000 through F f f f thisisthis a 15 linewillbehigh.
Butyoumightrememberfromthelastvideothatwhenthemicroprocessorstartsup, thefirstthingitdoesisitreadsfromaddress F, f, F, C and F F F D, anddoesthattofigureoutwheretostartfetchinginstructions.
Sowe'd reallylikethe F, F, C and F FTaddressestobesomewhereinourrumsothatwecanprogramthatstartaddressingtheRome.
Butyouknow, that's easyenough.
Wecanjustinvert a 15 beforewebeforeweconnectedtothechipenablesignal.
Sothisway, whenthemicroprocessorisreadingfromthisupperhalfoftheaddressspacethat a 15 lineisgonnabehigh, thatfirstbitis a one.
I'llhookuptheother 15 addresslinesfromtheprocessortothe e problemandagain, startingwith a zeroontheprocessor, connectingto a zeroonthepromandgoingallthewaythrough a 14 ontheprocessor, connectingto a 14 ontheproblem.
Sothen I'llhookuptheeightdatalinesfrommicroprocessortoGEprom, and I'llstartwith D sevenonthemicroprocessorandhookthatto D sevenonthepromandworkmywaybackto D zeroonthemicroprocessor, hookingto D zeroontheproblem.
Sonowwhenevertheprocessorwantstofetchaninstructionfromthe e problem, itcanreadfromanyaddressintheinthetophalfoftheaddressspaceandwillbeabletousethesedatalinesthesebluewirestoreadwhateverdatathe E problemspitsoutatit.
Sonowlet's programthepromwithsomeinstructions, andmaybe a goodplacetostartistoe.
Butanyway, I'm creating a bitearrayjustfullofhex E a bitesandthere's gonnabe 32,768 ofthemandlikethelastvideousingthe E a hex, becausethat's theopcodefor a noopinstruction.
Sowhentheprocessorreadsthat, A, it'lldonothingandjustmoveontothenextbite.
Sonothingbutheisdon't makefor a veryinterestingprogram, Butatleastitis a validprogram.
Andthen I canopen a filetowriteitto w B.
Meansright.
Binaryandthenoutfilewillbethefilehandle.
Andthen I couldjustuseoutfileTeohrighttherahmimage, andthat'llcreate a binaryfilecalledrahmdotbeenwithexactly 32,768 hexee A's init.
Andithastobeexactly 32,768 biteslongbecausethat's howbigthe E promise.
So 32 k a problem.
Ifwesavethatandrunit, that'llcreate a rahmdotbeenfile, andif I dumpthecontents, ifyoucanseeit's justfullofdaysanditgoesfromzeroallthewayupinthestarjustmeanstherestofthefilesisthesameasthisline.
Soit's just a wholebunchof e a czallthewayupto 8000 hex, whichis 32,768.
Butwhenweputthatontheprom, rememberthattheprocessorsactuallygonnafetchthosebitesfromaddress 8000 through f f f f becausethe e promiseonlyactivewhen a 15 thetopaddresslineisactive.
Okay, solet's getthepramprogrammed.
Soputthepraminthepramprogrammerhere.
Andthisisah, t l 8662 plus a promprogrammer, whichseemstoworkprettywell.
ItcomeswithWindowssoftware, whichwillletyouwrite a filetotheprom.
Butthere's alsothisopensourcemanyprosoftwarethatworkswithMacorLennox, so I couldjustdomanyprotellyouwhattypeofdevice I'm using.
Inthiscase, it's Ah 80 28 c 2 56 e promanduntilittorightthewrongdotbeenfileandtheregoesitsprogramming, thepromwiththecontentsofthatfilefullofease.
Andlet's tryitout.
I'llputtheprombackinthecircuit, and I'm gonnahookuptheArduinomegalike I didinthelastvideo.
So I'm hookingupall 16 addresslinessowecanmonitorexactlywhattheprocessorsdoingwith, um, Sothere's a 16 addresslinesandthen I'llhookupalleightdatalinestotheArduinoaswell, sowecanseethedatathatthepromisoutputting.
Weknowlikethatsomewhere, andthenwecanpoweritallupNowif I usethesameArduinoprogramforthelastvideoandopenuptheserialmonitor, wecouldseetheprocessorisreading e a bitesfromsomewhere, anditseemstobeexecutingthemnow.
We'resettingposition a seven f f c andseven f f d oftherahmtothesevalues, butbecauseinordertoenabletherum, theprocessoralsohastosetthat a 15 Thetopaddressbittoeone.
Aah!
Thesevalueswillactuallyappeartotheprocessorataddress F f, c and F F f d.
Sonowlet's trywriting a programthatdoessomething a littlemoreinterestingthanjust a bunchofnoups, becauseatthispoint, theprocessorisgonnatryandexecuteanyinstructionsthatitfindsstartingatthataddress 8000 whichisreallyaddresszerooftherum.
Andso, forexample, ifyouwantedto a load a flipoverhere, wecanfindthis L D.
A instruction, whichisgonnaloadsomevalueintothe A register.
Andwelookheretoseewhatthehexdecimalahupcodeisfor.
Forthatload a instructionandactually a numberofdifferentupcodesforlowday, dependingonyouknowwhatwewanttoloadintothe A register.
Forexample, if I'm gonnaloadthe A registerwiththevalueformemory, theopcodeis a D inhex.
Andthenwe'd giveit a memoryaddresstoloadfromorifwewanted a loadfromsomememoryaddress, plusanoffset, youknow, fromthe X or Y registertheirupcodesforthatandotherthings.
Orifwewanttojustloadthe A registerwith a particularimmediatevalue, there's anopcodeforthat, andthat's what a nineis.
Soifwegobacktowherewe'recreatingourrahmimagefile, ifwesaidthefirstfightin a rahmto a nine, youknow, thishasloadthenextbitefromRahmintotheregistersowecouldsetthenextbiteatLocationonehere, too, youknow, someotherrandomvalue, youknow?
Wehavesomehardwarethatrespondswhentheprocessorsetstheaddresslinestoto a particularaddresslikethisandthenfromtheprocessorsperspective, youknow, it'lljuststoredifferentvaluesto a particularaddresstotelltheoutputhardware.
Whatto d'oh.
Sothinkaboutwhatthatoutputhardwaremightlooklike.
Youknow, sofar, programandtheprocessorisgonnaoutputdatabywritingto a particulardresslikethis.
Someaddressdecodelogictodetectwhentheprocessoriswritingtothis 6000 addressandthen a latchtostorethedatathatitsoutputsothatitcanbedisplayedevenaftertheprocessorherehasmovedontootherthings.
Now, whenitcomestolatchingdata, I'vegot a wholeseriesofvideoswhere I build a CPUfromscratchandispartofthatSiri's I'vegotvideoswhere I talkabout s R latchesdelatches d flipflopson, andthenhowtobuild a registerandevenanoutputdisplayallfromscratch.
Soifyouwanttogodownthatrabbithole.
Well, you'reinluck.
Butforthisvideo, I mean, hewas a chipthatdoes a lotofthatworkforus.
Andthat's the 65 c 22 versatileinterfaceadapter.
Andasthenamewouldimply, the 65 c 22 virtualinterfaceadapterisdesignedtoworkalongsidethe 65 c zerotomicroprocessorthatwe'vealreadybeenusing.
Anditdoes a wholeyouknow, a bunchofinterestingandusefulthingsthatwouldyoutakemultiplevideostofullyexplore.
Andso, youknow, basically, oncewehookthisuptheprocess, we'regonnabeabletoeasilytalkbackandforthtothischipandthenontheotherside, there's just a wholebunchofiolinesthatarelatched.
Yes, we'vegotport A zerothroughsevenandimportantbezerothroughseven.
Andsooneofthethingsthatthischipletsusdoiswecansendsomedatafromtheprocessoroverhere, andthenit'lllatchthatdataonto, youknow, oneofthese i o portsoverhere, theportairport B andthenholdthatdatatherewhiletheprocessorgoesontodootherthings.
Andit's gotthesefourregisterselectpinsare a zerothroughRsthreethatareusedtoselectwhichportwe'retalkingtoouror, youknow, someoftheotherfunctionsthechipsupports.
Sojustliketheinverterwejustsawandthenwe'reendingitwiththewithone, andthenweget a zerooverhereandactuallycanfeedthatdirectlyintotheactivelowchipsLook, too.
So, really, youknow, thisdesignisonlyadding a singledamngate, so, yes, we'rekindofwasting, youknow, 8000 addressesorwhateveritistoactivatethisonechip.
Butwe'reactuallysaving, youknow, a wholebunchoflogic, gates, becauseifwehadtoputlogicgatesinheretocheckthatallofthesebitswerezerosandfeedthatintosomelogicthatactivatedthe 65 22.
Thatwouldrequire a wholebunchoflogicgates.
Andso, youknow, it's a tradeoffthatultimatelydependsonexactlywhatwe'rebuildingthisfor.
Youknow, we'retryingtobuildsomethingthatrequires, youknow, a certainnumberofaddresseswhereweneed a certainamountofmemoryor a certainamountofIoorsomethinglikethat.
We'llstartwith D zeroandconnectthatfromtheprocessortothe 65 22 andthen D one D, two d three d, four t five, t sixand d seven.
And I'lljustkindofcleanallthisup.
Trytomakeitastightas I can.
It's a wholebunchofwiresgoingeverywhere, soit's gonnabe a littlebitchallenging, buthopefullygetthis a littlebitneatersoyoucankindofseewhat's goingonhere.
Andwhatthosedoisthoseairusedtowell, asthenamewouldimply, select a differentregisterbecausethe 65 22 has 16 differentregistersthatyoucanaddressbyusingthosefourdifferentregisterselectpins.
Andforthisvideo, really, theonlythingwecareaboutistheoutputRegister A and B because, remember, ifwegobacktothepinouthere, we'vegoteightminuteshereforport a port a zerothroughthroughsevenandthenPort B zerothroughsevenin a waythatweoutputdatatoeitherportAirport B isbyusingtheseregisterselectpinshere.
Weactuallywanttoseewhat's beingoutputonport a importbe.
Let's hookupsomeladies, so I'm justgonnatemporarilystickeight.
Ledisoverhere, sowejustmonitor, youknow, eightoftheoutputbitsandthen I'llconnectthenegativesideofeachledtogroundthrough a 220 ohmresistorandyoucouldtellthenegativesideofthe L A.
Becauseit's usuallytheonewith a shorterleg.
It's alsotheonewiththeflatsideintheplastic.
Isthatinthepositivesideoftheled.
I'lljusthookuptotheeightpinsofPort B, whichdepends 10 through 17.
Andsofar, I haven't actuallychangedanythingabouthowthiscodeworks.
It's stilldoingexactlywhatitwasbefore, sothisfirstpartuphere, these 1st 2 bites, thisisessentially, ah, load A of 42 hex.
Andthenthisnextlineis a storyatAddress 6000.
Andsothisisexactlywhatwehadbefore.
Haven't changedanything.
It's just a littlebitmoreof a compactwaytowriteitsoeasy, Right?
Morecode, hopefullywillbe a littlebiteasiertofollow, butwewouldn't wanttostartoutbywriting a 42 toaddress 6000 becausethefirstthingweactuallyneedtodoissetthedate a directionfortheregister.