ENGN2219/COMP6719
Computer Architecture & Simulation Ramesh Sankaranarayana Semester 1, 2020 (based on original material by Ben Swit and Uwe Zimmer)
1
ENGN2219/COMP6719 ComputerArchitecture&Simulation - - PowerPoint PPT Presentation
ENGN2219/COMP6719 ComputerArchitecture&Simulation RameshSankaranarayana Semester1,2020 (basedonoriginalmaterialbyBenSwitandUweZimmer) 1 Week3:MemoryOperations 2 Outline addresses
1
2
3
4
5
6
7
r1
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 1 1 1 1 1 1 1 1
r2
1 1 1 1
r3
1 1 1 1
mov r1, 0xFF mov r2, 0b10101010 bic r3, r1, r2
8
9
10
<shift>} means on e.g. the cheat sheet
@ some examples adds r0, r2, r1, lsl 4 mov r3, 4 mov r3, r3, lsr 2 mov r3, r3, lsr 3 @ off the end!
11
12
13
14
add, etc.) manipulating values in registers.
15
16
17
18
19
20
21
22
23
24
25
byte[] memory = { 80, 65, 54, /* etc. */ };
26
27
28
29
30
31
32
33
34
35
36
ldr is the the load register instruction
37
@ load some data into r0 ldr r0, [r1]
38
39
40
41
mov r1, 0x20000000 @ put the address in r1 ldr r0, [r1] @ load the data into r0
42
43
44
45
46
0x55 0x5444666
0x467ab787e
47
48
str r0, [r1]
49
mov r0, 42 mov r1, 0x20000000 str r0, [r1]
50
51
52
53
54
55
56
57
ldrb @ load byte from register ldrh @ load halfword from register strb @ store byte to register strh @ store halfword to register
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
@ these two are the same label1: mov r0, 5 label1:
77
78
b 0x80001c8
79
80
81
82
main: mov r0, 0 @ infinite loop - r0 will overflow eventually loop: add r0, 1 b loop
83
84
b<c> <label>
85
beq <label> @ branch if Z = 1 bne <label> @ branch if Z = 0 bcs <label> @ branch if C = 1 bcc <label> @ branch if C = 0 bmi <label> @ branch if N = 1 bpl <label> @ branch if N = 0 bvs <label> @ branch if V = 1 bvc <label> @ branch if V = 0
86
87
r0
if (x > 5) x = 5 else x = 0
88
Compiling .pioenvs/disco_l476vg/src/main.S.o Linking .pioenvs/disco_l476vg/firmware.elf Calculating size .pioenvs/disco_l476vg/firmware.elf text data bss dec hex filename 792 1080 1600 3472 d90 .pioenvs/disco_l476vg/firmware.elf Building .pioenvs/disco_l476vg/firmware.bin
89
firmware.bin) which is uploaded to your discoboard
90
91
92
93