0% found this document useful (0 votes)
236 views14 pages

CSC 212 Assembler Practical 1

This document provides information about an ARM assembler programming course. It introduces ARM processors and their architecture, including load/store instructions and registers. It discusses tools for ARM assembly including Qemu emulator. It outlines the course structure, instruction syntax, and hints for practical assignments including using condition codes and a greatest common divisor algorithm. Students are asked to submit their first practical assignment by August 17th, 2018.

Uploaded by

Royal Gabriel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
236 views14 pages

CSC 212 Assembler Practical 1

This document provides information about an ARM assembler programming course. It introduces ARM processors and their architecture, including load/store instructions and registers. It discusses tools for ARM assembly including Qemu emulator. It outlines the course structure, instruction syntax, and hints for practical assignments including using condition codes and a greatest common divisor algorithm. Students are asked to submit their first practical assignment by August 17th, 2018.

Uploaded by

Royal Gabriel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Department Of Computer Science

University of the Western Cape


CSC 212
Architecture
ARM Assembler Programming
Teaching Staff
 Lecturers
 Dr. Hope Mauwa ([email protected])
 A/Prof. Antoine Bagula ([email protected])
 Practical Assistants
 Mr. André Henney ([email protected])
What is Arm?
 ARM is a central processing unit (CPU).
 ARM processors are known as Reduced Instraction Set
Computing (RISC).

 ARM processor can be seen as a very powerful


calculator.

 Mobile phones, tablets, wearables, routers and other


Internet of Things (IoT) devices e.g. Raspberry Pi.

 R0-R12, R13 (Stack Pointer), R14 (Link R egister)and


R15 (Program Counter).
What is Arm? Continued…
 Load/store architecture.
 load To load a value from memory, you copy the data
from memory into a register.
 store To store a value to memory, you copy the data
from a register to memory.
 Only load and store instructions can access memory
 Does not support memory to memory data processing
operations.
 Must move data values into registers before using
 them.
Load and Store…
 The basic load and store instructions are:
 LDR STR Word
 LDRB STRB Byte
 LDRH STRH Halfword
 LDRSB Signed byte load
 LDRSH Signed halfword load
 .data
string: .asciz "\nHello World!\n”
.extern printf
main:
push {ip, lr}
ldr r0, =string
bl printf
pop {ip, pc}
ARM Assembler
ARM Assembler…
Why Assembler?
 Why not assembly, maybe just because of curiousity!
 Better memory access and management.
 You will be as close to the hardware as possible.
 Hack maybe---Ethically!!!!
 To learn about Computer Architecture, Assembly
programming is better to use a tool to learn.
Tools
 Raspberry Pi Emulator
 Qemu Emulator - http://www.qemu.org/

 Download
 http://cs.uwc.ac.za/~ahenney/qemu.zip.

 https://sourceforge.net/projects/rpiqemuwindows/files/latest/d
ownload

 Follow the “Downloading the MatrixPi” section in the


practical sheet.
Practical 1
Default Structure

 myAssemblerfile.s
@myAssemblyfile.s
.global main
main:
mov r0, #2
bx lr
Instruction Syntax
 <operation>{cond}{flags} Rd,Rn,Operand2
 <operation> - A three-letter mnemonic, e.g. MOV or ADD.
 {cond} - An optional two-letter condition code, e.g. EQ or
CS.
 {flags} - An optional additional flags. e.g. S.
 Rd - The destination register.
 Rn - The first source register.
 Operand2 - A flexible second operand.
Compile, Link, Run and Display

 Compile
as -o myAssemblerfile.o myAssemblerfile.s

 Link
gcc –o myAssemblerprogram myAssemblerfile.o

 Run
./myAssemblerprogram

 Display
./myAssemblerprogram ; echo $?
Practical Hints

 Question 1 a
mov r2, #4
add r0, r1, r2

 Question 1b
gcd:
cmp r0, r1 @ compare r0 and r1
subgt r0, r0, r1@ if r0 > r1, r0 = r0 - r1
sublt r1, r1, r0 @ if r0 < r1, r1 = r1 - r0
bne gcd @ if r0 != r1, repeat
Practical Due Date

Friday, 17 thAugust 2018 @


5:00PM

You might also like