Commit 2dd16b7
Changed files (4)
assignments
assignments/3/main.c
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ for (int i = 0; i < 10; i++) {
+ printf("%d\n", i);
+ }
+}
assignments/3/main.s
@@ -0,0 +1,45 @@
+ .file "main.c"
+# GNU C17 (GCC) version 14.2.1 20240912 (Red Hat 14.2.1-3) (x86_64-redhat-linux)
+# compiled by GNU C version 14.2.1 20240912 (Red Hat 14.2.1-3), GMP version 6.2.1, MPFR version 4.2.1, MPC version 1.3.1, isl version none
+# GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+# options passed: -mtune=generic -march=x86-64 -O2
+ .text
+ .section .rodata.str1.1,"aMS",@progbits,1
+.LC0:
+ .string "%d\n"
+ .section .text.startup,"ax",@progbits
+ .p2align 4
+ .globl main
+ .type main, @function
+main:
+.LFB11:
+ .cfi_startproc
+ pushq %rbx #
+ .cfi_def_cfa_offset 16
+ .cfi_offset 3, -16
+# main.c:5: for (int i = 0; i < 10; i++) {
+ xorl %ebx, %ebx # i
+ .p2align 4
+ .p2align 3
+.L2:
+# main.c:6: printf("%d\n", i);
+ movl %ebx, %esi # i,
+ movl $.LC0, %edi #,
+ xorl %eax, %eax #
+# main.c:5: for (int i = 0; i < 10; i++) {
+ addl $1, %ebx #, i
+# main.c:6: printf("%d\n", i);
+ call printf #
+# main.c:5: for (int i = 0; i < 10; i++) {
+ cmpl $10, %ebx #, i
+ jne .L2 #,
+# main.c:8: }
+ xorl %eax, %eax #
+ popq %rbx #
+ .cfi_def_cfa_offset 8
+ ret
+ .cfi_endproc
+.LFE11:
+ .size main, .-main
+ .ident "GCC: (GNU) 14.2.1 20240912 (Red Hat 14.2.1-3)"
+ .section .note.GNU-stack,"",@progbits
assignments/3/Makefile
@@ -0,0 +1,4 @@
+default: main.s
+
+main.s: main.c
+ gcc -S -fverbose-asm -O2 main.c
assignments/3-solution.md
@@ -6,6 +6,11 @@ Choose ONE exercise each from Chapters 6, 7, and 8
Chapter 6:
+13. Write a complete assembly language program (including all necessary
+pseudo-ops) that reads in a series of integers, one at a time, and outputs the
+largest and smallest values. The input will consist of a list of integer values
+
+
Chapter 7:
Chapter 8: