Hello! I'm trying to swap some characters in this form, in Linux+NASM:
abc -> cab -> bca -> abc

I tried the following method

section .data
	string: db 'abc',10
	strlen:  equ $-string
section .text
	global _start
_start:
	mov ebx,1
	add ebx,string
	mov string, [ebx]

But it gives me these errors:
error: invalid combination of opcode and operands

Please help me understanding what it means and how to do it in the best way.

Hello! I'm trying to swap some characters in this form, in Linux+NASM:
abc -> cab -> bca -> abc

I tried the following method

section .data
	string: db 'abc',10
	strlen:  equ $-string
section .text
	global _start
_start:
	mov ebx,1
	add ebx,string
	mov string, [ebx]

But it gives me these errors:
error: invalid combination of opcode and operands

Please help me understanding what it means and how to do it in the best way.

mov ebx,1
	add ebx,string
	mov string, [ebx]

On the third line you're trying to copy the second character of string into the address of the first character in string. I don't think that's your actual intention though.

that code is all wrong. I have solved the problem already :

section .bss
	swap resb 3 
   %macro print 2 
      mov   eax, 4
      mov   ebx, 1
      mov   ecx, %1
      mov   edx, %2
      int   80h
   %endmacro

	%macro toswap 1 
      mov   eax, [%1]
	  mov	[swap],eax
      mov   eax, [%1+1]
	  mov	[swap+1],eax
      mov   eax, [%1+2]
	  mov	[swap+2],eax
   %endmacro

section .data
	alfa  db 'abc'
	alfalen equ $-alfa

section .text
	global _start
_start:
	mov si,3
	mov bp,1
	print alfa, alfalen
.loop:
	
	toswap alfa

	mov ah, [swap]
	mov bx, [swap+1]
	mov al, [swap+2]
	mov [alfa],al
	mov [alfa+1],ah
	mov [alfa+2],bx
	inc bp
	print alfa, alfalen

	test bp,si
	jnz .loop
	
;***EXIT***
	mov eax,1            ; (sys_exit)
	mov ebx,0            ; Exit with return code of 0 (no error)
	int 80h

Links that helped me

Linux Assembly - http://www.linuxassembly.org
NASM Manual ( available in doc/html directory of source )
Assembly Programming Journal - http://asmjournal.freeservers.com/
Mammon_'s textbase - http://www.eccentrica.org/Mammon/sprawl/textbase.html
Art Of Assembly - http://webster.cs.ucr.edu/Page_asm/ArtOfAsm.html
Sandpile - http://www.sandpile.org
comp.lang.asm.x86
NASM - http://www.cryogen.com/Nasm
Asmutils-HOWTO - doc/ directory of asmutils

http://maven.smith.edu/~thiebaut/ArtOfAssembly/artofasm.html
http://www.ibm.com/developerworks/library/l-gas-nasm.html ///very helpful
http://maven.smith.edu/~thiebaut/ArtOfAssembly/artofasm.html
http://www.laynetworks.com/assembly%20tutorials3.htm
http://www.nasm.us/

Be blessed

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.