Last active
August 29, 2015 13:55
-
-
Save lucansky/8767404 to your computer and use it in GitHub Desktop.
ASM: Kopirovanie z arrayu do arrayu, zaporne cisla nahradene nulou
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%include 'rw32.inc' ; nacteni knihovny rw32.inc | |
[segment .data use32] ; definice zacatku datoveho segmentu | |
; testovaci retezec | |
sArray1 dd 9000001,50000,-20432,98765 | |
length dd 4 | |
sArray2 times 100 dd 0 | |
[segment .code use32] ; definice zacatku kodoveho segementu | |
prologue ; makro -- inicializace programu | |
mov esi, sArray1 | |
mov ecx, 0 | |
begin_loop: ; for(ecx = 0; ecx != length; ecx++) | |
cmp ecx, [length] | |
je end_loop ; ukoncovacia podmienka | |
mov eax, [esi+4*ecx] ; 4*ecx kvoli 32 bitovej hodnote | |
cmp eax, 0 | |
jl if_negative ; jump less | |
jmp end_negative ; pokial sa dostal potialto program, znamena ze cislo je kladne | |
; preskakuje nulovanie eax | |
if_negative: | |
mov eax, 0 ; prepisanie zapornej hodnoty nulou | |
end_negative: | |
mov dword [sArray2+4*ecx], eax | |
call WriteUInt32 | |
call WriteNewLine | |
inc ecx | |
jmp begin_loop | |
end_loop: | |
epilogue ; makro -- ukonceni programu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment