LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-21-2010, 04:37 AM   #1
cvr
LQ Newbie
 
Registered: Jun 2010
Posts: 18

Rep: Reputation: 0
How to compile Assembly code in linux fedora11 ?


Can you please help me how to compile assembly code in linux?
I am using AMD processor code instructions...is that amd registers inbuilt?

with what file extension i should give while writing assembly code program?
 
Old 06-21-2010, 04:40 AM   #2
cvr
LQ Newbie
 
Registered: Jun 2010
Posts: 18

Original Poster
Rep: Reputation: 0
How to compile Assembly code in linux fedora11 ?

How to compile the below assembly code in linux?

MOV CX,533H


_SND_SPKR_TONE:

MOV AL,0B6H

OUT 43h,AL ; 43h = PIT mode control word (page 377)

MOV AX,CX

NEWIODELAY

OUT 42h,AL ; 42h = Counter 2 (page 376)

MOV AL,AH

NEWIODELAY

OUT 42h,AL ; 42h = Counter 2 (page 376)

IN AL,61h ; 61h = PIT conter 2 (Speaker) (page 378)

MOV AH,AL

OR AL,3

NEWIODELAY

OUT 61h,AL
 
Old 06-21-2010, 05:48 AM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by cvr View Post
Can you please help me how to compile assembly code in linux?
Is that assembly code written with gas syntax (gnu assembler) or with Intel/Masm syntax?

Is it 32 bit assembly or 64 bit assembly code?

Quote:
I am using AMD processor code instructions...is that amd registers inbuilt?
I don't understand what you mean. Maybe some examples would help.

Quote:
with what file extension i should give while writing assembly code program?
.asm is the traditional extension for Intel/Masm assembly files, though on Linux sometimes .s is used even for those. .s is the traditional extension for gas assembly files.

gas is the program normally used on Linux to "compile" assembly code. But for Intel/Masm syntax, you might need NASM (I think that is 32 bit only). I forget the name of the assembler that extends the feature set of NASM to include 64 bit and other enhancements. If you need 64 bit Intel/Masm syntax, I can look that up for you.

Edit: I just looked at your other thread started with the same subject (please don't do that). You want to "compile" 16 bit (not 32 or 64) assembly code in MASM syntax. NASM is probably the easiest tool for that. I'm not sure whether NASM is available as a package (.rpm) for Fedora.

With NASM, the correct command for compiling that code depends on how you plan to run that code. It looks like it is intended to run in DOS or maybe without an OS at all. Are you planning to reboot into to DOS (or no OS) to run it? Or do you plan to run it in some 16 bit DOS emulator? Or what?

Last edited by johnsfine; 06-21-2010 at 05:58 AM.
 
1 members found this post helpful.
Old 06-21-2010, 06:47 AM   #4
fruttenboel
Member
 
Registered: Jul 2008
Location: Tilburg NL
Distribution: Slackware 14.2 ciurrent, kernel 3.18.11
Posts: 270

Rep: Reputation: 48
Quote:
Originally Posted by cvr View Post
How to compile the below assembly code in linux?

MOV CX,533H
_SND_SPKR_TONE:
MOV AL,0B6H
OUT 43h,AL ; 43h = PIT mode control word (page 377)
MOV AX,CX
NEWIODELAY
OUT 42h,AL ; 42h = Counter 2 (page 376)
MOV AL,AH
NEWIODELAY
OUT 42h,AL ; 42h = Counter 2 (page 376)
IN AL,61h ; 61h = PIT conter 2 (Speaker) (page 378)
MOV AH,AL
OR AL,3
NEWIODELAY
OUT 61h,AL
This is DOS assembly (16 bit code). Use something like Tasm to assemble it in a DOSbox. Don't count on it that it runs in Linux since it requires I/O port access.
 
Old 06-21-2010, 06:51 AM   #5
fruttenboel
Member
 
Registered: Jul 2008
Location: Tilburg NL
Distribution: Slackware 14.2 ciurrent, kernel 3.18.11
Posts: 270

Rep: Reputation: 48
Quote:
Originally Posted by johnsfine View Post
Is that assembly code written with gas syntax (gnu assembler) or with Intel/Masm syntax?

Is it 32 bit assembly or 64 bit assembly code?
No. The code in the other thread is 16 bit DOS Realmode code. It is rather plain code and when in a dosbox use A86 to compile or assemble it. A86 is a very good assembler. A386 is the 32 bit version with support for at least the Pentium III, perhaps even more.

Get A86 from http://www.eji.com
 
Old 06-21-2010, 07:44 AM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
DOS assebler won't work on Linux. The system calls work very differently.
 
0 members found this post helpful.
Old 06-21-2010, 07:45 AM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
http://www.linuxquestions.org/questi...dora11-815387/

If you're talking about the code in this thread, then it simply won't work in Linux.

The system call mechanism and the system calls themselves are very different.
 
Old 06-22-2010, 12:13 PM   #8
fruttenboel
Member
 
Registered: Jul 2008
Location: Tilburg NL
Distribution: Slackware 14.2 ciurrent, kernel 3.18.11
Posts: 270

Rep: Reputation: 48
Quote:
Originally Posted by MTK358 View Post
DOS assebler won't work on Linux. The system calls work very differently.
Wrong

If you run it in a DOSbox it runs better than on a 386DX40 http://www.dosbox.com/

I run Wolfenstein 3D and it outperforms the dedicated DOS machines I used to run it on.
 
Old 06-22-2010, 12:15 PM   #9
fruttenboel
Member
 
Registered: Jul 2008
Location: Tilburg NL
Distribution: Slackware 14.2 ciurrent, kernel 3.18.11
Posts: 270

Rep: Reputation: 48
Quote:
Originally Posted by MTK358 View Post
http://www.linuxquestions.org/questi...dora11-815387/

If you're talking about the code in this thread, then it simply won't work in Linux.

The system call mechanism and the system calls themselves are very different.
It will in a DOSbox....

In dosbox I can use my FST Modula-2 compiler for DOS to do all kinds of magic. No sweat. Try it!
 
Old 06-22-2010, 12:21 PM   #10
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
I know it would work in a DOS emulator under Linux, but it still won't run on Linux.
 
1 members found this post helpful.
Old 06-22-2010, 06:24 PM   #11
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
cvr also you might want to install Fedora 13 FIRST .
fedora 11 is about to hit it's END OF LIFE in a week or 2 .
 
Old 06-23-2010, 04:19 AM   #12
fruttenboel
Member
 
Registered: Jul 2008
Location: Tilburg NL
Distribution: Slackware 14.2 ciurrent, kernel 3.18.11
Posts: 270

Rep: Reputation: 48
Quote:
Originally Posted by MTK358 View Post
I know it would work in a DOS emulator under Linux, but it still won't run on Linux.
I could now write: A dosbox is still 'on Linux' but I won't do that since it sounds so pedantic..
 
Old 06-23-2010, 07:28 AM   #13
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
I meant "not directly on Linux", as in:

Code:
bash$ ./dos-asm-program
 
1 members found this post helpful.
Old 06-23-2010, 07:50 AM   #14
cvr
LQ Newbie
 
Registered: Jun 2010
Posts: 18

Original Poster
Rep: Reputation: 0
How to know whether the code is 16-bit or 32-bit?

Sir,
By seeing just the assembly code,How can we tell the code is 16-bit or 32 bit?
In my opinion it depends on the number of data lines of the processor!
am i rite?
What is the entry function i need to give if i want to compile the assembly code? (LIKE we will give main() in c-language)
 
1 members found this post helpful.
Old 06-23-2010, 07:57 AM   #15
cvr
LQ Newbie
 
Registered: Jun 2010
Posts: 18

Original Poster
Rep: Reputation: 0
Regarding processor in assembly code used..

I was using cs 5536 chipset(AMD) in the above assembly code ...
 
0 members found this post helpful.
  


Reply



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
[solved] missing stropts.h(apue code compilation in Fedora11) joyrock Programming 5 02-11-2010 12:37 PM
porting an inline Intel assembly code with MMX technology into linux arienashwani Ubuntu 0 03-05-2009 05:35 AM
assembly code on linux omerlh Programming 1 06-01-2006 03:25 AM
Can gcc cross-compile C code to M68K Assembly? lowpro2k3 Programming 1 03-25-2005 07:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:02 PM.

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