Thread: [Tutorial] GBA ASM Programming
View Single Post
  #39    
Old November 30th, 2010 (09:10 PM).
Shiny Quagsire's Avatar
Shiny Quagsire
Working on KARL3DS
 
Join Date: May 2009
Location: Hoenn Safari Zone
Age: 17
Gender: Male
Nature: Jolly
Quote originally posted by forestw785:
I'm guessing you didn't route your cmd prompt to the folder with your ASM stuff.

If it's on your desktop, then how you route command prompt there would be:
xp: cd \Documents and Settings\(username for your computer)\Desktop\ASM
7/Vista: cd \Users\(username for your computer)\Desktop\ASM

And press enter, and then the command prompt is rerouted to your ASM folder.


My problems:
I follow your tutorial, and I get everything to work in the first two lessons with no problems, but even with your "explanations" I don't understand what these codes are actually doing. I'm basically just telling the ROM to behave a certain way without knowing how I'm making it behave that way.
Example:
  • What is a callasm?
  • What is buffernumber 0x0 lastresult

There are others too, and you even define them. An example of that would be:
.align 2-This aligns the ASM by a multiple of 2, since each instruction is 2 bytes long. (aligning the ASM does what exactly?, and a multiple of two what?)
push {r0-r1,lr}- This pushes registers r0, r1, and the link register into the stack. (what is {r0-r1,lr}? what is r0, r1, and lr?}

Look at it from someone else's perspective:
Gita monooto hon : These are words in another language, and they deal with sound.
Not specific enough, and provide no real understanding of the material, right?
Alright. It sounds like you havn't done too much scripting. Callasm calls a select routine from a script. It basically calls your ASM and returns. Call ASM. Buffernumber takes a number in a variable and stores it into a buffer such as [buffer1]. As for alignment, it makes sure the labels, and accessed data can are in addresses that are multiples of two.

Quote originally posted by ASM Book:

A Simple Example
Boundaries are evenly divisible memory addresses. For example, an address that is aligned on a 4-BYTE (DWORD) boundary is evenly divisible by 4. The processor will always get it's data from DWORD boundaries and in DWORD sizes. So, if you had the following
1111 2222 3333 4444...
and you wanted to get the second DWORD, the processor would find it on an address divisible by 4 (a boundary) and get it in one fetch. However, if the data was misaligned like this
1122 2233 3344 4400...
and you wanted the same DWORD, the processor would
1. Get the first DWORD (FETCH 1)
2. Chop off the leftmost 3 bytes
3. Get the second DWORD (FETCH 2)
4. Chop off the rightmost 1 byte
5. Then put them both together.
This requires 2 memory fetches and takes longer to execute. This is how it applies to DWORDs as in the previous example. For word size values, there would be no change because the 2 bytes are available in the first pass in both cases. There are certain instructions that work better on 16-BYTE boundaries (such as movsd) and some that require it (some FPU instructions).
So basically it allows code to be acessed right and it helps the processor to be faster.

r0, r1, and lr are your variables. They are used to keep data for code, and then the data is used. Some times they hold addresses, data to be written, and arguments for other routines.
__________________



Reply With Quote