-
Notifications
You must be signed in to change notification settings - Fork 0
/
proc-loop-ins.asm
66 lines (57 loc) · 1.18 KB
/
proc-loop-ins.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
section .data
prompt db "Enter a single digit (0-9): ", 0
below db "Input is below 5.", 0
equal db "Input is equal to 5.", 0
above db "Input is above 5.", 0
section .text
global _start
_start:
; Display prompt
mov eax, 4
mov ebx, 1
mov ecx, prompt
mov edx, 27
int 0x80
; Read user input
mov eax, 3
mov ebx, 0
mov ecx, input
mov edx, 2
int 0x80
; Compare input to 5
mov al, [input]
sub al, '0'
cmp al, 5
jl below_input
je equal_input
jmp above_input
below_input:
; Display below message
mov eax, 4
mov ebx, 1
mov ecx, below
mov edx, 18
int 0x80
jmp exit_program
equal_input:
; Display equal message
mov eax, 4
mov ebx, 1
mov ecx, equal
mov edx, 19
int 0x80
jmp exit_program
above_input:
; Display above message
mov eax, 4
mov ebx, 1
mov ecx, above
mov edx, 18
int 0x80
exit_program:
; Exit program
mov eax, 1
xor ebx, ebx
int 0x80
section .bss ; block of memory for uninitialized variables
input resb 11 ; reserves a block of 11 bytes