I'm writing an operating system. My experience allows me only to make that for 32 bit, but I want to convert it to 64 bit.
What do I do to make it 64-bit?
I wanted to just know the general information without linking code but contemplated it is not related. Therefore here goes my kernel.s code:
.set MAGIC, 0x1badb002
.set FLAGS, (1<<0 | 1<<1)
.set CHECKSUM, -(MAGIC + FLAGS)
.section .multiboot
.long MAGIC
.long FLAGS
.long CHECKSUM
.section .text
.extern kernelMain
.global loader
loader:
mov $kernel_stack, %esp
push %eax
push %ebx
call kernelMain
_stop:
cli
hlt
jmp _stop
.section .bss
.space 2*1024*1024; # 2 megabytes of space
kernel_stack:
And I don't think it is ready yet, though.
If necessary, here is my kernel.cpp code:
#include "types.h"
#include "gdt.h"
void print(char* str) {
unsigned short* VideoMemory = (unsigned short*)0xb8000;
static uint8_t x = 0, y = 0;
for(int i = 0; str[i] != '\0'; ++i) {
switch(str[i]) {
case '\n':
y++;
x = 0;
break;
default:
VideoMemory[80*y+x] = (VideoMemory[80*y+x] & 0xFF00) | str[i];
x++;
break;
}
if(x >= 80) {
y++;
x = 0;
}
if (y >= 25) {
for(y = 0; y < 25; y++)
for(x = 0; x < 80; x++)
VideoMemory[80*y+x] = (VideoMemory[80*y+x] & 0xFF00) | ' ';
x = 0;
y = 0;
}
}
}
extern "C" void kernelMain(void* multiboot_structure, unsigned int magicnumber) {
print("All the includes work fine, but I will only link them if really necessary!\n");
GlobalDescriptorTable gdt;
while(1);
}
I am building my assembly code with the as
assembler in Ubuntu; my C++ code by g++
.
If there are duplicates, please link them because I didn't discover them even though scrolled through a whole page.