Skip to content

Instantly share code, notes, and snippets.

View NunoLava1998's full-sized avatar

NunoLava1998 NunoLava1998

View GitHub Profile
if (strcmp(echo_check_char, "echo ") == 0) {
size_t size = strlen(com) - strlen(echo_check_char);
char *value[size];
*value = (char *)zero_string((const char*)value[size]);
for (size_t i = strlen(echo_check_char); i < strlen(com); i++) {
*value[i] = com[i];
}
writes("\n", 0, 15);
writes((const char*)value, 0, 15);
writes("\n", 0, 15);
if (strcmp(echo_check_char, "echo ") == 0) {
size_t size = strlen(com);
for (size_t i = 0; i <= 6; i++) {
size--; // Decrement size.
}
char *value = '\0';
for (size_t i = strlen(echo_check_char) + 1; i < strlen(com); i++) {
value[i] = com[(size_t)i];
}
writes("\n", 0, 15);
SMM: enter
EAX=000000b5 EBX=00008acc ECX=00005678 EDX=07ef3750
ESI=07fbde30 EDI=07ef3750 EBP=00006914 ESP=00006914
EIP=000f8acb EFL=00000016 [----AP-] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
CS =0008 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
SS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
DS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
FS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
GS =0010 00000000 ffffffff 00c09300 DPL=0 DS [-WA]
Options: qemu-system-i386 -kernel myos.bin -d int
No triple fault or double fault, screen still printed
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]
.extern gdtp
.global lgdt
lgdt:
lgdt gdtp
mov $0x10, %eax
mov %eax, %ds
mov %eax, %es
mov %eax, %fs
mov %eax, %gs
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]
.extern gdtp
.global lgdt
lgdt:
lgdt gdtp
mov $0x10, %eax
mov %ds, %eax
mov %es, %eax
mov %fs, %eax
mov %gs, %eax
// 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;
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;
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