COEN 311 LAB REPORT 3
COEN 311 LAB REPORT 3
Nicolas GHARZOUZI
40232064
Objectives
Understand different ways to access data in ARM assembly language.
Learn basic math instructions in assembly language.
Learn how to use these methods and instructions to work with a 2D array of numbers stored in
the computer's memory.
See how a compiler translates high-level language into assembly language.
Theory
The way an instruction in assembly language finds its data is called the "addressing mode." We've seen
some basic addressing modes like immediate mode, where the data is right in the instruction, and register
indirect mode, where the data's memory address is kept in a register. This lab will show us more complex
addressing modes and how they work. We'll also see how these modes are similar to using pointers in
languages like C++. Understanding these addressing modes helps us see how compilers turn high-level
code into assembly language, which is what the computer's processor can understand.
Questions
1) .data
mydata: .word 0xdeadbeef @ Define 'mydata' with a hexadecimal value
address_of_mydata: .word mydata @ Store the address of 'mydata' in 'address_of_mydata'
Here the value 0xDEADBEEF is assigned to mydata and address_of_mydata stores the address of
mydata.
2) The provided code fragment, "mydata:.word 0xdeadbeef 14," exemplifies the syntax often seen in
assembly or low-level programming, featuring the label "mydata" alongside a 32-bit word
(equivalent to 4 bytes) that includes the number 14 and the hexadecimal notation 0xdeadbeef.
Endianness refers to the sequence in which a processor stores data that spans multiple bytes. For
processors like the ARM found in the STM32F334 Nucleo board, as well as numerous other ARM-based
systems, a little-endian format is commonly employed. This format arranges data so that the least
significant byte (LSB) occupies the lowest memory address, with the most significant byte (MSB)
positioned at the highest memory address for any given multi-byte data item, such as a 32-bit word
0xdeadbeef.
In this format, the 32-bit hexadecimal figure 0xdeadbeef would be stored in memory starting from a base
address X as follows:
Address X: 0xef (Least significant byte)
Address X+1: 0xbe
Address X+2: 0xad
Address X+3: 0xde (Most significant byte)
Thus, the ARM processor within the STM32F334 Nucleo microcontroller board adopts a little-endian
configuration for its byte order, a choice that aligns with the common preference across ARM-based
platforms for its benefits in memory handling and software development efficiency.
Conclusion
This lab taught us about different ways to access data in assembly language, especially when dealing with
2D arrays. We saw firsthand how assembly language lets us control the computer's hardware directly,
though this requires careful planning and precision. The lab also showed us how compilers work to turn
high-level code into assembly language, bridging the gap between the programmer's intentions and the
processor's operations. Overall, the lab was a valuable lesson in both the capabilities and complexities of
low-level programming.