Congratulations to AcaCandy on her 100,000th post!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot bsod computer connection crash css dell display drive driver drivers email error ethernet excel firefox firefox 3 game hard drive internet internet explorer itunes laptop linux malware monitor network networking nvidia outlook outlook 2003 outlook 2007 outlook express partition problem router slow software sound trojan usb video virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Assembly Language and Linux


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
InterKnight's Avatar
Computer Specs
Senior Member with 288 posts.
 
Join Date: Oct 2004
Location: California
Experience: Advanced
21-Jan-2008, 04:13 PM #1
Assembly Language and Linux
Hello, everyone. Long time no see.

Well, last year I switched over to Linux. Now I am in an Assembly Language Programming course at college--this is where my problem begins.

I have a lab exercise which involves typing out a small ASM program from a typed hard copy. I have it typed out exactly as shown, but none of the assemblers on Linux (nasm, yasm, gas) are assembling--they all come up with errors.

This class focuses on programs for IA-32 family processors.

Is there something I need to do, ro is there a different assembler I would need to use? The book recommends the Microsoft Macro Assembler (MASM), and our professor recommended Borland Turbo Assembler (TASM). Neither the book nor the professor, however, had any present knowledge to recommend a Linux-based assembler.

Does anyone have a clue as to what I should do regarding this situation? Worst case scenario, I could try to run the Borland Turbo Assembler in Wine or a virtual machine to see if it would work.

Thanks for any and all help, everyone.

Please take care.
__________________
"No matter how hard things may seem, you are never trapped until you stop trying."
______________________________________________________

Proud low-vision Linux user (Ubuntu 7.04 "Feisty Fawn").
Member of the Ubuntu Accessibility Team

Registered Linux User #423082
InterKnight's Avatar
Computer Specs
Senior Member with 288 posts.
 
Join Date: Oct 2004
Location: California
Experience: Advanced
21-Jan-2008, 08:10 PM #2
Hello, again.

I found a slight workaround for this, but for anyone to do it, around 512MB-1GB of RAM would be necessary--and fortunately, I upgraded my RAM to 1GB last year.

Let me explain what happened: NASM (Netwide Assembler) for Linux does not support certain directives which are used in TASM (Turbo Assembler), such as .MODEL. The assembler works, but things have to be done a different way, and I do not have the knowledge to accomplish this at this time as I have no ASM programming experience.

My solution for this problem is this: I installed a Windows XP virtual machine under VirtualBox, setup TASM in the VM, and now use this method for doing the Assembly Language Programming course assignments. (This is why I mentioned the RAM necessity above)

In any case, it works.

Thanks, everyone.

Take care.
__________________
"No matter how hard things may seem, you are never trapped until you stop trying."
______________________________________________________

Proud low-vision Linux user (Ubuntu 7.04 "Feisty Fawn").
Member of the Ubuntu Accessibility Team

Registered Linux User #423082
tomdkat's Avatar
Computer Specs
Distinguished Member with 3,705 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
21-Jan-2008, 08:39 PM #3
What kind of errors were you getting from the GNU assembler (gas)?

Peace...
InterKnight's Avatar
Computer Specs
Senior Member with 288 posts.
 
Join Date: Oct 2004
Location: California
Experience: Advanced
21-Jan-2008, 09:01 PM #4
Hello, tomdkat.

Thanks for the response.

Here si the code for the program:
Code:
; AUTHOR:	RKC
; CLASS:	CS241
; DUE DATE:	January 23, 2008
; DESCRIPTION:	This is a simple program which will demonstrate the creation, assembling, linking, and execution of a basic
;		assembly language program.
.MODEL	SMALL
.STACK	100h

.DATA
	TimePrompt DB 'Is it after 12 noon?(Y/N)?$'
	GoodMorningMessage  LABEL  BYTE
	  DB  13,10,'Good morning, world!',13,10,'$'
	GoodAfternoonMessage  LABEL  BYTE
	  DB  13,10,'Good afternoon, world!',13,10,'$'
	
.CODE
	mov ax,@data
	mov ds,ax				;set DS to point to the data segment
	
	mov dx,OFFSET TimePrompt		;point to the time prompt
	mov ah,9				;DOS print string function #
	int 21h					;display the time prompt

	mov ah,1				;DOS get character function #
	int 21h					;get a single-character response

	cmp al,'y'				;typed lowercase y for afternoon?
	jz IsAfternoon				;yes, it's after noon

	cmp al,'Y'				;typed uppercase Y for afternoon?
	jnz IsMorning				;no, it's before noon

	IsAfternoon:
	  mov dx,OFFSET GoodAfternoonMessage	;point to the afternoon greeting
	  jmp DisplayGreeting

	IsMorning:
	  mov dx,OFFSET GoodMorningMessage	;point to the before noon greeting

	DisplayGreeting:
	  mov ah,9				;DOS print string function #
	  int 21h				;display the appropriate greeting

	mov ah,4ch				;DOS terminate program function #
	int 21h					;terminate the program

END						;this line is a must in every assembly language program
Here are the errors which I receive from gas:
Code:
Lab1.asm: Assembler messages:
Lab1.asm:1: Error: no such instruction: `RKC'
Lab1.asm:2: Error: no such instruction: `cs241'
Lab1.asm:3: Error: no such instruction: `due DATE:January 23,2008'
Lab1.asm:4: Error: no such instruction: `this is a simple program which will demonstrate the creation,assembling,linking,and execution of a basic'
Lab1.asm:5: Error: no such instruction: `assembly language program.'
Lab1.asm:6: Error: unknown pseudo-op: `.model'
Lab1.asm:7: Error: unknown pseudo-op: `.stack'
Lab1.asm:10: Error: no such instruction: `timeprompt DB 73s it after 12 noon?(Y/N)?$10GoodMorningMessage LABEL BYTE'
Lab1.asm:11: Error: no such instruction: `db 13,10,71ood morning,world!4413,10,36'
Lab1.asm:12: Error: no such instruction: `goodafternoonmessage LABEL BYTE'
Lab1.asm:13: Error: no such instruction: `db 13,10,71ood afternoon,world!4413,10,36'
Lab1.asm:15: Error: unknown pseudo-op: `.code'
Lab1.asm:16: Error: invalid char '@' beginning operand 2 `@data'
Lab1.asm:17: Error: too many memory references for `mov'
Lab1.asm:17: Error: no such instruction: `set DS to point to the data segment'
Lab1.asm:19: Error: too many memory references for `mov'
Lab1.asm:19: Error: no such instruction: `point to the time prompt'
Lab1.asm:20: Error: too many memory references for `mov'
Lab1.asm:20: Error: no such instruction: `dos print string function'
Lab1.asm:21: Error: junk `h' after expression
Lab1.asm:21: Error: suffix or operands invalid for `int'
Lab1.asm:21: Error: no such instruction: `display the time prompt'
Lab1.asm:23: Error: too many memory references for `mov'
Lab1.asm:23: Error: no such instruction: `dos get character function'
Lab1.asm:24: Error: junk `h' after expression
Lab1.asm:24: Error: suffix or operands invalid for `int'
Lab1.asm:24: Error: no such instruction: `get a single-character response'
Lab1.asm:26: Error: too many memory references for `cmp'
Lab1.asm:26: Error: no such instruction: `typed lowercase y for afternoon?'
Lab1.asm:27: Error: no such instruction: `yes, it115after noon'
Lab1.asm:29: Error: too many memory references for `cmp'
Lab1.asm:29: Error: no such instruction: `typed uppercase Y for afternoon?'
Lab1.asm:30: Error: no such instruction: `no, it115before noon'
Lab1.asm:33: Error: too many memory references for `mov'
Lab1.asm:33: Error: no such instruction: `point to the afternoon greeting'
Lab1.asm:37: Error: too many memory references for `mov'
Lab1.asm:37: Error: no such instruction: `point to the before noon greeting'
Lab1.asm:40: Error: too many memory references for `mov'
Lab1.asm:40: Error: no such instruction: `dos print string function'
Lab1.asm:41: Error: junk `h' after expression
Lab1.asm:41: Error: suffix or operands invalid for `int'
Lab1.asm:41: Error: no such instruction: `display the appropriate greeting'
Lab1.asm:43: Error: too many memory references for `mov'
Lab1.asm:43: Error: no such instruction: `dos terminate program function'
Lab1.asm:44: Error: junk `h' after expression
Lab1.asm:44: Error: suffix or operands invalid for `int'
Lab1.asm:44: Error: no such instruction: `terminate the program'
Lab1.asm:46: Error: no such instruction: `end'
Lab1.asm:46: Error: no such instruction: `this line is a must in every assembly language program'
I used Gedit to write the rpogram. Should I use something else? I see it's not recognizing comments (.

Thanks again.

Take care.
tomdkat's Avatar
Computer Specs
Distinguished Member with 3,705 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
21-Jan-2008, 09:06 PM #5
Naw, I doubt it's the editor you're using. Which version of gas are you running? Use the "gas --version" command to find out.

Peace...
InterKnight's Avatar
Computer Specs
Senior Member with 288 posts.
 
Join Date: Oct 2004
Location: California
Experience: Advanced
21-Jan-2008, 09:11 PM #6
Here is what I get for the version. Hope this helps.

Code:
GNU assembler (GNU Binutils for Ubuntu) 2.18
Copyright 2007 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `i486-linux-gnu'.
Thanks again.
tomdkat's Avatar
Computer Specs
Distinguished Member with 3,705 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
21-Jan-2008, 09:13 PM #7
Additionally, it looks like gas supports *different* comment characters on different platforms.

I presume you're using a 32-bit (i386) Linux system. Check out the gas manual on comments for your platform.

Peace...
InterKnight's Avatar
Computer Specs
Senior Member with 288 posts.
 
Join Date: Oct 2004
Location: California
Experience: Advanced
21-Jan-2008, 09:24 PM #8
Thanks.

I changed the comment format in the file, but GAS also (like NASM) seems to not recognize the .model and the .stack directives. I'm not sure how to work around this, but worse comes to worse I can just use the virtualization method.
tomdkat's Avatar
Computer Specs
Distinguished Member with 3,705 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
21-Jan-2008, 10:23 PM #9
Looks like .model and .stack are MASM-specific directives that TASM supports to be compatible with MASM. I think .stack might be implementable in GNU as using a ".section" directive. I would post a message on the GNU as mailing list to find out how to better deal with MASM specific directives.

Here is another link that might be helpful.

Peace...
ZeRealBigBoss's Avatar
Computer Specs
Senior Member with 204 posts.
 
Join Date: Mar 2007
Location: Auckland, NZ
Experience: Assembler freak
24-Jan-2008, 07:32 PM #10
NASM under Linux does not recognise the .model directive because it always runs in flat mode. You get rid of the 64k barrier for free. If you used MASM, you will have to re-think in many details. Indeed, TASM is a very good one, but before you have that one set up correctly on a certain machine, we are a few weeks and much trial-and-error onwards.

Many assembler compilers recognise the // or /*......*/ instead of the ;

Have a look here:

http://nasm.sourceforge.net/
http://nasm.sourceforge.net/doc/nasmdoc1.html
http://www.ibm.com/developerworks/li...-gas-nasm.html
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 04:06 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.