What is the meaning of register1:register2 in assembly language.
For example ax:bx, then which type of address will be used in this instruction.
Obviously two registers AX and BX are involved in this situation, how do they contribute to make the outcome of the instruction?
I saw a code line like this:
add [es:di], ax
I tried to debug, but no results.
register1:register2 (eg.
ax:bx) is never used in any instruction. It is never a valid instruction component, rather it is a way to convey a meaning: the notion of a value larger than what one register can carry.Please note that it need not stop at 2 registers.
It is always a combination of values, and the leftmost component is always considered the most-significant one.
Just how the individual values get combined varies.
Using general purpose registers
Your example of
ax:bxtypically signifies a 32-bit value for which the reconstituting rule is(ax * 65536) + bx.Another example could be
cl:bx:dx:axand that one would ordinarily represent a 56-bit value obeying the rule(cl << 48) + (bx << 32) + (dx << 16) + ax.Using special registers
If one of the registers is a segment register like in
ds:dx, the reconstituting rule is different. It becomes(ds << 4) + dx, at least in the real address mode of the CPU. Operating in protected mode the combinationcs:eipwould reconstitute from adding the value in the EIP register to some base address found in a segment descriptor.Even more special
There's nothing that prevents you from coming up with your very own formats. So, you could invent a combination of a 16-bit integral value with a fractional part in the range [0,99], simply by defining a combo like
AX:BL, just an example.This
es:diis not at all like theax:bxwe talked about above!Here the colon character does not really combine these two registers as was discussed before. The colon in this (valid) instruction is actually a terminating character for the Segment Override Prefix. In a MASM-style assembler you could write this instruction like:
add es:[di],ax, and in NASM you could write this same instruction also ases add [di],ax. See howes:no longer sticks to thedipart? The[di]that remains is just one of the available 16-bit effective address forms: