Build Your Own OS #2

KERNEL_STACK_SIZE equ 4096            ; size of stack in bytes

section .bss
align 4 ; align at 4 bytes
kernel_stack: ; label points to beginning of memory
resb KERNEL_STACK_SIZE ; reserve stack for the kernel
mov esp, kernel_stack + KERNEL_STACK_SIZE   ; point esp to the start of the
int sum_of_three(int arg1, int arg2, int arg3)
{
return arg1 + arg2 + arg3;
}
external sum_of_three   ; the function sum_of_three is defined elsewhere

push dword 3 ; arg3
push dword 2 ; arg2
push dword 1 ; arg1
call sum_of_three ; call the function, the result will be in eax
-m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs
-Wall -Wextra -Werror
.
|-- bochsrc.txt
|-- iso
| |-- boot
| |-- grub
| |-- menu.lst
| |-- stage2_eltorito
|-- kmain.c
|-- loader.s
|-- Makefile

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

LikeCoin Community Update #202110

Multithreading in IOS (Part 1)| Grand Central Dispatch(GCD)

Adyen Tech Radar: engineer’s autonomy to the next level

Colleagues at work

BU-ERC20 Contract Audit

Pairing and Feedback

Better Unit Testing with Hamcrest

How to build an end-to-end machine learning application

Analysis of Stack Overflow Developer Survey, 2017

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Niroshan Pushparaj

Niroshan Pushparaj

More from Medium

Send AT Commands to Smartphones Serial Modem With Python

How to remove all previous commits from a github account?

[Solved] The requested image’s platform (linux/arm64/v8) does not match the detected host platform…

[Tracebacks] Find some Common Python Traceback Error with Possible Fix

Common Python Traceback Error