Could someone help me with ASM? After reading 'An Introduction To Cpu Architecture And ASM', I think I understand the basics (stw, subi, addi). I did have a pdf to help me, but for some reason my pc can't read it. Any help will be appreciated, thanks.
That's a very broad topic. What don't you understand? Register? Certain commands? etc.
-You read it about PowerPC, right?
Yes, I read it about ppc. I'd just like help overall. I understand registers, but commands I find are a problem as well as how they're written. Such as;
addi rD, r2, 12
This, I think, is add 12 to r2, and store it in rD.
li rS, rA, d(rD)
Things like that I have no idea.
Quote from: doomkaiber001 on November 24, 2010, 08:09:36 AM
Yes, I read it about ppc. I'd just like help overall. I understand registers, but commands I find are a problem as well as how they're written. Such as;
addi rD, r2, 12
This, I think, is add 12 to r2, and store it in rD.
li rS, rA, d(rD)
Things like that I have no idea.
addi r3, r2, 12
r3 = r2 + 12; // where r3 and r2 are registers;
// can also be written addi 3, 2, 12 as registers don't have r before them in some assembly syntax
li rS, rA, d(rD) is absolutely nothing
li r3, 0 means
r3 = 0;
lwz r3, 4(r2) means
r3 = *(u32*)(r2 + 4); // you're grabbing the value located at the memory address r2 + 4
Here (http://class.ee.iastate.edu/cpre211/labs/quickrefPPC.html) is a reference to some of the most used opcodes.
Quote from: megazig on November 24, 2010, 11:54:45 AM
r3 = *(u32*)(r2 + 4); // you're grabbing the value located at the memory address r2 + 4
That's a very programmery way to write it. You can also write that this way
r3 = [r2 + 4]
The apps tend to use the brackets when it means "treat this value as an address, and get the data at that address".
Thanks guys. I have the pdf working now, but help is still appreciated!
Romaap, I looked at the link. Do you happen to have a link to something that explains them better? I'd like something that shows an example.
Quote from: dcx2 on November 24, 2010, 06:31:31 PM
Quote from: megazig on November 24, 2010, 11:54:45 AM
r3 = *(u32*)(r2 + 4); // you're grabbing the value located at the memory address r2 + 4
That's a very programmery way to write it. You can also write that this way
r3 = [r2 + 4]
The apps tend to use the brackets when it means "treat this value as an address, and get the data at that address".
the issue I have with that way is, lbz r3, 4(r2)
your version would still be r3 = [r2 + 4]
though, docs often list this, it's not verbose enough for a true description
I'm familiar with PowerPC (Wii) ASM and ARM9 (Nintendo DS) ASM. If you want one-on-one help with either send me a private message.
I can also show you the sources of some of the codes I've written in ASM and explain what I did and why I did it.
addi rD, r2, 12
This, I think, is add 12 to r2, and store it in rD.
add the immediate value of 12 to the value held in r2 and store the total in rD
li rS, rA, d(rD)
Things like that I have no idea.
You can't really do that...li = load immediate value
so, li r3, 0x0 would put a value of zero in r3, overwriting whatever value was there before.
lwz r27, 0(r14) would load the 32bit value in the address at r14+0x0 and store it in r27
lwz r27, 2(r14) would load the 32bit value in the address at r14+0x2 and store it in r27 (but the addition of 0x2 isn't saved)
lwzu r27, 2(r14) would load the 32bit value in the address at r14+0x2 and store it in r27 AND update the address at r14 (adding 0x2 to it)
lwz is 32 bit (w means "word")
lhz is 16bit (h means "half of a word")
lbz is 8bit (b means "byte")