I'm on an Ubuntu 22.04 x86_64 system, kernel 6.5.0-15-generic. I'm learning how to make simple programs that make system calls by using GAS AT&T assembly format. My goal was to create a simple classic main program in assembly that makes the write system call to write "Hello World". I have two assembly programs named hello1.s and hello2.s and the only difference between the two is the "q" suffix in some instructions which is absent in the former but it is included in the latter.
Are these two assembly programs the same ? I mean am I gonna get the same and correct result when doing :
"as hello1.s -o hello1.o"
"gcc hello1.o -o hello1"
and
"as hello2.s -o hello2.o"
"gcc hello2.o -o hello2"
?
Here are the programs :
hello1.s
.section .rodata
msg: .ascii "Hello, World!\n"
.set msglen, (. - msg)
.section .text
.global main
main:
mov $1, %rax
mov $1, %rdi
lea msg(%rip), %rsi
mov $msglen, %rdx
syscall
mov $60, %rax
mov $0, %rdi
syscall
hello2.s
.section .rodata
msg: .ascii "Hello, World!\n"
.set msglen, (. - msg)
.section .text
.global main
main:
movq $1, %rax
movq $1, %rdi
leaq msg(%rip), %rsi
movq $msglen, %rdx
syscall
movq $60, %rax
movq $0, %rdi
syscall