Author Topic: linux x64 sys_read problem  (Read 11475 times)

Offline nullptr

  • Jr. Member
  • *
  • Posts: 27
linux x64 sys_read problem
« on: May 03, 2013, 09:42:53 PM »
Hi folks, i'm beginner in asm.
probably someone had this same problem, but i can't find the right post and hard to any tutorials for linux x64 assembly.

What i'm doing wrong? I've written simple terminal program that asks user to enter his name and then welcomes him by his name. The program only displays only question string and hi string, but not input.

Code: [Select]
[BITS 64]

SECTION .TEXT
global _start

_start:
mov rax, 1
mov rdi, 1
mov rsi, tTxt
mov rdx, LEN_TTXT
syscall

xor rax, rax
xor   rdi, rdi
mov rsi, buff_Name
mov rdx, LEN_BNAME
syscall

mov rax, 1
mov rdi, 1
mov rsi, tHi
mov rdx, LEN_THI
syscall

mov rax, 1
mov rdi, 1
mov rsi, buff_Name
mov rdx, LEN_BNAME
syscall

xor rdi, rdi
mov rax, 60
syscall
SECTION .DATA
tTxt:         db "What is your name? "
LEN_TTXT: equ $ - tTxt
buff_Name: times 20 db 0
LEN_BNAME: equ $ - buff_Name
tHi         db "Hi "
LEN_THI:         equ $ - tHi


SECTION .BSS

thanks in advance.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: linux x64 sys_read problem
« Reply #1 on: May 03, 2013, 10:41:49 PM »
I'm not very familiar with 64-bit coding, and can't test it for ya. Your code "looks" right to me. The only thing that looks like a potential problem is that section names are case sensitive. ".TEXT" probably isn't a problem, but ".DATA" might be making your section readonly. Try lowercase ".text" and ".data" and see it that helps...

Best,
Frank


Offline nullptr

  • Jr. Member
  • *
  • Posts: 27
Re: linux x64 sys_read problem
« Reply #2 on: May 04, 2013, 08:10:58 AM »
You're right Frank. Now it works as it should, thanks