-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7d3a769
Showing
226 changed files
with
9,021 additions
and
0 deletions.
There are no files selected for viewing
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,28 @@ | ||
; Hello World Program (Count to 10) | ||
; Compile with: nasm -f elf helloworld-10.asm | ||
; Link with (64 bit systems require elf_i386 option): ld -m elf_i386 helloworld-10.o -o helloworld-10 | ||
; Run with: ./helloworld-10 | ||
%include 'functions.asm' | ||
SECTION .text | ||
global _start | ||
_start: | ||
mov ecx, 0 ; ecx is initalised to zero. | ||
nextNumber: | ||
inc ecx ; increment ecx | ||
mov eax, ecx ; move the address of our integer into eax | ||
add eax, 48 ; add 48 to our number to convert from integer to ascii for printing | ||
push eax ; push eax to the stack | ||
mov eax, esp ; get the address of the character on the stack | ||
call sprintLF ; call our print function | ||
pop eax ; clean up the stack so we don't have unneeded bytes taking up space | ||
cmp ecx, 10 ; have we reached 10 yet? compare our counter with decimal 10 | ||
jne nextNumber ; jump if not equal and keep counting | ||
call quit |
Binary file not shown.
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,22 @@ | ||
; Hello World Program (Count to 10 itoa) | ||
; Compile with: nasm -f elf helloworld-itoa.asm | ||
; Link with (64 bit systems require elf_i386 option): ld -m elf_i386 helloworld-itoa.o -o helloworld-itoa | ||
; Run with: ./helloworld-itoa | ||
%include 'functions.asm' | ||
SECTION .text | ||
global _start | ||
_start: | ||
mov ecx, 0 | ||
nextNumber: | ||
inc ecx | ||
mov eax, ecx | ||
call iprintLF ; NOTE call our new integer printing function (itoa) | ||
cmp ecx, 100000 | ||
jne nextNumber | ||
call quit |
Binary file not shown.
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,82 @@ | ||
%include 'functions.asm' | ||
|
||
section .data | ||
title db "Ceasar Cipher!",0h | ||
format db "-------------------------------------------",0h | ||
msg db "Plaintext string is:",0h | ||
plaintext db "Love Assembly programming",0h | ||
stringlen db "String length is:",0h | ||
ciphertext db "Encrypted text:",0h | ||
key db 3 | ||
alphabet: db 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' | ||
section .bss | ||
strlen db 2 | ||
ciphertext db 254 | ||
section .text | ||
global _start | ||
|
||
|
||
_start: | ||
;Title of program | ||
mov eax,format | ||
call sprintLF | ||
mov eax,title | ||
call sprintLF | ||
mov eax,format | ||
call sprintLF | ||
|
||
;print the plaintext | ||
mov eax,msg | ||
call sprint | ||
mov eax,plaintext | ||
call sprintLF | ||
|
||
;get plaintext length and print it | ||
mov eax,plaintext | ||
call slen | ||
push eax | ||
mov eax,stringlen | ||
call sprint | ||
pop eax | ||
mov [strlen],eax | ||
call iprintLF | ||
|
||
|
||
assign: | ||
mov ebx,0 | ||
jmp getpos | ||
|
||
getpos: | ||
cmp [alphabet+ebx],eax | ||
je pos | ||
inc ebx | ||
jmp getpos | ||
|
||
pos: | ||
push ebx | ||
ret | ||
|
||
Encrypt: | ||
mov edx,0 | ||
cmp [strlen],ecx | ||
je exit | ||
mov eax,byte[plaintext+edx] | ||
call getpos | ||
pop e | ||
|
||
|
||
exit: | ||
call quit | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
Binary file not shown.
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,46 @@ | ||
;args passed to an asm prog are loaded in reverse order | ||
;The name of the program is then loaded onto the stack | ||
;and lastly the total number of arguments is loaded onto the stack. | ||
section .text | ||
global _start | ||
|
||
_start: | ||
;The last two stack items for a NASM compiled program | ||
;are always the name of the program and the number of | ||
;passed arguments,pop the first value, no of args from stack | ||
pop ecx | ||
|
||
;iterate through the args | ||
nextarg: | ||
cmp ecx,0h | ||
jz exit ;if equal exit program | ||
pop eax ; pop the next argument off the stack | ||
call createdirs ;call createDirs func | ||
dec ecx ;mov to next arg.You dec ecx by 1 | ||
jmp nextarg ;iterate | ||
|
||
|
||
;create dirs function | ||
createdirs: | ||
|
||
;save registers | ||
push ebx | ||
push ecx | ||
push eax | ||
|
||
mov ebx,eax ;get dirname | ||
mov ecx,0666 ;add file permission e.g. 0777 | ||
mov eax,39 ;sys_mkdir | ||
int 80h;call kernel | ||
|
||
;restore registers | ||
pop eax ;pop registers in LIFO order | ||
pop ecx | ||
pop ebx | ||
ret | ||
|
||
;exit prog | ||
exit: | ||
mov eax,1 | ||
int 80h | ||
|
Binary file not shown.
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,45 @@ | ||
%include 'functions.asm' | ||
section .data | ||
design db '***********************',0h | ||
msg db 'Even Numbers',0h | ||
|
||
section .text | ||
global _start | ||
|
||
_start: | ||
|
||
decorate: | ||
mov eax,design | ||
call sprintLF | ||
mov eax,msg | ||
call sprintLF | ||
mov eax,design | ||
call sprintLF | ||
mov ecx,1 | ||
|
||
|
||
|
||
even: | ||
cmp ecx,20 | ||
je exit | ||
mov eax,ecx | ||
mov ebx,2 | ||
div ebx | ||
mov esi,edx | ||
cmp esi,0 | ||
je printf | ||
inc ecx | ||
jmp even | ||
|
||
|
||
printf: | ||
mov eax,ecx | ||
call iprintLF | ||
inc ecx | ||
jmp even | ||
|
||
exit: | ||
call quit | ||
|
||
|
||
|
Binary file not shown.
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,74 @@ | ||
%include 'functions.asm' | ||
section .data | ||
input db "Enter range:",0h | ||
fiboseries db "Fibonacci series of range: ",0h | ||
line db "-----------------------------------",0h | ||
comma db "," | ||
end db "",0h | ||
section .bss | ||
;reservered variables spaces | ||
first resd 1 | ||
second resd 1 | ||
next resw 1 | ||
range resw 1 | ||
count resw 1 | ||
section .text | ||
global _start | ||
_start: | ||
; User prompt | ||
;mov eax,input | ||
;call sprint | ||
; Print range message and input | ||
mov eax,fiboseries | ||
call sprint | ||
; Get Input failed manually enter range | ||
mov eax, 10 | ||
mov [range], eax | ||
mov ecx,range | ||
call iprintLF | ||
; initilise primes | ||
mov ebx,0 | ||
mov dword[first],0 | ||
mov dword[second],1 | ||
main_loop: | ||
inc ebx | ||
mov eax, dword[first] | ||
call iprint | ||
mov eax,comma | ||
call sprint | ||
mov eax, dword[second] | ||
call iprint | ||
mov eax,comma | ||
call sprint | ||
mov eax, dword[second] | ||
add dword[first],eax | ||
mov eax, dword[first] | ||
add dword[second],eax | ||
cmp ebx,[range] | ||
jne main_loop | ||
exit: | ||
mov eax,end | ||
call sprintLF | ||
call quit | ||
getInput: | ||
mov eax,3 | ||
mov ebx,2 | ||
mov ecx,range | ||
mov edx,2 | ||
int 80h | ||
ret |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.