Question: Why won't this code assemble ( AT&T syntax ) : . section . bss . lcomm input _ num, 2 . section . data format:
Why won't this code assemble AT&T syntax:
section bss
lcomm inputnum,
section data
format: string xd : fxd or xx
section text
global start
main:
#Read two charcter from stdin
movq $rax #syscall number
movq $rdi #stdin
movq $inputnum, rsi #buffer to store input
movq $rdx #number of bytes to read
syscall
#Convert ASCII digits to interger
movzbl inputnum, eax
sub $eax
imul $eax, eax
movzbl inputnumebx
sub $ebx
add ebx, eax
#Store integer in ebx
movq eax, ebx
#x
imul $eax, eax
add $eax
#Prepare for printf
movq ebx, edi #first argument x
movq eax, esi #second arugment fx
movq eax, edx #third argument fx in hex
lea format, rdi #format string
#Call printf
movq $rax #syscall for syswrite
call printf
#Exit
movq $rax #syscall for sysexit
movq $rdi #status
syscall
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
