Unconfigured Ad Widget

Collapse

Anúncio

Collapse
No announcement yet.

Recursividade em Assembley

Collapse
X
 
  • Filter
  • Tempo
  • Show
Clear All
new posts

  • Font Size
    #1

    Recursividade em Assembley

    Boas, estou a fazer um trabalho em assembley.
    onde tenho que inverter esta string usando recursividade:

    trabid: .string "Rio de Janeiro"


    main:
    .
    ...
    ...

    rec: # funçao recursiva que me irá inverter a string!

    ps: Ja tenho uma funçao que faz print da string, etc...
    objectivo: aparecer no output "orienaj ed ior"


    alguem me pode ajudar?
    obrigado

  • Font Size
    #2
    code.asm:
    Código:
    	SECTION .data		
    msg:	db "Rio de Janeiro"	
    len:	equ $-msg		
    			
    
    	SECTION .text		
            global main		 
    main:				
    	mov 	ecx, msg
    	add 	ecx, len
    
    	call 	print
    
    saida:	
    	mov	ebx,0		
    	mov	eax,1		
    	int	0x80		
    
    print:
    	mov 	edx, 1        
            mov     ebx,1           
            mov     eax,4           
    	push 	ecx
            int     0x80            
    	pop 	ecx
    	cmp 	ecx, msg
    	jne 	pula
    	ret
    pula:	dec	ecx
    	call 	print
    	ret
    para compilar e executar:
    Código:
    @linux-1jhe:~> nasm -f elf -l code.lst  code.asm
    @linux-1jhe:~> gcc -o code  code.o
    @linux-1jhe:~> ./code 
    orienaJ ed oiR
    print é a função recursiva

    Comment


    • Font Size
      #3
      cheira-me a trabalho de arquitectura de computadores do ISCTE.

      Am i right ?

      Comment

      X
      Working...
      X