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.
Can't get higher half bare bones working
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Re: Can't get higher half bare bones working
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?
That said, have you checked the values of the symbols used, specifically the stack?
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Re: Can't get higher half bare bones working
Code: Select all
# jump to higher half
lea (higher_half), %ecx
jmp *%ecx
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.
If a trainstation is where trains stop, what is a workstation ?
Re: Can't get higher half bare bones working
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.Patrick wrote:I'm trying to translate the NASM assembly in the tutorial to gas, which could be my problem.
Every good solution is obvious once you've found it.
Re: Can't get higher half bare bones working
My linker script is basically the same as in the tutorial. That line assembles togerryg400 wrote:What is the value of higher_half ?Code: Select all
# jump to higher half lea (higher_half), %ecx jmp *%ecx 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.
Code: Select all
lea 0xc0100031,%ecx
Thanks, I'll try that tomorrow.Solar wrote: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.Patrick wrote:I'm trying to translate the NASM assembly in the tutorial to gas, which could be my problem.