Update markdown and tabs and stuff

This commit is contained in:
2016-10-22 17:07:50 +02:00
parent 67e817490e
commit a27daafa0a
39 changed files with 2249 additions and 2139 deletions

View File

@@ -6,13 +6,14 @@ tags: [osdev]
Something that always annoyed me is how hard it is to synchronize constants
between assembly and c code. In assembler, you define a constant value as
EXACT_PI equ 3
{: .prettyprint .lang-nasm}
:::nasm
EXACT_PI equ 3
and in c
#define EXACT_PI 3
{: .prettyprint .lang-c}
:::c
#define EXACT_PI 3
As is usually the case with things that annoy me, there is of course a solution
to this, as I found out today. The solution is the c preprocessor.
@@ -30,27 +31,27 @@ Well, here's a minimal (non-working) example:
_myAsmFile.asm_
#include <header.h>
mov eax, EXACT_PI
{: .prettyprint .lang-nasm}
:::nasm
#include <header.h>
mov eax, EXACT_PI
_include/header.h_
#pragma once
#define EXACT_PI 3
#ifndef __ASSEMBLER__
// This is not evaluated if header.h is included from an assembly file.
#endif
{: .prettyprint .lang-c}
:::c
#pragma once
#define EXACT_PI 3
#ifndef __ASSEMBLER__
// This is not evaluated if header.h is included from an assembly file.
#endif
This is compiled through:
cpp -I include -x assembler-with-cpp myAsmFile.asm -o myAsmFile.s
nasm myAsmFile.s
{: .prettyprint}
:::bash
$ cpp -I include -x assembler-with-cpp myAsmFile.asm -o myAsmFile.s
$ nasm myAsmFile.s
The _-x_-flag tells the preprocessor what type of file the following input
files are. _assembler-with-cpp_ means _cpp_ will ignore everything but the