Page 1 of 1
Can't get higher half bare bones working
Posted: Wed Jun 16, 2010 12:59 pm
by Patrick
Hi. I'm following the "Higher Half bare bones" tutorial, and it's not working. I'm trying to translate the NASM assembly in the tutorial to gas, which could be my problem. I know the basics of how assembly works, but I am mostly just learning as I go.
Here's the code:
http://pastebin.com/wL1AMbHs
When I run it in VirtualBox it hangs at line 64 but there is no error message. If I run it on my actual hardware it makes it to line 65 and just reboots.
Thanks.
Re: Can't get higher half bare bones working
Posted: Wed Jun 16, 2010 9:04 pm
by thepowersgang
I would suggest running in bochs to begin with, it's far easier to debug.
That said, have you checked the values of the symbols used, specifically the stack?
Re: Can't get higher half bare bones working
Posted: Wed Jun 16, 2010 9:59 pm
by gerryg400
Code: Select all
# jump to higher half
lea (higher_half), %ecx
jmp *%ecx
higher_half:
What is the value of higher_half ?
You haven't shown your linker script. You need to link your code so that the load address is in low memory but the link (virtual) address in in higher memory. Did you do that ? Disassemble your binary and see what value if loaded into ecx.
Re: Can't get higher half bare bones working
Posted: Wed Jun 16, 2010 11:40 pm
by Solar
Patrick wrote:I'm trying to translate the NASM assembly in the tutorial to gas, which could be my problem.
Hint: Use NASM to assemble the tutorial code, then use objdump -d to disassemble the binary. Comparing the disassembly with your GAS source could give you pointers to where your translation didn't quite work out.
Re: Can't get higher half bare bones working
Posted: Wed Jun 16, 2010 11:59 pm
by Patrick
gerryg400 wrote:Code: Select all
# jump to higher half
lea (higher_half), %ecx
jmp *%ecx
higher_half:
What is the value of higher_half ?
You haven't shown your linker script. You need to link your code so that the load address is in low memory but the link (virtual) address in in higher memory. Did you do that ? Disassemble your binary and see what value if loaded into ecx.
My linker script is basically the same as in the tutorial. That line assembles to
.
Solar wrote:Patrick wrote:I'm trying to translate the NASM assembly in the tutorial to gas, which could be my problem.
Hint: Use NASM to assemble the tutorial code, then use objdump -d to disassemble the binary. Comparing the disassembly with your GAS source could give you pointers to where your translation didn't quite work out.
Thanks, I'll try that tomorrow.