2_cps310_ARC_I_ISA_Intro
2_cps310_ARC_I_ISA_Intro
Computer Organization II
Prof. Alex Ufkes
0x A B C 1 2 3
3 x 160 = 3
1 x 20 = 1 2 x 161 = 32
0 x 21 = 0 1 x 162 = 256
1 x 22 = 4 12 x 163 = 49152
0 x 23 = 0
11 x 164 = 720896
0 x 24 = 0
10 x 165 = 10485760
1 x 25 = 32
37 11256099
© Alex Ufkes, 2020, 2025 8
Last Week: Two’s Complement
Convert to
-12.62510 -1100.1012 Use remainder method
target base:
Normalize: -1100.1012 -1.1001012 x 23 Leading 1 assumed, not
Fill in bit fields: • Number is negative, sign bit is 1 included in bit pattern
• Exponent is biased: 3+127 = 130
• Fill in fraction, dropping implied 1
1 1 0 0 0 0 0 1 0 1 0 0 1 0 1 0
Application programmers
operate here
Assembly language
programmer operates here
ISA Level?
Typical scenario:
• User writes program in HLL
• Compiler translates into assembly
• Assembler translates into
machine code, stored on disk.
• Prior to execution, program
loaded into memory.
During execution:
• Instructions loaded into CPU from
memory one at a time
• CPU executes instruction, may
generate address
• Address placed on address bus,
received by memory.
• Buses not necessarily bi-directional • Memory writes data at that
• Memory does not generate addresses; address to the data bus
CPU does not receive addresses.
Computer memory:
• A collection of consecutively
numbered cells
• Each cell is typically one byte
• One byte == 8 bits
• We address at the byte level
• Can manipulate bits using bit
shifting, masking, etc.
Word size:
• Depends on CPU
• 32 bits is common,
as is 64 bits
• Text lists 32 bits as
most common
• (it’s from 2007)
Consider an integer:
• 4 bytes, however…
• CPU writes the integer at a
single byte address in memory
• In what order do we write the
bytes to memory?
Big-endian: Little-endian:
MSB stored at LSB stored at
00000000 01010101
lowest address lowest address
01001001 11100111
11100111 01001001
01010101 Multi-byte words are always 00000000
accessed by their lowest address
© Alex Ufkes, 2020, 2025 23
ISA Level: Big/Little Endian
Word at address
32-bit address 00001003
ARC is big-endian:
• 32-bit word at address 0x00001000 is 0xAABBCCDD
Instruction format
Integer format
Control unit tells ALU what to do, and with what registers
What to do?
• ALU implements a variety of binary (2-operand)
and unary (1 operand) operations.
• Binary: Addition, bit-wise AND, bit-shift, etc.
• Unary: Arithmetic negation, bitwise NOT, etc.
1. Data Movement
• Move data back and forth between CPU (registers) and memory or I/O
2. Arithmetic and Logic
• Perform operations on data that’s been moved into registers
3. Control
• Transfer control from one section of program to another.
• I.e., branching, calling subroutines, etc.
• Contrast this with HLL source code, typically need not change at all
between CPU architectures (just need to recompile).
• Given the right compiler, the same source code can be turned into
machine code compatible with any given CPU’s instruction set
Interesting exception?
Programs compiled for an IBM PC (or compatible) system use 80x86 instruction set
SPARC is a RISC:
• Reduced Instruction Set Computer
• A small set of simple instructions
• Accesses memory through specific
load/store instructions, as opposed
to as a part of most instructions
• Contrast this with CISC…
HOWEVER!
• Instruction cycle != CPU cycle
• One single instruction might take multiple
CPU cycles to complete.
• Especially true of CISC architectures.
HOWEVER!
• Instruction cycle != CPU cycle
• One single instruction might take multiple
CPU cycles to complete.
• Especially true of CISC architectures.
RISC: CISC:
• SPARC • IBM System/360
• Atmel AVR • IBM z/Architecture
• ARM • Motorola 6800, 6809
• Power ISA • Intel 8080, x86
(One of) the world’s fastest supercomputer uses RISC (and runs Linux):
ARC ISA:
• Memory
• CPU Registers
• Instruction set
User space:
• User’s assembled
program loaded here
• Can grow until it meets
system stack
System stack
• Starts at word 231-4
• Grows “downward” until
it meets user space
© Alex Ufkes, 2020, 2025 60
ARC ISA: Memory
System stack
• From 231-4 “down”
Accommodates:
• Small program, large stack
• Large program, small stack
ARC ISA:
• Memory
• CPU Registers
• Instruction set
ARC ISA:
• Memory User-visible?
• CPU Registers • Registers we can access as an
• Instruction set assembly programmer
• Note we can’t access the IR!
• IR is loaded based on PC,
which we do have access to.
• %r0, %r1, etc. are mnemonics
• Names we can use in assembly
programs to access registers
.begin
.org 2048 This program performs:
prog1: ld [x], %r1 z = x + y
ld [y], %r2
addcc %r1, %r2, %r3
Let’s see how to read it
st %r3, [z]
halt
x: 15
y: 9
z: 0
.end
Quick reminder:
• HLLs (depends on the language) get compiled into assembly
o Assembly is architecture specific, high-level languages are not.
• Assembly gets assembled by the assembler into machine language
• Machine language = binary bit strings loaded and decoded by the CPU
• One to one mapping between assembly and machine instructions!
• Not the case with HLLs, compiler might optimize many different ways.
© Alex Ufkes, 2020, 2025 73
ARC Assembly Language
• Denoted with a !
• Comments in assembly serve
the same purpose as HLLs
Immediate constants:
• Can be used immediately, don’t need to load into register first
• Number is baked right into the instruction.
Implications?
• Immediate constants are limited to 13 bits.
• Why? The whole instruction is 32 bits. Can’t have a full 32-bit number
• Immediate constants have a range of -4096 to 4095
© Alex Ufkes, 2020, 2025 82
ARC Assembly: Numbers
.begin
.org 2048
prog1: ld [x], %r1
ld [y], %r2 • x, y, z are labels corresponding
addcc %r1, %r2, %r3 to some address value
st %r3, [z] • %r1, %r2, %r3 are registers
halt
x: 15
y: 9
z: 0
.end
halt
© Alex Ufkes, 2020, 2025 88
ARC Assembly: VS Machine Instructions
ld, st
If instruction
begins with 10, it
is Arithmetic
i = 0: 2nd operand in register
rd: Destination register i = 1: 2nd operand is 13-bit
• 5 bits, we have 32 registers op3: Choose sign extended value
• Represent values 0-31 operation
© Alex Ufkes, 2020, 2025 91
If instruction op3: Choose
begins with 11, it operation
is Memory
rd: Register
• Load into i = 0: Address = rs1 + rs2 (register + register)
• Store from i = 1: Address = rs1 + simm13 (register + immediate constant)
© Alex Ufkes, 2020, 2025
Address from single register? Use %r0 for either rs1 or rs2 92
Assembly is daunting enough for most programmers, never mind
composing and decoding machine instructions.
Pop Quiz:
What is significant
about 2048?
.begin
.org 2048 • Set location counter to 2048
prog1: ld [x], %r1 • We can change this
ld [y], %r2 throughout our program
addcc %r1, %r2, %r3 • Dictate where things are
st %r3, [z] stored in memory.
x: 15 • I.e., place a large array higher
y: 9 up in the address space.
z: 0
.end
.begin
.org 2048 • Load value at address x into register 1
prog1: ld [x], %r1 • Load value at address y into register 2
ld [y], %r2
addcc %r1, %r2, %r3
st %r3, [z]
x: 15 • Add contents of registers 1 and
y: 9 2, place result in register 3.
z: 0 • Store contents of register 3 at
.end memory location z
Memory
Address Contents
Here we have:
rd = 1
rs1 = 0
simm13 = 2064
Address Contents
Address Contents
• We stored %r3
back to memory.
• 0x18 == 24