-
Notifications
You must be signed in to change notification settings - Fork 0
/
kernel.asm
46 lines (35 loc) · 1.59 KB
/
kernel.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
section .text
global _start
_start:
; Write "Hello, World!" to the screen
mov eax, 4 ; '4' is the system call number for sys_write
mov ebx, 1 ; '1' is the file descriptor for stdout
mov ecx, msg ; Load the memory address of 'msg' into ecx
mov edx, msg_len ; Length of the message in bytes
int 0x80 ; Perform the system call
; Call the 'kmain' function in C
call kmain
; Exit the program
mov eax, 1 ; '1' is the system call number for sys_exit
xor ebx, ebx ; Exit status 0
int 0x80 ; Perform the system call
section .text
global shutdown
shutdown:
; Implement the shutdown function here.
; This function should trigger the system shutdown sequence.
; For simplicity, we'll just print a "Shutting down..." message.
; Write "Shutting down..." to the screen
mov eax, 4 ; '4' is the system call number for sys_write
mov ebx, 1 ; '1' is the file descriptor for stdout
mov ecx, shutdown_msg ; Load the memory address of 'shutdown_msg' into ecx
mov edx, shutdown_msg_len ; Length of the message in bytes
int 0x80 ; Perform the system call
; TODO: Add the actual shutdown sequence here
ret
section .data
msg db 'Hello, World!',0x0A ; The message to be printed (with newline)
msg_len equ $ - msg ; Calculate the length of the message
section .data
shutdown_msg db 'Shutting down...',0x0A ; The shutdown message (with newline)
shutdown_msg_len equ $ - shutdown_msg ; Calculate the length of the message