Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %include "rw32-2018.inc"
- ;%include "io.inc"
- ;esp - stack 7c-end
- ; db dw dd
- ;byte word dword
- ; 8 16 32
- ; [var] - value var - adress
- section .bss ; uninicialized values
- ; name resb size
- ar_num_3 resd 10
- section .data ; inicialized values
- ; name size value
- ar_num_2 dd 1, 10, 100
- ar_num_1 dd 3, 30, 300
- section .text
- array_operations:
- xor ebx, ebx
- _for:
- cmp al, 0
- je .add
- cmp al, 1
- je .sub
- cmp al, 2
- je .div
- cmp al, 3
- je .mul
- .add:
- mov edx, [ar_num_1 + ebx]
- add edx, [ar_num_2 + ebx]
- mov dword [ar_num_3 + ebx], edx
- jmp .end
- .sub:
- mov edx, [ar_num_1 + ebx]
- sub edx, [ar_num_2 + ebx]
- mov dword [ar_num_3 + ebx], edx
- jmp .end
- .div:
- push eax
- mov eax, [ar_num_1 + ebx]
- mov edx, [ar_num_2 + ebx]
- div edx
- mov dword [ar_num_3 + ebx], eax
- pop eax
- jmp .end
- .mul:
- push eax
- mov eax, [ar_num_1 + ebx]
- mov edx, [ar_num_2 + ebx]
- mul edx
- mov dword [ar_num_3 + ebx], eax
- pop eax
- jmp .end
- .end:
- add ebx, 4
- sub ecx, 1
- cmp ecx, 0
- jne _for
- ret
- CMAIN:
- mov ebp, esp; for correct debugging
- xor eax, eax
- ;Implementujte podprogram, který sečte dvě pole a výsledek uloží do pole třetího.
- ;Bonus: Implementujte funkci, která na základě obsahu registru AL nad poli jednu z operací: +,-,*
- xor eax, eax
- mov al, 3; operation type 0-add 1-sub 2-div 3-mul
- mov ecx, 3; array size
- call array_operations
- mov eax, [ar_num_3]
- mov ebx, [ar_num_3+4]
- mov ecx, [ar_num_3+8]
- xor eax, eax
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement