Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
REV wrote:
==This is my GDT==
[tt]
gdt: ;This is a pointer. Its value will be help calculate its size
gdt_null: ;Null Segment
dw 0 ;Fill it up with 0s
dw 0 ;More 0s
db 0
db 0
db 0
db 0
gdt_code: ;Our code segment will be defined here
;First Double word
dw 0FFFFh ;Make this 4GB in size
dw 0 ;The first 16-bits of the base address
;Second Double Word
db 0 ;Bits 16-23 of the base address
db 10011010b ;Present = 1 Privilage = 0 Code = 1 CF = 0 Readable = 1 AF = 0
db 11001111b ;Granularity = 1 Size = 1 Reserved = 0 ASP = 0 Limit = 4GB
db 0 ;Last 24-31 of base address
gdt_data: ;Our data segment will be defined here
;First Double word
dw 0FFFFh ;Make this 4GB in size
dw 0 ;The first 16-bits of the base address
;Second Double Word
db 0 ;Bits 16-23 of the base address
db 10010010b ;Present = 1 Privilage = 0 Code = 0 CF = 0 Readable = 1 AF = 0
db 11001111b ;Granularity = 1 Size = 1 Reserved = 0 ASP = 0 Limit = 4GB
db 0 ;Last 24-31 of base address
[/tt]
==This is the kernel code==
All my assembly code is:
[tt]
[extern main_] ;NASM directive for the C function main()
SECTION .text USE32 ;NASM directive for code
[bits 32] ;NASM directive to use 32-bit instructions
call main_ ;Call the C/C++ code
cli ;Disable interrupts
hlt ;Halt the CPU
[/tt]
This is my C/C++ code:
[tt]
unsigned char *text = (char *)0xB80000;
You might still accept interrupts, since you don't disable them explicitly.
What about disassembling your intermediates, or tracing in bochs from the breakpoint at the start of your code? The first would show you whether NASM understood it and the second would show you what JLOC made of it. A hexdump of the image will be quite clear too.
seg000:0001000D is the problem, which doesn't relate to your source code. My only guess is made by watcom. I have some questions concerning watcom.. is there a "release" and "debug" compilation modes? If so which mode did you compile under? And, can you tell watcom to not use the default CRT libraries?
Oh yes.. the global: unsigned char *text = (char *)0xB80000; which could be why theres a call to initialize globals, and the code segment it runs in might have been disgarded during linkage.
Well I am using 11.0c. Its a release version. Thats cause Im too lazy to upgrade to Open Watcom 1.3 ;D
Looking at Wcc386 there are some command line perimaters that look intresting:
[tt]
-hc generate Codeview debugging information
-hd generate DWARF debugging information
-hw generate Watcom debugging information
[/tt]
Im compiling I guess under the release mode. The default librarys I don't belive are being compiled. Just to make sure I renamed the include and library directories
Ive also disabled all the compiler "extensions" so its compiling by the ANSI standard.
Well Im going to go over the documentation. But this still seems a little weird to me.
I'm just going to guess that the compiler inserted some form of call to some function at that point, which you don't have defined. It then defined the function arbitrarily to be at -1 (or 0xFFFFFFFF) and caused your program to jump to EIP=-1. This then wrapped around to run the IVT, which contained invalid code.
I'm guessing the function is called alloca(). Try defining it and see whether you get more sensible results. Next time, disassemble first or get a compiler you trust and understand.
I fixed it.
I had to turn off Stack Overflow checking. Which dosn't sound too good
Now Its time to work on my kernel.
Hmm how come nothings getting printed?
[tt]
unsigned char *textaddress = (char *)0xB8000;
All my segments work I belive. All these are in the same source file. I belive the memory is mapped correctly. (What do you mean by correctly?) Let me check Bochs aaaaannnnnd it dosn't tell me anything.
by testing in bochs he means using the bochs debugger to see where and if your characters are being printed to. Bochs' debugger can tell you where memory is mapped to in case you use paging, and to see where your segments are directing your memory accesses to. Just set a breakpoint for 0x7c00 and enjoy reading the rest of the bochs manual
Right now i'm expecting bochs (without debugger) to either ignore your attempts or flood warnings since you'll be running off the end of video memory straight into the bios region with this loop...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
If I enabled paging will that fix it? Paging is setting the last bit in the CR0 register right?
Well I know for a fact my C/C++ works
I know I was running the Bochs Debugger. Stepping through my bootloader it runs off in a weird direction but some how it later comes back on track with protected mode and then my kernel is called
REV wrote:
If I enabled paging will that fix it? Paging is setting the last bit in the CR0 register right?
Paging doesn't fix anything, it only gives you new options. An yes, PG is bit 31 in CR0
Well I know for a fact my C/C++ works
"I heard that one before"
I know I was running the Bochs Debugger. Stepping through my bootloader it runs off in a weird direction but some how it later comes back on track with protected mode and then my kernel is called
In case you wonder, it helps setting breakpoints after INT instructions. You probably ended up debugging the BIOS which is not really where your issues are right now.
Still i didnt hear of anything happening after protected mode was entered. Have you found yet if you got to something like your mov, inc, mov, inc, jmp printing sequence - maybe you can get a disassembly of that with a cpu dump so we can determine wether You or Bochs should upgrade...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]