LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-30-2015, 09:22 PM   #1
Tailor
LQ Newbie
 
Registered: Mar 2015
Posts: 2

Rep: Reputation: Disabled
Exclamation Can't compile Assembler code on Ubuntu 14.04


I keep getting messages in terminal like: "Error: operand type mismatch for `sub' " when i compile program with " gcc -g -o prog1 prog1.S " and i doubble checked every code i tried to compile. Need some help asap

Here's one of the codes i wrote using Text Editor:

#sum of the first N numbers

.section .text
.global main
main:
movl $0, %eax
movl $10, %ecx

compare:
cmpl $0, %ecx
je end
addl %ecx, %eax
subl $1, $ecx
jmp compare
end:
movl $1, %eax
int $0x80
 
Old 03-31-2015, 12:54 AM   #2
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Quote:
subl $1, $ecx
This line is creating the error. ecx is 32 bit register. So operand should be 32 bit number.
 
1 members found this post helpful.
Old 04-04-2015, 06:10 PM   #3
Tailor
LQ Newbie
 
Registered: Mar 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
Oh maan, can't belive i missed that. I've spent 2 hours typing in terminal, i even reinstalled ubuntu thinking compiler got messed up. Thanks mate
 
  


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
how to compile java code on ubuntu linux? ameya Linux - Newbie 1 04-26-2011 06:48 AM
GAS : Assembler Code for writing to memory :Segfault Saptarshi4031 Linux - Software 4 07-20-2010 03:33 AM
NASM assembler code, why is it outputting a letter? Omelas0469 Programming 2 03-15-2007 11:37 PM
Optimizing assembler code dogpatch Programming 6 02-06-2007 08:33 PM
unhandled page fault from assembler code lordofring Programming 2 09-14-2005 02:29 PM

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

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