diff --git a/risc-v/Makefile b/risc-v/Makefile index b0e47f4..2339473 100644 --- a/risc-v/Makefile +++ b/risc-v/Makefile @@ -1,4 +1,4 @@ default: rm -rf hello - riscv64-linux-gnu-as hello.s -o hello.o - riscv64-linux-gnu-gcc -o hello hello.s -nostdlib -static + riscv64-linux-gnu-as main.asm -o main.o + riscv64-linux-gnu-gcc -o main main.asm -nostdlib -static diff --git a/risc-v/hello b/risc-v/hello deleted file mode 100755 index f175cbe..0000000 Binary files a/risc-v/hello and /dev/null differ diff --git a/risc-v/main.o b/risc-v/main.o new file mode 100644 index 0000000..3a9cc95 Binary files /dev/null and b/risc-v/main.o differ diff --git a/risc-v/main.s b/risc-v/main.s new file mode 100644 index 0000000..c9b8ade --- /dev/null +++ b/risc-v/main.s @@ -0,0 +1,18 @@ +.globl __start + +.data +msg: + .string "Hello World!" + .byte 0 +.text + +__start: + LA a0, msg + li a7, 4 + ecall + + j Shutdown + +Shutdown: + li a7, 10 + ecall diff --git a/x86/exit_project/exit b/x86/exit_project/exit new file mode 100755 index 0000000..8627193 Binary files /dev/null and b/x86/exit_project/exit differ diff --git a/x86/exit_project/exit.o b/x86/exit_project/exit.o new file mode 100644 index 0000000..5bfb1c2 Binary files /dev/null and b/x86/exit_project/exit.o differ diff --git a/x86/exit_project/exit.s b/x86/exit_project/exit.s new file mode 100644 index 0000000..bb0eced --- /dev/null +++ b/x86/exit_project/exit.s @@ -0,0 +1,10 @@ +.section .data + +.section .text + +.globl _start +_start: + movl $1, %eax + movl $0, %ebx + + int $0x80 diff --git a/x86/maximum/att/maximum b/x86/maximum/att/maximum new file mode 100755 index 0000000..c462d0a Binary files /dev/null and b/x86/maximum/att/maximum differ diff --git a/x86/maximum/att/maximum.o b/x86/maximum/att/maximum.o new file mode 100644 index 0000000..81e88cb Binary files /dev/null and b/x86/maximum/att/maximum.o differ diff --git a/x86/maximum/att/maximum.s b/x86/maximum/att/maximum.s new file mode 100644 index 0000000..13504c7 --- /dev/null +++ b/x86/maximum/att/maximum.s @@ -0,0 +1,38 @@ +# VARIABLES: The registers have the following uses: +# +# %edi - Holds the index of the data item being examined +# %ebx - Largest data item found +# %eax - Current data item +# +# The following memory locations are used: +# +# data_items - contains the item data. A 0 is used to terminate the data +# + +.section .data + +data_items: + .long 3, 67, 34, 222, 45, 75, 54, 34, 44, 33, 22, 11, 66, 0 + +.section .text + +.globl _start +_start: + movl $0, %edi + movl data_items(, %edi, 4), %eax + movl %eax, %ebx + +start_loop: + cmpl $0, %eax + je loop_exit + incl %edi + movl data_items(,%edi,4), %eax + cmpl %ebx, %eax + jle start_loop + + movl %eax, %ebx + jmp start_loop + +loop_exit: + movl $1, %eax + int $0x80 diff --git a/x86/maximum/intel/Makefile b/x86/maximum/intel/Makefile new file mode 100644 index 0000000..d9a879a --- /dev/null +++ b/x86/maximum/intel/Makefile @@ -0,0 +1,3 @@ +default: + as maximum.asm --32 -o maximum.o + gcc -o maximum.elf -m32 maximum.o -nostdlib diff --git a/x86/maximum/intel/maximum b/x86/maximum/intel/maximum new file mode 100755 index 0000000..0bdbabc Binary files /dev/null and b/x86/maximum/intel/maximum differ diff --git a/x86/maximum/intel/maximum.asm b/x86/maximum/intel/maximum.asm new file mode 100644 index 0000000..7571fbb --- /dev/null +++ b/x86/maximum/intel/maximum.asm @@ -0,0 +1,33 @@ +# edi = index of data_items +# ebx = largest data item found +# eax = current data item + +.global _start +.intel_syntax noprefix +.section .text + +_start: + mov edi, 0 # copy 0 into edi - first addresss + mov eax, [data_items + edi * 4] # move the first number (edi * 4) to eax + mov ebx, eax # move ebx to eax + jmp start_loop + +start_loop: + cmp eax, 0 # check if eax is 0, return value stored in EFLAGS register + je loop_exit # checks EFLAGS if cmp is equal + inc edi # move to the next number (increase index which is edi) + + mov eax, [data_items + edi * 4] # move the next number (edi * 4) to eax + cmp eax, ebx # compare largest item (ebx) to current item (eax) + jle start_loop # if eax is less than ebx - jump to start_loop + + mov ebx, eax # move eax to ebx + jmp start_loop # jump back to start_loop + +loop_exit: + mov eax, 1 # move '1' into eax (exit syscall) + int 0x80 # call kernel interrupt to exit program + +.section .data + data_items: + .long 3, 67, 34, 222, 45, 75, 54, 34, 44, 33, 22, 11, 66, 0 diff --git a/x86/maximum/intel/maximum.elf b/x86/maximum/intel/maximum.elf new file mode 100755 index 0000000..11292bb Binary files /dev/null and b/x86/maximum/intel/maximum.elf differ diff --git a/x86/maximum/intel/maximum.o b/x86/maximum/intel/maximum.o new file mode 100644 index 0000000..4aa062f Binary files /dev/null and b/x86/maximum/intel/maximum.o differ