LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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

Reply
 
Search this Thread
Old 10-01-2009, 06:13 PM   #31
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,051

Rep: Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100

Quote:
Originally Posted by smeezekitty View Post
this is thhe code generated by the compiler
with -mt switch
That's annoying.

So to get tiny model to build correctly, you'll need to do something different in the startup code, which IIUC is your call.asm

I don't recall tasm well enough to both guess what you did and extrapolate to what to change. Post your call.asm and I'll have a better idea what to fix to accomplish one or both of two things (or you could read tasm documentation to figure this out yourself):

1) Use a group directive to define DGROUP as all of the segments used by tcc.

2) Make it clear to the linker that the entry point is at offset 0x100, so you can use both -mt for the compiler and /t for the linker to get a normal .com file.

Last edited by johnsfine; 10-01-2009 at 08:47 PM.
 
Old 10-01-2009, 06:25 PM   #32
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,223

Original Poster
Rep: Reputation: 167Reputation: 167
FYI i am not trying to drag this thread out
but this is not easy
call.asm:
Code:
    .MODEL TINY
    .CODE
    extrn _main:far
START:
mov si,ax
mov ax,cs
mov ss,ax
mov ds,ax
mov ax,si
jmp _main
END START
1 whats a group directive?
2 how do i change the entry point?
3 why is firefox running so slow right now?.......Just kidding
 
Old 10-01-2009, 06:59 PM   #33
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,223

Original Poster
Rep: Reputation: 167Reputation: 167
Hello World!
i get impatient easy no flames please
 
Old 10-01-2009, 08:41 PM   #34
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,051

Rep: Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100
Quote:
Originally Posted by smeezekitty View Post
call.asm:
I don't think that is consistent the disassembly you posted earlier, so you are posting confusing information.

Quote:
1 whats a group directive?
It is a line that goes in the .asm file and defines the group named DGROUP. The syntax of the line is

DGROUP group list of segments in sequence
But I don't recall enough about tasm/tcc to know what the segments are named nor whether they all need to be pre declared in the .asm file before including them in the group directive.

I found an tiny model example online example online
DGROUP GROUP _TEXT,_DATA,_BSS
but I'm not sure that fits your environment.

In the tlink documentation you posted earlier, it mentioned a switch /m
If you use tlink with that switch it creates a .map file. One of the things in the .map file is info on all the segments, which would be enough to remind me what would be needed in the group line.

Quote:
Originally Posted by smeezekitty View Post
setvector(0x1C, (unsigned long)clock_hook);
I don't know how clock_hook is defined. But I doubt that cast to unsigned long is the correct cast to create the right far pointer to the code.

Quote:
and the disasm of the functions:
Still looks right to me. So I think setvector is defined correctly but used incorrectly (or clock_hook is defined wrong, or you don't enable the clock interrupt correctly, or something like that).

Last edited by johnsfine; 10-01-2009 at 08:47 PM.
 
Old 10-01-2009, 08:58 PM   #35
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,223

Original Poster
Rep: Reputation: 167Reputation: 167
*THIS HAD BEEN UPDATED*
disassembled code always looks difrent that hand written code + there is another ASM file
heres the updated map file:
Code:
 Start  Stop   Length Name               Class

 00000H 00D5CH 00D5DH _TEXT              CODE
 00D5EH 00D87H 0002AH _DATA              DATA
 00D88H 00D88H 00000H _BSS               BSS

  Address         Publics by Name

 0000:0452       absread(int,int,int,void near*)
 0000:04AD       abswrite(int,int,int,void near*)
 0000:03A9       clock_hook()
 0000:07CD       createfile(char near*,int)
 0000:0272       farstrcpy(char far*,char near*)
 0000:074D       findfile(char near*,int)
 0000:0C83       find_data(int)
 0000:02CF       free(void near*)
 0000:056E       getstring(char near*,char near*,char,int)
 0000:0AD9       getvector(unsigned char)
 0000:09BA       jfclose(jfile near*)
 0000:0B5B       jfeof(jfile near*)
 0000:0911       jfopen(char near*,char near*)
 0000:0A52       jfread(void near*,long,long,jfile near*)
 0000:0B7E       jfseek(jfile near*,int,char)
 0000:0BC3       jftell(jfile near*)
 0000:0BE9       jfwrite(void near*,int,int,jfile near*)
 0000:0155       kernel_print(char near*)
 0000:00FA       keyready()
 0000:06EC       li(char near*,char)
 0000:0706       locate(char near*,char near*,int near*)
 0000:03E0       malloc(int)
 0000:08A0       mgen(char near*)
 0000:0009       rand()
 0000:0A18       readbyte(jfile near*)
 0000:010D       read_keyboard()
 0000:0865       refresh(jfile near*)
 0000:0508       seperate(char near*,__string near*)
 0000:09D5       setbyte(jfile near*,unsigned char)
 0000:0AAA       setvector(unsigned char,unsigned long)
 0000:03A4       sprintf(char near*,char near*,...)
 0000:05A6       str2int(char near*)
 0000:029A       strcat(char near*,char near*)
 0000:0181       strcmp(char near*,char near*)
 0000:0248       strcpy(char near*,char near*)
 0000:0058       strlen(char near*)
 0000:0325       strlwr(char near*)
 0000:00AC       strncat(char near*,char near*,int)
 0000:01D8       strncmp(char near*,char near*,int)
 0000:035F       strncmpi(char near*,char near*,int)
 0000:0070       strncpy(char near*,char near*,int)
 0000:03F5       strrev(char near*)
 0000:02EB       strupr(char near*)
 0000:0B04       timer(unsigned int)
 0000:0BD5       _k_panic(char near*,int)
 0000:0133       _video_clearscreen()
 0000:0146       _video_movecursor(char,char)
 0000:0125       _video_putchar(char)
 0000:0B2E       ____len(jfile near*)
 0000:03D2       ____ticker()
 0000:0CB6       _MAIN
 0000:0D62       _OLD_CLOCK
 0000:0D66       _P

  Address         Publics by Value

 0000:0009       rand()
 0000:0058       strlen(char near*)
 0000:0070       strncpy(char near*,char near*,int)
 0000:00AC       strncat(char near*,char near*,int)
 0000:00FA       keyready()
 0000:010D       read_keyboard()
 0000:0125       _video_putchar(char)
 0000:0133       _video_clearscreen()
 0000:0146       _video_movecursor(char,char)
 0000:0155       kernel_print(char near*)
 0000:0181       strcmp(char near*,char near*)
 0000:01D8       strncmp(char near*,char near*,int)
 0000:0248       strcpy(char near*,char near*)
 0000:0272       farstrcpy(char far*,char near*)
 0000:029A       strcat(char near*,char near*)
 0000:02CF       free(void near*)
 0000:02EB       strupr(char near*)
 0000:0325       strlwr(char near*)
 0000:035F       strncmpi(char near*,char near*,int)
 0000:03A4       sprintf(char near*,char near*,...)
 0000:03A9       clock_hook()
 0000:03D2       ____ticker()
 0000:03E0       malloc(int)
 0000:03F5       strrev(char near*)
 0000:0452       absread(int,int,int,void near*)
 0000:04AD       abswrite(int,int,int,void near*)
 0000:0508       seperate(char near*,__string near*)
 0000:056E       getstring(char near*,char near*,char,int)
 0000:05A6       str2int(char near*)
 0000:06EC       li(char near*,char)
 0000:0706       locate(char near*,char near*,int near*)
 0000:074D       findfile(char near*,int)
 0000:07CD       createfile(char near*,int)
 0000:0865       refresh(jfile near*)
 0000:08A0       mgen(char near*)
 0000:0911       jfopen(char near*,char near*)
 0000:09BA       jfclose(jfile near*)
 0000:09D5       setbyte(jfile near*,unsigned char)
 0000:0A18       readbyte(jfile near*)
 0000:0A52       jfread(void near*,long,long,jfile near*)
 0000:0AAA       setvector(unsigned char,unsigned long)
 0000:0AD9       getvector(unsigned char)
 0000:0B04       timer(unsigned int)
 0000:0B2E       ____len(jfile near*)
 0000:0B5B       jfeof(jfile near*)
 0000:0B7E       jfseek(jfile near*,int,char)
 0000:0BC3       jftell(jfile near*)
 0000:0BD5       _k_panic(char near*,int)
 0000:0BE9       jfwrite(void near*,int,int,jfile near*)
 0000:0C83       find_data(int)
 0000:0CB6       _MAIN
 0000:0D62       _OLD_CLOCK
 0000:0D66       _P

Program entry point at 0000:0000
Warning: No stack

Last edited by smeezekitty; 10-01-2009 at 09:15 PM. Reason: map file old
 
Old 10-01-2009, 09:13 PM   #36
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,051

Rep: Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100
Quote:
Originally Posted by smeezekitty View Post
Code:
 00000H 00D20H 00D21H _TEXT              CODE
 00D22H 00D43H 00022H _DATA              DATA
 00D44H 00D44H 00000H _BSS               BSS
That is what I wanted to see. It confirms my guess that the segment names are _TEXT, _DATA and _BSS, so my suggested DGROUP line (in my previous post) is correct.

So adding that line to the .asm file may make the link work correctly with tiny memory model (the -mt on the tcc line) or maybe tasm won't like that line because the .asm file containing doesn't declare data or bss. In that case, my best guess would be to replace the line:

Code:
    .CODE
with all these lines

Code:
    .CODE
    .DATA
    .BSS
DGROUP GROUP _TEXT,_DATA,_BSS
    .CODE
But remember, I haven't done this stuff myself in over ten years and even then I didn't use tasm much (I used masm and nasm).
 
Old 10-01-2009, 09:21 PM   #37
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,223

Original Poster
Rep: Reputation: 167Reputation: 167
Code:
Turbo Assembler  Version 4.1  Copyright (c) 1988, 1996 Borland International

Assembling file:   call.ASM
**Error** call.ASM(5) Illegal instruction
**Error** call.ASM(6) Undefined symbol: _BSS
Error messages:    2
Warning messages:  None
Passes:            1
Remaining memory:  615k
here is the new code
Code:
    .MODEL TINY
        .CODE
            .DATA
                .BSS
                DGROUP GROUP _TEXT,_DATA,_BSS
                    .CODE
    extrn _main:far
START:
mov si,ax
mov ax,cs
mov ss,ax
mov ds,ax
mov ax,si
jmp _main
END START
 
Old 10-01-2009, 09:23 PM   #38
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,051

Rep: Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100
You can leave the ,_BSS off the end of that line for now and see how that works.

That detail needs to be fixed for uninitialized global and static variables to work right. But for now you are trying to get initialized data to work and that doesn't need bss.

Edit: I just did an online search and found a tasm manual here
http://www.bitsavers.org/pdf/borland...Guide_1988.pdf

That seems to say the line to define _BSS is
Code:
.DATA?
So instead of leaving _BSS off the dgroup line, you might try changing the .bss line to instead be .data?

Last edited by johnsfine; 10-01-2009 at 09:40 PM.
 
Old 10-01-2009, 09:45 PM   #39
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,223

Original Poster
Rep: Reputation: 167Reputation: 167
now the linker says Undefined symbol DGROUP@.
i hate linkers
 
Old 10-01-2009, 09:59 PM   #40
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,223

Original Poster
Rep: Reputation: 167Reputation: 167
heres what the compiler generates--its very odd:
Code:
_TEXT   ends
DGROUP  group   _DATA,_BSS
        assume  cs:_TEXT,ds:DGROUP
_DATA   segment word public 'DATA'
d@      label   byte
d@w     label   word
_DATA   ends
_BSS    segment word public 'BSS'
b@      label   byte
b@w     label   word
_BSS    ends
_DATA   segment word public 'DATA'
        db      4 dup (?)
_DATA   ends
_TEXT   segment byte public 'CODE'
 
Old 10-01-2009, 11:37 PM   #41
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,223

Original Poster
Rep: Reputation: 167Reputation: 167
is it possable to move the data segment or data segment pointer
so it finds the data?
 
Old 10-02-2009, 07:25 AM   #42
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,051

Rep: Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100
Quote:
Originally Posted by smeezekitty View Post
now the linker says Undefined symbol DGROUP@.
I expect DGROUP@ is just another name for DGROUP, so it could be defined the same way as DGROUP
DGROUP& GROUP _TEXT,_DATA,_BSS
but I'm not sure.

You found where the compiler output uses DGROUP. Can you find where it uses DGROUP@
That might tell me what DGROUP@ is really supposed to be.

Quote:
Originally Posted by smeezekitty View Post
heres what the compiler generates--its very odd:
Code:
_TEXT   ends
DGROUP  group   _DATA,_BSS
        assume  cs:_TEXT,ds:DGROUP
That is not at all odd for "small" memory model. That is what small memory model should look like. It is odd for tiny memory model.

There are multiple ways to do the same segment declaration. In your asm code you used the line
.CODE
That is almost the same meaning as
_TEXT segment byte public 'CODE'
except that when you do it that longer way you also need to balance it with a later
_TEXT ends

Quote:
Originally Posted by smeezekitty View Post
is it possable to move the data segment or data segment pointer
so it finds the data?
Yes. That would be "small" memory model.

For tiny memory model, your startup code does this

mov ax,cs
mov ss,ax
mov ds,ax

For small memory model, it would do this

mov ax,cs
add ax, SOMETHING
mov ss,ax
mov ds,ax

But I'm not sure in this tool chain what you could put in place of that SOMETHING that would end up with the right number there after linking and running exetobin. My first guess would be DGROUP. The value you actually want is not equal to DGROUP, so in an .exe file (where the loader would fix that instruction to have the correct value of DGROUP) using add ax,DGROUP would be wrong. But it is likely that exetobin will get that usage of DGROUP "wrong" in exactly the right way to be the value you actually want.

But I think you are almost there with tiny model and you may find tiny model less confusing for later complex operations.
 
Old 10-02-2009, 12:04 PM   #43
manu-tm
Member
 
Registered: May 2008
Location: France
Distribution: Ubuntu, Debian
Posts: 239

Rep: Reputation: 23
I've been trying to follow this conversation guys. I was too using a lot tc and masm about 15 years ago and the only thing I remember very well is that the segmented memory model was confusing and prompt to bug-writing. Fortunatly I found very valuable doc at the time from the tasm manual even if I was using masm. If I may suggest one thing, getting and reading the online copy, mainly the stuff about memory layout, could be very helpfull for you.
 
Old 10-02-2009, 12:05 PM   #44
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,223

Original Poster
Rep: Reputation: 167Reputation: 167
it only uses DGROUP@ in tiny model
Code:
mov     bp,cs:DGROUP@
mov     ds,bp
mov     bp,sp
and
Code:
        db      '%s [%d]-'
        db      0
        db      'w+'
        db      0
        db      'w'
        db      0
        db      'r'
        db      0
        db      'a'
        db      0
        db      'panic::'
        db      0
        db      'Hey!'
        db      0
_DATA   ends
_TEXT   segment byte public 'CODE'
        extrn   DGROUP@:word
_TEXT   ends
 
Old 10-02-2009, 12:06 PM   #45
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,223

Original Poster
Rep: Reputation: 167Reputation: 167
Quote:
Originally Posted by manu-tm View Post
I've been trying to follow this conversation guys. I was too using a lot tc and masm about 15 years ago and the only thing I remember very well is that the segmented memory model was confusing and prompt to bug-writing. Fortunatly I found very valuable doc at the time from the tasm manual even if I was using masm. If I may suggest one thing, getting and reading the online copy, mainly the stuff about memory layout, could be very helpfull for you.
i dont have the tasm doc
 
  


Reply

Tags
asm, assembler, boot, data, find, kernel, loader


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:34 PM
Reiserfs - how to find which file contains data in a block Vrajgh Linux - Software 8 09-14-2007 03:04 AM
Retrieving semi-formatted data: Kernel Panic (cannot find file or dir /dev/root) majorGrey Linux - General 2 09-05-2007 04:02 AM
Kernel Panic: Resume Machine: Unable to find suspended-data signature ( - mispelled? ToddM Linux - General 1 09-30-2004 10:59 AM
can't find data mcd Linux - Software 1 08-12-2003 12:12 AM


All times are GMT -5. The time now is 02:32 AM.

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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration