x86 - Why is this line of assembly an 'invalid use of register'? -
i going through os development tutorials , see following section of code:
.intel_syntax noprefix do_e820: xor ebx, ebx # ebx must 0 start xor bp, bp # keep entry count in bp mov edx, 0x0534d4150 # place "smap" edx mov eax, 0xe820 mov [es:di + 20], dword 1 # <<<this line don't mov ecx, 24 # ask 24 bytes int 0x15 jc short .failed # carry set on first call means "unsupported function" mov edx, 0x0534d4150 # bioses apparently trash register? cmp eax, edx # on success, eax must have been reset "smap" jne short .failed test ebx, ebx # ebx = 0 implies list 1 entry long (worthless) je short .failed jmp short .jmpin
when try assemble home-rolled kernel, assembler complains error: invalid use of register
@ line have marked. if helps understand situation, using gcc i686-elf cross assembler.
the use of 16-bit registers inside otherwise 32 bit code suggests snippet of ancient "magic" code, passed on father son in eldritch rituals. during time, supported syntax of assemblers changed, , once valid line no longer accepted modern assembler using.
this line
mov [es:di + 20], dword 1
is more commonly written as
mov dword ptr es:[di + 20], 1
which notation used intel in manuals.
Comments
Post a Comment