diff options
Diffstat (limited to 'doc/assembly-programming.md')
-rw-r--r-- | doc/assembly-programming.md | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/doc/assembly-programming.md b/doc/assembly-programming.md deleted file mode 100644 index 78f81ac..0000000 --- a/doc/assembly-programming.md +++ /dev/null @@ -1,28 +0,0 @@ -# Assembly Programming on Portland - -Assembly programming on Portland OS works pretty similarly to other OS's, but the linking phase varies in order to get the proper Portland Executable format for the output. - -## Portland-specific quirks - -The linker script used in the "Compiling and linking" section only recognizes `.text`, `.rodata`, `.data` and `.bss` sections, so please only use these. All of these except `.bss` are treated the same when the executable is loaded, so it doesn't really matter which section you put anything in except for alignment considerations, but it is still helpful for debugging and for readability to put things into the proper sections. This linker script provides a symbol `__pl_length` at the end of the `.data` section, used for generating the PLE header, so don't name any symbols this. - -## Portland ABI - -At program startup¸ we are in 32-bit protected mode in ring 3. The data and stack segments are equal, and these and the code segment refer to a region of memory containing `.text`, `.rodata` and `.data` (all three loaded verbatim from the executable) at address zero, followed by an uninitialized region of memory the size of `.bss`. The stack pointer is initialized to the end of this region, and the instruction pointer is initialized to the `_entry` label. - -See `ints.txt` for information about system calls. - -## Compiling and linking - -The following commands are used to compile and link an (NASM) assembly program into a Portland Executable. Replace the parts in all caps (except the `-O` argument to `objcopy`) with the relevant file names. The `user_elf.ld` file can be found at `src/user-elf.ld` in the kernel repository. - -``` -nasm -f elf32 SOURCE_FILE_1.asm -o SOURCE_FILE_1.o -nasm -f elf32 SOURCE_FILE_2.asm -o SOURCE_FILE_2.o -... - -ld -T user_elf.ld SOURCE_FILE_1.o SOURCE_FILE_2.o ... -o PROGRAM.elf -objcopy -O binary PROGRAM.elf PROGRAM.ple -``` - -After running each of these commands, `PROGRAM.elf` is a regular 32-bit ELF file containing the compiled program, with symbol table and all, useful for debugging. The `.ple_head` section contains the PLE header placed at the start of the executable by `objcopy`, and can be ignored when examining the ELF file. The `PROGRAM.ple` file is an executable file that can be run by Portland OS.
\ No newline at end of file |