Find the answer to your Linux question:
Results 1 to 3 of 3
I wrote this code and i dont know why only write a 1, it's in intel syntax: It assemble and link ok but, then only write 1 character: Code: section ...
  1. #1
    Just Joined!
    Join Date
    Dec 2009
    Posts
    2

    assembly nasm

    I wrote this code and i dont know why only write a 1, it's in intel syntax:
    It assemble and link ok but, then only write 1 character:

    Code:
    section .data
    
    	vacio db "0", 0ah, 0
    	activo db "1", 0ah, 0
    	numero dq 01010101b
    	
    	
    section .text
    global main
    	main:
    	
    	
    	xor rax, rax
    	xor ecx, ecx
    	mov rcx, 1
    	mov rax, 8
    	push rax
    	push rcx
    princ:
    	
    	pop rcx
    	pop rax
    	dec rax
    	cmp rax, 0
    	push rax
    	jz exit
    	
    	
    	mov rax, numero
    	and rax, rcx
    	add rcx, rcx
    	push rcx
    	cmp rax, 0
    	jz escribe0
    	jnz escribe1 
    	
    	
    	
    	escribe1:
    	
    	
    	mov rax, 4
    	mov rbx, 1
    	mov rcx, activo 
    	mov rdx, 2
    	int 0x80
    	jmp princ
    	
    	escribe0:
    	
    
    	
    	mov rax, 4
    	mov rbx, 1
    	mov rcx, vacio
    	mov rdx, 2
    	int 0x80
    	jmp princ
    	
    	exit:
    	mov rax, 1
    	int 0x80
    I would be pleased if any1 could help me

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    I'm not really comfortable with nasm style but I still have a few questions..

    Why do you do this:

    Code:
    	xor rax, rax
    	xor ecx, ecx
    	mov rcx, 1
    	mov rax, 8
    	push rax
    	push rcx
    You clear registers rax and ecx? Are you writing 32 bit or 64 bit. Plus clearing the registers rax and ecx then moving 1 and 8 to them is redundant and then pushing rax and rcx is again redundant. Just push 1 and 8 onto the stack..

    And what is the role of

    Code:
    numero dq 01010101b
    I can't see any reason for this variable...I guess what I'm getting at is, what's the logic of your program? What does it do?
    Make mine Arch Linux

  3. #3
    Just Joined!
    Join Date
    Dec 2009
    Posts
    2
    Sorry the code works perfectly, the problem was i was running other app XDDDDDDDDDDDDDDDDD
    TY for the answers so

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...