-
Notifications
You must be signed in to change notification settings - Fork 0
/
004_Jump_Flag.asm
executable file
·88 lines (65 loc) · 1.65 KB
/
004_Jump_Flag.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
;Declaring Datas and Constants
section .data
;Constants
LF equ 10 ;New Line
numero_max equ 10 ;Buffer Size
;Program Strings
string_1 db LF, "Input: " ;String Output
length_1 equ $ - string_1 ;String Length
string_2 db LF, " Impar!!! ", LF ;String Output
length_2 equ $ - string_2 ;String Length
string_3 db LF, " Par!!!", LF ;String Output
length_3 equ $ - string_3 ;String Length
;Declaring Variables
section .bss
;Program Input
numero resb numero_max ;Buffer Length
num resd 1 ;Buffer Variable
;Declaring Code
section .text
global _start ;declared entrypoint (ld)
_start: ;entrypoint
;[04]output
mov edx,length_1 ;message length
mov ecx,string_1 ;message to write
mov ebx,1 ;[out text]file descriptor
mov eax,4 ;[sys write] system call number
int 0x80 ;call kernel
;[03]input
mov edx,numero_max ;input length
mov ecx,numero ;input text
mov ebx,0 ;[in text]file descriptor
mov eax,3 ;[sys read] system call number
int 0x80
sub eax,2
mov [num],eax ;move EAX para variavel num
;Bloco de Comparacao
mov esi,eax
mov edx,0
mov ebx,2
mov al,[numero + esi]
div ebx
cmp edx, 0 ;comparacao com 0
jz teste ;jump se Zero
;Bloco False
;[04]output
mov edx,length_2 ;message length
mov ecx,string_2 ;message to write
mov ebx,1 ;[out text]file descriptor
mov eax,4 ;[sys write] system call number
int 0x80 ;call kernel
jmp exit_prog ;jump exit
;Bloco True
teste:
;[04]output
mov edx,length_3 ;message length
mov ecx,string_3 ;message to write
mov ebx,1 ;[out text]file descriptor
mov eax,4 ;[sys write] system call number
int 0x80 ;call kernel
jmp exit_prog ;jump exit
exit_prog:
;[01]exit
mov ebx,0
mov eax,1
int 0x80