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
19 changes: 18 additions & 1 deletion laborator/content/apel-functii/0-fibo/fibo.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,29 @@ main:
sub esp, NUM_FIBO * 4

mov ecx, NUM_FIBO
xor edx, edx
mov edi, 1
mov esi, 0
push esi
push edi
foor:
xor eax, eax
add eax, esi
add eax, edi
push eax
mov esi, edi
mov edi, eax

inc edx
cmp edx, ecx
jl foor

print:
mov eax, dword [esp + (ecx - 1) * 4]
mov eax, dword [esp + (ecx + 1) * 4]
PRINTF32 `%d \x0`, eax
dec ecx
cmp ecx, 0
ja print

PRINTF32 `\n\x0`
mov esp, ebp
Expand Down
61 changes: 57 additions & 4 deletions laborator/content/apel-functii/3-print-string/print-string.asm
Original file line number Diff line number Diff line change
@@ -1,21 +1,74 @@
%include "../utils/printf32.asm"

section .data
section .data
mystring db "This is my string", 0
format db "String length is %u", 10, 0
format2 db "reversed string: %s", 10, 0
store_string times 64 db 0
len dd 0

section .text
section .text

extern puts
extern printf
global main

reverse_string:
push ebp
mov ebp, esp

mov eax, dword [ebp+8]
mov ecx, dword [ebp+12]
add eax, ecx
dec eax
mov edx, dword [ebp+16]

copy_one_byte:
mov bl, byte [eax]
mov byte [edx], bl
dec eax
inc edx
loopnz copy_one_byte

inc edx
mov byte [edx], 0

leave
ret

main:
push ebp
mov ebp, esp

PRINTF32 `[PRINTF32]: %s\n[PUTS]: \x0`, mystring
mov eax, mystring
xor ecx, ecx

test_one_byte:
mov bl, byte [eax]
test bl, bl

je out
inc eax
inc ecx
jmp test_one_byte

out:
PRINTF32 `[PRINTF32]: %d\n[printf]: \x0`, ecx
mov dword[len], ecx
push ecx
push format
call printf
add esp, 8

; TODO: call puts on string
push store_string
push dword[len]
push mystring
call reverse_string
add esp, 12

push store_string
push format2
call printf
add esp, 8
leave
ret
15 changes: 14 additions & 1 deletion laborator/content/apel-functii/6-toupper/toupper.asm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,20 @@ toupper:
push ebp
mov ebp, esp

; TODO
mov eax, [ebp + 8]
xor ecx, ecx

iterate:
xor ebx, ebx
mov bl, byte[eax + ecx]
cmp bl, 0
je out
sub bl, 32
mov byte[eax + ecx], bl
add ecx, 1
jmp iterate

out:; TODO

leave
ret
Expand Down