diff --git a/207SE/wk2/a.out b/207SE/wk2/a.out new file mode 100755 index 0000000..9d9bc71 Binary files /dev/null and b/207SE/wk2/a.out differ diff --git a/207SE/wk2/dumbStars.asm b/207SE/wk2/dumbStars.asm new file mode 100644 index 0000000..b066a71 --- /dev/null +++ b/207SE/wk2/dumbStars.asm @@ -0,0 +1,69 @@ +section .data ;Data segment + + star1 db '*', 0x0a ;new lines + lenStar1 equ $-star1 + star2 db '**', 0x0a + lenStar2 equ $-star2 + star3 db '***', 0x0a + lenStar3 equ $-star3 + star4 db '****', 0x0a + lenStar4 equ $-star4 + star5 db '*****', 0x0a + lenStar5 equ $-star5 + + newLine db '0x0a' + lenNL equ $-newLine + +section .text ;Code Segment + global _start + +_start: ;User prompt + mov eax, 4 + mov ebx, 1 + mov ecx, star1 + mov edx, lenStar1 + int 0x80 + + mov eax, 4 + mov ebx, 1 + mov ecx, star2 + mov edx, lenStar2 + int 0x80 + + mov eax, 4 + mov ebx, 1 + mov ecx, star3 + mov edx, lenStar3 + int 0x80 + + mov eax, 4 + mov ebx, 1 + mov ecx, star4 + mov edx, lenStar4 + int 0x80 + + mov eax, 4 + mov ebx, 1 + mov ecx, star5 + mov edx, lenStar5 + int 0x80 + +;exit condition + + mov eax, 1 + mov ebx, 0 + int 0x80 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/207SE/wk2/dumbStars.o b/207SE/wk2/dumbStars.o new file mode 100644 index 0000000..80ea2ec Binary files /dev/null and b/207SE/wk2/dumbStars.o differ diff --git a/207SE/wk2/hello.asm b/207SE/wk2/hello.asm new file mode 100644 index 0000000..1c2958e --- /dev/null +++ b/207SE/wk2/hello.asm @@ -0,0 +1,17 @@ +global _start + +section .data + msg db "Hello, word!", 0x0a + len equ $ - msg + +section .text +_start: + mov eax, 4 ; sys_write system call + mov ebx, 1 ; stdout file descriptor + mov ecx, msg ; bytes to write + mov edx, len ; numbeer of bytes to write + int 0x80 ; perform system call + + mov eax, 1 ; sys_exit system call + mov ebx, 0 ; exit status 0 + int 0x80 ; perform system call \ No newline at end of file diff --git a/207SE/wk2/hello.o b/207SE/wk2/hello.o new file mode 100644 index 0000000..83dd2ff Binary files /dev/null and b/207SE/wk2/hello.o differ diff --git a/207SE/wk2/stars.asm b/207SE/wk2/stars.asm new file mode 100644 index 0000000..9ddedfd --- /dev/null +++ b/207SE/wk2/stars.asm @@ -0,0 +1,85 @@ +section .data ;Data segment + userMsg db 'Please enter a number: ' ;Ask the user to enter a number + lenUserMsg equ $-userMsg ;The length of the message + plus db '+' + lenPlus equ $-plus + + newLine db '0x0a' + lenNL equ $-newLine + +section .bss ;Uninitialized data + num resb 5 + +section .text ;Code Segment + global _start + +_start: ;User prompt + mov eax, 4 + mov ebx, 1 + mov ecx, userMsg + mov edx, lenUserMsg + int 0x80 + + ;Read and store the user input + mov eax, 3 + mov ebx, 2 + + mov ecx, num ;your input is not an int, but a string. help. + + mov edx, 5 ;5 bytes (numeric, 1 for sign) of that information + int 0x80 + +label: + + mov esi, 4 + mov ebp, 35 + mov edi, 0 + jmp stars + + + mov esi, 3 + mov ebp, 42 + mov edi, 0 + jmp stars + + ; Exit code + + mov eax, 1 + mov ebx, 0 + int 0x80 + + +stars: ;prints amount of stars in esi then returns to ebp line + + mov eax, 4 ; system write + mov ebx, 1 ; exit code + + mov ecx, plus ; this is what we write + mov edx, lenPlus ; this is how many bytes we write + + int 0x80 ;write it + + inc edi + + cmp edi, esi + jl stars ; if edi is lower than esi, write another star + + mov ecx, newLine + mov edx, lenNL + + int 0x80 ;add a newline + + jmp ebp ;jump back to origin + + + + + + + + + + + + + \ No newline at end of file diff --git a/207SE/wk2/stars.o b/207SE/wk2/stars.o new file mode 100644 index 0000000..78ebd81 Binary files /dev/null and b/207SE/wk2/stars.o differ