120 likes | 271 Views
ITEC 352. Lecture 14 ISA(5). Review. Questions? Exam 1 next Friday Assembly Assembler Basic structure Registers Memory. Outline. More assembly Instructions Structure Usage Intro to loops Textbook link http:// www.mrkay.org / zenpc /ARCHMAN/. Instruction Format.
E N D
ITEC 352 Lecture 14 ISA(5)
Review • Questions? • Exam 1 next Friday • Assembly • Assembler • Basic structure • Registers • Memory
Outline • More assembly • Instructions • Structure • Usage • Intro to loops • Textbook link • http://www.mrkay.org/zenpc/ARCHMAN/
InstructionFormat • Every ARC instruction is 32 bits in length. • For instance, the instruction below must fit within 32 bits when represented in binary. • To do this, ARC enforces certain formats that allow us to use the 32 bits in different ways. • These are called instruction formats. • A format defines how the various bit fields of an instruction are laid out within 32 bits and how it is interpreted by the ARC control unit.
PSR • A register that is used to store results of instructions • Not values • If a result is 0 • If a result is negative • Carry bit (c) • Overflow bit (v)
ARC Pseudo-Ops • • Pseudo-ops are instructions to the assembler. They are not part of the ISA.
.org 3000 a: 10 25 2 3 4 a_start: 3000 counter: 0 output: 0 Adding 5 integers … Variables for the program ld [a_start], %r1 ! Load the starting address of a into %r1 ld [counter], %r2 ! Register r2 is the counter. andcc %r3,%r0, %r3 ! What does this do? loop: subcc%r2, 5, %r0 ! Have we reached the end ? be done ! If %r2 – 5 = 0, exit loop. addcc %r2, 1, %r2 ! Increment counter ld %r1, %r4 ! Load the number from the array addcc %r4, %r3, %r3 ! Accumulate sum into %r3. addcc %r1, 4, %r1 ! Goto next address ba loop done: st %r3, [output] jmpl %r15+4, %r0
Summary Storage location for address of the array a. Having this location allows us to load the address “3000” into a register. Length is being used as a “counter” to determine when to end the loop.
Other ARC instructions • Software traps: • Allows programs to invoke services from the OS/hardware, e.g., reading a keyboard or writing onto a display. • ARC has trap instructions – but they do not control the OS/hardware (due to JVM limitations).
Summary • Assembly programming 101 • Different language, but still within same paradigm