I am trying to calculate factorial of 30 using x86_64 assembly on Linux. Here's my code:
mov %RCX, 1 # counter
mov %RAX, 1 # factorial result
cmp %RCX, n
n: .byte 30
I am converting it using these two commands:
ldd file.s -o a
However when running the executable `a`, segmention fault is raised. checking with gdb it seems that it is raised right at the first instruction after `_start`. Where am I wrong?
@farooqkz it's been forever since I worked with asm. I could be totally wrong. Shouldn't the first instruction be `mov $1, %rcx`? Since it looks like you're using AT&T syntax.
QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.