The following is the classical Hello world program. When I run it nothing happens. Here it is:
Code:
# ----------------------------------------------------------------------------------------
# Writes "Hello, World" to the console using only system calls. Runs on 64-bit Linux only.
# To assemble and run:
#
# gcc -c hello.s && ld hello.o && ./a.out
#
# or
#
# gcc -nostdlib hello.s && ./a.out
# ----------------------------------------------------------------------------------------
.intel_syntax noprefix
.global _start
.text
_start:
# write(1, message, 13)
mov ax,4 # system call 1 is write
mov bx,1 # file handle 1 is stdout
mov cx,message # address of string to output
mov dx,13 # number of bytes
int 0x80 # invoke operating system to do the write
# exit(0)
mov ax,1 # system call 60 is exit
xor bx,bx # we want return code 0
int 0x80 # invoke operating system to exit
message:
.ascii "Hello, world\n"
# $ gcc -c hello.s && ld hello.o && ./a.out
# Hello, World
If instead of int 0x80 I use syscall then the register usage is different but, more important, I get 'Illegal instruction' at runtime. What should I use to make a system call: int 0x80 or syscall? My intel processor is Intel Celeron N3050 which is 64-bit.