So I have this Assembly program where I'm trying to output some data using a call to printf, but it wont print the whole thing that I'm trying to print.
.section .data
output:
.asciz "The processor Vendor ID is ‘%s’\n"
.section .bss
.lcomm buffer, 64
.section .text
.globl _start
_start:
pushq %rbx
movq $0, %rax
cpuid
movq $buffer, %rsi
movq $output, %rdi
mov %ebx, 28(%rdi)
mov %ecx, 32(%rdi)
#mov %edx, 35(%rdi)
movq $0, %rax
call printf
movq $60, %rax
movq $0, %rdi
popq %rbx
syscall
This version prints absolutely nothing, however; this version:
.section .data
output:
.asciz "The processor Vendor ID is ‘%s’\n"
.section .bss
.lcomm buffer, 64
.section .text
.globl _start
_start:
pushq %rbx
movq $0, %rax
cpuid
movq $buffer, %rsi
movq $output, %rdi
mov %ebx, 27(%rdi)
mov %ecx, 31(%rdi)
#mov %edx, 35(%rdi)
movq $0, %rax
call printf
movq $60, %rax
movq $0, %rdi
popq %rbx
syscall
This version prints out The processor Vendor ID is Genuntel even though the offset only changed by one. If I include the commented line, the program doesn't print anything no matter what (I am aware that the offset is wrong, in the first example, but even if it is 36 it won't print). As such, I'm curious as to how the offset affects it so that it wont print at all for the first one but it prints for the second one.
Keep in mind that this is a school assignment, but I have been trying for days now and I can't seem to get it to work.