Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
wk2 homework
- Loading branch information
Sergiu Harjau
committed
Feb 4, 2019
1 parent
400fd34
commit 1d329d8eca1376a49f782aeb46a63ca5998a84d9
Showing
7 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
BIN
+1 KB
207SE/wk2/a.out
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
BIN
+1008 Bytes
207SE/wk2/dumbStars.o
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
BIN
+640 Bytes
207SE/wk2/hello.o
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
BIN
+976 Bytes
207SE/wk2/stars.o
Binary file not shown.