MIPS #11: Store Word

sw mips
This is a topic that many people are looking for. https://granthamandira.org/ is a channel providing useful information about learning, life, digital marketing and online courses …. it will help you have an overview and solid multi-faceted knowledge . Today, https://granthamandira.org/ would like to introduce to you MIPS #11: Store Word. Following along are instructions in the video below:


okay welcome back P&G 460 its hard to say Eng 460 chai say in that 10 times eh Eng 460 number 11 last time we did a load word and when you say load youre always referencing the register so load what load register load register that means youre taking stuff from memory and loading a register now theres another command called the store word command and again its reference to a register so youre storing a register where are you storing the register youre storing it in memory so load word brings it from memory to the register and store word goes from the register to memory okay so this program shows you how to use the store word and it stores data to memory okay now we have our usual parts got my little comment section up top I have the data segment here but notice Im going to use store word to write data to memory so I dont need to declare anything Ill just actually write it to memory okay then the next part is the text segment a and then we want to label the main program with a global preprocessor directive and then of course what do we have down here at the end of all the programs we have exit the program Li B 0 load immediate V 0 10 Cesc all know that you want that at the end of all your programs alright so lets talk about the store word command what does the store word command do well what the store word command does is it takes the contents of T 0 and it writes it to memory defined by this address and the way you read this is the contents of T 1 is a memory address add an offset of zero to that and thats the memory address that youre going to store the contents of T 0 apt for example this one here says look at the contents of T 1 thats a memory address add 4 bytes to that that resulting

memory address is where youre going to store the contents of T 0 okay down here the contents of t 1 is a memory address add 8 to it the resulting address is where youre going to store T 0 and then down here same thing but now youre going to offset 12 the is your base address the contents is your base address youre going to offset 12 from there thats going to give you a new 32-bit address and youre going to store t0 there so when you look at this code what Im really doing is Im Im setting up t0 with the value and then Im writing it to memory so here I increment t0 and then I write it to memory here I set T zero to one two three four five six seven eight and write it to memory then here I set it with a5 a5 a5 a5 and I write it to memory alright lets just go ahead and open this guy lets go over to here and do file reinitialize load and this would be a store word name now lets go look at our data segment did we expect anything to appear in the data segment well no we dont because we didnt put anything in the data segment in our code all right lets bring our code back up here and verify that the data segment was empty hey all right lets go look at our text segment well theres our code all right so lets hit f10 first thing we did is I had loaded t0 with hex 3-0 alright lets go look at that t0 should have hex 3 0 and it does alright lets go back and hit f10 right now when I hit f10 here what am I going to do Im going to do a load immediate again but this time Im going to load t1 with one thousand and one quad zero why am I doing one thousand and one quad zero well because thats the location Im

going to write data at all right lets hit f10 here and verify that t1 now has one thousand and one quad 0 t1 has 1,001 quad zero why do I want one thousand and one quad zero because thats where Im going to write in the data segment right now theres nothing out 1,001 quad zero because all these locations are 0 and 1,001 quad zero is in the middle there alright so now Im going to use my store word command and the store word command is going to say well the cut get the contents of t1 which is one thousand and one quad 0 add 0 to it which is still going to be one thousand and one quad zero thats a memory address store t0 to that memory address well t0 is a 3-0 so whats going to end up being at that location is three zero lets say at f10 and go check the data section segment and there you go we just wrote 3:02 location 1001 quod 0 but it did a 32-bit right it also wrote those upper 24 bits – its a 32-bit right okay all right now lets come along here and heres a command you havent seen before I dont think add immediate we talked about add command which does adds two registers and stores the result in a third well the add immediate takes on the contents of one register which we know is three zero and adds one to it and then stores it back in this register so t0 is going to be three one after we do that add immediate alright lets go check t0 and it is three one good lets go back to our program now what were going to do is we are going to store t0 which is currently 3 1 2 T 1 which is 1001 plus 4 so Im going to write T 0 to 1000 and 1 0 0 0 for base address plus an offset store t0 t0 is 3 1 lets

go look and see whats at 1001 0 0 4 before we do the command 1001 0 0 4 is this guy right here okay theres nothing there lets hit f10 and go take a look and see our data segment again there you go we just wrote the contents of that register which is 0 0 0 0 0 0 3 1 to that location and then it filled in the other 24 bytes for us now lets put a 32-bit number in there now here what Im going to do is Im going to put 1 2 3 4 5 6 7 8 into t0 okay lets go look at t0 first t0 currently has 31 all right lets go back to our text segment and I am going to hit f10 Im single stepping through it Ive got to do it twice this this command maps to two actual mips command so I had to hit f10 twice Ill explain that later has to do with a sudo command so now T 0 should have the contents 1 2 3 4 5 6 7 8 lets go check it out theres T 0 1 2 3 4 5 6 7 8 great alright now here Im going to take the contents of t0 which is one two three four five six seven eight and Im going to store it at the memory address t1 which is equal to 1,001 quad zero plus eight all right lets go look at our data segment this guy right here is one thousand and one quad zero this is one thousand and one zero zero zero four this one is one thousand and one zero zero zero eight so were going to write one two three four five six seven eight a 32-bit right thats going to start here at eight and go to eight nine a and B let me hit f10 and lets go see what happened at one thousand and one zero zero zero eight and there you go we just wrote it

at eight nine a and B and wrote that 32 bit quantity okay what are we going to do next alright now Im going to load T 0 with a5 a5 a5 a5 okay lets go look at T 0 85 85 85 85 and now what Im going to do is Im going to store that at 12 bytes past my offset of 1,001 quad 0 so its going to go to 1,000 and 1 0 0 0 see if you go to your data segment that would correspond to this location right here 1001 0 0 0 see when we execute that statement I left n step over we should get a five a five a five a five and there you go and we just wrote to memory we didnt use our data segment we actually use the store word command to take a value in a register that we put in with load immediate and then write it to memory now notice remember the zero zero zero those are all in printable characters right and then youve got a three zero here alright which corresponds here and then the 3 1 corresponds here and then you got the 3 non-printable characters its kind of backward over here and then lets see the seven eight okay seven eight actually corresponds to an X you can double check me a five six corresponds to a capital v a 34 corresponds to a four and a hex 12 is an unprintable ASCII character which is going to be represented as a period and all so a five is an unprintable ASCII character which is going to give you the dots right there all right nice and then then we just do load immediate v-0 ten to terminate our program all right and as we start using procedures itll make more sense while we always do that D zero load immediate ten determinate well thats enough fun store word but store word basically takes the contents of a register and writes it to memory all right

tags:
MIPS, AssemblyProgramming
Thank you for watching all the articles on the topic MIPS #11: Store Word. All shares of https://granthamandira.org/ are very good. We hope you are satisfied with the article. For any questions, please leave a comment below. Hopefully you guys support our website even more.

Leave a Comment