forked from cirosantilli/x86-assembly-cheat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loopcc.asm
53 lines (36 loc) · 1003 Bytes
/
loopcc.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# LOOPcc
%include "lib/asm_io.inc"
RODATA
bs4 db 0, 0, 1, 0
ENTRY
; # LOOP
; ecx--;
; if (ecx != 0) goto lbl
mov ecx, 3
loop_lbl:
;3, 2, 1
PRINT_INT ecx
loop loop_lbl
mov ecx, 3
mov ebx, ecx
loop_lbl_2:
mov eax, ebx
sub eax, ecx
;0, 1, 2
call print_int
loop loop_lbl_2
; # LOOPE
; ecx--; if (ecx != 0 && ZF == 1) goto lbl
; # Search for first non-zero elem in range
; bx will contain its index afterwards.
; If not found, bx is the length + 1.
mov ecx, 4
mov ebx, -1
loope_lbl:
inc ebx
cmp byte [bs4 + ebx], 0
loope loope_lbl
ASSERT_EQ ebx, 2
; # LOOPNE
; ecx--; if (ecx != 0 && ZF == 0) goto lbl
EXIT