- #1
twoski
- 181
- 2
Homework Statement
I have a homework question: Calculate the effective address and determine the addressing mode that is specified for each memory operand in the following statements.
(a) MOV EAX, [label1] ; label1 is at location 0x00D5A360
(b) MOV EAX, [EBX] ; EBX points to location 0x00D5A360
(c) MOV EAX, label1[EDI] ;label1 is at location 0x00D5A360, DI is equal to 8
(d) MOV EAX, [EBP + ESI*4] ;EBP points to location 0x00D5A360, ESI is equal to 4
(e) MOV EAX, [EBX+100h] ;EBX points to location 0x00D5A360
The Attempt at a Solution
First of all, i am confused as to why assembly uses these addresses with arbitrary names. Why do EAX, EBX, etc. exist? My professor is terrible at explaining these things and his slides for lectures are cryptic.
Secondly, i cannot find a website that sufficiently explains the differences between direct/immediate/direct register/indirect register/base/base indexed/simple addressing. I don't know how to calculate effective addresses either and i can't find anything in the lecture slides about it.
My guesses for these:
- Direct addressing is when you use [] to denote the data stored in a location.
- Indirect is the opposite, you do not use [] and you access a location rather than data. (I don't get how this is any different though. if i did MOV X,Y and MOV X,[Y] where Y = 3 wouldn't it do the same thing?)
- Register addressing looks to me like it's the exact same as indirect addressing, at least from the examples our teacher gave. Maybe it only uses the arbitrary predefined addresses?
- Register indirect addressing is when you use [] on the predefined addresses like EAX.
- Base addressing is like indirect addressing except you add a displacement to your base address (why would anyone do this?! wouldn't you be accessing data from some place that you don't want to?!)
- Indexed addressing is when you access an array address(?)
- Base indexed is like a combination of indexed and base addressing. Again, i don't see the use in it.
Anyhoo, back to solving it.
MOV EAX, [label1] makes no sense to me since [label1] results in the data stored at label1. But the question doesn't specify what is stored there, it just gives the address. I am guessing that using [] on a label results in its location. So if i have this hexadecimal number as my result, how do i figure out the effective address? Is that all i need?
I can't make much headway without knowing a lot of this stuff. It's just frustrating because i can't find any concrete definitions of anything.