Page 1 of 1
non os-specific assembly
Posted: Fri Sep 06, 2002 5:48 pm
by CoolnessItself
I know theres DOSSEG for DOS and SECTION for linux and all that stuff, but how do you make code that can be run in any OS?
Re:non os-specific assembly
Posted: Sat Sep 07, 2002 4:04 am
by pskyboy
Correct me if im wrong, but i would guess what you wish to acheive would only be possible if you don't call any operatying specific calls. So you would have to directly access the hardware (which would mean you would have to write your program for a specific platform) or you will have to use interupts only.
Peter
Re:non os-specific assembly
Posted: Sat Sep 07, 2002 1:18 pm
by CoolnessItself
Im wondering what the format of the asm file to make would be. (Correct me if im wrong:) I cant have dosseg at the top, that need dos. I cant have SECTION, that requires linux
So what do I use?
Re:non os-specific assembly
Posted: Sun Sep 08, 2002 4:55 am
by Tim
What assembler are you using? No assembler I know of inserts OS-specific code into its output, although all assemblers will write to a specific object format if asked.
Re:non os-specific assembly
Posted: Sun Sep 08, 2002 6:26 am
by frank
assembly is always os-specific,
in linux you can only use syscalls (ok, libs too
)
in dos you can directly access the hardware (ugh!, what's the use of an os then ?
) and use syscalls.
The syscalls differ on both systems, dos uses int 21h, linux uses 80h.
That's why C is "invented", on both systems it makes different binaries.
Code: Select all
int main()
{
exit(0); // syscall
}
will make 2 different binary files on both systems.
(check using ndisasm)
Re:non os-specific assembly
Posted: Sun Sep 08, 2002 9:20 am
by Tim
No, assembly is always processor-specific. Example: the INT instruction is available on the x86 regardless of whether you're programming for DOS, Windows or Linux. What happens when you execute the INT instruction depends on what OS you run your code under, but the instruction set (and hence the assembler) is the same under each OS.
Conversely, if you changer processor but keep the OS the same, the assembly code you write will be completely different. A Linux program written in ARM assembly looks completely different to the same program written using x86 assembly.