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
|
# Given a list of X numbers, find the maximum number of the list and use it as
# the argument of exit() syscall
# %rbx holds the maximum number through the whole scanning process
# %rax holds the current element being examined
# %rdi holds the currend position in the list
# zero marks the end of the list
# Data section, now containing some statically created data
.section .data
# Just a label to refer to the first item in the list
data_items:
# "Type" of memory location to be reserved. In quotes because it just
# says how many bytes should be reserved to each item, not the 'type'
# itself
# Reserves 10 '8byte' (quad) slots consecutive in memory,
.quad 3,10,9,230,66,77,23,66,12,69,0
.section .text
.globl _start
_start:
movq $0, %rdi
movq data_items(, %rdi,8), %rax
movq %rax, %rbx
start_loop:
cmpq $0, %rax
je loop_exit
incq %rdi
movq data_items(,%rdi,8), %rax
cmpq %rbx, %rax
jle start_loop
movq %rax, %rbx
jmp start_loop
loop_exit:
movq $1, %rax
int $0x80
|