main
1 .global _start
2
3 .text
4_start:
5 movq $0, max # initialize max to 0
6 movq $0, min # initialize min to 0
7
8 # write(1, greeting, 16)
9 mov $1, %rax # system call 1 is write
10 mov $1, %rdi # file handle 1 is stdout
11 mov $greeting, %rsi # address of variable to pring
12 mov $16, %rdx # number of bytes to write
13 syscall # invoke operating system to do the write
14
15read_input:
16 # read(0, input, 3)
17 mov $0, %rax # system call 0 is read
18 mov $0, %rdi # file handle 0 is stdin
19 mov $input, %rsi # address of var to input
20 mov $4, %rdx # number of bytes to read
21 syscall # invoke operating system to do the write
22
23print_results:
24 # write(1, max_message, 4)
25 mov $1, %rax # system call 1 is write
26 mov $1, %rdi # file handle 1 is stdout
27 mov $max_message, %rsi # address of string to output
28 mov $5, %rdx # number of bytes to write
29 syscall # invoke operating system to do the write
30
31 # write(1, input, 4)
32 mov $1, %rax # system call 1 is write
33 mov $1, %rdi # file handle 1 is stdout
34 mov $input, %rsi # address of string to output
35 mov $4, %rdx # number of bytes read
36 syscall # invoke operating system to do the write
37
38 # write(1, min_message, 4)
39 mov $1, %rax # system call 1 is write
40 mov $1, %rdi # file handle 1 is stdout
41 mov $min_message, %rsi # address of string to output
42 mov $5, %rdx # number of bytes
43 syscall # invoke operating system to do the write
44
45 # write(1, input, 4)
46 mov $1, %rax # system call 1 is write
47 mov $1, %rdi # file handle 1 is stdout
48 mov $input, %rsi # address of string to output
49 mov $4, %rdx # number of bytes
50 syscall # invoke operating system to do the write
51
52 # exit(0)
53 mov $60, %rax # system call 60 is exit
54 xor %rdi, %rdi # we want return code 0
55 syscall # invoke operating system to exit
56
57 .data
58greeting: .ascii "Enter numbers: \n"
59max_message: .ascii "Max: "
60min_message: .ascii "Min: "
61input: .word 0
62max: .word 0
63min: .word 0