Create learn asm repo
Repository for learning assembly language
This commit is contained in:
commit
9165f49e62
4
info
Normal file
4
info
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
https://asmtutor.com/
|
||||
|
||||
https://www.chromium.org/chromium-os/developer-library/reference/linux-constants/syscalls/#x86-32-bit
|
||||
BIN
lesson1/l1
Executable file
BIN
lesson1/l1
Executable file
Binary file not shown.
16
lesson1/l1.asm
Normal file
16
lesson1/l1.asm
Normal file
@ -0,0 +1,16 @@
|
||||
; Lesson 1
|
||||
; nasm -f elf l1.asm
|
||||
; ld -m elf_i386 l1.o -o l1
|
||||
|
||||
SECTION .data
|
||||
msg db 'Hello, World!', 0Ah
|
||||
|
||||
SECTION .text
|
||||
global _start
|
||||
|
||||
_start:
|
||||
mov edx, 13
|
||||
mov ecx, msg
|
||||
mov ebx, 1
|
||||
mov eax, 4
|
||||
int 80h
|
||||
BIN
lesson1/l1.o
Normal file
BIN
lesson1/l1.o
Normal file
Binary file not shown.
BIN
lesson2/l2
Executable file
BIN
lesson2/l2
Executable file
Binary file not shown.
17
lesson2/l2.asm
Normal file
17
lesson2/l2.asm
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
SECTION .data
|
||||
msg db 'cat!', 0Ah
|
||||
|
||||
SECTION .text
|
||||
global _start
|
||||
|
||||
_start:
|
||||
mov edx, 5
|
||||
mov ecx, msg
|
||||
mov ebx, 1
|
||||
mov eax, 4
|
||||
int 80h
|
||||
|
||||
mov ebx, 0
|
||||
mov eax, 1
|
||||
int 80h
|
||||
BIN
lesson2/l2.o
Normal file
BIN
lesson2/l2.o
Normal file
Binary file not shown.
BIN
lesson3/l3
Executable file
BIN
lesson3/l3
Executable file
Binary file not shown.
28
lesson3/l3.asm
Normal file
28
lesson3/l3.asm
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
SECTION .data
|
||||
msg db 'Le Chat!', 0Ah
|
||||
|
||||
SECTION .text
|
||||
global _start
|
||||
|
||||
_start:
|
||||
mov ebx, msg
|
||||
mov eax, ebx
|
||||
|
||||
nextchar:
|
||||
cmp byte [eax], 0
|
||||
jz finished
|
||||
inc eax
|
||||
jmp nextchar
|
||||
|
||||
finished:
|
||||
sub eax, ebx
|
||||
mov edx, eax
|
||||
mov ecx, msg
|
||||
mov ebx, 1
|
||||
mov eax, 4
|
||||
int 80h
|
||||
|
||||
mov ebx, 0
|
||||
mov eax, 1
|
||||
int 80h
|
||||
BIN
lesson3/l3.o
Normal file
BIN
lesson3/l3.o
Normal file
Binary file not shown.
BIN
lesson3/l3i
Executable file
BIN
lesson3/l3i
Executable file
Binary file not shown.
26
lesson3/l3i.asm
Normal file
26
lesson3/l3i.asm
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
SECTION .data
|
||||
msg db 'Le Chat!', 0Ah
|
||||
|
||||
SECTION .text
|
||||
global _start
|
||||
|
||||
_start:
|
||||
mov ecx, msg
|
||||
mov edx, ecx
|
||||
|
||||
nextchar:
|
||||
cmp byte [edx], 0
|
||||
jz finished
|
||||
inc edx
|
||||
jmp nextchar
|
||||
|
||||
finished:
|
||||
sub edx, ecx
|
||||
mov ebx, 1
|
||||
mov eax, 4
|
||||
int 80h
|
||||
|
||||
mov ebx, 0
|
||||
mov eax, 1
|
||||
int 80h
|
||||
BIN
lesson3/l3i.o
Normal file
BIN
lesson3/l3i.o
Normal file
Binary file not shown.
BIN
lesson4/l4
Executable file
BIN
lesson4/l4
Executable file
Binary file not shown.
34
lesson4/l4.asm
Normal file
34
lesson4/l4.asm
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
SECTION .data
|
||||
msg db 'A cat!', 0Ah
|
||||
|
||||
SECTION .text
|
||||
global _start
|
||||
|
||||
_start:
|
||||
mov edx, msg
|
||||
call strlen
|
||||
|
||||
mov ecx, msg
|
||||
mov ebx, 1
|
||||
mov eax, 4
|
||||
int 80h
|
||||
|
||||
mov ebx, 0
|
||||
mov eax, 1
|
||||
int 80h
|
||||
|
||||
strlen:
|
||||
push ebx
|
||||
mov ebx, edx
|
||||
|
||||
nextchar:
|
||||
cmp byte [edx], 0
|
||||
jz finished
|
||||
inc edx
|
||||
jmp nextchar
|
||||
|
||||
finished:
|
||||
sub edx, ebx
|
||||
pop ebx
|
||||
ret
|
||||
BIN
lesson4/l4.o
Normal file
BIN
lesson4/l4.o
Normal file
Binary file not shown.
BIN
lesson5/l5
Executable file
BIN
lesson5/l5
Executable file
Binary file not shown.
18
lesson5/l5.asm
Normal file
18
lesson5/l5.asm
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
%include '../lib/fl.asm'
|
||||
|
||||
SECTION .data
|
||||
msg1 db 'Cats and', 0Ah
|
||||
msg2 db 'Dogs', 0Ah
|
||||
|
||||
SECTION .text
|
||||
global _start
|
||||
|
||||
_start:
|
||||
mov eax, msg1
|
||||
call sprint
|
||||
|
||||
mov eax, msg2
|
||||
call sprint
|
||||
|
||||
call quit
|
||||
BIN
lesson5/l5.o
Normal file
BIN
lesson5/l5.o
Normal file
Binary file not shown.
45
lib/fl.asm
Normal file
45
lib/fl.asm
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
slen:
|
||||
push ebx
|
||||
mov ebx, eax
|
||||
|
||||
nextchar:
|
||||
cmp byte [eax], 0
|
||||
jz finished
|
||||
inc eax
|
||||
jmp nextchar
|
||||
|
||||
finished:
|
||||
sub eax, ebx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
|
||||
|
||||
sprint:
|
||||
push edx
|
||||
push ecx
|
||||
push ebx
|
||||
push eax
|
||||
call slen
|
||||
|
||||
mov edx, eax
|
||||
pop eax
|
||||
|
||||
mov ecx, eax
|
||||
mov ebx, 1
|
||||
mov eax, 4
|
||||
int 80h
|
||||
|
||||
pop ebx
|
||||
pop ecx
|
||||
pop edx
|
||||
ret
|
||||
|
||||
|
||||
|
||||
quit:
|
||||
mov ebx, 0
|
||||
mov eax, 1
|
||||
int 80h
|
||||
ret
|
||||
Loading…
x
Reference in New Issue
Block a user