Welcome! Log In Create A New Profile


registers and memory locations

Posted by yegengovender 
Announcements Last Post
Announcement : Programming Students at UNISA School of Computing 06/19/2019 02:01PM
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
registers and memory locations
September 08, 2008 02:51PM
Hi all

Here's something that confused me while working through the 2007 paper.
I stored a few numbers like so:

input_array: db 023, 043, 012, 033, 231

, then I stored the address of the first number in DX:

mov dx, input_array

Now it is my understanding that the memory location that DX is pointing to is one byte, which can be stored in a lower order (or higher order) register. Yet the following command fails:

mov al, [dx]

Yet the following commands accomplishes what i need:

mov si, dx
mov al, [si]

Why is it that AL cannot directly store the value DX is pointing to, but can store the value that SI is pointing to? Any suggestions out there?

Anonymous User
Re: registers and memory locations
September 09, 2008 10:48AM
not too sure about this but have you tried

mov ax, [dx]

the thing I remember from my days of studying this module is that al refers to the lower half of the full ax register. so there might be a sizing issue when moving from the full dx reg into the lower half of the ax reg.

But then again - maybe i'm talking cr4p?!


Re: registers and memory locations
September 09, 2008 10:56AM
Hi thornza

You are quite right in that AL does refer to the lower register of AX, but [DX] is actually referring to the contents at the memory location addressed in DX. Since this is a single memory location, the contents are not larger than a byte, and hence we refer to the lower order register.

Thanks for the thought though. I did try the change, but still it didnt work. Hopefully someone out there will be able to shed some light.

Anonymous User
Re: registers and memory locations
September 09, 2008 11:45AM
does adding sizing information e.g.

mov al, byte [dx]


--edit actually no - it seems that the size will be assumed - so just ignore this suggestion
Re: registers and memory locations
September 09, 2008 12:19PM
Hi all

I managed to find the cause of this problem:

The operation mov register, [address] is known as Indirect memory addressing

eg. mov AX, [BX]

According to http://www.husseinsspace.com/teaching/udw/1996/asmnotes/chaptwo.htm ,
"For indirect addressing, the 8086 can only use the BX, BP, SI and DI registers."

This is why [DX] is not a valid source operand for the move instruction.
I don't think I came across this in the tutorial matter, but I am more than willing to be corrected on that.

Has anybody else come across some rules/pointers that is worth sharing?


another site worth looking at:

Sorry, only registered users may post in this forum.

Click here to login