Reputation: 101
I was reading the source code of LILO for a project and I stumbled across this line
mov dh, [d_dev](bp)
I wished to know what the mov instruction is doing here, I know that if it is
mov dh, [d_dev]
then the value pointed by d_dev is placed in dh but what happens with the (bp).
Any help would be appreciated.
Source Link: https://github.com/a2o/lilo/blob/master/src/first.S line 205
Upvotes: 0
Views: 125
Reputation: 363980
LILO still uses AS86 (note the get common.s /* as86 "include" will bypass the CPP */
) line at the top.
AS86 apparently has op dst, src
operand order, but memory-operand syntax looks like a cross between AT&T and Intel. [d_dev](bp)
is AT&T d_dev(%bp)
or NASM [d_dev + bp]
, i.e. base register = BP, with the address of d_dev
as a disp8 or disp16.
An earlier line in the same file zeros BP:
xor bp,bp ! shorted addressing
Presumably d_dev
is an offset that fits in a signed 8-bit displacement. Yes, the label appears pretty soon after a .org 6
, so its address is a small displacement, and mov dh, [bp + disp8]
is only a 3 byte instruction, vs. mov dh, [disp16]
being a 4 byte instruction (opcode + modrm + disp16).
So mov dh, [d_dev](bp)
does the same thing as mov dh, [d_dev]
, but in one less byte of machine code, because BP=0.
Upvotes: 1