Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved lab5 #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

section .text
global main
Expand All @@ -11,12 +12,23 @@ main:
mov ecx, 6 ; N = valoarea registrului ecx
mov eax, 1
mov ebx, 1

for:
cmp eax, ecx
jg print2 ; TODO1: eax > ebx?
cmp eax, ebx
je print ; TODO1: eax > ebx?
ret
jge print1

print:
continue:
inc eax
jmp for

print1:
PRINTF32 `%s\n\x0`, myString
jmp continue

print2:
PRINTF32 `%s\n\x0`, myString2
; TODO2.2: afisati "Hello, World!" de N ori
; TODO2.1: afisati "Goodbye, World!"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ section .text
extern printf

main:
mov eax, 0xdeadc0de ; TODO3.1: modify eax register
mov ebx, 0x1337ca5e ; TODO3.1: modify ebx register
mov eax, 0x2 ; TODO3.1: modify eax register
mov ebx, 0x170 ; TODO3.1: modify ebx register
mov ecx, 0x5 ; hardcoded; DO NOT change
cmp eax, ebx
jns bad
mov ebx, ecx
cmp ecx, ebx
jb bad
add eax, ebx
xor eax, ecx
xor eax, eax
jnz bad

good:
PRINTF32 `%s\n\x0`, right
ret

bad:
PRINTF32 `%s\n\x0`, wrong
Expand Down
10 changes: 9 additions & 1 deletion laborator/content/introducere-asamblare/5-min/min.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ main:
mov eax, 4
mov ebx, 1
; TODO: aflati minimul
PRINTF32 `%d\n\x0`, eax ; afiseaza minimul
cmp eax, ebx
jl greata
jmp greatb

greata:
PRINTF32 `%d\n\x0`, eax
ret

greatb:
PRINTF32 `%d\n\x0`, ebx
ret