diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..6d4965f --- /dev/null +++ b/build.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +FILE="lesson$1/l$1" + +nasm -f elf $FILE.asm -o $FILE.o +ld -m elf_i386 $FILE.o -o $FILE + +if [ "$2" = "r" ] +then + ./$FILE +fi diff --git a/lesson10/l10 b/lesson10/l10 new file mode 100755 index 0000000..b36f8b9 Binary files /dev/null and b/lesson10/l10 differ diff --git a/lesson10/l10.asm b/lesson10/l10.asm new file mode 100644 index 0000000..aa6b926 --- /dev/null +++ b/lesson10/l10.asm @@ -0,0 +1,24 @@ + +; %include '../lib/fl.asm' ; local +%include 'lib/fl.asm' ; build.sh + +SECTION .text +global _start + +_start: +mov ecx, 0 + +nextNumber: +inc ecx + +mov eax, ecx +add eax, 48 +push eax +mov eax, esp +call sprintLF + +pop eax +cmp ecx, 10 +jne nextNumber + +call quit diff --git a/lesson10/l10.o b/lesson10/l10.o new file mode 100644 index 0000000..bd45660 Binary files /dev/null and b/lesson10/l10.o differ diff --git a/lesson5/l5.asm b/lesson5/l5.asm index 8a419b1..38228af 100644 --- a/lesson5/l5.asm +++ b/lesson5/l5.asm @@ -1,5 +1,6 @@ -%include '../lib/fl.asm' +; %include '../lib/fl.asm' ; local +%include 'lib/fl.asm' ; build.sh SECTION .data msg1 db 'Cats and', 0Ah diff --git a/lesson6/l6 b/lesson6/l6 new file mode 100755 index 0000000..e6a70c6 Binary files /dev/null and b/lesson6/l6 differ diff --git a/lesson6/l6.asm b/lesson6/l6.asm new file mode 100644 index 0000000..77e6ee7 --- /dev/null +++ b/lesson6/l6.asm @@ -0,0 +1,19 @@ + +; %include '../lib/fl.asm' ; local +%include 'lib/fl.asm' ; build.sh + +SECTION .data +msg1 db 'Cats and', 0Ah, 0h +msg2 db 'Dogs', 0Ah, 0h + +SECTION .text +global _start + +_start: +mov eax, msg1 +call sprint + +mov eax, msg2 +call sprint + +call quit diff --git a/lesson6/l6.o b/lesson6/l6.o new file mode 100644 index 0000000..9cbdad7 Binary files /dev/null and b/lesson6/l6.o differ diff --git a/lesson7/l7 b/lesson7/l7 new file mode 100755 index 0000000..97319b3 Binary files /dev/null and b/lesson7/l7 differ diff --git a/lesson7/l7.asm b/lesson7/l7.asm new file mode 100644 index 0000000..490dea9 --- /dev/null +++ b/lesson7/l7.asm @@ -0,0 +1,19 @@ + +; %include '../lib/fl.asm' ; local +%include 'lib/fl.asm' ; build.sh + +SECTION .data +msg1 db 'Cats and', 0h +msg2 db 'Dogs', 0h + +SECTION .text +global _start + +_start: +mov eax, msg1 +call sprintLF + +mov eax, msg2 +call sprintLF + +call quit diff --git a/lesson7/l7.o b/lesson7/l7.o new file mode 100644 index 0000000..ed01412 Binary files /dev/null and b/lesson7/l7.o differ diff --git a/lesson8/l8 b/lesson8/l8 new file mode 100755 index 0000000..4f1dca4 Binary files /dev/null and b/lesson8/l8 differ diff --git a/lesson8/l8.asm b/lesson8/l8.asm new file mode 100644 index 0000000..e605938 --- /dev/null +++ b/lesson8/l8.asm @@ -0,0 +1,20 @@ + +; %include '../lib/fl.asm' ; local +%include 'lib/fl.asm' ; build.sh + +SECTION .text +global _start: + +_start: +pop ecx + +nextArg: +cmp ecx, 0h +jz noMoreArgs +pop eax +call sprintLF +dec ecx +jmp nextArg + +noMoreArgs: +call quit diff --git a/lesson8/l8.o b/lesson8/l8.o new file mode 100644 index 0000000..b05524a Binary files /dev/null and b/lesson8/l8.o differ diff --git a/lesson9/l9 b/lesson9/l9 new file mode 100755 index 0000000..26523ad Binary files /dev/null and b/lesson9/l9 differ diff --git a/lesson9/l9.asm b/lesson9/l9.asm new file mode 100644 index 0000000..6529c22 --- /dev/null +++ b/lesson9/l9.asm @@ -0,0 +1,31 @@ + +; %include '../lib/fl.asm' ; local +%include 'lib/fl.asm' ; build.sh + +SECTION .data +msg1 db 'Gii du namma lea?: ', 0h +msg2 db 'Bures, ', 0h + +SECTION .bss +sinput: resb 255 + +SECTION .text +global _start + +_start: +mov eax, msg1 +call sprint + +mov edx, 255 +mov ecx, sinput +mov ebx, 0h +mov eax, 3 +int 80h + +mov eax, msg2 +call sprint + +mov eax, sinput +call sprint + +call quit diff --git a/lesson9/l9.o b/lesson9/l9.o new file mode 100644 index 0000000..4cb809f Binary files /dev/null and b/lesson9/l9.o differ diff --git a/lib/fl.asm b/lib/fl.asm index 03bcf45..cd1af23 100644 --- a/lib/fl.asm +++ b/lib/fl.asm @@ -1,4 +1,6 @@ - +;------------------------------------------ +; int slen(String message) +; String length calculation function slen: push ebx mov ebx, eax @@ -16,6 +18,9 @@ ret +;------------------------------------------ +; void sprint(String message) +; String printing function sprint: push edx push ecx @@ -38,6 +43,27 @@ ret +;------------------------------------------ +; void sprintLF(String message) +; String printing with line feed function +sprintLF: +call sprint + +push eax +mov eax, 0Ah +push eax + +mov eax, esp +call sprint +pop eax +pop eax +ret + + + +;------------------------------------------ +; void exit() +; Exit program and restore resources quit: mov ebx, 0 mov eax, 1