LinuxQuestions.org
Review your favorite Linux distribution.
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 12-12-2006, 12:12 AM   #1
manas_sem
LQ Newbie
 
Registered: Dec 2006
Posts: 29

Rep: Reputation: 15
how to create an object file from an assembly program, with org 100h


how to create an object file from an assembly program, with org 100h & linking it with other .o files.
 
Old 12-12-2006, 12:48 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,398
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I has been a while, but as I recall, the ORG 100h business had only to do with MS-DOS applications, as a way to provide space for the Program Segment Prefix. Are you sure your application requires this?

In general, you will just need an assembler, such as as, or nasm. That will create your object module from the assembly language source file.

--- rod.
 
Old 12-15-2006, 09:44 PM   #3
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 450
Blog Entries: 4

Rep: Reputation: 212Reputation: 212Reputation: 212
If theNbomr is correct, and this is original MS-DOS, tell me more about your question; i should be able to help.
 
Old 12-17-2006, 09:15 AM   #4
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
There'll be problems with the linker tags. Might be able to fix those in the object file using a hex editor, so long as the strings are the exact same length.
 
Old 12-17-2006, 09:48 PM   #5
manas_sem
LQ Newbie
 
Registered: Dec 2006
Posts: 29

Original Poster
Rep: Reputation: 15
i am using NASM

Quote:
Originally Posted by theNbomr
I has been a while, but as I recall, the ORG 100h business had only to do with MS-DOS applications, as a way to provide space for the Program Segment Prefix. Are you sure your application requires this?

In general, you will just need an assembler, such as as, or nasm. That will create your object module from the assembly language source file.

--- rod.

i am using NASM. but with ORG 100h mentioned, nasm is giving error while producing the object file.
My Problem: I want to put my own Interrupt handler for timer interrupt (8253). but while putting the ISR in IVT in real mode, segmentation fault is coming (Without ORG 100h included in the program). If ORG 100h is declared, then only i can produce .com files, for which i don't have any problem in registering the ISR in IVT. But as mentioned earlier, with ORG 100h i am unable to produce object files.

---manas_sem
 
Old 12-17-2006, 09:52 PM   #6
manas_sem
LQ Newbie
 
Registered: Dec 2006
Posts: 29

Original Poster
Rep: Reputation: 15
Registering own ISR in IVT in REAL mode in i386

Quote:
Originally Posted by dogpatch
If theNbomr is correct, and this is original MS-DOS, tell me more about your question; i should be able to help.
Question:
I want to put my own Interrupt handler for timer interrupt (8253). but while putting the ISR in IVT in real mode, segmentation fault is coming (Without ORG 100h included in the program). If ORG 100h is declared, then only i can produce .com files, for which i don't have any problem in registering the ISR in IVT. But as mentioned earlier, with ORG 100h i am unable to produce object files.

manas
 
Old 12-17-2006, 10:47 PM   #7
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
manas_sem -

Could you please give us a little more background about just what this "IVT" project is? Specifically:

1. What is your hardware? Does "i386" mean a Pentium P4 or higher CPU, or "something else"? Are you using a standard motherboard (ASUS, ABIT, Intel, etc etc) or "something else" (including a board of your own design)?

2. What is the operating system? Linux? DOS? Or "Something else"?

3. What exactly do you mean by "IVT"? could you give us a web link to this particular "IVT"?

4. You're talking about "nasm" and ".o" object files: so far, so good. This is what I would expect using NASM under Linux. But then you start talking about ".com" files (DOS executables), which come from .obj (which, in turn, are typically "OMF" object formats).

You cannot mix'n'match different object and executable formats (like .o and .com).

So what exactly is your development platform (Linux?) and what is your target platform (are you trying to cross-compile for DOS? For "something else")?

5. What exactly goes wrong when you try to assemble "org 100h"?
Could you cut/paste your command line, and the corresponding error message?


Please give us some more background, and perhaps we might be able to help you better.

Thanx in advance .. PSM

PS:
And please - PLEASE - read the link I already gave you for details on DOS/BIOS level timer interrupt programming:

http://www.delorie.com/djgpp/doc/ug/...handlers1.html

Last edited by paulsm4; 12-17-2006 at 10:51 PM.
 
Old 12-17-2006, 11:06 PM   #8
manas_sem
LQ Newbie
 
Registered: Dec 2006
Posts: 29

Original Poster
Rep: Reputation: 15
IVT- Interrupt Vector Table

[QUOTE=paulsm4]manas_sem -

Could you please give us a little more background about just what this "IVT" project is? Specifically:

1. What is your hardware? Does "i386" mean a Pentium P4 or higher CPU, or "something else"? Are you using a standard motherboard (ASUS, ABIT, Intel, etc etc) or "something else" (including a board of your own design)?

2. What is the operating system? Linux? DOS? Or "Something else"?

3. What exactly do you mean by "IVT"? could you give us a web link to this particular "IVT"?

4. You're talking about "nasm" and ".o" object files: so far, so good. This is what I would expect using NASM under Linux. But then you start talking about ".com" files (DOS executables), which come from .obj (which, in turn, are typically "OMF" object formats).

You cannot mix'n'match different object and executable formats (like .o and .com).

So what exactly is your development platform (Linux?) and what is your target platform (are you trying to cross-compile for DOS? For "something else")?

5. What exactly goes wrong when you try to assemble "org 100h"?
Could you cut/paste your command line, and the corresponding error message?


Please give us some more background, and perhaps we might be able to help you better.

Thanx in advance .. PSM[/QUOTE

Processor - P4 ,Motherboard - intel, OS - DOS (32 bit GCC port)

IVT-Interrupt vector table at location 0000:0000 ( Hardware Timer handler address 0000:0020 H).

Problem: I want to register my own interrupt handler address at physiacl location 0000:0020h ( which is default handler address for hardware timer ,8253). i am writing the program in assembly, assembler NASM.
Now, to link the assembly program with other programs i need an object file(.o) of the assembly program.

In the assembly program if i am declaring ORG 100h at the beginning, i am able to genarate a .com file ( nasm -o test.com test.asm), which is working fine with my interrupt handler at the specified address.

Now with ORG 100h being in the program if i am trying to get an .o file (nasm -f coff test.asm), it is giving error. ERROR: Instruction expected at line 1,i.e., ORG 100h , OR no directive ORG...

But if i don't give ORG 100h , i am able to get an .o file with no error. BUT while i am linking this .o file with other .o files, i am getting a segmentation fault ( while loading my interrupt handler address at 0000: 0020h physical address).

You can type IVT + i386, in google to get idea about IVT. the adrress of the IVT is processor specific.
 
Old 12-18-2006, 12:20 PM   #9
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,398
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
You say that you are loading the Interrupt Vector Table (IVT) in real mode, but getting a Segmentation Fault. This does not make sense, since in Real Mode, there is no protected memory. It seems that you are trying to execute your code, which is intended to run in real mode, from a protected mode OS, presumeably Linux. Linux seg faults your code, because you just aren't allowed to subvert low level things like timer interrupts.

--- rod.
 
Old 12-18-2006, 06:30 PM   #10
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 450
Blog Entries: 4

Rep: Reputation: 212Reputation: 212Reputation: 212
manas_sem: Are you, in fact, developing in a Dos environment using DJGPP or DJGCC?

I believe that The DPMI spec says that the timer tick interrupt requires a protected-mode handler.

Last edited by dogpatch; 12-18-2006 at 06:47 PM.
 
  


Reply


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
PHP Web Page Unable to create DOMDocument Object linux_pioneer Programming 0 03-11-2006 01:01 PM
Producing assembly and object output with GNU make markelo Programming 2 12-22-2005 03:21 AM
how to create unlinked object files from source irfanhab Programming 1 08-18-2005 12:11 PM
Please help me with my assembly program flamesrock Programming 2 01-30-2005 10:27 PM
Is there a way to make a program create a pid file? blk96gt Slackware 1 10-29-2004 11:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:41 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration