LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 11-15-2003, 11:01 AM   #1
usr
Member
 
Registered: Oct 2003
Posts: 44

Rep: Reputation: 15
assembler


I tried nasm as a linux assembler and I created a test file to see if it works.
My test.asm looks like this:

.model small
.stack 10
.data
mesaj db 'exemplu program$'
.code
start:
mov ax, @data
mov dx, ax
mov dx, offset mesaj
mov ah, 9
int 21h
mov ax, 4c00h
int 21h
end start

unfortunately, I received errors:

[ti@localhost Desktop]$ vi test.asm
[ti@localhost Desktop]$ nasm -o test -a test.asm
test.asm:1: error: attempt to define a local label before any non-local labels
test.asm:1: error: parser: instruction expected
test.asm:2: error: attempt to define a local label before any non-local labels
test.asm:2: error: parser: instruction expected
test.asm:3: error: attempt to define a local label before any non-local labels
test.asm:9: error: comma or end of line expected
test.asm:14: error: parser: instruction expected
[ti@localhost Desktop]$

How can I fix these errors?

Thanks!
 
Old 11-15-2003, 12:52 PM   #2
dorian33
Member
 
Registered: Jan 2003
Location: Poland, Warsaw
Distribution: LFS, Gentoo
Posts: 587

Rep: Reputation: 32
I belive everything is incorrect.
1. You've chosen improper operating system for your code. The code is for DOS rather that for linux. 2. 'Int21' is DOS-specific.
3. There is no 'small' or 'large' models in linux since the CPU works in protected mode.
4. Same concerns registers which are named differently in this mode.
5. You used the syntax used by DOS assemblers which is usually non-acceptable by linux ones.
 
Old 11-15-2003, 05:15 PM   #3
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,536

Rep: Reputation: 148Reputation: 148
Assembler writing in Linux is much different than in DOS. Mainly because you can't write directly to hardware. But you still can do interesting things.
One thing that may be helpful. When learning Linux assembler, it's sometimes a good idea to see how your C prog looks in Asembler. It can be done using
gcc -S -O3 filename.c
It converts the C code to ASM code (it's not perfect, but with optimalization -O3 it's good).
 
  


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
Assembler samjkd General 7 03-14-2005 01:52 PM
m6800 assembler kafnir Linux - Newbie 1 03-05-2005 01:29 AM
Assembler Firari Programming 9 12-10-2004 02:26 PM
assembler tda Programming 4 08-21-2002 02:54 AM
Need an Assembler ChimpFace9000 Programming 1 07-18-2001 09:36 PM


All times are GMT -5. The time now is 04:50 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration