Added build script and continued to lesson 10

This commit is contained in:
2025-06-22 21:03:18 +03:00
parent 9165f49e62
commit 6a824fbbda
18 changed files with 153 additions and 2 deletions
Executable
+11
View File
@@ -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
Executable
BIN
View File
Binary file not shown.
+24
View File
@@ -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
BIN
View File
Binary file not shown.
+2 -1
View File
@@ -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
Executable
BIN
View File
Binary file not shown.
+19
View File
@@ -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
BIN
View File
Binary file not shown.
Executable
BIN
View File
Binary file not shown.
+19
View File
@@ -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
BIN
View File
Binary file not shown.
Executable
BIN
View File
Binary file not shown.
+20
View File
@@ -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
BIN
View File
Binary file not shown.
Executable
BIN
View File
Binary file not shown.
+31
View File
@@ -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
BIN
View File
Binary file not shown.
+27 -1
View File
@@ -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