how to create an object file from an assembly program, with org 100h
ProgrammingThis 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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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.
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:
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)
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.