Linux Assembler

This is a discussion on Linux Assembler within the Linux Programming forums, part of the Platform Specific Boards category; I'm following a tutorial @ http://www.geocities.com/SiliconVall.../linux-asm.txt however, the second program (command line arguments) example apparently has an error in it. ...

  1. #1
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361

    Linux Assembler

    I'm following a tutorial @ http://www.geocities.com/SiliconVall.../linux-asm.txt
    however, the second program (command line arguments) example apparently has an error in it.

    The line is:
    Code:
    movb (%ecx,%edx,$1), %al
    Does anyone see anything wrong with that? It's the line `as' flags as having an error.

    The entire program:
    Code:
    ########################################################################
    	.section .data
    
    new_line_char:
    	.byte 0x0a
    ########################################################################
    	.section .text
    
    	.globl _start
    
    	.align 4
    _start:
    	movl %esp, %ebp		# store %esp in %ebp
    again:
    	addl $4, %esp		# %esp ---> next parameter on stack
    	movl (%esp), %eax	# move next parameter into %eax
    	testl %eax, %eax	# %eax (parameter) == NULL pointer?
    	jz end_again		# get out of loop if yes
    	call putstring		# output parameter to stdout.
    	jmp again		# repeat loop
    end_again:
    	xorl %eax, %eax		# %eax = 0
    	incl %eax		# %eax = 1, system call _exit ()
    	xorl %ebx, %ebx		# %ebx = 0, normal program exit.
    	int $0x80		# execute _exit () system call
    
    putstring:	.type @function
    	pushl %ebp
    	movl %esp, %ebp
    	movl 8(%ebp), %ecx
    	xorl %edx, %edx
    count_chars:
    	movb (%ecx,%edx,$1), %al
    	testb %al, %al
    	jz done_count_chars
    	incl %edx
    	jmp count_chars
    done_count_chars:
    	movl $4, %eax
    	xorl %ebx, %ebx
    	incl %ebx
    	int $0x80
    	movl $4, %eax
    	leal new_line_char, %ecx
    	xorl %edx, %edx
    	incl %edx
    	int $0x80
    	movl %ebp, %esp
    	popl %ebp
    	ret
    Any help on this would be greatly appreciated.

  2. #2
    Registered User zahid's Avatar
    Join Date
    Aug 2001
    Posts
    532
    Getting interest on asm in Linux. ..
    zero knowledge to help you. I guess you will find one to help you.

    Now tell tell me, how did you start asm...

    Give me some online sources. First how to compile code. Then if any tutorial.. I have visited the above url already.
    [ Never code before desk work ]
    -------------------------------------:-->
    A man who fears Nothing is the man who Loves Nothing
    If you Love Nothing, what joy is there in your life.
    =------------------------------------------------------= - I may be wrong.

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Have you tried here
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    What is the error? This shoudl be a valid AT&T ASM Syntax line. Although I have not done much ASM in awhile.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thinking of upgrading to linux...
    By Yarin in forum General Discussions
    Replies: 37
    Last Post: 07-24-2009, 12:40 PM
  2. Wireless Network Linux & C Testbed
    By james457 in forum Networking/Device Communication
    Replies: 3
    Last Post: 06-11-2009, 12:03 PM
  3. Dabbling with Linux.
    By Hunter2 in forum Tech Board
    Replies: 21
    Last Post: 04-21-2005, 05:17 PM
  4. installing linux for the first time
    By Micko in forum Tech Board
    Replies: 9
    Last Post: 12-06-2004, 05:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21