-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbmpdiag.ys
101 lines (94 loc) · 1.89 KB
/
bmpdiag.ys
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
89
90
91
92
93
94
95
96
97
98
99
100
101
#------------------------------------------------------------------
#
# 4190.308 Computer Architecture (Spring 2019)
#
# Project #4: Optimizing Program for a Pipelined Y86-64 Processor
#
# May 28, 2019
#
# Jin-Soo Kim ([email protected])
# Systems Software & Architecture Laboratory
# Dept. of Computer Science and Engineering
# Seoul National University
#
#------------------------------------------------------------------
bmp_diag:
# imgptr is in %rdi
# width is in %rsi
# height is in %rdx
# gap is in %rcx
#-----------------------------------------------------------------
# FILL HERE
# You are allowed to use any register supported by Y86-64 architecture
rrmovq %rdi, %r12
#set r12(imgptr)
rrmovq %rdx, %r8
rrmovq %rcx, %r9
iaddq $-1, %r8
divq %r9, %r8
mulq %r9, %r8
subq %rdx, %r8
irmovq $-1, %rdi
subq %r8, %rdi
cmove %rcx, %rdi
irmovq $3, %r8
mulq %r8, %rdi
#set rdi(index)
irmovq $3, %r8
irmovq $4, %rbx
irmovq $3, %rax
mulq %rax, %rsi
andq %rsi, %r8
cmove %rbx, %r8
rrmovq %rsi, %r9
addq %rbx, %r9
subq %r8, %r9
#set r9(one line size)
irmovq $3, %r8
mulq %rcx, %r8
#set r8(gap size)
rrmovq %rsi, %r10
#set r10(checker size)
rrmovq %rdx, %r11
#set r11(height)
irmovq $0, %r13
irmovq $0xff, %r14
#set r13,r14(color value)
#coloring
LOOPSTART:
rrmovq %r12, %rax
addq %rdi, %rax
rrmovq %r10, %rbx
subq %rdi, %rbx
FIRST:
rmmovb %r13, (%rax)
rmmovb %r13, 1(%rax)
rmmovb %r14, 2(%rax)
addq %r8, %rax
subq %r8, %rbx
jg FIRST
rrmovq %r8, %rcx
subq %rdi, %rcx
rrmovq %r12, %rax
addq %rcx, %rax
rrmovq %r10, %rbx
subq %rcx, %rbx
SECOND:
rmmovb %r13, (%rax)
rmmovb %r13, 1(%rax)
rmmovb %r14, 2(%rax)
addq %r8, %rax
subq %r8, %rbx
jg SECOND
#DEBUG
#jmp ENDING
#DEBUG.END
iaddq $-1, %r11
je ENDING
iaddq $-3, %rdi
cmovle %r8, %rdi
addq %r9, %r12
jmp LOOPSTART
#-----------------------------------------------------------------
ENDING:
ret