I'm sorry for this hardly understandable caption - I could not make up a better one.
I am trying to learn assembly (AT&T) and have a question about registers:
Are register-names each accessing completely different and independent memory? Or do they give access to specific smaller parts of one register and therefore address the same memory?
e.g.: Is al addressing the lowest 8 bits of ax, eax & rax, so that modifying ah modifies bit 9-16 of ax, eax & rax ? Or are ah, al, ax, eax & rax all different independent registers ?
Thanks in advance
Moritz
Registers use some type of electronic cycles called flip-flops, a flip-flop is a cycle that stores 0 or 1 and keeps it stored. An N size register is a block of N flip-flops. The flip-flop looks like this:
In a 32 bit register, 32 of these are aligned in one block with 32 bit input and 32 bit output:
notice, in this register there is no sub-registers, like eax
, ax
, ah
, al
. I guess Intel guys had to use 4 bit clock rather than 1 as:
eax
.ax
.ah
.al
.something like (8 FF, 8 flip-flops, and the dots means the line is connected there):
now when the processor decodes the instructions, it can tell which instruction you want and which register you target, which clock to trigger, using the opcode of the instruction:
[b0] ff mov $0xff, %al
[b4] ff mov $0xff, %ah
[66 b8] ff ff mov $0xffff, %ax
[b8] ff ff ff ff mov $0xffffffff, %eax
The realty might be different, but the principle is the same. You can read more about this stuff in any logic-design or computer architecture book, but you don't need to it to start program in assembly, but it will help you to understand how stuff works.