-
Notifications
You must be signed in to change notification settings - Fork 1
/
asm.s
90 lines (73 loc) · 2.06 KB
/
asm.s
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
area |.text|, code, readonly
; C-code of the ASM function
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
; convenient register renaming
name0 RN 0
name1 RN 1
name2 RN 2
name3 RN 3
name4 RN 4
name5 RN 5
name6 RN 6
name7 RN 7
name8 RN 8
name9 RN 9
; NB append S to any instruction in order to update the flags
nome_molto_lungo_e_complicato proc
export nome_molto_lungo_e_complicato
; r12: value of the stack before the push
; mov r12, sp
push {r4-r8, r10-r11, lr}
; 5th paramenter
; ldr r4, [r12]
; 6th parameter
; ldr r5, [r12, #4]
subs r1, r1, #1
blt exit
loop ldr r7, [r0, r1, LSL #2] ; load first vett val
; if VETT is an array of char (bytes)
; - change ldr -> ldrb, remove LSL #2 (aka *4)
; if VETT is an array of in16
; - change ldr -> ldrh, LSL #2 -> LSL#1 (aka *2)
; subs r1, #1 ; update r1
; blt exit ; if not sure N is even
; ldr r8, [r0, r1, LSL #2] ; load second vett val
; if VETT is an array of char (bytes)
; - change ldr -> ldrb, remove LSL #2 (aka *4)
; if VETT is an array of int16
; - change ldr -> ldrh, LSL #2 -> LSL #1 (aka *2)
; logic here
subs r1, r1, #1 ; exit condition
bge loop
exit ; put return value into r0
; mov r0, #0
pop {r4-r8, r10-r11, pc}
endp
end
;******************************************************************************
;** End Of File
;******************************************************************************