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.
I am trying to print buffer which is pointed by bp and this buffer reside in ES.
while i am running this code in bochs emulator it showing following error: write_virtual_checks(): write beyond limit, r/w
Can we see the code for cprint(c)? May be helpful to see what else is going on here.
My i386-based kernel: https://github.com/bmelikant/missy-kernel Picking a name for my kernel was harder than picking my wife, so I just used her name until I decide!
1. Why are you trying to read from ES:BP in C code?
2. Have you checked that the generated assembler is sane.
3. Have you double-checked the register values that cause the error? Including comparing the register used by the load to the base of ES.
1. Why are you trying to read from ES:BP in C code?
2. Have you checked that the generated assembler is sane.
3. Have you double-checked the register values that cause the error? Including comparing the register used by the load to the base of ES.
I use ES segment as buffer so every file open is going to reside in ES.That why i am trying to print the block started at ES:BP.
No you can't. This is why your code doesn't work. Use assembly or do 32 bit code. Stack overflow is not evidence. The GNU assembler does support 16 bit code, gcc doesn't.
Edit: Ok. .code16gcc does work, it doesn't make gcc support 16 bit code, it just magically translate at assembly time. I don't consider this a good approach, but it might just work.
sortie wrote:You cannot compile to 16 bit code with gcc. Use assembly or switch to 32 bit mode.
The correct formulation is "If a person requires help, that person cannot compile to 16 bit code with gcc". The bug in the code is "You are using code16gcc when you don't know the implications at all.", and everything in what you posted show you are relying on someone else's magic that you just happen to have copied and can't deal with.
The appropriate solution definitely is to use proper assembly, if only to learn how things should work in reality.
"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 ]
Thank you for your answer. I use the same approach to compile my code but first i used .code16 instead of .code16gcc directive. Now it is working fine.
sortie wrote:You cannot compile to 16 bit code with gcc. Use assembly or switch to 32 bit mode.
The correct formulation is "If a person requires help, that person cannot compile to 16 bit code with gcc". The bug in the code is "You are using code16gcc when you don't know the implications at all.", and everything in what you posted show you are relying on someone else's magic that you just happen to have copied and can't deal with.
The appropriate solution definitely is to use proper assembly, if only to learn how things should work in reality.
yes I am newbie.I trying to do something by myself.This not someone else magic.My git repo https://github.com/raseshshah/Ranix. This might not as neat code as you are able to write but this is my first attempt. I wanted to write 16 bit kernel in c , that's why i used inline assembly whenever there is need.