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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
|
10-01-2009, 06:13 PM
|
#31
|
|
Senior Member
Registered: Dec 2007
Distribution: Mepis, Centos
Posts: 4,674
|
Quote:
Originally Posted by smeezekitty
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.
|
|
|
|
10-01-2009, 06:25 PM
|
#32
|
|
Senior Member
Registered: Sep 2009
Location: Washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,136
Original Poster
Rep: 
|
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 
|
|
|
|
10-01-2009, 06:59 PM
|
#33
|
|
Senior Member
Registered: Sep 2009
Location: Washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,136
Original Poster
Rep: 
|
Hello World!
i get impatient easy no flames please
|
|
|
|
10-01-2009, 08:41 PM
|
#34
|
|
Senior Member
Registered: Dec 2007
Distribution: Mepis, Centos
Posts: 4,674
|
Quote:
Originally Posted by smeezekitty
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
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.
|
|
|
|
10-01-2009, 08:58 PM
|
#35
|
|
Senior Member
Registered: Sep 2009
Location: Washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,136
Original Poster
Rep: 
|
*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
|
|
|
|
10-01-2009, 09:13 PM
|
#36
|
|
Senior Member
Registered: Dec 2007
Distribution: Mepis, Centos
Posts: 4,674
|
Quote:
Originally Posted by smeezekitty
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:
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).
|
|
|
|
10-01-2009, 09:21 PM
|
#37
|
|
Senior Member
Registered: Sep 2009
Location: Washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,136
Original Poster
Rep: 
|
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
|
|
|
|
10-01-2009, 09:23 PM
|
#38
|
|
Senior Member
Registered: Dec 2007
Distribution: Mepis, Centos
Posts: 4,674
|
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
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.
|
|
|
|
10-01-2009, 09:45 PM
|
#39
|
|
Senior Member
Registered: Sep 2009
Location: Washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,136
Original Poster
Rep: 
|
now the linker says Undefined symbol DGROUP@.
i hate linkers
|
|
|
|
10-01-2009, 09:59 PM
|
#40
|
|
Senior Member
Registered: Sep 2009
Location: Washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,136
Original Poster
Rep: 
|
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'
|
|
|
|
10-01-2009, 11:37 PM
|
#41
|
|
Senior Member
Registered: Sep 2009
Location: Washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,136
Original Poster
Rep: 
|
is it possable to move the data segment or data segment pointer
so it finds the data?
|
|
|
|
10-02-2009, 07:25 AM
|
#42
|
|
Senior Member
Registered: Dec 2007
Distribution: Mepis, Centos
Posts: 4,674
|
Quote:
Originally Posted by smeezekitty
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
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
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.
|
|
|
|
10-02-2009, 12:04 PM
|
#43
|
|
Member
Registered: May 2008
Location: France
Distribution: Ubuntu, Debian
Posts: 239
Rep:
|
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.
|
|
|
|
10-02-2009, 12:05 PM
|
#44
|
|
Senior Member
Registered: Sep 2009
Location: Washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,136
Original Poster
Rep: 
|
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
|
|
|
|
10-02-2009, 12:06 PM
|
#45
|
|
Senior Member
Registered: Sep 2009
Location: Washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,136
Original Poster
Rep: 
|
Quote:
Originally Posted by manu-tm
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:41 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|