Tiva Lab ASM 01: Arithmetics, Logical, and Shift Operations

Objective

  • Learn how to control the execution flow by using the conditional flags
  • Learn how to access array and/or structure data in the memory.

Required Reading Material

Background Information

High-level computer programming languages have a level of abstraction between the code and the processor. The abstraction means that the programmer never has to worry about the details of the computer, and this also allows the programmer to write code that could run on various different processors. All the high-level programming languages need to be converted into assembly language and then into machine code. The executable code in the high-level language is huge, and hence it is sometimes not efficient. This means that if performance is critical, the programmer might have to write their code differently.

The best way of getting the performance is by understanding how the machine works so that the programmer can do large architectural transformations that a compiler can't easily. Assembly language is a really good way of learning this performance in detail since it helps programmers understand practical concepts of the computer such as what a registry is and how it is used. Assembly language uses a symbolic designation of programming elements instead of machine code, so it is considered to be a low-level language, compare with other transitional computer languages such as C and Java.

One advantage of assembly language programming has to do with its use in increasing the running speed of programs. Should an algorithm be optimally complex, we can choose to write instructions using assembly language in order to achieve faster execution times.

Assembly language is not without its disadvantages. It is not portable, meaning an application written for a PC would not run on ARM devices. In addition, a program in assembly language is more difficult to write and takes more time than a program written in C or another high-level language.

Assembly is still used for some key tasks, e.g.

  • Hardware-specific code, such as device drivers, boot-loader, BIOS ...
  • Embedded devices, Real-time systems where the size of code and performance are important
  • Low-level code where performance is critical etc.

Procedure


Part-I. Loop

Write ARM assembly code to calculate sum of numbers from 1 to 100 (R0 = 1 + 2 + 3 + ... + 100 = 5050 = 0x13BA) using the following flowcharts:

Assembly Code 1-1: Counting up with while-loop.
Loop01

Assembly Code 1-2: Counting up with a do-while loop.
Loop02
Assembly Code 1-3: Counting down with a do-while loop
Loop03

You need to submit one assembly code for each flowchart. The total you will create three assembly codes.


Part-II. Accessing Arrays

Using assembly code to calculate the sum, average value, find the maximum and minimum value in array A[10], which is already predefined the initial value.

© 2024 Air Supply Information Center (Air Supply BBS)