For each of the following four assembly programs, explain what they compute and why. Suggest changes to make them more sensible. This homework is due next Friday. Each problem is 5 points. Submission instructions will be emailed later---look out for an email from Rishav. The idea of these exercises is to understand exactly what the instructions do. You can build and run these programs, use GDB or another debugger, or any other approach you like. No matter what you do, you have to explain the result. A note on AIs: We fed these to perplexity.ai in a single shot per program, and it had them all wrong. Extra points for some generic (not problem-specific) prompt that would make perplexity get them right. ===[ 1. Hello hello! .file "p1.c" .text .section .rodata .LC0: .string "Hello" .text .globl main .type main, @function main: pushq %rbp movq %rsp, %rbp subq $16, %rsp movl $10, -4(%rbp) .L2: subl $1, -4(%rbp) leaq .LC0(%rip), %rax movq %rax, %rdi call puts@PLT jns .L2 ===[ 2. Interacting with integers. .file "p2.c" .text .section .rodata .LC0: .string "%x\n" .text .globl main .type main, @function main: pushq %rbp movq %rsp, %rbp subq $16, %rsp movl $65535, -6(%rbp) movl $43690, -4(%rbp) movl -6(%rbp), %eax leaq .LC0(%rip), %rdx movl %eax, %esi movq %rdx, %rdi movl $0, %eax call printf@PLT movl $0, %eax leave ret ===[ 3. I can has alignment? .file "p3.c" .text .section .rodata .LC1: .word 65 .text .globl main .type main, @function main: pushq %rbp movq %rsp, %rbp subq $16, %rsp movq $0, %rcx .L1: jmp .L3 .L2: pushq %rcx movq %rbp, %rax subq $16, %rax movq %rax, %rdi call puts@PLT leave ret .L3: pushq %rax movq $1, %rax addq %rax, %rcx popq %rax cmpq .LC1(%rip), %rcx je .L2 jmp .L1 ===[ 4. I can has strings? .file "p4.c" .text .section .rodata .LC0: .string "Uh oh!\n" .string ":)\n" .text .globl main .type main, @function L1: push %rax leaq .LC0(%rip), %rcx addq $7, %rcx ret main: pushq %rbp movq %rsp, %rbp subq $16, %rsp leaq .LCO(%rip), %rax call L1 movq %rcx, %rax movq %rax, %rdi call puts@PLT leave ret .LCO: leaq .LC0(%rip), %rax movq %rax, %rdi call puts@PLT leave ret