ITEC 352 Lecture 14 ISA5 Review Questions Exam

  • Slides: 12
Download presentation
ITEC 352 Lecture 14 ISA(5)

ITEC 352 Lecture 14 ISA(5)

Review • Questions? • Exam 1 next Friday • Assembly – Assembler – Basic

Review • Questions? • Exam 1 next Friday • Assembly – Assembler – Basic structure – Registers – Memory ISA(5)

Outline • More assembly – Instructions • Structure • Usage – Intro to loops

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,

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)

ARC Instruction and PSR Formats ISA(5)

PSR • A register that is used to store results of instructions • Not

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)

Data Formats ISA(5)

ARC Pseudo-Ops ISA(5) • Pseudo-ops are instructions to the assembler. They are not part

ARC Pseudo-Ops ISA(5) • Pseudo-ops are instructions to the assembler. They are not part of the ISA.

Adding 5 integers … . org 3000 a: 10 25 2 3 4 Variables

Adding 5 integers … . org 3000 a: 10 25 2 3 4 Variables for the program a_start: 3000 counter: 0 output: 0 ld [a_start], %r 1 ! Load the starting address of a into %r 1 ld [counter], %r 2 ! Register r 2 is the counter. andcc %r 3, %r 0, %r 3 ! What does this do? loop: subcc %r 2, 5, %r 0 ! Have we reached the end ? be done ! If %r 2 – 5 = 0, exit loop. addcc %r 2, 1, %r 2 ! Increment counter ld %r 1, %r 4 ! Load the number from the array addcc %r 4, %r 3 ! Accumulate sum into %r 3. addcc %r 1, 4, %r 1 ! Goto next address ba loop done: st %r 3, [output] jmpl %r 15+4, %r 0 ISA(5)

Summary Storage location for address of the array a. Having this location allows us

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

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 ISA(5)

Summary • Assembly programming 101 • Different language, but still within same paradigm ISA(5)