Skip to content

Instantly share code, notes, and snippets.

View NunoLava1998's full-sized avatar

NunoLava1998 NunoLava1998

View GitHub Profile
myos.bin: file format elf32-i386
Disassembly of section .text:
00100000 <_start-0xc>:
100000: 02 b0 ad 1b 03 00 add 0x31bad(%eax),%dh
100006: 00 00 add %al,(%eax)
100008: fb sti
SMM: enter
EAX=00000001 EBX=0000000b ECX=02000000 EDX=02000628
ESI=00000000 EDI=02000000 EBP=07fab7b0 ESP=00006d2c
EIP=000ee54b EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00cf9b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
#include "../defs.h"
void* memmove(void* dstptr, const void* srcptr, size_t size) {
unsigned char* dst = (unsigned char*) dstptr;
const unsigned char* src = (const unsigned char*) srcptr;
if (dst < src) {
for (size_t i = 0; i < size; i++)
dst[i] = src[i];
} else {
for (size_t i = size; i != 0; i--)
#include "../defs.h"
void run(void) {
int* val = (int *)malloc(128);
if (val == 0) {
if ((const char*)command == (const char*)"ver") {
y++;
x = 0;
terminal_writestring("Dixium OS v1.1 alpha", WHITE, BLACK, x, y);
y++;
// Beacuse we don't want to include any files, we'll have
// to predefine it here, then actually define it.
size_t strlen(const char* str);
void update_videoptr(void);
void newline(void);
void restrictions_tty(char c);
void writec(char c, uint8_t bc, uint8_t fc);
void writes(const char* c, uint8_t bc, uint8_t fc);
// Beacuse we don't want to include any files, we'll have
// to predefine it here, then actually define it.
size_t strlen(const char* str);
void update_videoptr(void);
void newline(void);
void backspace(void);
void restrictions_tty(void);
void writec(char c, uint8_t bc, uint8_t fc);
typedef bit unsigned char;
struct gdt_table {
uint16_t limit_low;
uint16_t base_low;
uint8_t base_medium;
bit accessed_bit; // Often set as uint8_t access_byte
bit read_write_bit; // Often set as uint8_t access_byte
bit direction_bit; // Often set as uint8_t access_byte
struct gdt_table {
uint16_t limit_low;
uint16_t base_low;
uint8_t base_medium;
uint8_t access_byte;
uint8_t limit_high << 4;
uint8_t flags << 4;
uint8_t base_high;
// Warning to viewers: This is a .h file with code, beacuse we are basically including from a .c file, so this will be in the same format as .c,
// and the WhyToNotPutCodeInHeaderFiles will not apply.
struct gdt_table {
uint16_t limit_low;
uint16_t base_low;
uint8_t base_medium;
uint8_t access;
.extern gdtp
.global lgdt
lgdt:
lgdt gdtp
mov $0x10, %eax
mov %ds, %eax
mov %es, %eax
mov %fs, %eax
mov %gs, %eax