before i state my question i'll like to note that i'm a beginner in HLA.. and it seems ever interesting to me seeing how its based on previous languages i've studied.. however, i understand the concept and that 32 bit registers overlay 16 bit registers.. and 16 bit registers overlay 8 bit registers.. but,i'm still confused when it comes to the the "mov" instruction. for example:

mov(0,al); // 8 bit register is copied to 0
sub(10,al); // 8 bit register is copied to 10
mov(al,18); // 18 is copied to 8 bit register

is it possible to use either high or low? or even both? and why the strange assignments? like al into 10 and 18 into al? these question also relate to the other instructions below..

mov(0,ax); //8 bit register is copied to 0
sub(116,ax); //ax is copied to 116
mov(ax,116); //116 is copied to ax

mov(0,eax); //32 bit register is copied to 0
sub(132,eax); //32 bit register is copied to 132
mov(eax,132); //132 is copied to 32 bit register

just by taking a wild guess, is it possible that, when making a program you have to stick with the registers within a 32 bit register.. meaning.. for example in this programing the author used eax which extents to ax.. and then al and ah.. but ah wasn't used.. also, it is possible to use 2 32 registers with in a single program? i would greatly appreciate if someone has the time to clearify this for me. Even though asm is a complicated language i'm dedicated in learning it.. but for now i'm :shock:
Posted on 2004-09-02 12:53:25 by JuJuMagic
before i state my question i'll like to note that i'm a beginner in HLA.. and it seems ever interesting to me seeing how its based on previous languages i've studied.. however, i understand the concept and that 32 bit registers overlay 16 bit registers.. and 16 bit registers overlay 8 bit registers.. but,i'm still confused when it comes to the the "mov" instruction. for example:

mov(0,al);      // 8 bit register is copied to 0

sub(10,al); // 8 bit register is copied to 10
mov(al,18); // 18 is copied to 8 bit register
I don't want to be cruel, but you seem to be missing the operand ordering. "mov(0,al);" copies 0 into the al register.

is it possible to use either high or low? or even both? and why the strange assignments? like al into 10 and 18 into al? these question also relate to the other instructions below..
To assign the value 8 to al, use "mov(8,al);". To copy 200 to ax, use "mov(200, ax);" To copy 3 into eax, use "mov(3,eax);". In a general purpose register, the xl part is the lower byte, xh is the high byte of the lower word, xx is the lower word, and exx is the full 32-bit register.

Originally, on the 8086, there were only 16-bit registers. The use of xl and xh were to allow you to access the low and high bytes individually. When they created the 32-bit 80386, they extended the registers to 32 bits, but didn't allow you to access the high word of its bytes as individual pieces.

mov(0,ax);       //8 bit register is copied to 0

sub(116,ax); //ax is copied to 116
mov(ax,116); //116 is copied to ax

mov(0,eax); //32 bit register is copied to 0
sub(132,eax); //32 bit register is copied to 132
mov(eax,132); //132 is copied to 32 bit register
One big thing, why are you using the sub instruction? That's used to subtract two numbers, not move values.

just by taking a wild guess, is it possible that, when making a program you have to stick with the registers within a 32 bit register.. meaning.. for example in this programing the author used eax which extents to ax.. and then al and ah.. but ah wasn't used.. also, it is possible to use 2 32 registers with in a single program? i would greatly appreciate if someone has the time to clearify this for me. Even though asm is a complicated language i'm dedicated in learning it.. but for now i'm :shock:
Nice to know your willing to learn new languages.

EAX isn't the only register. There's four general purpose registers: EAX, EBX, ECX, and EDX. There are four other nearly general purpose registers that can be accessed as only 16- or 32-bit quantities. They are: ESI, EDI, EBP, and ESP. ESP is the stack pointer, so you can't use it for anything else other than stack operations. EBP is used for the stack frame, so you don't have to address values reletive to the stack pointer all the time, which can be confusing. ESI and EDI are general purpose, though their best use is as pointers to blocks of memory. That's what they were origionally designed for. (E)SI stands for (Extended) Source Index, meaning it's original intent was for use as a source pointer. (E)DI stands for (Extended) Destination Index, meaning it was intended to be used to hold the destination adress.

I hope I cleared this up for you and not made things worse. It wouldn't surprise me if I did. :roll:
Posted on 2004-09-04 15:22:01 by NoDot