Page 2 of 2

Posted: Sat Mar 24, 2007 11:03 am
by XCHG
The truth is that up to this point, I have not pushed a WORD value onto the stack in my kernel. I have not developed a big kernel yet but I try to use 32-bit registers/values as much as possible because of the whole partial register stall you can get on modern CPUs. By the way, sorry about my interpretation of your opcodes :wink: I must have been really sleep not to have seen the rest of the lines.

Posted: Sat Mar 24, 2007 12:37 pm
by mystran
You should always push 32-bits if you're in 32-bit mode, to keep your stack aligned properly. Properly aligned data in general is a "Good Thing(tm)". Even if you wanted to push 16-bit value in stack, you'd better off extending it to 32-bits before, to avoid misaligning the stack.

In 16-bits mode that's ofcourse not a problem, but I guess it mostly makes sense to push 16-bit values there... YMMV.

Posted: Sat Mar 24, 2007 1:45 pm
by ehird
I must be a terrible translator, my kernel is acting /weird/...

Bochs' log is not terribly helpful, it says `unknown instruction, page splitting instruction' or something like that

Posted: Sat Mar 24, 2007 7:58 pm
by mystran
Bochs log IS terribly helpful when it gives weird errors, because chances are there aren't many place in Bochs where it can be from, and I've managed to trace several bugs by looking at Bochs sources to see why it would give such a strange error message..

Bochs source is a bit tedious at first, but grep is your friend. :)

Re: nasm -> gas

Posted: Sun Mar 25, 2007 9:39 am
by anon19287473
ehird wrote:

Code: Select all

    push byte 0
    push byte 1
etc
^ bonafide kernel dev tutorial

GAS only accepts "push something". What does nasm do here, and how would I do it in gas?

thanks
In NASM, you would use

Code: Select all

push byte
, whereas in GAS, instead of postfixing it w/ a word, you would use something along the lines of

Code: Select all

pushb
or

Code: Select all

pushl
. Those aren't exact, but thats the gist.