nasm -> gas

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.
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post 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.
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post 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.
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
ehird
Member
Member
Posts: 214
Joined: Thu Mar 15, 2007 8:48 am

Post 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
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post 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. :)
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
anon19287473
Member
Member
Posts: 97
Joined: Thu Mar 15, 2007 2:27 pm

Re: nasm -> gas

Post 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.
Post Reply