Last active
January 25, 2020 14:34
-
-
Save M1nified/899816fca692066cba6e3ddec59ad038 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
; conditional statements examples; so called "if" | |
mov eax, 4 | |
; if(eax<=3) | |
cmp eax,3 | |
jle if_true_label | |
; if(eax<4) | |
cmp eax,4 | |
jl if_true_label | |
; if(eax==4) | |
cmp eax,4 | |
je if_true_label | |
jmp end_ifs_label | |
if_true_label: | |
nop | |
end_ifs_label: | |
nop | |
; stos; push; pop | |
push 10 | |
pop eax | |
; now: eax == 10 | |
; stack used to swap registers | |
mov eax, 5 | |
mov ecx, 8 | |
; swap(eax, ecx) | |
push eax | |
push ecx | |
pop eax | |
pop ecx | |
; now: | |
; eax == 8 | |
; ecx == 5 | |
; loop example | |
; for(eax=0;eax<4;eax++) | |
; ecx = eax + ecx | |
xor ecx,ecx ; ecx = 0 | |
xor eax,eax ; cx-register is the counter, set to 0; eax = 0 | |
loop1: ; etykietka, do ktorej skaczemy (poczatek petli) | |
add ecx,eax ; exc += eax | |
inc eax ; Increment ; eax++ | |
cmp eax,4 ; Compare eax to the limit ; | |
jl loop1 ; Loop while less or equal ; if eax < 4 ; Jump If Less | |
; switch(eax) | |
; case 4: ecx -= edx; break; | |
; case 7: ecx = aex + ebx; break; | |
; default: ecx = 0; | |
cmp eax,4 | |
je case4 | |
cmp eax,7 | |
je case7 | |
jmp default | |
nop | |
case4: | |
sub ecx, edx | |
jmp break | |
case7: | |
mov ecx,eax | |
add ecx,ebx | |
jmp break | |
default: | |
xor ecx, ecx ; ecx = 0 | |
break: | |
nop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment