Added build script and continued to lesson 10
This commit is contained in:
parent
9165f49e62
commit
6a824fbbda
11
build.sh
Executable file
11
build.sh
Executable 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
|
||||
BIN
lesson10/l10
Executable file
BIN
lesson10/l10
Executable file
Binary file not shown.
24
lesson10/l10.asm
Normal file
24
lesson10/l10.asm
Normal 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
lesson10/l10.o
Normal file
BIN
lesson10/l10.o
Normal file
Binary file not shown.
@ -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
|
||||
|
||||
BIN
lesson6/l6
Executable file
BIN
lesson6/l6
Executable file
Binary file not shown.
19
lesson6/l6.asm
Normal file
19
lesson6/l6.asm
Normal 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
lesson6/l6.o
Normal file
BIN
lesson6/l6.o
Normal file
Binary file not shown.
BIN
lesson7/l7
Executable file
BIN
lesson7/l7
Executable file
Binary file not shown.
19
lesson7/l7.asm
Normal file
19
lesson7/l7.asm
Normal 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
lesson7/l7.o
Normal file
BIN
lesson7/l7.o
Normal file
Binary file not shown.
BIN
lesson8/l8
Executable file
BIN
lesson8/l8
Executable file
Binary file not shown.
20
lesson8/l8.asm
Normal file
20
lesson8/l8.asm
Normal 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
lesson8/l8.o
Normal file
BIN
lesson8/l8.o
Normal file
Binary file not shown.
BIN
lesson9/l9
Executable file
BIN
lesson9/l9
Executable file
Binary file not shown.
31
lesson9/l9.asm
Normal file
31
lesson9/l9.asm
Normal 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
lesson9/l9.o
Normal file
BIN
lesson9/l9.o
Normal file
Binary file not shown.
28
lib/fl.asm
28
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user