Re: MOV AX, 0x0000 doesn't work.
Posted: Thu Feb 25, 2010 4:38 pm
Hello,
Thanks for the information, the base-address in my VS project is indeed 1MB, and the KERNEL.EXE (the VS project) is correctly called, so the bootloader stage is over (for the 32 bit OS). I've found out now that calling the InitMem is exactly where the crash occurs, and one strange thing is that before calleng the function a constant is substracted from esp, 0x00180010 to be precise, the output from bochs, I made a screenshot from it, because I couldn't let bochs put it in a log. This is uploaded. The InitMem function looks like this:
But it's not even called, do any of you know why the constant is substracted from esp? Or why it crashes, because I don't think it's a real stack error, altough I'm going to check that right now. I'll post when I find something.
Thanks.
Thanks for the information, the base-address in my VS project is indeed 1MB, and the KERNEL.EXE (the VS project) is correctly called, so the bootloader stage is over (for the 32 bit OS). I've found out now that calling the InitMem is exactly where the crash occurs, and one strange thing is that before calleng the function a constant is substracted from esp, 0x00180010 to be precise, the output from bochs, I made a screenshot from it, because I couldn't let bochs put it in a log. This is uploaded. The InitMem function looks like this:
Code: Select all
void InitMem(void)
{
__asm{
cli
hlt
mov ecx, 0x00007E00
mov eax, [ecx]
cmp eax, 'SOGR'
jne checkag
tochok:
add ecx, 4
mov ax, [ecx]
mov K64blocks, ax
add ecx, 2
mov ax, [ecx]
mov M1M16, ax
add ecx, 2
mov ax, [ecx]
mov EntryCount, ax
add ecx, 2
mov ax, [ecx]
mov MemLoEntry, ax
add ecx, 2
mov ax, [ecx]
mov MemHiEntry, ax
add ecx, 2
mov eax, [ecx]
mov OK, 0x01
cmp eax, 'RGOS'
je ready
jmp ready
checkag:
cmp eax, 'RGOS'
je tochok
mov OK, 0x00
ready:
}
if(K64blocks == 0 || M1M16 == -1 || EntryCount == 0 || OK == 0){
panicrsod("MEMORY AMOUNT ERROR", "Something went wrong while checking the amount of RAM in the system.\nThis can be caused by a faulty BIOS or broken memory or if you have only 16MB of memory.");
}
KBTotal = (K64blocks * 64) + M1M16;
memSize = KBTotal;
MemLinEntry = (MemHiEntry * 16) + MemLoEntry;
unsigned long long BaseAddress[65535];
unsigned long long Length[65535];
unsigned Type[65535];
unsigned ACPINull[65535];
for(unsigned int i = 0; i <= EntryCount; ++i)
{
unsigned char BAFFI = 0;
unsigned char BAFFII = 0;
unsigned char BAFFIII = 0;
unsigned char BAFFIV = 0;
unsigned char LFFI = 0;
unsigned char LFFII = 0;
unsigned char LFFIII = 0;
unsigned char LFFIV = 0;
unsigned char TFFI = 0;
unsigned char TFFII = 0;
unsigned char ACPINFFI = 0;
unsigned char ACPINFFII = 0;
unsigned int MEMADRFF = (i * 24) + MemLinEntry;
__asm
{
mov eax, MEMADRFF
mov bl, [eax]
inc eax
mov bh, [eax]
inc eax
mov BAFFI, bl
mov BAFFII, bh
mov bl, [eax]
inc eax
mov bh, [eax]
inc eax
mov BAFFIII, bl
mov BAFFIV, bh
mov bl, [eax]
inc eax
mov bh, [eax]
inc eax
mov LFFI, bl
mov LFFII, bh
mov bl, [eax]
inc eax
mov bh, [eax]
inc eax
mov LFFIII, bl
mov LFFIV, bh
mov bl, [eax]
inc eax
mov bh, [eax]
inc eax
mov TFFI, bl
mov TFFII, bh
mov bl, [eax]
inc eax
mov bh, [eax]
inc eax
mov ACPINFFI, bl
mov ACPINFFII, bh
}
BaseAddress[i] = (BAFFI * 16777216) + (BAFFII * 65536) + (BAFFIII * 256) + BAFFIV;
Length[i] = (LFFI * 16777216) + (LFFII * 65536) + (LFFIII * 256) + LFFIV;
Type[i] = (TFFI * 256) + TFFII;
ACPINull[i] = (ACPINFFI * 256) + ACPINFFII;
}
Thanks.