From 8cf7bf49195c5054bf5cc32c6c2b3d9efb699903 Mon Sep 17 00:00:00 2001 From: "Hazal2.Veziroglu@live.uwe.ac.uk" <hazal2.veziroglu@live.uwe.ac.uk> Date: Wed, 4 Dec 2024 00:43:27 +0000 Subject: [PATCH] Update 165 files - /worksheet_1/src/asm_io.asm - /worksheet_1/src/asm_io.inc - /worksheet_1/src/asm_io.o - /worksheet_1/src/driver.c - /worksheet_1/src/driver.o - /worksheet_1/src/task1.asm - /worksheet_1/src/task1.o - /worksheet_1/src/task2.asm - /worksheet_1/src/task3.asm - /worksheet_1/src/task4.asm - /worksheet_1/README.md - /worksheet_1/makefile - /worksheet2_1/Makefile - /worksheet2_1/README.md - /worksheet2_1/iso/boot/grub/menu.lst - /worksheet2_1/iso/boot/grub/stage2_eltorito - /worksheet2_1/loader.asm - /worksheet2_1/loader.o - /worksheet2_1/source/link.ld - /worksheet_0/foo.txt - /worksheet_0/task1_pointer - /worksheet_0/task1_pointer.c - /worksheet_0/task1_pointer.dSYM/Contents/Info.plist - /worksheet_0/task1_pointer.dSYM/Contents/Resources/DWARF/task1_pointer - /worksheet_0/task1_pointer.dSYM/Contents/Resources/Relocations/x86_64/task1_pointer.yml - /worksheet_0/task2_array_pointer - /worksheet_0/task2_array_pointer.c - /worksheet_0/task2_array_pointer.dSYM/Contents/Info.plist - /worksheet_0/task2_array_pointer.dSYM/Contents/Resources/DWARF/task2_array_pointer - /worksheet_0/task2_array_pointer.dSYM/Contents/Resources/Relocations/x86_64/task2_array_pointer.yml - /worksheet_0/task3_array_compare - /worksheet_0/task3_array_compare.c - /worksheet_0/task3_array_compare.dSYM/Contents/Info.plist - /worksheet_0/task3_array_compare.dSYM/Contents/Resources/DWARF/task3_array_compare - /worksheet_0/task3_array_compare.dSYM/Contents/Resources/Relocations/x86_64/task3_array_compare.yml - /worksheet_0/task4_file_sum - /worksheet_0/task4_file_sum.c - /worksheet_0/task4_file_sum.dSYM/Contents/Info.plist - /worksheet_0/task4_file_sum.dSYM/Contents/Resources/DWARF/task4_file_sum - /worksheet_0/task4_file_sum.dSYM/Contents/Resources/Relocations/x86_64/task4_file_sum.yml - /worksheet_0/task5_swap_function - /worksheet_0/task5_swap_function.c - /worksheet_0/task5_swap_function.dSYM/Contents/Info.plist - /worksheet_0/task5_swap_function.dSYM/Contents/Resources/DWARF/task5_swap_function - /worksheet_0/task5_swap_function.dSYM/Contents/Resources/Relocations/x86_64/task5_swap_function.yml - /worksheet_0/task6_print_2d_array - /worksheet_0/task6_print_2d_array.c - /worksheet_0/task6_print_2d_array.dSYM/Contents/Info.plist - /worksheet_0/task6_print_2d_array.dSYM/Contents/Resources/DWARF/task6_print_2d_array - /worksheet_0/task6_print_2d_array.dSYM/Contents/Resources/Relocations/x86_64/task6_print_2d_array.yml - /worksheet_0/task7_tic_tac_toe - /worksheet_0/task7_tic_tac_toe.c - /worksheet_0/task7_tic_tac_toe.dSYM/Contents/Info.plist - /worksheet_0/task7_tic_tac_toe.dSYM/Contents/Resources/DWARF/task7_tic_tac_toe - /worksheet_0/task7_tic_tac_toe.dSYM/Contents/Resources/Relocations/x86_64/task7_tic_tac_toe.yml - /worksheet2_2/Makefile - /worksheet2_2/frame_buffer.c - /worksheet2_2/frame_buffer.h - /worksheet2_2/hardware_interrupt_enabler.s - /worksheet2_2/interrupt_asm.o - /worksheet2_2/interrupt_asm.s - /worksheet2_2/interrupt_handlers.o - /worksheet2_2/interrupt_handlers.s - /worksheet2_2/interrupts.c - /worksheet2_2/interrupts.h - /worksheet2_2/interrupts.o - /worksheet2_2/io.h - /worksheet2_2/io.o - /worksheet2_2/io.s - /worksheet2_2/keyboard.c - /worksheet2_2/keyboard.h - /worksheet2_2/keyboard.o - /worksheet2_2/kmain.c - /worksheet2_2/kmain.o - /worksheet2_2/loader.s - /worksheet2_2/pic.c - /worksheet2_2/pic.h - /worksheet2_2/pic.o - /worksheet2_2/types.h - /Worksheet_1/Dockerfile - /Worksheet_1/Makefile - /Worksheet_1/README.md - /Worksheet_1/src/task2.asm - /Worksheet_1/src/task2.o - /Worksheet_1/src/task3.asm - /Worksheet_1/src/task1.asm - /Worksheet_1/src/task1 - /Worksheet_1/src/task1.o - /Worksheet_1/src/driver.o - /Worksheet_1/src/print_int.o - /Worksheet_1/src/task3 - /Worksheet_1/src/task2 - /Worksheet_1/src/asm_io.o - /Worksheet_1/src/task3.o - /Worksheet_1/src/asm_io.inc - /Worksheet_1/src/asm_io.asm - /Worksheet_1/src/print_int.c - /Worksheet_1/src/driver.c - /Worksheet2_1/iso/boot/grub/stage2_eltorito - /Worksheet2_1/iso/boot/grub/menu.lst - /Worksheet2_1/source/link.ld - /Worksheet2_1/README.md - /Worksheet2_1/loader.o - /Worksheet2_1/loader.asm - /Worksheet2_1/Makefile - /Worksheet_0/task1_pointer.dSYM/Contents/Resources/DWARF/task1_pointer - /Worksheet_0/task1_pointer.dSYM/Contents/Resources/Relocations/x86_64/task1_pointer.yml - /Worksheet_0/task1_pointer.dSYM/Contents/Info.plist - /Worksheet_0/task2_array_pointer.dSYM/Contents/Resources/DWARF/task2_array_pointer - /Worksheet_0/task2_array_pointer.dSYM/Contents/Resources/Relocations/x86_64/task2_array_pointer.yml - /Worksheet_0/task2_array_pointer.dSYM/Contents/Info.plist - /Worksheet_0/task3_array_compare.dSYM/Contents/Resources/DWARF/task3_array_compare - /Worksheet_0/task3_array_compare.dSYM/Contents/Resources/Relocations/x86_64/task3_array_compare.yml - /Worksheet_0/task3_array_compare.dSYM/Contents/Info.plist - /Worksheet_0/task4_file_sum.dSYM/Contents/Resources/DWARF/task4_file_sum - /Worksheet_0/task4_file_sum.dSYM/Contents/Resources/Relocations/x86_64/task4_file_sum.yml - /Worksheet_0/task4_file_sum.dSYM/Contents/Info.plist - /Worksheet_0/task5_swap_function.dSYM/Contents/Resources/DWARF/task5_swap_function - /Worksheet_0/task5_swap_function.dSYM/Contents/Resources/Relocations/x86_64/task5_swap_function.yml - /Worksheet_0/task5_swap_function.dSYM/Contents/Info.plist - /Worksheet_0/task6_print_2d_array.dSYM/Contents/Resources/DWARF/task6_print_2d_array - /Worksheet_0/task6_print_2d_array.dSYM/Contents/Resources/Relocations/x86_64/task6_print_2d_array.yml - /Worksheet_0/task6_print_2d_array.dSYM/Contents/Info.plist - /Worksheet_0/task7_tic_tac_toe.dSYM/Contents/Resources/DWARF/task7_tic_tac_toe - /Worksheet_0/task7_tic_tac_toe.dSYM/Contents/Resources/Relocations/x86_64/task7_tic_tac_toe.yml - /Worksheet_0/task7_tic_tac_toe.dSYM/Contents/Info.plist - /Worksheet_0/task2_array_pointer.c - /Worksheet_0/task1_pointer - /Worksheet_0/task4_file_sum.c - /Worksheet_0/foo.txt - /Worksheet_0/task3_array_compare.c - /Worksheet_0/task1_pointer.c - /Worksheet_0/task7_tic_tac_toe - /Worksheet_0/task2_array_pointer - /Worksheet_0/task3_array_compare - /Worksheet_0/task5_swap_function - /Worksheet_0/task6_print_2d_array.c - /Worksheet_0/task6_print_2d_array - /Worksheet_0/task7_tic_tac_toe.c - /Worksheet_0/task5_swap_function.c - /Worksheet_0/task4_file_sum - /Worksheet2_2/hardware_interrupt_enabler.s - /Worksheet2_2/frame_buffer.c - /Worksheet2_2/keyboard.h - /Worksheet2_2/frame_buffer.h - /Worksheet2_2/interrupt_asm.o - /Worksheet2_2/io.o - /Worksheet2_2/interrupt_asm.s - /Worksheet2_2/Makefile - /Worksheet2_2/io.s - /Worksheet2_2/interrupt_handlers.s - /Worksheet2_2/loader.s - /Worksheet2_2/keyboard.c - /Worksheet2_2/keyboard.o - /Worksheet2_2/interrupts.c - /Worksheet2_2/interrupts.h - /Worksheet2_2/interrupts.o - /Worksheet2_2/kmain.o - /Worksheet2_2/kmain.c - /Worksheet2_2/pic.h - /Worksheet2_2/io.h - /Worksheet2_2/pic.o - /Worksheet2_2/pic.c - /Worksheet2_2/types.h - /Worksheet2_2/interrupt_handlers.o --- {worksheet2_1 => Worksheet2_1}/Makefile | 0 {worksheet2_1 => Worksheet2_1}/README.md | 0 .../iso/boot/grub/menu.lst | 0 .../iso/boot/grub/stage2_eltorito | 0 {worksheet2_1 => Worksheet2_1}/loader.asm | 0 {worksheet2_1 => Worksheet2_1}/loader.o | Bin {worksheet2_1 => Worksheet2_1}/source/link.ld | 0 {worksheet2_2 => Worksheet2_2}/Makefile | 0 {worksheet2_2 => Worksheet2_2}/frame_buffer.c | 0 {worksheet2_2 => Worksheet2_2}/frame_buffer.h | 0 .../hardware_interrupt_enabler.s | 0 .../interrupt_asm.o | Bin .../interrupt_asm.s | 0 .../interrupt_handlers.o | Bin .../interrupt_handlers.s | 0 {worksheet2_2 => Worksheet2_2}/interrupts.c | 0 {worksheet2_2 => Worksheet2_2}/interrupts.h | 0 {worksheet2_2 => Worksheet2_2}/interrupts.o | Bin {worksheet2_2 => Worksheet2_2}/io.h | 0 {worksheet2_2 => Worksheet2_2}/io.o | Bin {worksheet2_2 => Worksheet2_2}/io.s | 0 {worksheet2_2 => Worksheet2_2}/keyboard.c | 0 {worksheet2_2 => Worksheet2_2}/keyboard.h | 0 {worksheet2_2 => Worksheet2_2}/keyboard.o | Bin {worksheet2_2 => Worksheet2_2}/kmain.c | 0 {worksheet2_2 => Worksheet2_2}/kmain.o | Bin {worksheet2_2 => Worksheet2_2}/loader.s | 0 {worksheet2_2 => Worksheet2_2}/pic.c | 0 {worksheet2_2 => Worksheet2_2}/pic.h | 0 {worksheet2_2 => Worksheet2_2}/pic.o | Bin {worksheet2_2 => Worksheet2_2}/types.h | 0 {worksheet_0 => Worksheet_0}/foo.txt | 0 {worksheet_0 => Worksheet_0}/task1_pointer | Bin {worksheet_0 => Worksheet_0}/task1_pointer.c | 0 .../task1_pointer.dSYM/Contents/Info.plist | 0 .../Contents/Resources/DWARF/task1_pointer | Bin .../Relocations/x86_64/task1_pointer.yml | 0 .../task2_array_pointer | Bin .../task2_array_pointer.c | 0 .../Contents/Info.plist | 0 .../Resources/DWARF/task2_array_pointer | Bin .../x86_64/task2_array_pointer.yml | 0 .../task3_array_compare | Bin .../task3_array_compare.c | 0 .../Contents/Info.plist | 0 .../Resources/DWARF/task3_array_compare | Bin .../x86_64/task3_array_compare.yml | 0 {worksheet_0 => Worksheet_0}/task4_file_sum | Bin {worksheet_0 => Worksheet_0}/task4_file_sum.c | 0 .../task4_file_sum.dSYM/Contents/Info.plist | 0 .../Contents/Resources/DWARF/task4_file_sum | Bin .../Relocations/x86_64/task4_file_sum.yml | 0 .../task5_swap_function | Bin .../task5_swap_function.c | 0 .../Contents/Info.plist | 0 .../Resources/DWARF/task5_swap_function | Bin .../x86_64/task5_swap_function.yml | 0 .../task6_print_2d_array | Bin .../task6_print_2d_array.c | 0 .../Contents/Info.plist | 0 .../Resources/DWARF/task6_print_2d_array | Bin .../x86_64/task6_print_2d_array.yml | 0 .../task7_tic_tac_toe | Bin .../task7_tic_tac_toe.c | 0 .../Contents/Info.plist | 0 .../Resources/DWARF/task7_tic_tac_toe | Bin .../Relocations/x86_64/task7_tic_tac_toe.yml | 0 Worksheet_1/Dockerfile | 17 + Worksheet_1/Makefile | 31 ++ Worksheet_1/README.md | 84 +++ Worksheet_1/src/asm_io.asm | 502 ++++++++++++++++++ {worksheet_1 => Worksheet_1}/src/asm_io.inc | 0 Worksheet_1/src/asm_io.o | Bin 0 -> 3648 bytes Worksheet_1/src/driver.c | 8 + Worksheet_1/src/driver.o | Bin 0 -> 1128 bytes Worksheet_1/src/print_int.c | 5 + Worksheet_1/src/print_int.o | Bin 0 -> 1236 bytes Worksheet_1/src/task1 | Bin 0 -> 15208 bytes Worksheet_1/src/task1.asm | 23 + Worksheet_1/src/task1.o | Bin 0 -> 768 bytes Worksheet_1/src/task2 | Bin 0 -> 17824 bytes Worksheet_1/src/task2.asm | 132 +++++ Worksheet_1/src/task2.o | Bin 0 -> 2160 bytes Worksheet_1/src/task3 | Bin 0 -> 17532 bytes Worksheet_1/src/task3.asm | 98 ++++ Worksheet_1/src/task3.o | Bin 0 -> 1728 bytes worksheet_1/README.md | 9 - worksheet_1/makefile | 27 - worksheet_1/src/asm_io.asm | 26 - worksheet_1/src/asm_io.o | Bin 304 -> 0 bytes worksheet_1/src/driver.c | 7 - worksheet_1/src/driver.o | Bin 664 -> 0 bytes worksheet_1/src/task1.asm | 17 - worksheet_1/src/task1.o | Bin 704 -> 0 bytes worksheet_1/src/task2.asm | 53 -- worksheet_1/src/task3.asm | 35 -- worksheet_1/src/task4.asm | 78 --- 97 files changed, 900 insertions(+), 252 deletions(-) rename {worksheet2_1 => Worksheet2_1}/Makefile (100%) rename {worksheet2_1 => Worksheet2_1}/README.md (100%) rename {worksheet2_1 => Worksheet2_1}/iso/boot/grub/menu.lst (100%) rename {worksheet2_1 => Worksheet2_1}/iso/boot/grub/stage2_eltorito (100%) rename {worksheet2_1 => Worksheet2_1}/loader.asm (100%) rename {worksheet2_1 => Worksheet2_1}/loader.o (100%) rename {worksheet2_1 => Worksheet2_1}/source/link.ld (100%) rename {worksheet2_2 => Worksheet2_2}/Makefile (100%) rename {worksheet2_2 => Worksheet2_2}/frame_buffer.c (100%) rename {worksheet2_2 => Worksheet2_2}/frame_buffer.h (100%) rename {worksheet2_2 => Worksheet2_2}/hardware_interrupt_enabler.s (100%) rename {worksheet2_2 => Worksheet2_2}/interrupt_asm.o (100%) rename {worksheet2_2 => Worksheet2_2}/interrupt_asm.s (100%) rename {worksheet2_2 => Worksheet2_2}/interrupt_handlers.o (100%) rename {worksheet2_2 => Worksheet2_2}/interrupt_handlers.s (100%) rename {worksheet2_2 => Worksheet2_2}/interrupts.c (100%) rename {worksheet2_2 => Worksheet2_2}/interrupts.h (100%) rename {worksheet2_2 => Worksheet2_2}/interrupts.o (100%) rename {worksheet2_2 => Worksheet2_2}/io.h (100%) rename {worksheet2_2 => Worksheet2_2}/io.o (100%) rename {worksheet2_2 => Worksheet2_2}/io.s (100%) rename {worksheet2_2 => Worksheet2_2}/keyboard.c (100%) rename {worksheet2_2 => Worksheet2_2}/keyboard.h (100%) rename {worksheet2_2 => Worksheet2_2}/keyboard.o (100%) rename {worksheet2_2 => Worksheet2_2}/kmain.c (100%) rename {worksheet2_2 => Worksheet2_2}/kmain.o (100%) rename {worksheet2_2 => Worksheet2_2}/loader.s (100%) rename {worksheet2_2 => Worksheet2_2}/pic.c (100%) rename {worksheet2_2 => Worksheet2_2}/pic.h (100%) rename {worksheet2_2 => Worksheet2_2}/pic.o (100%) rename {worksheet2_2 => Worksheet2_2}/types.h (100%) rename {worksheet_0 => Worksheet_0}/foo.txt (100%) rename {worksheet_0 => Worksheet_0}/task1_pointer (100%) rename {worksheet_0 => Worksheet_0}/task1_pointer.c (100%) rename {worksheet_0 => Worksheet_0}/task1_pointer.dSYM/Contents/Info.plist (100%) rename {worksheet_0 => Worksheet_0}/task1_pointer.dSYM/Contents/Resources/DWARF/task1_pointer (100%) rename {worksheet_0 => Worksheet_0}/task1_pointer.dSYM/Contents/Resources/Relocations/x86_64/task1_pointer.yml (100%) rename {worksheet_0 => Worksheet_0}/task2_array_pointer (100%) rename {worksheet_0 => Worksheet_0}/task2_array_pointer.c (100%) rename {worksheet_0 => Worksheet_0}/task2_array_pointer.dSYM/Contents/Info.plist (100%) rename {worksheet_0 => Worksheet_0}/task2_array_pointer.dSYM/Contents/Resources/DWARF/task2_array_pointer (100%) rename {worksheet_0 => Worksheet_0}/task2_array_pointer.dSYM/Contents/Resources/Relocations/x86_64/task2_array_pointer.yml (100%) rename {worksheet_0 => Worksheet_0}/task3_array_compare (100%) rename {worksheet_0 => Worksheet_0}/task3_array_compare.c (100%) rename {worksheet_0 => Worksheet_0}/task3_array_compare.dSYM/Contents/Info.plist (100%) rename {worksheet_0 => Worksheet_0}/task3_array_compare.dSYM/Contents/Resources/DWARF/task3_array_compare (100%) rename {worksheet_0 => Worksheet_0}/task3_array_compare.dSYM/Contents/Resources/Relocations/x86_64/task3_array_compare.yml (100%) rename {worksheet_0 => Worksheet_0}/task4_file_sum (100%) rename {worksheet_0 => Worksheet_0}/task4_file_sum.c (100%) rename {worksheet_0 => Worksheet_0}/task4_file_sum.dSYM/Contents/Info.plist (100%) rename {worksheet_0 => Worksheet_0}/task4_file_sum.dSYM/Contents/Resources/DWARF/task4_file_sum (100%) rename {worksheet_0 => Worksheet_0}/task4_file_sum.dSYM/Contents/Resources/Relocations/x86_64/task4_file_sum.yml (100%) rename {worksheet_0 => Worksheet_0}/task5_swap_function (100%) rename {worksheet_0 => Worksheet_0}/task5_swap_function.c (100%) rename {worksheet_0 => Worksheet_0}/task5_swap_function.dSYM/Contents/Info.plist (100%) rename {worksheet_0 => Worksheet_0}/task5_swap_function.dSYM/Contents/Resources/DWARF/task5_swap_function (100%) rename {worksheet_0 => Worksheet_0}/task5_swap_function.dSYM/Contents/Resources/Relocations/x86_64/task5_swap_function.yml (100%) rename {worksheet_0 => Worksheet_0}/task6_print_2d_array (100%) rename {worksheet_0 => Worksheet_0}/task6_print_2d_array.c (100%) rename {worksheet_0 => Worksheet_0}/task6_print_2d_array.dSYM/Contents/Info.plist (100%) rename {worksheet_0 => Worksheet_0}/task6_print_2d_array.dSYM/Contents/Resources/DWARF/task6_print_2d_array (100%) rename {worksheet_0 => Worksheet_0}/task6_print_2d_array.dSYM/Contents/Resources/Relocations/x86_64/task6_print_2d_array.yml (100%) rename {worksheet_0 => Worksheet_0}/task7_tic_tac_toe (100%) rename {worksheet_0 => Worksheet_0}/task7_tic_tac_toe.c (100%) rename {worksheet_0 => Worksheet_0}/task7_tic_tac_toe.dSYM/Contents/Info.plist (100%) rename {worksheet_0 => Worksheet_0}/task7_tic_tac_toe.dSYM/Contents/Resources/DWARF/task7_tic_tac_toe (100%) rename {worksheet_0 => Worksheet_0}/task7_tic_tac_toe.dSYM/Contents/Resources/Relocations/x86_64/task7_tic_tac_toe.yml (100%) create mode 100644 Worksheet_1/Dockerfile create mode 100644 Worksheet_1/Makefile create mode 100644 Worksheet_1/README.md create mode 100644 Worksheet_1/src/asm_io.asm rename {worksheet_1 => Worksheet_1}/src/asm_io.inc (100%) create mode 100644 Worksheet_1/src/asm_io.o create mode 100644 Worksheet_1/src/driver.c create mode 100644 Worksheet_1/src/driver.o create mode 100644 Worksheet_1/src/print_int.c create mode 100644 Worksheet_1/src/print_int.o create mode 100644 Worksheet_1/src/task1 create mode 100644 Worksheet_1/src/task1.asm create mode 100644 Worksheet_1/src/task1.o create mode 100644 Worksheet_1/src/task2 create mode 100644 Worksheet_1/src/task2.asm create mode 100644 Worksheet_1/src/task2.o create mode 100644 Worksheet_1/src/task3 create mode 100644 Worksheet_1/src/task3.asm create mode 100644 Worksheet_1/src/task3.o delete mode 100644 worksheet_1/README.md delete mode 100644 worksheet_1/makefile delete mode 100644 worksheet_1/src/asm_io.asm delete mode 100644 worksheet_1/src/asm_io.o delete mode 100644 worksheet_1/src/driver.c delete mode 100644 worksheet_1/src/driver.o delete mode 100644 worksheet_1/src/task1.asm delete mode 100644 worksheet_1/src/task1.o delete mode 100644 worksheet_1/src/task2.asm delete mode 100644 worksheet_1/src/task3.asm delete mode 100644 worksheet_1/src/task4.asm diff --git a/worksheet2_1/Makefile b/Worksheet2_1/Makefile similarity index 100% rename from worksheet2_1/Makefile rename to Worksheet2_1/Makefile diff --git a/worksheet2_1/README.md b/Worksheet2_1/README.md similarity index 100% rename from worksheet2_1/README.md rename to Worksheet2_1/README.md diff --git a/worksheet2_1/iso/boot/grub/menu.lst b/Worksheet2_1/iso/boot/grub/menu.lst similarity index 100% rename from worksheet2_1/iso/boot/grub/menu.lst rename to Worksheet2_1/iso/boot/grub/menu.lst diff --git a/worksheet2_1/iso/boot/grub/stage2_eltorito b/Worksheet2_1/iso/boot/grub/stage2_eltorito similarity index 100% rename from worksheet2_1/iso/boot/grub/stage2_eltorito rename to Worksheet2_1/iso/boot/grub/stage2_eltorito diff --git a/worksheet2_1/loader.asm b/Worksheet2_1/loader.asm similarity index 100% rename from worksheet2_1/loader.asm rename to Worksheet2_1/loader.asm diff --git a/worksheet2_1/loader.o b/Worksheet2_1/loader.o similarity index 100% rename from worksheet2_1/loader.o rename to Worksheet2_1/loader.o diff --git a/worksheet2_1/source/link.ld b/Worksheet2_1/source/link.ld similarity index 100% rename from worksheet2_1/source/link.ld rename to Worksheet2_1/source/link.ld diff --git a/worksheet2_2/Makefile b/Worksheet2_2/Makefile similarity index 100% rename from worksheet2_2/Makefile rename to Worksheet2_2/Makefile diff --git a/worksheet2_2/frame_buffer.c b/Worksheet2_2/frame_buffer.c similarity index 100% rename from worksheet2_2/frame_buffer.c rename to Worksheet2_2/frame_buffer.c diff --git a/worksheet2_2/frame_buffer.h b/Worksheet2_2/frame_buffer.h similarity index 100% rename from worksheet2_2/frame_buffer.h rename to Worksheet2_2/frame_buffer.h diff --git a/worksheet2_2/hardware_interrupt_enabler.s b/Worksheet2_2/hardware_interrupt_enabler.s similarity index 100% rename from worksheet2_2/hardware_interrupt_enabler.s rename to Worksheet2_2/hardware_interrupt_enabler.s diff --git a/worksheet2_2/interrupt_asm.o b/Worksheet2_2/interrupt_asm.o similarity index 100% rename from worksheet2_2/interrupt_asm.o rename to Worksheet2_2/interrupt_asm.o diff --git a/worksheet2_2/interrupt_asm.s b/Worksheet2_2/interrupt_asm.s similarity index 100% rename from worksheet2_2/interrupt_asm.s rename to Worksheet2_2/interrupt_asm.s diff --git a/worksheet2_2/interrupt_handlers.o b/Worksheet2_2/interrupt_handlers.o similarity index 100% rename from worksheet2_2/interrupt_handlers.o rename to Worksheet2_2/interrupt_handlers.o diff --git a/worksheet2_2/interrupt_handlers.s b/Worksheet2_2/interrupt_handlers.s similarity index 100% rename from worksheet2_2/interrupt_handlers.s rename to Worksheet2_2/interrupt_handlers.s diff --git a/worksheet2_2/interrupts.c b/Worksheet2_2/interrupts.c similarity index 100% rename from worksheet2_2/interrupts.c rename to Worksheet2_2/interrupts.c diff --git a/worksheet2_2/interrupts.h b/Worksheet2_2/interrupts.h similarity index 100% rename from worksheet2_2/interrupts.h rename to Worksheet2_2/interrupts.h diff --git a/worksheet2_2/interrupts.o b/Worksheet2_2/interrupts.o similarity index 100% rename from worksheet2_2/interrupts.o rename to Worksheet2_2/interrupts.o diff --git a/worksheet2_2/io.h b/Worksheet2_2/io.h similarity index 100% rename from worksheet2_2/io.h rename to Worksheet2_2/io.h diff --git a/worksheet2_2/io.o b/Worksheet2_2/io.o similarity index 100% rename from worksheet2_2/io.o rename to Worksheet2_2/io.o diff --git a/worksheet2_2/io.s b/Worksheet2_2/io.s similarity index 100% rename from worksheet2_2/io.s rename to Worksheet2_2/io.s diff --git a/worksheet2_2/keyboard.c b/Worksheet2_2/keyboard.c similarity index 100% rename from worksheet2_2/keyboard.c rename to Worksheet2_2/keyboard.c diff --git a/worksheet2_2/keyboard.h b/Worksheet2_2/keyboard.h similarity index 100% rename from worksheet2_2/keyboard.h rename to Worksheet2_2/keyboard.h diff --git a/worksheet2_2/keyboard.o b/Worksheet2_2/keyboard.o similarity index 100% rename from worksheet2_2/keyboard.o rename to Worksheet2_2/keyboard.o diff --git a/worksheet2_2/kmain.c b/Worksheet2_2/kmain.c similarity index 100% rename from worksheet2_2/kmain.c rename to Worksheet2_2/kmain.c diff --git a/worksheet2_2/kmain.o b/Worksheet2_2/kmain.o similarity index 100% rename from worksheet2_2/kmain.o rename to Worksheet2_2/kmain.o diff --git a/worksheet2_2/loader.s b/Worksheet2_2/loader.s similarity index 100% rename from worksheet2_2/loader.s rename to Worksheet2_2/loader.s diff --git a/worksheet2_2/pic.c b/Worksheet2_2/pic.c similarity index 100% rename from worksheet2_2/pic.c rename to Worksheet2_2/pic.c diff --git a/worksheet2_2/pic.h b/Worksheet2_2/pic.h similarity index 100% rename from worksheet2_2/pic.h rename to Worksheet2_2/pic.h diff --git a/worksheet2_2/pic.o b/Worksheet2_2/pic.o similarity index 100% rename from worksheet2_2/pic.o rename to Worksheet2_2/pic.o diff --git a/worksheet2_2/types.h b/Worksheet2_2/types.h similarity index 100% rename from worksheet2_2/types.h rename to Worksheet2_2/types.h diff --git a/worksheet_0/foo.txt b/Worksheet_0/foo.txt similarity index 100% rename from worksheet_0/foo.txt rename to Worksheet_0/foo.txt diff --git a/worksheet_0/task1_pointer b/Worksheet_0/task1_pointer similarity index 100% rename from worksheet_0/task1_pointer rename to Worksheet_0/task1_pointer diff --git a/worksheet_0/task1_pointer.c b/Worksheet_0/task1_pointer.c similarity index 100% rename from worksheet_0/task1_pointer.c rename to Worksheet_0/task1_pointer.c diff --git a/worksheet_0/task1_pointer.dSYM/Contents/Info.plist b/Worksheet_0/task1_pointer.dSYM/Contents/Info.plist similarity index 100% rename from worksheet_0/task1_pointer.dSYM/Contents/Info.plist rename to Worksheet_0/task1_pointer.dSYM/Contents/Info.plist diff --git a/worksheet_0/task1_pointer.dSYM/Contents/Resources/DWARF/task1_pointer b/Worksheet_0/task1_pointer.dSYM/Contents/Resources/DWARF/task1_pointer similarity index 100% rename from worksheet_0/task1_pointer.dSYM/Contents/Resources/DWARF/task1_pointer rename to Worksheet_0/task1_pointer.dSYM/Contents/Resources/DWARF/task1_pointer diff --git a/worksheet_0/task1_pointer.dSYM/Contents/Resources/Relocations/x86_64/task1_pointer.yml b/Worksheet_0/task1_pointer.dSYM/Contents/Resources/Relocations/x86_64/task1_pointer.yml similarity index 100% rename from worksheet_0/task1_pointer.dSYM/Contents/Resources/Relocations/x86_64/task1_pointer.yml rename to Worksheet_0/task1_pointer.dSYM/Contents/Resources/Relocations/x86_64/task1_pointer.yml diff --git a/worksheet_0/task2_array_pointer b/Worksheet_0/task2_array_pointer similarity index 100% rename from worksheet_0/task2_array_pointer rename to Worksheet_0/task2_array_pointer diff --git a/worksheet_0/task2_array_pointer.c b/Worksheet_0/task2_array_pointer.c similarity index 100% rename from worksheet_0/task2_array_pointer.c rename to Worksheet_0/task2_array_pointer.c diff --git a/worksheet_0/task2_array_pointer.dSYM/Contents/Info.plist b/Worksheet_0/task2_array_pointer.dSYM/Contents/Info.plist similarity index 100% rename from worksheet_0/task2_array_pointer.dSYM/Contents/Info.plist rename to Worksheet_0/task2_array_pointer.dSYM/Contents/Info.plist diff --git a/worksheet_0/task2_array_pointer.dSYM/Contents/Resources/DWARF/task2_array_pointer b/Worksheet_0/task2_array_pointer.dSYM/Contents/Resources/DWARF/task2_array_pointer similarity index 100% rename from worksheet_0/task2_array_pointer.dSYM/Contents/Resources/DWARF/task2_array_pointer rename to Worksheet_0/task2_array_pointer.dSYM/Contents/Resources/DWARF/task2_array_pointer diff --git a/worksheet_0/task2_array_pointer.dSYM/Contents/Resources/Relocations/x86_64/task2_array_pointer.yml b/Worksheet_0/task2_array_pointer.dSYM/Contents/Resources/Relocations/x86_64/task2_array_pointer.yml similarity index 100% rename from worksheet_0/task2_array_pointer.dSYM/Contents/Resources/Relocations/x86_64/task2_array_pointer.yml rename to Worksheet_0/task2_array_pointer.dSYM/Contents/Resources/Relocations/x86_64/task2_array_pointer.yml diff --git a/worksheet_0/task3_array_compare b/Worksheet_0/task3_array_compare similarity index 100% rename from worksheet_0/task3_array_compare rename to Worksheet_0/task3_array_compare diff --git a/worksheet_0/task3_array_compare.c b/Worksheet_0/task3_array_compare.c similarity index 100% rename from worksheet_0/task3_array_compare.c rename to Worksheet_0/task3_array_compare.c diff --git a/worksheet_0/task3_array_compare.dSYM/Contents/Info.plist b/Worksheet_0/task3_array_compare.dSYM/Contents/Info.plist similarity index 100% rename from worksheet_0/task3_array_compare.dSYM/Contents/Info.plist rename to Worksheet_0/task3_array_compare.dSYM/Contents/Info.plist diff --git a/worksheet_0/task3_array_compare.dSYM/Contents/Resources/DWARF/task3_array_compare b/Worksheet_0/task3_array_compare.dSYM/Contents/Resources/DWARF/task3_array_compare similarity index 100% rename from worksheet_0/task3_array_compare.dSYM/Contents/Resources/DWARF/task3_array_compare rename to Worksheet_0/task3_array_compare.dSYM/Contents/Resources/DWARF/task3_array_compare diff --git a/worksheet_0/task3_array_compare.dSYM/Contents/Resources/Relocations/x86_64/task3_array_compare.yml b/Worksheet_0/task3_array_compare.dSYM/Contents/Resources/Relocations/x86_64/task3_array_compare.yml similarity index 100% rename from worksheet_0/task3_array_compare.dSYM/Contents/Resources/Relocations/x86_64/task3_array_compare.yml rename to Worksheet_0/task3_array_compare.dSYM/Contents/Resources/Relocations/x86_64/task3_array_compare.yml diff --git a/worksheet_0/task4_file_sum b/Worksheet_0/task4_file_sum similarity index 100% rename from worksheet_0/task4_file_sum rename to Worksheet_0/task4_file_sum diff --git a/worksheet_0/task4_file_sum.c b/Worksheet_0/task4_file_sum.c similarity index 100% rename from worksheet_0/task4_file_sum.c rename to Worksheet_0/task4_file_sum.c diff --git a/worksheet_0/task4_file_sum.dSYM/Contents/Info.plist b/Worksheet_0/task4_file_sum.dSYM/Contents/Info.plist similarity index 100% rename from worksheet_0/task4_file_sum.dSYM/Contents/Info.plist rename to Worksheet_0/task4_file_sum.dSYM/Contents/Info.plist diff --git a/worksheet_0/task4_file_sum.dSYM/Contents/Resources/DWARF/task4_file_sum b/Worksheet_0/task4_file_sum.dSYM/Contents/Resources/DWARF/task4_file_sum similarity index 100% rename from worksheet_0/task4_file_sum.dSYM/Contents/Resources/DWARF/task4_file_sum rename to Worksheet_0/task4_file_sum.dSYM/Contents/Resources/DWARF/task4_file_sum diff --git a/worksheet_0/task4_file_sum.dSYM/Contents/Resources/Relocations/x86_64/task4_file_sum.yml b/Worksheet_0/task4_file_sum.dSYM/Contents/Resources/Relocations/x86_64/task4_file_sum.yml similarity index 100% rename from worksheet_0/task4_file_sum.dSYM/Contents/Resources/Relocations/x86_64/task4_file_sum.yml rename to Worksheet_0/task4_file_sum.dSYM/Contents/Resources/Relocations/x86_64/task4_file_sum.yml diff --git a/worksheet_0/task5_swap_function b/Worksheet_0/task5_swap_function similarity index 100% rename from worksheet_0/task5_swap_function rename to Worksheet_0/task5_swap_function diff --git a/worksheet_0/task5_swap_function.c b/Worksheet_0/task5_swap_function.c similarity index 100% rename from worksheet_0/task5_swap_function.c rename to Worksheet_0/task5_swap_function.c diff --git a/worksheet_0/task5_swap_function.dSYM/Contents/Info.plist b/Worksheet_0/task5_swap_function.dSYM/Contents/Info.plist similarity index 100% rename from worksheet_0/task5_swap_function.dSYM/Contents/Info.plist rename to Worksheet_0/task5_swap_function.dSYM/Contents/Info.plist diff --git a/worksheet_0/task5_swap_function.dSYM/Contents/Resources/DWARF/task5_swap_function b/Worksheet_0/task5_swap_function.dSYM/Contents/Resources/DWARF/task5_swap_function similarity index 100% rename from worksheet_0/task5_swap_function.dSYM/Contents/Resources/DWARF/task5_swap_function rename to Worksheet_0/task5_swap_function.dSYM/Contents/Resources/DWARF/task5_swap_function diff --git a/worksheet_0/task5_swap_function.dSYM/Contents/Resources/Relocations/x86_64/task5_swap_function.yml b/Worksheet_0/task5_swap_function.dSYM/Contents/Resources/Relocations/x86_64/task5_swap_function.yml similarity index 100% rename from worksheet_0/task5_swap_function.dSYM/Contents/Resources/Relocations/x86_64/task5_swap_function.yml rename to Worksheet_0/task5_swap_function.dSYM/Contents/Resources/Relocations/x86_64/task5_swap_function.yml diff --git a/worksheet_0/task6_print_2d_array b/Worksheet_0/task6_print_2d_array similarity index 100% rename from worksheet_0/task6_print_2d_array rename to Worksheet_0/task6_print_2d_array diff --git a/worksheet_0/task6_print_2d_array.c b/Worksheet_0/task6_print_2d_array.c similarity index 100% rename from worksheet_0/task6_print_2d_array.c rename to Worksheet_0/task6_print_2d_array.c diff --git a/worksheet_0/task6_print_2d_array.dSYM/Contents/Info.plist b/Worksheet_0/task6_print_2d_array.dSYM/Contents/Info.plist similarity index 100% rename from worksheet_0/task6_print_2d_array.dSYM/Contents/Info.plist rename to Worksheet_0/task6_print_2d_array.dSYM/Contents/Info.plist diff --git a/worksheet_0/task6_print_2d_array.dSYM/Contents/Resources/DWARF/task6_print_2d_array b/Worksheet_0/task6_print_2d_array.dSYM/Contents/Resources/DWARF/task6_print_2d_array similarity index 100% rename from worksheet_0/task6_print_2d_array.dSYM/Contents/Resources/DWARF/task6_print_2d_array rename to Worksheet_0/task6_print_2d_array.dSYM/Contents/Resources/DWARF/task6_print_2d_array diff --git a/worksheet_0/task6_print_2d_array.dSYM/Contents/Resources/Relocations/x86_64/task6_print_2d_array.yml b/Worksheet_0/task6_print_2d_array.dSYM/Contents/Resources/Relocations/x86_64/task6_print_2d_array.yml similarity index 100% rename from worksheet_0/task6_print_2d_array.dSYM/Contents/Resources/Relocations/x86_64/task6_print_2d_array.yml rename to Worksheet_0/task6_print_2d_array.dSYM/Contents/Resources/Relocations/x86_64/task6_print_2d_array.yml diff --git a/worksheet_0/task7_tic_tac_toe b/Worksheet_0/task7_tic_tac_toe similarity index 100% rename from worksheet_0/task7_tic_tac_toe rename to Worksheet_0/task7_tic_tac_toe diff --git a/worksheet_0/task7_tic_tac_toe.c b/Worksheet_0/task7_tic_tac_toe.c similarity index 100% rename from worksheet_0/task7_tic_tac_toe.c rename to Worksheet_0/task7_tic_tac_toe.c diff --git a/worksheet_0/task7_tic_tac_toe.dSYM/Contents/Info.plist b/Worksheet_0/task7_tic_tac_toe.dSYM/Contents/Info.plist similarity index 100% rename from worksheet_0/task7_tic_tac_toe.dSYM/Contents/Info.plist rename to Worksheet_0/task7_tic_tac_toe.dSYM/Contents/Info.plist diff --git a/worksheet_0/task7_tic_tac_toe.dSYM/Contents/Resources/DWARF/task7_tic_tac_toe b/Worksheet_0/task7_tic_tac_toe.dSYM/Contents/Resources/DWARF/task7_tic_tac_toe similarity index 100% rename from worksheet_0/task7_tic_tac_toe.dSYM/Contents/Resources/DWARF/task7_tic_tac_toe rename to Worksheet_0/task7_tic_tac_toe.dSYM/Contents/Resources/DWARF/task7_tic_tac_toe diff --git a/worksheet_0/task7_tic_tac_toe.dSYM/Contents/Resources/Relocations/x86_64/task7_tic_tac_toe.yml b/Worksheet_0/task7_tic_tac_toe.dSYM/Contents/Resources/Relocations/x86_64/task7_tic_tac_toe.yml similarity index 100% rename from worksheet_0/task7_tic_tac_toe.dSYM/Contents/Resources/Relocations/x86_64/task7_tic_tac_toe.yml rename to Worksheet_0/task7_tic_tac_toe.dSYM/Contents/Resources/Relocations/x86_64/task7_tic_tac_toe.yml diff --git a/Worksheet_1/Dockerfile b/Worksheet_1/Dockerfile new file mode 100644 index 0000000..85516ee --- /dev/null +++ b/Worksheet_1/Dockerfile @@ -0,0 +1,17 @@ +# Use an official lightweight Linux image +FROM debian:latest + +# Install NASM and GCC for assembly and linking +RUN apt-get update && apt-get install -y \ + nasm \ + gcc \ + && rm -rf /var/lib/apt/lists/* + +# Set the working directory +WORKDIR /app + +# Copy the current directory contents into the container +COPY . /app + +# Set default command to bash +CMD ["/bin/bash"] diff --git a/Worksheet_1/Makefile b/Worksheet_1/Makefile new file mode 100644 index 0000000..aaec790 --- /dev/null +++ b/Worksheet_1/Makefile @@ -0,0 +1,31 @@ +all: task1 task2 task3 + +task1: src/task1.o src/driver.o src/asm_io.o + gcc -m32 -o src/task1 src/task1.o src/driver.o src/asm_io.o + +task2: src/task2.o src/driver.o src/asm_io.o src/print_int.o + gcc -m32 -o src/task2 src/task2.o src/driver.o src/asm_io.o src/print_int.o + +task3: src/task3.o src/driver.o src/asm_io.o src/print_int.o + gcc -m32 -o src/task3 src/task3.o src/driver.o src/asm_io.o src/print_int.o + +src/task1.o: src/task1.asm + nasm -f elf src/task1.asm -o src/task1.o + +src/task2.o: src/task2.asm + nasm -f elf src/task2.asm -o src/task2.o + +src/task3.o: src/task3.asm + nasm -f elf src/task3.asm -o src/task3.o + +src/driver.o: src/driver.c + gcc -m32 -c src/driver.c -o src/driver.o + +src/asm_io.o: src/asm_io.asm + nasm -f elf src/asm_io.asm -o src/asm_io.o + +src/print_int.o: src/print_int.c + gcc -m32 -c src/print_int.c -o src/print_int.o + +clean: + rm -f src/*.o src/task1 src/task2 src/task3 diff --git a/Worksheet_1/README.md b/Worksheet_1/README.md new file mode 100644 index 0000000..dc4aefd --- /dev/null +++ b/Worksheet_1/README.md @@ -0,0 +1,84 @@ +# Worksheet 1: Assembly Programming with Docker Integration + +This project is part of the **Worksheet 1** task, focusing on assembly programming and integration with Docker for build and run processes. + +## Project Overview + +This repository contains assembly language programs and supporting files to demonstrate basic programming concepts in assembly language. The workflow involves writing assembly code, integrating it with C for execution, and containerizing the build process using Docker. + +### Files in the Repository + +- **Assembly Files** + - `task1.asm`: First task in assembly programming. + - `task2.asm`: Second task in assembly programming. + - `task3.asm`: Third task in assembly programming. + +- **C Files** + - `driver.c`: Main driver file that calls the assembly program. + - `print_int.c`: Helper function to print integers. + +- **Include Files** + - `asm_io.asm` and `asm_io.inc`: Assembly IO routines. + +- **Build Files** + - `Makefile`: Automates the build process. + - `Dockerfile`: Containerizes the build and execution process. + +## Getting Started + +### Prerequisites + +- **Docker**: Ensure Docker is installed on your machine. +- **NASM**: An assembler for x86 assembly. +- **GCC**: A C compiler to link the assembly and C code. + +### Building and Running + +1. **Using Docker**: + - Build the Docker container: + ```bash + docker build -t asm_project . + ``` + - Run the container: + ```bash + docker run --rm asm_project + ``` + +2. **Locally**: + - Compile using `make`: + ```bash + make + ``` + - Run the program: + ```bash + ./program + ``` + +## Project Structure + +worksheet_1/ +├── README.md # Project documentation (to be created or updated by you) +├── Makefile # Build file for automating compilation +├── Dockerfile # Docker configuration for containerized builds +├── src/ # Directory containing all source files +│ ├── asm_io.asm # Provided Assembly IO code +│ ├── asm_io.inc # Provided IO include file +│ ├── driver.c # Main C program calling assembly functions +│ ├── print_int.c # Helper C program for printing integers +│ ├── task1.asm # Assembly code for Task 1 +│ ├── task2.asm # Assembly code for Task 2 +│ ├── task3.asm # Assembly code for Task 3 + + +## Authors + +- Hazal Veziroglu + +## License + +This project is licensed under the MIT License. See the `LICENSE` file for details. + +## Acknowledgments + +- UWE Course Material on Assembly Programming +- Online assembly programming resources and communities. diff --git a/Worksheet_1/src/asm_io.asm b/Worksheet_1/src/asm_io.asm new file mode 100644 index 0000000..96c5e49 --- /dev/null +++ b/Worksheet_1/src/asm_io.asm @@ -0,0 +1,502 @@ +; +; file: asm_io.asm +; Assembly I/O routines +; To assemble for DJGPP +; nasm -f coff -d COFF_TYPE asm_io.asm +; To assemble for Borland C++ 5.x +; nasm -f obj -d OBJ_TYPE asm_io.asm +; To assemble for Microsoft Visual Studio +; nasm -f win32 -d COFF_TYPE asm_io.asm +; To assemble for Linux +; nasm -f elf -d ELF_TYPE asm_io.asm +; To assemble for Watcom +; nasm -f obj -d OBJ_TYPE -d WATCOM asm_io.asm +; IMPORTANT NOTES FOR WATCOM +; The Watcom compiler's C library does not use the +; standard C calling convention. For example, the +; putchar() function gets its argument from the +; the value of EAX, not the stack. + + +%define NL 10 +%define CF_MASK 00000001h +%define PF_MASK 00000004h +%define AF_MASK 00000010h +%define ZF_MASK 00000040h +%define SF_MASK 00000080h +%define DF_MASK 00000400h +%define OF_MASK 00000800h + + +; +; Linux C doesn't put underscores on labels +; +; %ifdef ELF_TYPE +%define _scanf scanf +%define _printf printf +%define _getchar getchar +%define _putchar putchar +; %endif + +; ; +; ; Watcom puts underscores at end of label +; ; +; %ifdef WATCOM +; %define _scanf scanf_ +; %define _printf printf +; %define _getchar getchar_ +; %define _putchar putchar_ +; %endif + +%ifdef OBJ_TYPE +segment .data public align=4 class=data use32 +%else +segment .data +%endif + +int_format db "%i", 0 +string_format db "%s", 0 +reg_format db "Register Dump # %d", NL + db "EAX = %.8X EBX = %.8X ECX = %.8X EDX = %.8X", NL + db "ESI = %.8X EDI = %.8X EBP = %.8X ESP = %.8X", NL + db "EIP = %.8X FLAGS = %.4X %s %s %s %s %s %s %s", NL + db 0 +carry_flag db "CF", 0 +zero_flag db "ZF", 0 +sign_flag db "SF", 0 +parity_flag db "PF", 0 +overflow_flag db "OF", 0 +dir_flag db "DF", 0 +aux_carry_flag db "AF", 0 +unset_flag db " ", 0 +mem_format1 db "Memory Dump # %d Address = %.8X", NL, 0 +mem_format2 db "%.8X ", 0 +mem_format3 db "%.2X ", 0 +stack_format db "Stack Dump # %d", NL + db "EBP = %.8X ESP = %.8X", NL, 0 +stack_line_format db "%+4d %.8X %.8X", NL, 0 +math_format1 db "Math Coprocessor Dump # %d Control Word = %.4X" + db " Status Word = %.4X", NL, 0 +valid_st_format db "ST%d: %.10g", NL, 0 +invalid_st_format db "ST%d: Invalid ST", NL, 0 +empty_st_format db "ST%d: Empty", NL, 0 + +; +; code is put in the _TEXT segment +; +%ifdef OBJ_TYPE +segment text public align=1 class=code use32 +%else +segment .text +%endif + global read_int, print_int, print_string, read_char + global print_char, print_nl, sub_dump_regs, sub_dump_mem + global sub_dump_math, sub_dump_stack + extern _scanf, _printf, _getchar, _putchar + +read_int: + enter 4,0 + pusha + pushf + + lea eax, [ebp-4] + push eax + push dword int_format + call _scanf + pop ecx + pop ecx + + popf + popa + mov eax, [ebp-4] + leave + ret + +print_int: + enter 0,0 + pusha + pushf + + push eax + push dword int_format + call _printf + pop ecx + pop ecx + + popf + popa + leave + ret + +print_string: + enter 0,0 + pusha + pushf + + push eax + push dword string_format + call _printf + pop ecx + pop ecx + + popf + popa + leave + ret + +read_char: + enter 4,0 + pusha + pushf + + call _getchar + mov [ebp-4], eax + + popf + popa + mov eax, [ebp-4] + leave + ret + +print_char: + enter 0,0 + pusha + pushf + +%ifndef WATCOM + push eax +%endif + call _putchar +%ifndef WATCOM + pop ecx +%endif + + popf + popa + leave + ret + + +print_nl: + enter 0,0 + pusha + pushf + +%ifdef WATCOM + mov eax, 10 ; WATCOM doesn't use the stack here +%else + push dword 10 ; 10 == ASCII code for \n +%endif + call _putchar +%ifndef WATCOM + pop ecx +%endif + popf + popa + leave + ret + + +sub_dump_regs: + enter 4,0 + pusha + pushf + mov eax, [esp] ; read FLAGS back off stack + mov [ebp-4], eax ; save flags + +; +; show which FLAGS are set +; + test eax, CF_MASK + jz cf_off + mov eax, carry_flag + jmp short push_cf +cf_off: + mov eax, unset_flag +push_cf: + push eax + + test dword [ebp-4], PF_MASK + jz pf_off + mov eax, parity_flag + jmp short push_pf +pf_off: + mov eax, unset_flag +push_pf: + push eax + + test dword [ebp-4], AF_MASK + jz af_off + mov eax, aux_carry_flag + jmp short push_af +af_off: + mov eax, unset_flag +push_af: + push eax + + test dword [ebp-4], ZF_MASK + jz zf_off + mov eax, zero_flag + jmp short push_zf +zf_off: + mov eax, unset_flag +push_zf: + push eax + + test dword [ebp-4], SF_MASK + jz sf_off + mov eax, sign_flag + jmp short push_sf +sf_off: + mov eax, unset_flag +push_sf: + push eax + + test dword [ebp-4], DF_MASK + jz df_off + mov eax, dir_flag + jmp short push_df +df_off: + mov eax, unset_flag +push_df: + push eax + + test dword [ebp-4], OF_MASK + jz of_off + mov eax, overflow_flag + jmp short push_of +of_off: + mov eax, unset_flag +push_of: + push eax + + push dword [ebp-4] ; FLAGS + mov eax, [ebp+4] + sub eax, 10 ; EIP on stack is 10 bytes ahead of orig + push eax ; EIP + lea eax, [ebp+12] + push eax ; original ESP + push dword [ebp] ; original EBP + push edi + push esi + push edx + push ecx + push ebx + push dword [ebp-8] ; original EAX + push dword [ebp+8] ; # of dump + push dword reg_format + call _printf + add esp, 76 + popf + popa + leave + ret 4 + +sub_dump_stack: + enter 0,0 + pusha + pushf + + lea eax, [ebp+20] + push eax ; original ESP + push dword [ebp] ; original EBP + push dword [ebp+8] ; # of dump + push dword stack_format + call _printf + add esp, 16 + + mov ebx, [ebp] ; ebx = original ebp + mov eax, [ebp+16] ; eax = # dwords above ebp + shl eax, 2 ; eax *= 4 + add ebx, eax ; ebx = & highest dword in stack to display + mov edx, [ebp+16] + mov ecx, edx + add ecx, [ebp+12] + inc ecx ; ecx = # of dwords to display + +stack_line_loop: + push edx + push ecx ; save ecx & edx + + push dword [ebx] ; value on stack + push ebx ; address of value on stack + mov eax, edx + sal eax, 2 ; eax = 4*edx + push eax ; offset from ebp + push dword stack_line_format + call _printf + add esp, 16 + + pop ecx + pop edx + + sub ebx, 4 + dec edx + loop stack_line_loop + + popf + popa + leave + ret 12 + + +sub_dump_mem: + enter 0,0 + pusha + pushf + + push dword [ebp+12] + push dword [ebp+16] + push dword mem_format1 + call _printf + add esp, 12 + mov esi, [ebp+12] ; address + and esi, 0FFFFFFF0h ; move to start of paragraph + mov ecx, [ebp+8] + inc ecx +mem_outer_loop: + push ecx + push esi + push dword mem_format2 + call _printf + add esp, 8 + + xor ebx, ebx +mem_hex_loop: + xor eax, eax + mov al, [esi + ebx] + push eax + push dword mem_format3 + call _printf + add esp, 8 + inc ebx + cmp ebx, 16 + jl mem_hex_loop + + mov eax, '"' + call print_char + xor ebx, ebx +mem_char_loop: + xor eax, eax + mov al, [esi+ebx] + cmp al, 32 + jl non_printable + cmp al, 126 + jg non_printable + jmp short mem_char_loop_continue +non_printable: + mov eax, '?' +mem_char_loop_continue: + call print_char + + inc ebx + cmp ebx, 16 + jl mem_char_loop + + mov eax, '"' + call print_char + call print_nl + + add esi, 16 + pop ecx + loop mem_outer_loop + + popf + popa + leave + ret 12 + +; function sub_dump_math +; prints out state of math coprocessor without modifying the coprocessor +; or regular processor state +; Parameters: +; dump number - dword at [ebp+8] +; Local variables: +; ebp-108 start of fsave buffer +; ebp-116 temp double +; Notes: This procedure uses the Pascal convention. +; fsave buffer structure: +; ebp-108 control word +; ebp-104 status word +; ebp-100 tag word +; ebp-80 ST0 +; ebp-70 ST1 +; ebp-60 ST2 ... +; ebp-10 ST7 +; +sub_dump_math: + enter 116,0 + pusha + pushf + + fsave [ebp-108] ; save coprocessor state to memory + mov eax, [ebp-104] ; status word + and eax, 0FFFFh + push eax + mov eax, [ebp-108] ; control word + and eax, 0FFFFh + push eax + push dword [ebp+8] + push dword math_format1 + call _printf + add esp, 16 +; +; rotate tag word so that tags in same order as numbers are +; in the stack +; + mov cx, [ebp-104] ; ax = status word + shr cx, 11 + and cx, 7 ; cl = physical state of number on stack top + mov bx, [ebp-100] ; bx = tag word + shl cl,1 ; cl *= 2 + ror bx, cl ; move top of stack tag to lowest bits + + mov edi, 0 ; edi = stack number of number + lea esi, [ebp-80] ; esi = address of ST0 + mov ecx, 8 ; ecx = loop counter +tag_loop: + push ecx + mov ax, 3 + and ax, bx ; ax = current tag + or ax, ax ; 00 -> valid number + je valid_st + cmp ax, 1 ; 01 -> zero + je zero_st + cmp ax, 2 ; 10 -> invalid number + je invalid_st + push edi ; 11 -> empty + push dword empty_st_format + call _printf + add esp, 8 + jmp short cont_tag_loop +zero_st: + fldz + jmp short print_real +valid_st: + fld tword [esi] +print_real: + fstp qword [ebp-116] + push dword [ebp-112] + push dword [ebp-116] + push edi + push dword valid_st_format + call _printf + add esp, 16 + jmp short cont_tag_loop +invalid_st: + push edi + push dword invalid_st_format + call _printf + add esp, 8 +cont_tag_loop: + ror bx, 2 ; mov next tag into lowest bits + inc edi + add esi, 10 ; mov to next number on stack + pop ecx + loop tag_loop + + frstor [ebp-108] ; restore coprocessor state + popf + popa + leave + ret 4 \ No newline at end of file diff --git a/worksheet_1/src/asm_io.inc b/Worksheet_1/src/asm_io.inc similarity index 100% rename from worksheet_1/src/asm_io.inc rename to Worksheet_1/src/asm_io.inc diff --git a/Worksheet_1/src/asm_io.o b/Worksheet_1/src/asm_io.o new file mode 100644 index 0000000000000000000000000000000000000000..d2921f0c774600089db73d581638199c58d10228 GIT binary patch literal 3648 zcmb<-^>JflWMqH=Mh0dE1doBi0V-hvrZpJY8JNK=QVEcmAPm!;z{tSR0}_B5!~&(+ z85qF!vqAYEm>3v-FhMyC3=9HLCNBd6ic3DQGB6lI<v<k7XmJJx1|;na1|Wl37#LU? z7#NHg7#KkIg3OdhGtYpFfnhn4Mwof(3=9mMAPb=Q0S^O11S7;8kaCcD98ftBrJBj0 zTFelXnx0u)l3JwTQkq+!psb*p!sY51p<t_^s%H_Q;Oc~6IwP1aFeaC4uqRxt3xeqs z02d90F}YklVN3-#A4m6Kuo9C91=V6q#Kqw3#t`Mk5bVYf;KtzZ#^B<{;ONGnpupgp znwwu#iEyrhV@gU<YH=~xG>Zr>2C%~!RP~G^6c~a_5|gtLYPnpoI*dV8+ayH+;$tw$ z#o(J*lA++7Ur>~voLXF*j}$x#&iQ#IMfo`j;rT@=U`tIR6oN|<OG=B8g}4}kLsV0& z6jb#L4bov8&%Cn4oXix3;1HOIYi>bFB^M|<7*4P-FeJ?Bb^Q~N0ph>-^Z)<<$jG^g z-L8L59zMYUl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#K3R?i7(B>!0-@>uffE? zzy_*#!ERt;Fk@n15Jlp<FflMlA@MVr7#RAH_(e<%4BL_TRZI*FyOH?KObiTrk@z6J z*O2%#nHU(JAo2O&ZiBQ{M9}!sXnbWfzBUS<iNS=Cfk77RH;{Qu40enR43M@MgzwGB zz~GG}AIiwUkbuMol@o<X{7gm$hGr!G14aghFsPjZ3``9F85tPXBJrb{7#JL&{sYM~ zBo^n!XXfiA7Uwc#=9R>!<rn29mM|2T6lLb6!+1rhaAtC1QBh@lT25j*Lse=~K7>`A znVtt>6(kmAmO$n6%TkNda`MX|GAWrw5JqBYMLd!zrFq4vB@mh1)Lf{Ih71U{5fa;& zp%~OQfvSRXax(K$VIsMSB^gk*Ap^MC5MK=UR3@Y$fh3X&YDggQi<1-c(ijSgGV@B( z7}8Tqk~0#E7z#=ubWv(zN_=Ks2}B-=1qmz$uslQu$bfhxW?l|MacNR~N@;FEd{Jt8 zF+*}%e12LQLqTbAMtpJ_Lje-EAdMjriJO?lP=&;;N@FNS;ufbdq#$uq(irlQxcO-a zYrz4B9AY{7`2`5++|*ofIOms^q!z`4<v>x8ky?S^fII}@<>lwagF`7XDJK=I4=xv< zoS#>cnOB;MWOian217|=Iz%rx*%X(+V+R_XMX8B742T$F02vbx*91-B3=G_${sa>! zuP`t$88LwC7e*!q1}#wOY0SW21C@7#@`FIM2?GPDb;xAOz)%I^n=&v=hpL+grPo4f zP+b8s?=X~q3QFIE(hs2Ydno-4O0zODFo5*&Kxt690OBh_`7Th}laYae$(Vs59m>yv z@+U+2GoXA>ISkUjAIiTBl?RotApI|({I^i~1SW|6sZ0>_S3>#gp!^e1{#hvh29$pn I%7+Co060G;Hvj+t literal 0 HcmV?d00001 diff --git a/Worksheet_1/src/driver.c b/Worksheet_1/src/driver.c new file mode 100644 index 0000000..64ba900 --- /dev/null +++ b/Worksheet_1/src/driver.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +// Declare the external assembly function +int _asm_main(void); + +int main() { + return _asm_main(); +} diff --git a/Worksheet_1/src/driver.o b/Worksheet_1/src/driver.o new file mode 100644 index 0000000000000000000000000000000000000000..8090fe23abb575b716b15004787dfe40aa48f0be GIT binary patch literal 1128 zcmb<-^>JflWMqH=Mh0dE1doBif(asH0;V(=_!xM>@@xzY456J*gPWgxc=6}||NpEY zO`V6q?C#h<Cl7bCs2pZ+cXqZ?&<IT`%_}KYFf`UP(lgLCGA;%4O*Ek*3?g8&85kI= zf*2TUI2fgQSXeq385k587#L)ra<U-Wk&mO5$%&WMrI|VO=wTif76t|Z1_lNPkQ@U8 z0}GT!r$A1FiLo$z{10P;Xl4ee2SFSL1_ovZHU?`b8)T;t0}}%mln<hWnApJX0<l3D zWWO1R0mUFbLrPI*S!$79GDCcPg@u`3dTL30L2`UaMrmHQUSb79yt|LTlcP_(znfdI zYe;;Eqmz$oJVSh9ac+EWVrCu#2Ll5G6DtD)F9QPu7aIdOd|22a;laejz~BOsXJ%kv z&?~OYElEsb&?_z}g3uW-R#9q>UP)?234>lrVo4%{UQ%%}16V*0yPNcq^K)}k^GX=> z^72bk_1yhJb&E?9ld~E0KqjST#HSS{=B6^}r5ELw7C`+<3{}j)z#xdE5R{HU{^Mp~ zU|@yD87SW585rQ{3Z&eIfq?-O{vb98!{Shyfq{V&DbA-bGB8LmFff431H~lBERgxC zQ1d{+1kxV~B9Ji5JZ%OBaCj3^X8<*i4P*%e0|UrBkX<k%VdnWj)q&K5<YE~Z7}P-w zC<dtm;ZUeLs4zndi~*%VYCz0Ps5+>%V08f?2`GlSAr&oL)-Xcy1}I!W;RR9$3Kx*M zFtb2LTw!2fXkcJq;6aKDP#Om5frSZ3T?iv0pMm%wb3imGZjsgPVPs&a0!ctIOdSAZ CVs%ge literal 0 HcmV?d00001 diff --git a/Worksheet_1/src/print_int.c b/Worksheet_1/src/print_int.c new file mode 100644 index 0000000..8204964 --- /dev/null +++ b/Worksheet_1/src/print_int.c @@ -0,0 +1,5 @@ +#include <stdio.h> + +void _print_int(int num) { + printf("%d\n", num); +} diff --git a/Worksheet_1/src/print_int.o b/Worksheet_1/src/print_int.o new file mode 100644 index 0000000000000000000000000000000000000000..e5ddce09277b33588795be751817c50edd637d83 GIT binary patch literal 1236 zcmb<-^>JflWMqH=Mh0dE1doBCh6y5L0;V(=_!;=X^6U%@456J*gPY&5y!i9~|9@7H zrsg*s|4TV~CxFxjbsh#wG#?R|&>j2d<YCnmE{1LvmBS3~&dyc}8lg$0c_pO^hQ@kE zdIq{i#-(7si6&G8WP}KaU|?WitO{aatl?mk=3!y!U}RuWU|?X7fy(KDXh%MdRwgH2 zR+nbxw4;Z4SXdYs1Q-|?96)jm3=Aw#8l3_;879WU@bN#44WgMDpdJTt7#J9s8Q7pK z2*u36&cF*{GJxD5#K6QL0p)`zAtrXPIEW3xAosX{7*Gu2GZYkM=9R=}=9TCrGsMF= z4Ds<57G`?ssU`6R$?+u_rFq$Ui4_d-?mqrbjz01JZf?P@A@L!OPCl;j5F^qU7&sUh z7?{`?z;5DVXJC+IU|`^6W?)bR`JV$4W=u>B3?Mf!fdWLYxH7jSF^NI1xTFX|XTVrR zsX2NjsTCy*dMSw|i41y4#l;MIMfng8NJ0<03-yxob8}PkN*MI=@=H?n-2Fmzi%Sxd zvl;Y2CZ=Y@rxhjUrZVWI7v+~0K*NC;s+xg;K@dqHC@q5g%fr9`junu1Kv*7>R-j@a z<u(iqC~*LbZ)s52Af=BJ&@=@y4;1Slvq0vnLd|0a8OFfCkOie-6wEwr21xi5QfB}) z4`c_(43K#syFhFZhM8vpRmTQZm<NhOkOC-%sSAOs1DOkwDq>(@PzN!f7^Dt_W1;Gx z!VEKE3@8m!17a3J)j_Rgn8U!p5CD>ZVwhWV(ZcTqBP73p!jB8;R#5nX%!Qc+GU5#b z0|TgR0OcE2s5($S-~{I{kO~N{VPs(NhA_b-$Q%#@lm=j74C4P_WMF6lF`yWx4gkuS Bg^~aO literal 0 HcmV?d00001 diff --git a/Worksheet_1/src/task1 b/Worksheet_1/src/task1 new file mode 100644 index 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/asm_io.inc" + +section .data + num1 dd 10 + num2 dd 20 + result dd 0 + +section .text + global _asm_main + extern _print_int + +_asm_main: + mov eax, [num1] + add eax, [num2] + mov [result], eax + + push eax + call _print_int + + add esp, 4 + ret + +section .note.GNU-stack noalloc noexec nowrite progbits diff --git a/Worksheet_1/src/task1.o b/Worksheet_1/src/task1.o new file mode 100644 index 0000000000000000000000000000000000000000..0fdf34bad3608b40d06e60add49bf528077429b4 GIT binary patch literal 768 zcmb<-^>JflWMqH=Mh0dE1doBi0V-hvrZpHi7+An8QVEcmAj}Na*ucoZzyoE2D4412 z3=ClV*+7B}3=9((85pFXY!D>?A{ZDLc%kZ`T!sxG!(kjGIavk<2AG{7X^=Wc5Ce)~ z+SC~s7?_}9V2X)>VF3dJ1IQg53=CjjgY4EvGj9PC1A`%01B8H?XU@RDzzGoolMk2} z7!(*77+9h9fcy(Gmy3acK?JM<LM#MP%&Z{k#US~B7k~c$|KEIs<uFKsfq_9UC9x!t zL9ZmWqJ%*&FTW&J&)qLnx40xRIh#SRIHS0vs3b9oL9e(n7eYh%MX5OuJy2tCQ84#| z<XIR#{s+-8jG8h);ffMs49pD74BRlqV49Hu6lNgLfVm8e45ADS3?P5O_%aX%m;|W> z#RHhbz`!5?ijk7U;%q~`#Nu3rywY4l5Mjhnlv-SxQ^F8mP?VWh5}%n@!VsTWoEx8; fn3)ID3!_2)VPs-p0H-S^NSXujg+TGZ!N33j10gzD literal 0 HcmV?d00001 diff --git a/Worksheet_1/src/task2 b/Worksheet_1/src/task2 new file mode 100644 index 0000000000000000000000000000000000000000..46d2d578c808f6fe51cb84355814143a0094b4c5 GIT binary patch literal 17824 zcmb<-^>JflWMqH=W(H;k5O0D21A_?z1H%Ugh>Qt?0s}XL27?@fECU+@L=Gem!U>EF z3?R(Hz`y{)%nS?+Qy39gn1O)-gh6s3vq2bQDugs(V_*PbkUWC`1K55L4a09(85lsA z6{H*{ufV{-0L5z<7#KhpS^o_^28J7U5M0B|z!1X90CqRXOeO{f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n0?JGz-brO=g1_1^J5C*vi zstmk`9>kxGqz=?317Q!4<Dd#bVGLp}L{bMDUj$)jlMEycT8Iy(L1PIZe}KXdJa7Rz zM*=JZAz=Pk4>b>@4*8r3h$@I5Ky1+11I#=f1qKEX2JHm^$$>D;yyFa@o;&E|0LYmb zpz|kSaxiru{$&OR27YLo0gZ>=(L>mUtnNNEt%14%;Bz$eAPxq{54ax!+4nvTA`I%1 zF@W}<KhQ_4BSJP0w66r@50H7FzQ-4R$oLOP4G4qW2Erea%mei?L<|@h96*5tQUtXZ z#QY9QPf&k=#(qMK7#MDVEC5L&srv&p&j2b8QYQ~(gD8*|7)G*&p~Q%R;Q~7YgA4-$ vLp0PpP+9<`d5|AKdO_I5ih*GnQhEWI1ri5!SCG}cvS(mmg-Jr)1X2e8FDP(b literal 0 HcmV?d00001 diff --git a/Worksheet_1/src/task2.asm b/Worksheet_1/src/task2.asm new file mode 100644 index 0000000..841981a --- /dev/null +++ b/Worksheet_1/src/task2.asm @@ -0,0 +1,132 @@ +%include "src/asm_io.inc" + +section .data + prompt_name db "Enter your name: ", 0 + prompt_num db "Enter a number (50-100): ", 0 + error_msg db "Error: Number must be 50-100.", 10, 0 + welcome_msg db "Welcome, ", 0 + newline db 10, 0 + prompt_start db "Enter start index (1-100): ", 0 + prompt_end db "Enter end index (1-100): ", 0 + range_error db "Invalid range.", 10, 0 + sum_msg db "Sum of range: ", 0 + +section .bss + user_name resb 50 ; Buffer for user name + user_num resd 1 + array resd 100 + start_index resd 1 + end_index resd 1 + range_sum resd 1 + +section .text + global main + +main: + ; Prompt for and read user name + mov eax, prompt_name + call print_string + call read_name + + ; Get user number + mov eax, prompt_num + call print_string + call read_int + mov [user_num], eax + cmp eax, 50 + jl show_error + cmp eax, 100 + jg show_error + + ; Print welcome message + mov ecx, eax +welcome_loop: + mov eax, welcome_msg + call print_string + mov eax, user_name + call print_string + call print_nl + loop welcome_loop + jmp fill_array + +show_error: + mov eax, error_msg + call print_string + call print_nl + ret + +fill_array: + mov ecx, 100 + xor edi, edi +fill_loop: + mov eax, edi + inc eax + mov [array + edi * 4], eax + inc edi + loop fill_loop + call sum_range + +sum_range: + mov eax, prompt_start + call print_string + call read_int + mov [start_index], eax + mov eax, prompt_end + call print_string + call read_int + mov [end_index], eax + + ; Validate range + mov eax, [start_index] + cmp eax, 1 + jl invalid_range + cmp eax, 100 + jg invalid_range + mov ebx, [end_index] + cmp ebx, 1 + jl invalid_range + cmp ebx, 100 + jg invalid_range + cmp eax, ebx + jg invalid_range + + ; Sum range + xor ecx, ecx + mov edi, eax +sum_loop: + add ecx, [array + (edi - 1) * 4] + inc edi + cmp edi, ebx + jg display_sum + jmp sum_loop + +display_sum: + mov [range_sum], ecx + mov eax, sum_msg + call print_string + mov eax, [range_sum] + call print_int + call print_nl + ret + +invalid_range: + mov eax, range_error + call print_string + call print_nl + ret + +; Reads a name character-by-character and stores it in user_name +read_name: + mov edi, user_name ; Point to user_name buffer +read_char_loop: + call read_char ; Read one character + cmp al, 10 ; Check for Enter key (newline) + je end_read_name ; If Enter, finish + mov [edi], al ; Store the character in the buffer + inc edi ; Move to the next position + cmp edi, user_name + 50 ; Ensure we don't exceed the buffer + jne read_char_loop ; Repeat until buffer is full or Enter is pressed + +end_read_name: + mov byte [edi], 0 ; Null-terminate the string + ret diff --git a/Worksheet_1/src/task2.o b/Worksheet_1/src/task2.o new file mode 100644 index 0000000000000000000000000000000000000000..1350a839d50964848196e916937d40860000b6cb GIT binary patch literal 2160 zcmb<-^>JflWMqH=Mh0dE1doBi0V-hvrZpHi7+An8QVEcmAj}Na*ucoZum;KoQ7}{4 z85kHi7#J8}>I|3|7%qV{f)p_@z-{MYU;w+54Jr;&Cy%5~04gqoWEMy$fSG~848(w9 zm=+lZ1_mam7>Js{%)k)9#J~VDUmj{N$V?S9^B%A=FvP(Ofw~E#Ux$H#ffK}lVh45x z1_MS023Dwkkbgn`bj>SCEmEk=FD+8YOUzBRQec3HBr4>U<|d^UDQK7)=o%UrXo6&l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&krn3<jV&f{B3v6mKB)Rv<nz1A{$C zogxE+3y4-`VDJTrGchm(f%u9H44^#6q|CsO2@+>!U?>C8ObiUwP<c>3WRhoKXa$Kg zGca_4XeI`ReyIEu5G~KZFcT!s%)l@YO0R>`$D#BUD18$|GchpS1L;#_V0aATGcz!N w%3~%428OpFab*SuP$dBJ?+*}Pk%8eah*oA`U}j`s0Qr{#lpmBB7(}6b0FwBaWdHyG literal 0 HcmV?d00001 diff --git a/Worksheet_1/src/task3 b/Worksheet_1/src/task3 new file mode 100644 index 0000000000000000000000000000000000000000..875aa5b4cd87366df0cf448446624b48bddae443 GIT binary patch literal 17532 zcmb<-^>JflWMqH=W(H;k5O0D21A_?z1H&16h>Qt?0s}XL27?@fECU+@L=Gem!U>EF z3?R(Hz`y{)%nS?+Qy39gn1O)-gh6s3vq2bQDumQvV_*PbkUWC`1K55L4Z~|#85lsA z6{H*{ufV{-0L5z<7#KhpS^o_^28J7U5bVLs!0?8J0qky&nM@1}3=i}e7#`R`FxWyy zh&;#)5MIH^zyQN83=9k)3=#+7fTtxX9108!Fs#DBzyQJ^IS>wfT9N{CDmrFoU;tUq z5cISp1=)QXj0_AQ4AKh<8~vQjB>kKe-JHz4(h9xed_5ybxQZ|^Fo43=-7l2kf5*$9 zf?uA}KavkU72n%=XC~XEZ6N&u43O{xsR7v!QV;Skhz+8-pz`3bQ~-w{14wMG_u~T~ zHOLrb7K|^%z`#%m<3NL63yBYscSGYFBJq_N7#JLo_#pLDk@%pf1gU`uf#jFKI8ggQ zVZ)*T2@63`NXC2m#}}8RWah<}7N@2##K-4kCMCxgmn0UI#OEev<}nnMmLz8+7BLhQ zW#*NnF~r9wS0u)#W#%R3WLBjz6elO<r7@(ZLezltf&$x&!QIEx$vNIg&rr`8&NhIv zj7=EgJwtrsQ&Njk(=&@pQj0=-opbW@QbQ7xa#9)M<I{8V^PrB1hbYCWkb!}Tfsp}} z-&nwT4wUa0!6JUpbOQ2zv3w>c$j1>-F@elXUQj9kB`{F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A$UIOx8-zjXKvf`2 z9Y`%`yaqJB0#XMWa{=KE43IGxklR3NKviZKbU!>u9cYXOghBl`kXaxMQVXKv7$D;) zAazyD3=AL)8h3%&3laz6Yz77f(6|eT4H|m^VNlZxblw5TERek*^Qssa7&sXi7(nVk zV>%!V8q<N92T}(b+W{@G2dM)$w?Kw~&N*O!j46S}g<$GHYb-$KgOq^As6ZGLE+D%= z7^DtFw}ac5kZ@2CU|;}Y@EQt`B)B~SX*W(nQr95BzyQJ^_du0__lJY{vys$++DIVG z0rLdZJdmD+Na{diXCMr1LV=_~i`2n1sBaDO2Pj;?9eL0h31Arr0rSUtsCgiD$Y&@( zR6+azV(&##r=!5Y0K%Yk@*p`7hM5Q2eZU7z3!wejptBWVaxiru{$&OR27ahI&{*Fc zJ%nAz>h43+8mK7^J|jX8;t+8BfcpiIz1`Cw!r(I*K>Ms8=p)w1Ae;9BNgb#!@I@ao z9s*JW!XUSS@JA$dpf<mV0Rsal?Ss^SFh~uE{tg--g!%*2mRB%hU|0eQc#tI2eIVu^ zsCfn;4ye6p#K0gAWrHY?78nM_1xO5p9gG+l0@xWCWI$sdQ1d|f4V0EaVFFSE!V@eR e7|fB<3&<>xIH>!8tnRoS0|RIr1SAK-Fm(Vh%>mK? literal 0 HcmV?d00001 diff --git a/Worksheet_1/src/task3.asm b/Worksheet_1/src/task3.asm new file mode 100644 index 0000000..8846cb9 --- /dev/null +++ b/Worksheet_1/src/task3.asm @@ -0,0 +1,98 @@ +%include "src/asm_io.inc" + +section .data + prompt_array db "Enter numbers (one by one): ", 0 + prompt_size db "Enter size of the array: ", 0 + max_msg db "Maximum value is: ", 0 + min_msg db "Minimum value is: ", 0 + sum_msg db "Sum of all values is: ", 0 + newline db 10, 0 + +section .bss + array resd 100 ; Reserve space for an array of 100 integers + size resd 1 ; Store the size of the array + max_val resd 1 ; Store the maximum value + min_val resd 1 ; Store the minimum value + total resd 1 ; Store the sum of the array elements + +section .text + global main + +main: + ; Prompt user for array size + mov eax, prompt_size + call print_string + call read_int + mov [size], eax + + ; Fill the array + mov ecx, [size] + xor edi, edi ; Index for the array +fill_array: + mov eax, prompt_array + call print_string + call read_int ; Read one integer + mov [array + edi * 4], eax + inc edi + loop fill_array + + ; Find maximum and minimum values + call find_max_min + + ; Calculate the sum of the array + call calculate_sum + + ; Print results + mov eax, max_msg + call print_string + mov eax, [max_val] + call print_int + call print_nl + + mov eax, min_msg + call print_string + mov eax, [min_val] + call print_int + call print_nl + + mov eax, sum_msg + call print_string + mov eax, [total] + call print_int + call print_nl + ret + +find_max_min: + mov ecx, [size] + mov edi, 0 + mov eax, [array] ; Load the first element + mov ebx, eax ; Assume it is the maximum + mov edx, eax ; Assume it is the minimum +find_loop: + mov eax, [array + edi * 4] + cmp eax, ebx + jle check_min + mov ebx, eax ; Update maximum +check_min: + cmp eax, edx + jge next + mov edx, eax ; Update minimum +next: + inc edi + loop find_loop + mov [max_val], ebx + mov [min_val], edx + ret + +calculate_sum: + mov ecx, [size] + mov edi, 0 + xor eax, eax ; Initialize sum to 0 +sum_loop: + add eax, [array + edi * 4] + inc edi + loop sum_loop + mov [total], eax + ret + + diff --git a/Worksheet_1/src/task3.o b/Worksheet_1/src/task3.o new file mode 100644 index 0000000000000000000000000000000000000000..82d98d4c2bf567bc1b89f1f5b354fa9ad290bb0d GIT binary patch literal 1728 zcmb<-^>JflWMqH=Mh0dE1doBi0V-hvrZpHi7+An8QVEcmAj}Na*ucoZPzGg#D4412 z3=9k$3=9k~bqq`l3=2RSL5dg{;I{KHFo5031{DXXyANYCFfa%}*+R%>F)%PZU}9h} zgUW#@n9(u}3?L&wLSU@G%)oGfk%0kZzBtrgkeMpz=CLp^+y?7_5HRy}7#J8hAwppC z04v17APVF+kbgn`bj>SCEmFuU%}q)zDpt_Q&r4NEs#M6&OVzYeV1P&#XI7;u<fkc= zWTYx278NB{S}8F2CRSwTmgXvyCFYc-Dr6RegfjEcg@Q|SK^hZtav%zeAu74RE`ks{ zWEmJ3Ui|t0|38>mJb{scp_>;(8vfq_QUVqR6P+x3K?3fNp1%kLX=-L*VAx>}Vu7?T zoWh7~&<-!S#0*r4Sh&O-6p6zSYxjffSO_9I4|g8whS+I&qmHTbu;qnXrp`m|k6v}k zf-LJ41(}Sj&F}y-M7{f?Z;L^uA7)_COGzwAWY9}0E@sdxNv$Yh&@0X;E-5NWOk&V0 zuFQqdP<~Nr4nz&edh8e$zaUu_hL8V2Gz_EW98el&f=PjCW(H;kNIn8{!3n~Vfq?-O z1rQNN244mS22hy7_@N9844|Nd@j;;n!Z3a+0|P?|gabA&7tRJTm>7x~7#KjY3F3iL zcm)Fk11Rud{00UF22e1<_#F%k44{yM@h3AdFo5y~gwM<{kAZ=q8^QtSgw+fT4D*rr zTNxM_)*$gg(YXnUe}sX7;Sdu45(5Lnc_cnJoDIptB4~U$G`=<(zYm4a%)n5RSe$LF zmsp(3P?VaO5}%n@!cb6@nOB0uDlRF?%u9y~=jAXI6y@g@l*EJc8jJ(VgbcZf74f;n z=?uA<d0@J@G#5<grIzPp=A|+~bikFCCFX#Yg6NX`5)dyjGmjxHGbaaXcv@y&N<7$9 zuy|fdd`^CT0Yh>|YI1gbZe|`s9w@~oC*~xV<|LM+#uu07GJq@vs{;EJlpYzGAmtR3 zBm)B|{FuZcVaLeKz#s-n70i${22!U4D(55_7}P<uI0J(oR322$gXCR7;*yXw2h#5k z;!7|vgn(!%28KwGdL{;jI1pcwfgu^hXJ%l?0P!Ul7(nTdNs57?2qezLz)%hnmt<h5 w0r8m`7#cx*2?mBX5G}>P&<hox4y6}C>FrP&ROEo%0ZKO@8kAl@^ew170DbErD*ylh literal 0 HcmV?d00001 diff --git a/worksheet_1/README.md b/worksheet_1/README.md deleted file mode 100644 index c4ab675..0000000 --- a/worksheet_1/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Operating Systems Worksheet 1 - -## Overview -This repository contains my solutions for Worksheet 1 of the Operating Systems module. The tasks include: -- Basic assembler programming. -- Translating C loops into assembler. -- Using Makefiles to automate builds. - -## Repository Structure diff --git a/worksheet_1/makefile b/worksheet_1/makefile deleted file mode 100644 index f36e333..0000000 --- a/worksheet_1/makefile +++ /dev/null @@ -1,27 +0,0 @@ -NASM = nasm -f macho64 -GCC = gcc -arch x86_64 -SRC_DIR = src -OBJ_DIR = src - -all: task1 task2 task3 task4 - -task1: $(OBJ_DIR)/task1.o $(OBJ_DIR)/asm_io.o $(OBJ_DIR)/driver.o - $(GCC) $^ -o task1 - -task2: $(OBJ_DIR)/task2.o $(OBJ_DIR)/asm_io.o $(OBJ_DIR)/driver.o - $(GCC) $^ -o task2 - -task3: $(OBJ_DIR)/task3.o $(OBJ_DIR)/asm_io.o $(OBJ_DIR)/driver.o - $(GCC) $^ -o task3 - -task4: $(OBJ_DIR)/task4.o $(OBJ_DIR)/asm_io.o $(OBJ_DIR)/driver.o - $(GCC) $^ -o task4 - -$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm - $(NASM) $< -o $@ - -$(OBJ_DIR)/driver.o: $(SRC_DIR)/driver.c - $(GCC) -c $< -o $@ - -clean: - rm -f task1 task2 task3 task4 $(OBJ_DIR)/*.o diff --git a/worksheet_1/src/asm_io.asm b/worksheet_1/src/asm_io.asm deleted file mode 100644 index 2e6e666..0000000 --- a/worksheet_1/src/asm_io.asm +++ /dev/null @@ -1,26 +0,0 @@ -; -; file: asm_io.asm -; Assembly I/O routines -; To assemble for DJGPP -; nasm -f coff -d COFF_TYPE asm_io.asm -; To assemble for Borland C++ 5.x -; nasm -f obj -d OBJ_TYPE asm_io.asm -; To assemble for Microsoft Visual Studio -; nasm -f win32 -d COFF_TYPE asm_io.asm -; To assemble for Linux -; nasm -f elf -d ELF_TYPE asm_io.asm -; To assemble for Watcom -; nasm -f obj -d OBJ_TYPE -d WATCOM asm_io.asm -; IMPORTANT NOTES FOR WATCOM -; The Watcom compiler's C library does not use the -; standard C calling convention. For example, the -; putchar() function gets its argument from the -; the value of EAX, not the stack. - - -%define NL 10 -%define CF_MASK 00000001h -%define PF_MASK 00000004h -%define AF_MASK 00000010h -%define ZF_MASK 00000040h -%define SF_MASK 00000080h \ No newline at end of file diff --git a/worksheet_1/src/asm_io.o b/worksheet_1/src/asm_io.o deleted file mode 100644 index d75ea1f27158915097669a9fe1672cfa3c2e56e7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 304 zcmb<-^>JflWMqH=Mh0dE1doBi0V-hvrZpH?P-MY^L=hk}nUPdJU|?X7M&g6yL0oPI z1_mY&1BMwH7!(*77(jYK;w%gd3<3-c48l+`m@)-Mh&YT7Gmk;9IHS0vs3b9oL9e(n l7eYh$Fr_FoTpt4i0}I2){|v=N$@+=Kx$&9#dWprk3;^=O6ZZfB diff --git a/worksheet_1/src/driver.c b/worksheet_1/src/driver.c deleted file mode 100644 index d386c74..0000000 --- a/worksheet_1/src/driver.c +++ /dev/null @@ -1,7 +0,0 @@ -int __attribute__((cdecl)) asm_main(void); - -int main() { - int ret_status; - ret_status = asm_main(); - return ret_status; -} diff --git a/worksheet_1/src/driver.o b/worksheet_1/src/driver.o deleted file mode 100644 index 6c725f2e37968a41072c6e57680baf5d9f6f68d9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 664 zcmX^A>+L^w1_nlE1_lO31_lNe1_p*5Acg`17)UZOFj#>2U>+vX02R6cRRiO*GcYiK zFvwhxlKA+N)QS=i3xeb0LtG<5AZ%n3YAplEJdj%=m>}+AU}1n64OSi>pPZjtkeFN& zUz%5*nU@kD@8bfNfD$lsVDt}01_qE@5@6;rFfc)tf~olU)QtGFqQu-(FqZ+{eGU*| z1{f{D1ThaP%)rgSkO5<ZXd?y&1_@}GGBEHnFfj6igu#}A#50&64(MQFU=Uzn0O@B4 z0INU{pdf`|geY;WP>;^19?fqAj=TN=X?Ou5I$eKsyZ-QKJ|Yl%7{mu*X!wAv0de72 z1j=Hp3SwZa5MUJGVdt2@$iSe&z`!8Gz`(HJKLkMaGcY*v3A8ae^Rhwpf&9eCz@Q7_ iGBPl*u`)0)@FUp*VuCP89*pA?i*w_16EpL`JO%&&N<2XT diff --git a/worksheet_1/src/task1.asm b/worksheet_1/src/task1.asm deleted file mode 100644 index 34d554a..0000000 --- a/worksheet_1/src/task1.asm +++ /dev/null @@ -1,17 +0,0 @@ -section .data - num1 dd 10 - num2 dd 20 - result dd 0 - -section .text - global asm_main - extern print_int - -asm_main: - mov eax, [num1] - add eax, [num2] - mov [result], eax - push eax - call print_int - add rsp, 8 - ret diff --git a/worksheet_1/src/task1.o b/worksheet_1/src/task1.o deleted file mode 100644 index 16322411018601cd7b758cef60386d91406c0583..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 704 zcmb<-^>JflWMqH=Mh0dE1doBi0V-hvrZpJY8JNK=QVEcmAPm!;z{tSBgJcK`l+Dh- z0JfhE$}eDKV32~cL6iW9U|?Y2Wne&Y$pl6Q21BSEhyvLKqQw~)7??l|D89hRz%YS< zfq|8QfdOO}$X<|{@@VEIFflL~L-l|tn0e|93=Etg0VrO;#K54yz`y`92V@V3=77q9 zC@uyD1`!YgiWh=tW>%20#UOP7FaG@h|G)VN%VCfN0|SFzN@7VOgI-B$MG1pmaYk`T zQAuJFgI;lEE`)~ii&AqSYM|P1Q80Id<XIR#{s+-8j2hFR@ML1(he?8IMzGsKjs<fW z7#SoP7#KkAhVemuhp-tKK;ftb<1m2uObiUgMalXliN)E5dWprk40)xwh9JU-p(wSu vG^d22peQr1BtA2*gdwpwH$FEpGY`oCXj))og2WYw2BjGgEd+{Jb_NCje!w)V diff --git a/worksheet_1/src/task2.asm b/worksheet_1/src/task2.asm deleted file mode 100644 index 9a783d9..0000000 --- a/worksheet_1/src/task2.asm +++ /dev/null @@ -1,53 +0,0 @@ -section .bss - name resb 32 - count resd 1 - -section .text - global asm_main - extern print_string, print_int, read_int, read_string - -asm_main: - ; Prompt for name - push message_name - call print_string - add rsp, 8 - - push name - call read_string - add rsp, 8 - - ; Prompt for count - push message_count - call print_string - add rsp, 8 - - push count - call read_int - add rsp, 8 - - ; Validate count - mov eax, [count] - cmp eax, 50 - jl invalid - cmp eax, 100 - jg invalid - - ; Print welcome message -print_loop: - push name - call print_string - add rsp, 8 - dec eax - jnz print_loop - ret - -invalid: - push error_message - call print_string - add rsp, 8 - ret - -section .data - message_name db "Enter your name: ", 0 - message_count db "Enter a number (50-100): ", 0 - error_message db "Invalid input!", 0 diff --git a/worksheet_1/src/task3.asm b/worksheet_1/src/task3.asm deleted file mode 100644 index d26a59f..0000000 --- a/worksheet_1/src/task3.asm +++ /dev/null @@ -1,35 +0,0 @@ -section .data - array dd 1, 2, 3, ..., 100 ; Replace ... with remaining numbers - sum dd 0 - -section .text - global asm_main - extern print_int - -asm_main: - mov ecx, 100 ; Counter for 100 elements - mov esi, array ; Start of the array - xor eax, eax ; Accumulator - -sum_loop: - add eax, [esi] - add esi, 4 ; Move to the next integer - loop sum_loop - - mov [sum], eax - push eax - call print_int - add rsp, 8 - ret - -array dd 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, - 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, - 91, 92, 93, 94, 95, 96, 97, 98, 99, 100 - diff --git a/worksheet_1/src/task4.asm b/worksheet_1/src/task4.asm deleted file mode 100644 index 64bd5fa..0000000 --- a/worksheet_1/src/task4.asm +++ /dev/null @@ -1,78 +0,0 @@ -section .bss - start resd 1 - end resd 1 - -section .data - array dd 1, 2, 3, ..., 100 ; Replace ... with remaining numbers - sum dd 0 - -section .text - global asm_main - extern print_int, read_int, print_string - -asm_main: - ; Prompt for range - push message_start - call print_string - add rsp, 8 - push start - call read_int - add rsp, 8 - - push message_end - call print_string - add rsp, 8 - push end - call read_int - add rsp, 8 - - ; Validate range - mov eax, [start] - cmp eax, 1 - jl invalid - mov ebx, [end] - cmp ebx, 100 - jg invalid - cmp eax, ebx - jg invalid - - ; Calculate sum - xor ecx, ecx - mov esi, array - sub eax, 1 - imul eax, eax, 4 - add esi, eax - mov ecx, ebx - sub ecx, eax ; Range length - -sum_range: - add eax, [esi] - add esi, 4 - loop sum_range - - push eax - call print_int - add rsp, 8 - ret - -invalid: - push error_message - call print_string - add rsp, 8 - ret - -section .data - message_start db "Enter start of range (1-100): ", 0 - message_end db "Enter end of range (1-100): ", 0 - error_message db "Invalid range!", 0 - -array dd 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, - 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, - 91, 92, 93, 94, 95, 96, 97, 98, 99, 100 -- GitLab