OS dev newbie question+ indespensable pc hardware book views

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.
Post Reply
eax
Member
Member
Posts: 57
Joined: Mon Jun 23, 2008 6:45 am

OS dev newbie question+ indespensable pc hardware book views

Post by eax »

Hi wheres the cheapest place for me to buy the indispensable pc hardware book 4th edition? Also would people recommend this book? It seems an extreme amount of cash so Im wandering what peoples thoughts are, I havent got any of this authors books

Also have a newbie question about brans tutorial, I have gcc v4.x and am using ubuntu 8.04, I am trying to compile and link on linux and wun it in a virtual machine then a real machine but I get an unresolved _main error

I have checked gcc and ld manuals but cant figure out how to get it to link succesfully. Heres the commands and code

Code: Select all

[BITS 32]
global start
start:
    mov esp, _sys_stack     ; This points the stack to our new stack area
    jmp stublet

; This part MUST be 4byte aligned, so we solve that issue using 'ALIGN 4'
ALIGN 4
mboot:
    ; Multiboot macros to make a few lines later more readable
    MULTIBOOT_PAGE_ALIGN	equ 1<<0
    MULTIBOOT_MEMORY_INFO	equ 1<<1
    MULTIBOOT_AOUT_KLUDGE	equ 1<<16
    MULTIBOOT_HEADER_MAGIC	equ 0x1BADB002
    MULTIBOOT_HEADER_FLAGS	equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
    MULTIBOOT_CHECKSUM	equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
    EXTERN code, bss, end

    ; This is the GRUB Multiboot header. A boot signature
    dd MULTIBOOT_HEADER_MAGIC
    dd MULTIBOOT_HEADER_FLAGS
    dd MULTIBOOT_CHECKSUM
    
    ; AOUT kludge - must be physical addresses. Make a note of these:
    ; The linker script fills in the data for these ones!
    dd mboot
    dd code
    dd bss
    dd end
    dd start

; This is an endless loop here. Make a note of this: Later on, we
; will insert an 'extern _main', followed by 'call _main', right
; before the 'jmp $'.
stublet:
extern _main ;I think these are the problems because I read gcc or ld ;doesnt add the underscore
call _main

    jmp $


; Shortly we will add code for loading the GDT right here!


; In just a few pages in this tutorial, we will add our Interrupt
; Service Routines (ISRs) right here!



; Here is the definition of our BSS section. Right now, we'll use
; it just to store the stack. Remember that a stack actually grows
; downwards, so we declare the size of the data before declaring
; the identifier '_sys_stack'
SECTION .bss
    resb 8192               ; This reserves 8KBytes of memory here
_sys_stack:
See comments above I think pon linux and compiling linking causes problems where extern is used because gcc doesnt aqdd the underscores , at least thats what I have read, I also only found 1 google result with a guy who has the exact same problem but the proposed fix doesnt work for me , here are my commands

nasm -f aout -o start.o start.asm
rem Remember this spot here: We will add 'gcc' commands here to compile C sources
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c

Code: Select all

rem This links all your files. Remember that as you add *.o files, you need to
rem add them after start.o. If you don't add them at all, they won't be in your kernel!
ld -T link.ld -o kernel.bin start.o main.o
any help on this and/or feedback on the hardware book is greatly appreciated! I want to get equipped with all the books I need this time around and would appreciate anyplace less expensive than amazon

edit: just checked the price of that book , dont know if I can afford that, amazon are charging £163 from the UK site and approx £110 from the us site , really would appreciate a good book store reccomend as I think there are people who have bought up stock of the books in amazon and are selling them used much higher
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: OS dev newbie question+ indespensable pc hardware book views

Post by Combuster »

There's the -fleading-underscores and -fno-leading-underscores parameters for GCC. Better even is to remove them from the code as they are just for DJGPP users - linux and cygwin crosscompilers do not use the extra underscores.

As for the book, I have done without it all this time, and anything i might think of being in that book that I needed can be found on the internet in one form or another.
"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 ]
eax
Member
Member
Posts: 57
Joined: Mon Jun 23, 2008 6:45 am

Re: OS dev newbie question+ indespensable pc hardware book views

Post by eax »

Thanks combuster that does make me feel better :) , It just annoys me the fact sellers have bought up stock and selling very high and stopping people who need those books from getting them, I was thinking of getting the 3rd edition, is that still relevant? I would still like to buy the book but only place I can find it on is amazon and its overpriced :(
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Re: OS dev newbie question+ indespensable pc hardware book views

Post by lukem95 »

try www.abebooks.com

or... a library? your local library should be able to get it in, but it may take a few months.
~ Lukem95 [ Cake ]
Release: 0.08b
Image
eax
Member
Member
Posts: 57
Joined: Mon Jun 23, 2008 6:45 am

Re: OS dev newbie question+ indespensable pc hardware book views

Post by eax »

Hey all thanks very much for the replies :) Kinda worried about spending that kind of money but I bought the book in the hope it will help me out longterm with various things. I tried that book site you suggested and the prices were about the same at this time, still thanks!

I bought the book just because I know its a good thing to have but in future I think I will do as suggested and go down to my local library with my membership and get them to get the book questioned

Anyway Im away to compile my code on linux and try whats been suggested.

Final edit:

Ok the suggested gcc switches work a treat, I went into the man page and checked out all similiar commands so thats another thing Ive learned :) cheers! In hindsight I really should have managed to figure that one out so what I have done and am going to do in future is any time I want to view a man page because I cant do something I will redirect it into a text file then I can do searches for what I require, no doubt there will be a search feature immplemented into the default console view of the man pages but Im happy with this way for the time being :). Im looking forward to running vmware on ubuntu now!, I used vmware on windows and bochs on windows and linux so this should be interesting. (Hopefully I wont have to wait to long on the book I ordered)
Post Reply