ISA(5) Outline More assembly –Instructions Structure Usage –Intro to loops Textbook link –http://www.mrkay.org/zenpc/ARCHMAN/
ISA(5) Instruction Format 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.
ISA(5) ARC Instruction and PSR Formats
ISA(5) 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)
ISA(5) Data Formats
ISA(5) ARC Pseudo-Ops Pseudo-ops are instructions to the assembler. They are not part of the ISA.
ISA(5) Adding 5 integers … 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.org 3000 a: a_start: 3000 counter: 0 output: 0 Variables for the program
ISA(5) 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.
ISA(5) 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).
ISA(5) Summary Assembly programming 101 Different language, but still within same paradigm