LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Tags used in this thread
Popular LQ Tags , , , , , , , , ,

Reply
 
Thread Tools
Old 09-30-2009, 08:40 PM   #1
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 1,245
Thanked: 60
a kernel i wrote myself cannot find data


[Log in to get rid of this advertisement]
for example if i put
Code:
kernel_print("Hey!");
the cursor moves 4 spaces but i see nothing on screen
windows_vista smeezekitty is offline  
Tag This Post , , , , , , , , ,
Reply With Quote
Old 09-30-2009, 09:15 PM   #2
manu-tm
Member
 
Registered: May 2008
Location: France
Distribution: Ubuntu
Posts: 47
Thanked: 2
What do you mean exactly? Did you compile the kernel or develop one on your own? And you must give much more info because I have no idea about what you want to know...
linux manu-tm is offline     Reply With Quote
Old 09-30-2009, 10:13 PM   #3
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 1,245
Thanked: 60

Original Poster
i developed it from scratch and got the bootloader from theNbomr
it bootloads and runs but string litterals cannot be read
windows_vista smeezekitty is offline     Reply With Quote
Old 09-30-2009, 11:50 PM   #4
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 1,245
Thanked: 60

Original Poster
ok let me MAKE MY SELF CLEAR
i wrote a kernel from scratch and had a F### of a time getting it to work
i finnaly got it to work but i cannot read anything in the data segment
i think that DS is set wrong but i really ddo not know how to fix it
so could someone with experence please help me?
windows_vista smeezekitty is offline     Reply With Quote
Old 10-01-2009, 07:42 AM   #5
manu-tm
Member
 
Registered: May 2008
Location: France
Distribution: Ubuntu
Posts: 47
Thanked: 2
I understand now but I have no experience in this, sorry. You use assembly?
linux manu-tm is offline     Reply With Quote
Old 10-01-2009, 10:33 AM   #6
ntubski
Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 699
Thanked: 51
Unless you are doing something fancy, you should use the flat memory model, so DS should be same as the other segments. EDIT: didn't realize this is a 16-bit kernel.

Does it work if you print data from the stack?
Code:
char str[] = "Hey!";
kernel_print(str);

Last edited by ntubski; 10-01-2009 at 06:15 PM.. Reason: I had assumed 32-bit...
ntubski is offline     Reply With Quote
Thanked by:
Old 10-01-2009, 01:29 PM   #7
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 1,245
Thanked: 60

Original Poster
Quote:
Originally Posted by ntubski View Post
Unless you are doing something fancy, you should use the flat memory model, so DS should be same as the other segments. Does it work if you print data from the stack?
Code:
char str[] = "Hey!";
kernel_print(str);
no but this does:
Code:
char str[5];
str[0] = 'H';
str[1] = 'e';
str[2] = 'y';
str[3] = '!';
str[4] = 0;
kernel_print(string);
yours did not work because it still had a constant
windows_vista smeezekitty is offline     Reply With Quote
Old 10-01-2009, 02:48 PM   #8
johnsfine
Senior Member
 
Registered: Dec 2007
Posts: 1,685
Thanked: 182
If your goal is the "tiny" memory model (CS == DS == SS) then you should make sure your tool chain is linking that way and you should have your startup code copy CS to both DS and SS.

Your failure to get DS right, could represent either or both of the above are wrong.

If your goal is some other memory model, make sure you understand what memory model you want and how to get the tool chain to compile/link for that memory model and how to make your startup code initialize for that memory model.

Quote:
Originally Posted by smeezekitty View Post
no but this does:
Code:
char str[5];
str[0] = 'H';
str[1] = 'e';
str[2] = 'y';
str[3] = '!';
str[4] = 0;
kernel_print(string);
That working indicates that DS == SS. It does not indicate that either DS or SS is correct and it doesn't indicate that you are linking correctly for the desired memory model.

Quote:
Originally Posted by ntubski View Post
you should use the flat memory model
There is not complete agreement on the terminology, but usually "flat" memory model implies the offset size is at least 32 bits. In 16 bit programming, the "flat" memory model is usually called the "tiny" memory model.

So if you want to look up in your tool chain documentation how to get that memory model, you'll have an easier time using the common terminology.

You can find that terminology documented at:

http://en.wikipedia.org/wiki/C_memory_model

The default memory model in 16 bit tool chains is "small". CS < DS == SS. If you want "small" memory model, you need to figure out how to make your startup code initialize DS and SS with the correct value.

Last edited by johnsfine; 10-01-2009 at 03:04 PM..
linux johnsfine is online now     Reply With Quote
Old 10-01-2009, 02:57 PM   #9
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 1,245
Thanked: 60

