LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 07-10-2011, 05:00 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
as: a syntax question.


as 2.17

Hi:
I want to code this:

and byte[45],03

In words, AND the byte at memory location 45 with immediate value 03.
as reports "Ambiguous operand size for and". How could I code the instruction such that as understands my intention?

john: .byte 45
and byte[john],03

gives the same error.
 
Old 07-10-2011, 05:06 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by stf92 View Post
as 2.17

Hi:
I want to code this:

and byte[45],03

In words, AND the byte at memory location 45 with immediate value 03.
as reports "Ambiguous operand size for and". How could I code the instruction such that as understands my intention?

john: .byte 45
and byte[john],03

gives the same error.
You probably have to declare '03' as byte too.
 
Old 07-10-2011, 10:30 PM   #3
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 490
Blog Entries: 4

Rep: Reputation: 238Reputation: 238Reputation: 238
I am not familiar with as, but in gcc assembly, the op code must in many cases specify the size, as in

Code:
 andb $3,$John
the 'b' in 'andb' designating 'byte'.

This thread has me wondering how i missed as. I went through alot of work converting many of my old Dos masm source files to gcc assembly. Wrote a C program to do most of the converting.
 
1 members found this post helpful.
Old 07-11-2011, 02:55 AM   #4
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Thanks. andb turned up to be correct. I had the .intel_syntax directive in the source, but it surely is the same in AT&T syntax.

I am also in the task of converting a MASM source file to some linux assembler.
 
Old 07-11-2011, 09:15 AM   #5
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 490
Blog Entries: 4

Rep: Reputation: 238Reputation: 238Reputation: 238
Quote:
Originally Posted by stf92 View Post
I am also in the task of converting a MASM source file to some linux assembler.
If you have lots of code to convert, it may be worth the effort to write a C program to convert the code line by line. I don't think a shell script would answer in this case, since there are too many factors in just a single line. e.g. transposing the operands, adding byte or word indicators, converting comments, etc.

Anyway, that's how i skinned this particular cat. Still had some tinkering to do afterwards by hand, but in the end saved me lots of time.
 
Old 07-11-2011, 11:17 AM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by dogpatch View Post
...it may be worth the effort to write a C program to convert the code line by line. ...
Rather a Perl program. And probably a lot of conversions can be made writing specialized macros in the the assembly itself.
 
Old 07-11-2011, 11:39 AM   #7
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
@dogpatch: the program would have to do much less work if you feed the output to nasm instead of as. Nasm is almost compatible with MASM. Also, in as, you can turn intel syntax on with the .intel_syntax directive.
 
Old 07-11-2011, 04:14 PM   #8
dogpatch
Member
 
Registered: Nov 2005
Location: Central America
Distribution: Mepis, Android
Posts: 490
Blog Entries: 4

Rep: Reputation: 238Reputation: 238Reputation: 238
In any case, whether Perl or C, nasm or as: a batch program to do most of the conversion seems like a good investment of time.
 
Old 07-11-2011, 05:42 PM   #9
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Indeed!
 
  


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] What is the syntax of this question? raviteja_s Linux - Networking 1 10-07-2010 11:34 PM
If...then...else syntax question kaplan71 Linux - Software 8 10-14-2009 10:32 PM
question about C++ syntax bx.s Programming 3 07-27-2006 07:50 PM
C++ syntax question jiml8 Programming 6 06-20-2006 04:19 PM
Syntax question satimis Linux - Newbie 9 09-23-2004 07:47 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:08 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