CS 2810 Architecture Module 2
First byte sequence when coding binary
128, 64, 32, 16 - 8, 4, 2, 1
Binary is a base..
2
What number do you put by a shift operator to 4 bits?
2 The shift operators constant is actually 2^i " i being 2 in this case to shift by 4
How to represent negative numbers in binary
2's compliemnt
Unsigned 16 bits range Signed 16 bits range
2^16 = 65536 -2^15 to (2^15 -1)
How many memory words are in MIPS?
2^30
Operations need exactly how many operands?
3 - no more no less
How many bits are in a MIPS instruction set?
32
In MIPS how many registers are there?
32
Represent an Integer in MIPS requires...
4 bytes / or 32 bits each byte has 8 bits 8*4 = 32
Field names (I-type (for immediate))
6 bit Opcode 5 bit Register Source 5 bit Second Register Source(rt) 16 bit Constant or address lw destinationRegister,
Explain: add a , b, c
# The sum of b and c is placed in a
Which register is reserved for large constants?
$a0
$a_ range?
$a0 - $a3
Unique registers in MIPS
$gp $fp $sp $ra $at $zero
$s_ range?
$s0 - $s7 *Correspond to variables in C an Java
$t_ range?
$t0 - $t9 *Used for Temporary holds
Label all parts: add $t0, $t0, 5
$t0 - register 5 - immediate
$v_ range?
$v0 - $v1
Register always equal to zero?
$zero
Addresses of sequential words differ by..
*4
Range of 8 bits signed
-128 to +127 (0 is apart of the positive)
Logical operator OR
At least one of the conditions needs to be true.
Binary to Hexadecimal
Group into groups of 4. *can zeros to the left hand side if needed to make it a group of 4 A 4 bit can be at most 15. Use a-f for 10-15
What are data transfer instructions?
Instruction with the memory address (index in that array starting at 0), moves data between memory and registers
Memory
Larger, but slower to access - coming from RAM maybe only addressing constraints. store and load data
What are Registers
Limited amount of special locations built into the hardware
How to: 14 OR 3
Line up binary for each number. check vertically and apply OR to each
Big- Endian
Most significant bytes first. ( Left most byte = address 0 ) Out of 4 bytes (32 bits)
Little-Endian
Most significant bytes last. ( Right most byte = address 3) Out of 4 bytes (32 bits)
Hexadecimal to Decimal
Multiply place value by hex equivalent
Using 2's compliment, left-most bit is 1
Negative number
Machine Language vs Machine code
Numeric language, sequence code
Each line can hold how many instructions in MIPS?
One instruction per line
Logical operator XOR
Opposite of OR Cannot both be true
Registers
Part of hardware built into CPU Instruction set: how many registers available (MIPS 32 registers) fixed number benefit of registers - fast to access, no delay as you wait for data to come in but.. limited only so much data you can fit
Using 2's compliment, left-most bit is 0
Positive number
2's compliment
Positive numbers: normal binary with 0's out to the amount of bits given Negative numbers: binary number, find compliment, ADD 1 to the right-most bit of the complement. 1 +1 = 0 carry the one
What hardware unit hold the registers?
Processor
What are memory words used for?
To hold data structures, arrays, and spilled registers.
Byte
a group of 8 bits
A group of 32 bits in MIPS is called
a word
Extend an 8bit two's complement to 16 bit
add leading 0's if positive, add leading 1's if negative, until all bits used
Label all parts: add $t0, $t1, $t2
all are registers
b label
always takes that particular branch - not often used
Logical operators
and, or, not, xor, not
Byte addressing affects...
array index
How to save into an array
arrayName .space or .word li $v0, 5 (will read input INT) sw $v0, arrayName
Branch if equal Branch if equal than zero Branch if greater than Branch if not equal Branch if not equal to zero
beq beqz bgt benq benqz
bit
binary digit
Arithmetic Operations
bit shifts, boolean, or, and, etc. add, sub, mul, div, shift, or, and, sll
Branches allow us to control
flow of execution. Branch point - based on a value or set of values, we go to a different part of the program. Based on condition
Convert negative to positive bit using 2's compliment
get the complement of the bit, add 1.
Control Flow
instead of data, it moves where the programming is being executed, where its being read. ((If, else, method calls, for loops in other languages)) Branch, call, beqz, j,
What is the 'Store' and what is its format
instruction complementary to load - Copies data from a register to memory name of operation. register to be stored, offset(base register)
Computers vocabulary is called
instruction set
Computers language is called
instructions
Leading zeros vs trailing zeros
leading doesn't change the number. trailing does change the number
Syscall always needs...
load imediate into v0 =, number depends on TYPE it'll print 4 = print string 1 = print int 5 = READ int always prints whatever is in $a0 li $v0, 4 (string) syscall
Instruction Set Architecture (ISA)
set of instructions comp knows how to process and compute x86 - IBM MIPS ARMv7 ARMv8 older: 8080 modorolla 68K one processor doesn't run a different processors instruction set. Multiple processors that use same instruction set can use applications made on one.
Base address
starting address of an array
Address of a word matches...
the address of one of the 4 bytes in the word
Range of 8 bits unsigned
0-255 ( 256 number all together)
Logical operator NOT (unitary operator)
1 variable Opposite/ complement of input. Must be 0 to be true
Field names (R-Type (for register))
1. Opcode 2. register source 3. second register source 4. register destination 5. shift amount (or unused in many operations 6. function code - selects specific variant of the operation in the op field
Design Principles:
1. Simplicity favors regularity 2. Smaller is faster (usually) 3. Good design demands good compromises
How many data elements are in memory
Billions
Logical operator AND
Both of the conditions need to be true.
Decimal to Hexadecimal
Can do decimal to binary, then to hex. OR Divide 3162 into 256, put in the whole amount. 3162/256 = 12...
What are the ways you can manipulate 1's and 0's?
Categories Instructions: Data Handling, Arithmetic Operations, Control Flow
END OF VIDEO LECTURE
END OF VIDEO LECTURE
What are fields?
Each field (having many bits) represents one part of an instruction in an instruction set
We want to keep the clock cycle ___ fast or slow__?
Fast
Stored-Program concept
Programs, Instructions and data are stored in memory as numbers
Operands types
Registers Memory Immediates (constant values)
START OF TIO
START OF TIO
Represent 1, 026,854,800 in Little-Endian
Take each Byte from big-endian and flip backwards. Do not flip whole binary string!
How are memory words accessed?
They are accessed by data transfer instructions
What is Overflow?
When a number is too large to be represented with the number of bits allocated. occurs when the numbers' sign bits match but yield a SUM with a different sign bit.
a XOR a Will always equal
Zero. The same number will copy the bottom, so each bit will always be zero when XOR
Immediates
constant values hardcoded - stored in instruction itself - don't load from memory or store it. Can't even fit 32 bits in MIPS - not changeable
What is a load? And what is it's format
data transfer instruction type: specifically copies dat from memory to register. nameOfOperation regToBeLoaded, ConstantLocationInMemory(registerUsedToAccessMemory) lw $t0, 8($s3) In Proper terms: Loadword tempStorage, offset(register holding base address)
The first and last fields of an instruction do what?
define what operation/function will be preformed. add $t0 $s1 $s2 field 1 and 6 will be add
Instruction Set ARitecture differences
design devisors differ, availablities Two categories - Compex instruction set computer reduced instruction set computer *can have grey area, have some of each primary diff - CISC run one or more instructions, take multiple steps. variable length. fewer registers. hardware to implement. Hardware centric. Examples include Motorola 68K and x86 RISC - each instruction take exact same act of time. 1 instruction per clock cycle. fixed length. more registers. software break into single steps - no complex circitry like cisc. Software centric. Single-cycle instructions
Hexadecimal to Binary
each number or letter gets 4 bits (8,4,2,1) covert from left to right. Put them together in same order.
How to read in a user input integer?
load immediate, into 5 (READS int, meaning takes in user input) syscall to grab it store it into arry - store the value entered FROM syscall li $v0, 5 syscall move $t0, $v0 *to not overwrite on accident sw $t0, arrayName $t0 - store user inputted value
Load Word - Instruction
lw $t0, 32($s3) loadWord temporaryRegister, index*4(baseArray)
Arrays are held in...
memory
Data Handling
move 1 and 0 around. load into memory, load into reg. store in memory. copy from one location to another. Load, Store, Move
What does a shift operator do
moves all bits to left or right, filling the emptied bits with 0's sll willBeStoredHere, originalValue of word, shift how many places. sll $t1, $s0, 4
In MIPS, words must start addresses that
multiples of 4 *Alignment restriction
Goal: Invert every bit of $s3. Ex: If $s3 is 1010...1010, make $s3 0101...0101. _____ $s3, $s3, _____
nor / $zero $zero is just 0000 1 1 0 1 not or = both zero or both 1 0010
To get a valid byte address you must..
offset needs to be added to the base register by a multiple of 4
Logical operations do what
pack and unpacking of bits into words (32)
table all parts: lw $t1, num
register, memory
Read integer needs what kind of addressing? How do you ensure proper addressing?
to be at an address of a multiple of 4 items: .space 40 may not be aligned with .asciiz etc above it align 2 ( aligns it on a word boundary)