diff --git a/laborator/content/introducere-asamblare/1-2-hello-world/hello_world b/laborator/content/introducere-asamblare/1-2-hello-world/hello_world new file mode 100755 index 00000000..f96687c3 Binary files /dev/null and b/laborator/content/introducere-asamblare/1-2-hello-world/hello_world differ diff --git a/laborator/content/introducere-asamblare/1-2-hello-world/hello_world.asm b/laborator/content/introducere-asamblare/1-2-hello-world/hello_world.asm index 7f8a337b..dd248e1f 100644 --- a/laborator/content/introducere-asamblare/1-2-hello-world/hello_world.asm +++ b/laborator/content/introducere-asamblare/1-2-hello-world/hello_world.asm @@ -2,6 +2,7 @@ section .data myString: db "Hello, World!", 0 + myownString: db "Goodbye, World!", 0 section .text global main @@ -12,12 +13,13 @@ main: mov eax, 1 mov ebx, 1 cmp eax, ebx - je print ; TODO1: eax > ebx? + je print ; TODO1: eax > ebx? ret print: PRINTF32 `%s\n\x0`, myString - ; TODO2.2: afisati "Hello, World!" de N ori - ; TODO2.1: afisati "Goodbye, World!" - + sub ecx,eax + cmp ecx,0 + jne print ; TODO2.2: afisati "Hello, World!" de N ori + je PRINTF32 `%s\n\x0`, myownString ; TODO2.1: afisati "Goodbye, World!"PRINTF32 `%s\n\x1`, myownString ret diff --git a/laborator/content/introducere-asamblare/3-grumpy-jumps/grumpy_jumps b/laborator/content/introducere-asamblare/3-grumpy-jumps/grumpy_jumps new file mode 100755 index 00000000..be677770 Binary files /dev/null and b/laborator/content/introducere-asamblare/3-grumpy-jumps/grumpy_jumps differ diff --git a/laborator/content/introducere-asamblare/3-grumpy-jumps/grumpy_jumps.asm b/laborator/content/introducere-asamblare/3-grumpy-jumps/grumpy_jumps.asm index b35ff63e..8cc18e2a 100644 --- a/laborator/content/introducere-asamblare/3-grumpy-jumps/grumpy_jumps.asm +++ b/laborator/content/introducere-asamblare/3-grumpy-jumps/grumpy_jumps.asm @@ -9,8 +9,8 @@ section .text extern printf main: - mov eax, 0xdeadc0de ; TODO3.1: modify eax register - mov ebx, 0x1337ca5e ; TODO3.1: modify ebx register + mov eax, 0x1 ; TODO3.1: modify eax register + mov ebx, 0x4 ; TODO3.1: modify ebx register mov ecx, 0x5 ; hardcoded; DO NOT change cmp eax, ebx jns bad @@ -19,10 +19,9 @@ main: add eax, ebx xor eax, ecx jnz bad - good: PRINTF32 `%s\n\x0`, right - + ret bad: PRINTF32 `%s\n\x0`, wrong ret diff --git a/laborator/content/introducere-asamblare/4-sets/sets b/laborator/content/introducere-asamblare/4-sets/sets new file mode 100755 index 00000000..4a652d21 Binary files /dev/null and b/laborator/content/introducere-asamblare/4-sets/sets differ diff --git a/laborator/content/introducere-asamblare/4-sets/sets.asm b/laborator/content/introducere-asamblare/4-sets/sets.asm index e6f58d5f..d8e05b33 100644 --- a/laborator/content/introducere-asamblare/4-sets/sets.asm +++ b/laborator/content/introducere-asamblare/4-sets/sets.asm @@ -12,22 +12,38 @@ main: PRINTF32 `%u\n\x0`, ebx ; afiseaza cea de-a doua multime ; TODO1: reuniunea a doua multimi - + mov ecx, eax + or ecx, ebx + PRINTF32 `%u\n\x0`, ecx ; afiseaza prima multime ; TODO2: adaugarea unui element in multime - + mov ecx, eax + or ecx, 0x22 + PRINTF32 `%u\n\x0`, ecx ; afiseaza prima multime ; TODO3: intersectia a doua multimi - + mov ecx, eax + mov edx, eax + xor ecx, ebx + sub edx,ecx + PRINTF32 `%u\n\x0`, edx ; afiseaza prima multime ; TODO4: complementul unei multimi - + mov ecx, eax + not ecx + and ecx, 0x00000111 ;il aducem in 4 biti + PRINTF32 `%u\n\x0`, ecx ; afiseaza prima multime ; TODO5: eliminarea unui element - + mov ecx, eax + mov edx, 0x17 + not edx + and ecx,edx + PRINTF32 `%u\n\x0`, ecx ; afiseaza prima multime ; TODO6: diferenta de multimi EAX-EBX - + xor eax,ebx + PRINTF32 `%u\n\x0`, eax xor eax, eax ret diff --git a/laborator/content/introducere-asamblare/5-min/min b/laborator/content/introducere-asamblare/5-min/min new file mode 100755 index 00000000..7d05ca69 Binary files /dev/null and b/laborator/content/introducere-asamblare/5-min/min differ diff --git a/laborator/content/introducere-asamblare/5-min/min.asm b/laborator/content/introducere-asamblare/5-min/min.asm index 6d08dbc4..5847eda0 100644 --- a/laborator/content/introducere-asamblare/5-min/min.asm +++ b/laborator/content/introducere-asamblare/5-min/min.asm @@ -6,9 +6,16 @@ section .text main: ;cele doua numere se gasesc in eax si ebx - mov eax, 4 - mov ebx, 1 + mov eax, 1 + mov ebx, 3 ; TODO: aflati minimul + mov ecx, eax + cmp ecx, ebx + jg swap +back: PRINTF32 `%d\n\x0`, eax ; afiseaza minimul - ret + +swap: + xchg eax, ebx + jmp back diff --git a/laborator/content/introducere-asamblare/6-fibonacci/fibonacci b/laborator/content/introducere-asamblare/6-fibonacci/fibonacci new file mode 100755 index 00000000..e5243b9a Binary files /dev/null and b/laborator/content/introducere-asamblare/6-fibonacci/fibonacci differ diff --git a/laborator/content/introducere-asamblare/6-fibonacci/fibonacci.asm b/laborator/content/introducere-asamblare/6-fibonacci/fibonacci.asm index a0f2bc07..0911cc5d 100644 --- a/laborator/content/introducere-asamblare/6-fibonacci/fibonacci.asm +++ b/laborator/content/introducere-asamblare/6-fibonacci/fibonacci.asm @@ -5,8 +5,20 @@ section .text extern printf main: - mov eax, 7 ; vrem sa aflam al N-lea numar; N = 7 + mov eax, 4 ; vrem sa aflam al N-lea numar; N = 7 + mov ebx, 0 + mov ecx, 1 + mov edx, 0 +start: + cmp eax, 0 + jne addone + je PRINTF32 `%d\n\x0`, ebx ; afiseaza numarul + ret - ; TODO: calculati al N-lea numar fibonacci (f(0) = 0, f(1) = 1) +addone: + sub eax, 1 ;scadem pasul + mov edx, ecx ;valoarea mare e pastrata + add ecx, ebx ;valoarea mare e incementata cu cea precedenta + mov ebx, edx ;valoarea mare devine cea mica + jmp start - ret