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 input_num, 2
.section .data
format: .string "x=%d : f(x)=%d or 0x%x
\0"
.section .text
.global _start
main:
#Read two charcter from stdin
movq $0,%rax #syscall number
movq $0,%rdi #stdin
movq $input_num, %rsi #buffer to store input
movq $2,%rdx #number of bytes to read
syscall
#Convert ASCII digits to interger
movzbl input_num, %eax
sub $'0',%eax
imul $10,%eax, %eax
movzbl input_num+1,%ebx
sub $'0',%ebx
add %ebx, %eax
#Store integer in %ebx
movq %eax, %ebx
#27x +17
imul $27,%eax, %eax
add $17,%eax
#Prepare for printf
movq %ebx, %edi #first argument - x
movq %eax, %esi #second arugment - f(x)
movq %eax, %edx #third argument - f(x) in hex
lea format, %rdi #format string
#Call printf
movq $0,%rax #syscall for sys_write
call printf
#Exit
movq $60,%rax #syscall for sys_exit
movq $0,%rdi #status =0
syscall

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!