Original Poster
let me post the batch file i used to compile it
just a second
linux smeezekitty is offline     Reply With Quote
Old 10-01-2009, 03:02 PM   #10
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 1,245
Thanked: 60

Original Poster
Code:
tasm call.asm
nasm16 -f bin -o bnl.bin boot.asm
tcc -c nodos.c
tlink /n call+nodos, _k.exe
exetobin _k.exe kernel.ker
copy /b bnl.bin+kernel.ker kernel.out
copy kernel.ker dbg.com
dbg.com is to be debugged with a debugger
kernel.out is the bootable image
windows_vista smeezekitty is offline     Reply With Quote
Old 10-01-2009, 03:09 PM   #11
johnsfine
Senior Member
 
Registered: Dec 2007
Posts: 1,685
Thanked: 182
Quote:
Originally Posted by smeezekitty View Post
let me post the batch file i used to compile it
It has been many years since I used tlink. I expect the same is true for almost anyone else here who ever used it.

I certainly don't remember tlink command line switches for tiny memory model, nor do I remember where my copy of tlink documentation is.

If you have an easy URL for tlink documentation, I might take a look and then explain the relevant switches.
linux johnsfine is online now     Reply With Quote
Old 10-01-2009, 03:24 PM   #12
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 1,245
Thanked: 60

Original Poster
i copy and pasted this from the output of tlink
Code:
  /3      │ Enables processing of 32-bit modules
  /A      │ Specifies segment alignment
  /c      │ Treats case as significant in symbols
  /d      │ Warns of duplicate symbols in libraries
  /e      │ Ignores Extended Dictionary
  /i      │ Initializes all segments
  /l      │ Includes source line numbers
  /L      │ Specifies library search paths
  /m      │ Creates map file with publics
  /n      │ Doesn't use default libraries
  /o      │ Overlays following modules or libraries
  /s      │ Creates detailed map of segments
  /t      │ Generates .COM file. (Also /Tdc.)
  /Td     │ Creates target DOS executable
  /Tdc    │ Creates target DOS .COM file
  /Tde    │ Creates target DOS .EXE file
  /v      │ Includes full symbolic debug information
  /x      │ Does not create map file
  /ye     │ Uses expanded memory for swapping
  /yx     │ Configures TLINK's use of extended memory
  /r      │ Restores the AX register on return
windows_vista smeezekitty is offline     Reply With Quote
Old 10-01-2009, 03:44 PM   #13
johnsfine
Senior Member
 
Registered: Dec 2007
Posts: 1,685
Thanked: 182
I thought you could get tlink to generate tiny memory model after tcc compiles object files for small memory model. Maybe you can by specifying /t which also makes the output a .com instead of a .exe. Or maybe I'm misremembering and you need a switch to tcc to get tiny memory model instead of small.

Do you understand which you want "tiny" or "small"?

I don't recall the exetobin program. A .com is a flat binary format normally used with tiny memory model, but there is an implied extra 0x100 bytes at the beginning. Does exetobin also have an implied extra 0x100 bytes?

All those details must be coordinated between your loader and startup code and the way you use the tool chain.
windows_xp_2003 johnsfine is online now     Reply With Quote
Thanked by:
Old 10-01-2009, 03:48 PM   #14
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 1,245
Thanked: 60

Original Poster
yes it converts .exe to .com files
because if i tell the linker to do it i get an error (Error: Cannot generate COM file : invalid initial entry point address)
windows_vista smeezekitty is offline     Reply With Quote
Old 10-01-2009, 04:35 PM   #15
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 1,245
Thanked: 60

Original Poster
I attach the a dissasmebley of most of the kernel below
i will release the full C source when i am done with it
Attached Files
File Type: txt kdisasm.asm.txt (50.3 KB, 8 views)
windows_vista smeezekitty is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
missing/lost data - where is it, how do I find it ????? bigjohn Linux - General 10 10-05-2008 03:34 PM
Reiserfs - how to find which file contains data in a block Vrajgh Linux - Software 8 09-14-2007 04:04 AM
Retrieving semi-formatted data: Kernel Panic (cannot find file or dir /dev/root) majorGrey Linux - General 2 09-05-2007 05:02 AM
Kernel Panic: Resume Machine: Unable to find suspended-data signature ( - mispelled? ToddM Linux - General 1 09-30-2004 11:59 AM
can't find data mcd Linux - Software 1 08-12-2003 01:12 AM


All times are GMT -5. The time now is 04:41 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration