Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I have found your site brilliant. What makes it good are the people that contribute to the site..."

Geography

Where in the world do Tek-Tips members come from?

register indirect mode in Assembly

posterise (TechnicalUser)
8 Jun 06 9:35
Is it allowed to do the following?:

mov CX, [EAX]
mov [EAX], CX

???

mov W1, [EAX]
mov [EAX],W1
where W1 is not doubleword (word or byte)

In plain english, what is the real difference between direct and indirect access mode ?
I can't find examples of invalid descriptions and the reasons why.
TessaBonting (TechnicalUser)
9 Jun 06 3:04
All of the above are correct.

Indirect addressing, as it says, lets you get the memory
value that is pointed by the given register.

So if EAX = 100

    mov ebx,[eax] gets the 100th dword relativ to DS into
EBX.

    mov [eax],ebx puts the contents of EBX into the double
word at address DS:100

Succes, Tessa
posterise (TechnicalUser)
9 Jun 06 12:38
Thank you TessaBonting, but I don't understand what exactly happens in case I try to do this kind of thing:
mov W1, [EAX]     W1 - type of the W1: word or byte
or
mov BX, [EAX]

if the number, that [EAX] points to, is a doubleword, is this number going to be just truncated when trying to put into BX or W1(which is in the memory), because BX and W1 can contain only word meaning ? Or because of the different types is it going to display an error, just like in case of move BX, EAX ?

(I just started learning Assembly recently, and don't get some of that abstract stuff)
denc4 (Programmer)
10 Jun 06 11:06

Quote (TessaBonting):


So if EAX = 100

    mov ebx,[eax] gets the 100th dword relativ to DS into
EBX.
shouldn't that be the 25th dword??

posterize

most assemblers will fetch the byte/word (depends on the size of W1) from [EAX] and handle this correctly.

if W1 is a word and you want to be sure the assembler will
treat it that way you can explicitely tell it with what it
is dealing with:

  mov W1,word ptr [EAX]

or in case of a byte sized variable:

  mov W1,byte ptr [EAX]

i'm a 16bit programmer myself, so i'm not 100% convinced
if it will work for you. just try it and you'll see.
posterise (TechnicalUser)
10 Jun 06 13:16
Thank you denc4

I've tried it in a program practically, and actually this is what is going on:
it accepts when I use mov BX, [EAX]
but it doesn't when I use
mov W1, [EAX]   where W1 - word

Actually it gives the same number of the error which appears in case I put for expample add W1, W2
so, I guess that declaration is incorrect because parameters are affiliated only with the memory, which is incorrect
denc4 (Programmer)
10 Jun 06 15:30
exactly.
to add a value in memory to another value in memory you have to use an intermediate step.

for example:
to add word at [eax] to W1 use:

  mov ax,[eax]
  add W1,ax

to add W2 to W1 use:

  mov ax,W2
  add W1,ax
posterise (TechnicalUser)
10 Jun 06 16:27
yeah, after I tried that experimentally, practically, and also compared numbers of mistakes, I finally realized what is the difference between [EAX] and EAX - indirect and direct register access, - which I could not understand before, that's why in the first post I asked what it means in plain english.

Anyway, everybody, thanks for participation in the thread! :)

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close