Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

section .data
myString: db "Hello, World!", 0
myownString: db "Goodbye, World!", 0

section .text
global main
Expand All @@ -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
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Binary file not shown.
28 changes: 22 additions & 6 deletions laborator/content/introducere-asamblare/4-sets/sets.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file added laborator/content/introducere-asamblare/5-min/min
Binary file not shown.
13 changes: 10 additions & 3 deletions laborator/content/introducere-asamblare/5-min/min.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file not shown.
18 changes: 15 additions & 3 deletions laborator/content/introducere-asamblare/6-fibonacci/fibonacci.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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