CSE 230 part 1

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

data segment

contains global data for program, .word designated has an initial value and address

arithmetic

convert by integer division, dividing by target base and keep track of remainder, use for decimal to binary and decimal to hex

Von Neumann model

created in the 1940's, common memory system where memory holds data and code/program

parts of MIPS program

data (.data) and code (.text), data starts at 0x10010000 and text starts at 0x00400000

discrete data

data values that have a defined predecessor and successor, ex: integer, char, [floating point not discrete]

assembly language

dependent on hardware (not portable), text representation of machine code

two's complement

one's complement +1, leftmost bit is sign bit, used for negative numbers

pseudo instructions

only core instructions turn to machine code, try not to use

one's complement

opposite of every bit, leftmost bit is sign bit

label

placeholder in a program, value is an address, data segment has assembler directives to specify data and initial values, ex) .data first: .word 5 second: .word 7 str: .asciiz "hello"

high level language

portable, easier to read/write, abstract

Methods for converting bases

positional notation, grouping/expansion, arithmetic

Instruction Set Architecture (ISA)

programmer view of processor, PC, IR, M

memory instructions

read (copy value from memory and store in register) or write (copy from register and store in memory)

the constant zero

$0 is the constant zero, cannot be overwritten

registers

$0 or $zero for all zeroes, $s0, $t0, etc.

syscall memory numbers

(go to memory lecture slides) 4 print a string,5 print an integer

0x2 in binary

0010

0x3 in binary

0011

0x4 in binary

0100

0x5 in binary

0101

0x6 in binary

0110

0x7 in binary

0111

Hex notation

0x comes before

0x8 in binary

1000

0x9 in binary

1001

0xA in binary

1010

0xB in binary

1011

0xC in binary

1100

0xD in binary

1101

word

32 bits/4 bytes (depends on processor but for this class)

byte

8 bits

5 classic components of a computer

CPU control: what to do, CPU datapath: support execution, Memory: primary and secondary, Devices: input and output to communicate to the outside world

Fetch/Execute Cycle

Fetch instruction; .......IR = M[PC]; .......PC = PC + increment; Execute instruction in IR;

Instructions

R-format, <mnemonic> <dest>, <source 1>, <source 2>

nor

a NOR b = NOT (a OR b), NOT operation by NOR with zero, ex) nor $t0, $t1, $0

IR = M[PC]

get instruction address from memory, occurs concurrently with PC increment

base N converted to base M

given an unlimited number of digits, they can be converted without losing any information, BUT when storing data in a computer is not unlimited, data loss could occur

levels of program code

high level language -> compiler -> assembly language -> assembler -> machine code

unconditional branch

j: jump, jal: jump and link (call to function), jr: jump from register (return from function), jumps have to be marked with a label

load upper immediate

lui <reg>, <const>, load half word (2 bytes) into upper half of register, set lower half to 0x0000

load word (reading memory)

lw <reg>, <disp> (<reg>), read word of data from memory, base register holds the address

positional notation

most number systems use this, value depends on digit's position and number's base, use for binary to decimal and hex to decimal

Signed integers can be stored in

signed magnitude, one's complement, two's complement

shift left

sll <dest>, <reg>, <shift>, shift left logical, specify how many bits, 0 to 31 positions, fills on right side with 0, to calculate, convert to bits and then change appropriate bytes

shift right

srl <dest>, <reg>, <shift>, shift right logical, specify bits shift to right, fill on left side with 0, do not sign fill, shift 4 moves over one hex digit, use for dividing by powers of 2

strings

strings end in null terminator, ex: hello takes 6 bytes

save word (writing memory)

sw <reg>, <disp> (<reg>), need base register to hold address, source register with value, write

and

used for mask or isolation of part of register, bitwise

0x1 in binary

0001

0xE in binary

1110

0xF in binary

1111

arithmetic swap

add $s1, $s1, $s2 sub $s2, $s1, $s2 sub $s1, $s1, $s2

Subtract a constant

add a negative value, addi $t0, $t0, -3

or

add bits to a word, bitwise

signed vs unsigned

add vs addu

address v. data

address is location in memory, word address may be divisible by 4

how to access memory

address must be stored in a base register, memory location is calculated by adding base register contents to an offset or displacement, ex) no offset: 0($t0), add 4: 4($t0) [$t0 does not change]

impact on performance

algorithm, programming language, compiler, architecture, processor and memory system

Below your program

applications software above systems software above hardware

machine code

binary

grouping/expansion

binary to hex, hex to binary

logical operations

bitwise manipulation, useful for extracting and inserting groups of bits in a word

labels in code

can mark beginning/ending of loop, functions, target instructions, must be unique in program, do not take up space in assembled program

MIPS instruction set

commercial processor, typical of moderns ISAs, all instructions 32 bits, 32 general registers, some registers for special purposes, 32 bit address

set on less than

compare 2 registers and set a register with result of comparison, 0x00000001 if 1st < 2nd, 0x00000000 if 1st >- 2nd, slt for signed, sltu for unsigned

constants

constant in 2nd source, marked with 'i' for immediate data, values can be decimal or hexadecimal, ex: addi, addiu (16 bits extended to 32 bits)

levels of precedence

evaluate left to right, subtraction and addition same level of precedence

format of MIPS program

every line has only one instruction, #for comments on every instruction

sign extension

extend from 16 to 32 bits, same value

zero extension

extend value zero filled, put zeros in left 4 bytes, value of result may not be the same

printing a string

get address by counting or having assembler do the work, extended instruction la, use in .text, la <reg>, <label name> [loads address of label into register]

program counter (PC)

holds address of next instruction

memory (M)

holds data and code

instruction register (IR)

holds instructions to execute

system calls

not standard MIPS instructions, syscall used for calls to the operating system (input/output), load $v0 with command to execute, put output value in $a0 (or $f12), get input result from $v0 (or $f0)

signed magnitude

one bit is for the sign, leftmost bit

Range of values in N bits

unsigned: 0...(2^N) -1, 1's complement: -((2^N-1)-1)...((2^N-1)-1), 2's complement: -(2^N-1)...((2^N-1)-1); 2's has one more value because 1's has + and - 0


संबंधित स्टडी सेट्स

economics chapter 5, economics chapter 7, economics chapter 8, economics chapter 10, economics chapter 11, economics chapter 12, economics chapter 13, economics chapter 15, economics chapter 16, economics chapter 1, economics chapter 2, economics cha...

View Set

Chapter 15: Management of Patients with Oncologic disorders

View Set

Project Time Management (Chap 6)

View Set

chapter 5 - the flow of food intro

View Set

OB Ch 27 Care of the Mother and Newborn

View Set

Chapter 4 Human Digestion & Absorption

View Set