2
votes

I'm reading https://0xax.gitbooks.io/linux-insides/content/Booting/linux-bootstrap-1.html and it reads some assembly like

    .section ".reset", "ax", %progbits
    .code16
.globl    _start
_start:
    .byte  0xe9
    .int   _start16bit - ( . + 2 )
    ...

There's a line where he compiles like this

nasm -f bin boot.nasm && qemu-system-x86_64 boot

So I thougth it was NASM assembly for linux. I went and found https://asmtutor.com/# which says it uses NASM assembly for linux. However, it's not the same thing. Just to name a few: linux kernel uses .section instead of SECTION, .globl instead of global and I don't recognize what .byte, .int, etc does.

So which assembly does linux use and where can I learn it?

1
The kernel uses gnu assembler. You can of course use nasm or various other assemblers on linux if you like. - Jester
Note that each assembler comes with its own syntax. - fuz

1 Answers

5
votes

The Linux kernel uses the GAS assembler(GNU Assembler) which is part of GCC. You can find reference documentation on it here.

You can find a pretty thorough introduction to GAS here provided that you already have a basic understanding of assembly in general.

As for .byte and .int, .byte places 1 or more 1 byte values that follow it into memory at the current assembler address, and .int does the same but for 32 bit integers instead of bytes.