Converting barebones boot.s to intel syntax

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Twicetimes
Posts: 13
Joined: Sun May 29, 2016 10:53 am

Converting barebones boot.s to intel syntax

Post by Twicetimes »

Hi,

I followed the barebones guide and got the 'hello world' OS up and running.

As an exercise, I tried changing the boot.s file to intel syntax. As far as I can see, this just involved changing

Code: Select all

movl $stack_top, %esp
to

Code: Select all

mov esp, offset dword ptr stack_top
and then recompiling it with

Code: Select all

i686-elf-as -msyntax=intel
This all went fine. However, when it came to linking time, I received the following error:

Code: Select all

(.text+0x2): undefined reference to 'esp'
which instantly made me think it was still looking for ATT-syntax mnemonics like '%esp' instead of 'esp'. I tried combinations of adding '-masm=intel' to the i686-elf-gcc call, and '-mmnemonic=intel' to the i686-elf-as call, but these made no difference.

What finally did work was adding '.intel_syntax noprefix' to the top of the boot.s file. However, I'm assuming that the command line options are meant to make it so you don't have to specify this in each .s file. The flags seem to affect the general syntax, but not the register names somehow.

Any guidance on this would be much appreciated.
mikegonta
Member
Member
Posts: 229
Joined: Thu May 19, 2011 5:13 am
Contact:

Re: Converting barebones boot.s to intel syntax

Post by mikegonta »

Twicetimes wrote:What finally did work was adding '.intel_syntax noprefix' to the top of the boot.s file. However, I'm assuming that the command line
options are meant to make it so you don't have to specify this in each .s file. The flags seem to affect the general syntax, but not the
register names somehow. Any guidance on this would be much appreciated.
Silly, but that's the way it is.
By the way, this is all you need to specify an offset.

Code: Select all

  mov esp, OFFSET stack_top
Mike Gonta
look and see - many look but few see

https://mikegonta.com
Twicetimes
Posts: 13
Joined: Sun May 29, 2016 10:53 am

Re: Converting barebones boot.s to intel syntax

Post by Twicetimes »

Fair enough. Thanks for the tip about 'offset'.
Post Reply