CPSC355 studying

studied byStudied by 7 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions
Get a hint
Hint

A basic computer system consists of:

1 / 174

flashcard set

Earn XP

Description and Tags

175 Terms

1

A basic computer system consists of:

Central Processing Unit (CPU)

System Clock

Primary Memory

Secondary Memory

Peripheral devices

Bus

New cards
2

What is the the purpose of the CPU?

Executes instructions

Controls the transfer of data across the BUS

New cards
3

What are the 3 main parts of the CPU?

Control Unit (CU)

Arithmetic Logic Unit (ALU)

Registers

New cards
4

What is the Job of the CU?

  • Directs the execution of instructions

New cards
5

What is the Job of the ALU?

Preforms arithmetic and logical operations on data stored in registers

New cards
6

What are Registers?

Are binary storage units within the CPU

New cards
7

What are general-purpose registers?

Used to temporarily hold data and addresses

New cards
8

The Program Counter(PC)?

Contains the address in memory of the currently executing instruction

New cards
9

The Status Register?

Contains information(flags) about the results of a previous instruction

New cards
10

What is the System Clock?

Generates a clock signal to synchronize the CPU and other clocked devices

iMac(2016) - 3.2 GHz

Raspberry Pi - 700 MHz

New cards
11

What is Primary Memory?

Is Random Access Memory that is volatile and is used to store program instructions and program data

New cards
12

What is a Bus?

Is a set of parallel data/signal lines used to transfer information between computer components

New cards
13

3 types of Bus?

Address Bus - Specifies memory location in RAM

Data Bus - Used for bidirectional data transfer

Control Bus - Used to control or monitor devices connected to the bus

New cards
14

What is Secondary Memory?

Is used to hold a computer's file systemIs non-volatile read/write memory

Usually embodied on a hard disk drive (HDD)

New cards
15

What are peripheral I/O Devices?

Allow communication between the computer and the external environment

New cards
16

Examples of input Devices

Keyboard

Pointing devices

Microphone

Scanner

New cards
17

Examples of output devices

Monitior

Printer

Speakers

New cards
18

Examples of I/O devices

HDD

Modem

Connection to networks

New cards
19

Where do operands for an instruction come from?

The accumulator register (ACC) and from a single location in RAM

New cards
20

What is the typical program sequence?

-Load registers from memory

-Execute an instruction using two source registers, putting the result into a destination register

-Store the result back into memory

New cards
21

What is a RISC architecture

Reduced Instruction Set Computer

  • Uses only simple instruction that can be executed in one machine cycle

  • Machine instructions are always the same size

  • Enables faster clock rates, thus faster overall execution

  • Makes programs larger and more complex

  • Makes decoding simpler and faster

New cards
22

What is a CISC architecture?

May have instructions that take many cycles to execute

  • Provided for programmer convenience

  • Slows down overall execution speed

  • Machine instructions vary in length and may be followed by immediate data

  • makes coding difficult and slow

New cards
23

What is an Instruction Cycle?

Also called the fetch-execute or fetch-decode-execute cycle

  1. Fetch the next instruction from memory into the IR

  2. Increments PC to point to the next instruction

  3. Decode the instruction

  4. If the instruction uses an operand in RAM, calculate its address

  5. Fetch the operand(4 and 5, repeat if necessary)

  6. Execute the instruction

  7. If the instruction produces a result that is stored in RAM, calculate its address

(6 and 7, repeat necessary)

  1. Store the result

New cards
24

What is the basis of Assembly Language Programs?

-Consists of a series of statements, each corresponding to a machine instruction

- Each statement consists of an opcode and a variable number of operands

New cards
25

What are assemblers?

Translate assembly source code into machine code

New cards
26

What are macro processors

Assemblers that can support macros where you can define a piece of text with a macro name

New cards
27

What type of Computer is the ARMv8-A architecture?

  • Is a RISC- Is a Load/Store machine

New cards
28

The ARMv8-A architecture has two execution states

  • AArch64

  • AArch32

New cards
29

The ARMv8-A has 4 exception levels

EL0: for normal user applications with limited privileges

- Restricted access to a limited set of instructions and registers

EL1: for the OS kernel

- Privileged access to instructions, registers, and memory

EL2: for a Hypervisor

- Support virtualization, where the computer hosts multiple guest operating systems, each on its own virtual machine

El3: Low-level firmware

- Include the Secure Monitor

New cards
30

How many registers in AArch64?

31 64-bit wide general-purpose registers, labeled x0-x31

New cards
31

What are registers x0-x7 used for?

Used to pass arguments into a procedure and return results

New cards
32

What is register x8 used for?

Indirect result location register

New cards
33

What are registers x9-x15 used for?

Temporary registers

New cards
34

What are registers x16-x17 used for?

intra-procedure-call temporary registers

New cards
35

What are registers x18, x29, and x30 used for?

x18: Platform register

x29: Frame Pointer

x30: Procedure Link register

New cards
36

What registers are used as callee-saved registers?

X19-X28

New cards
37

What are the three special-purpose registers?

  • Stack Pointer: (SP) Used to point to the top of the run-time stack

  • Zero Register: (XZR) gives 0 value when read from, discards value when written to you

  • Program Counter: (PC) holds the address of the currently executing instruction

New cards
38

What is the form of the move instruction?

32 bit immediate mov Wd, #imm32 32 bit register mov Wd, Wn 64 bit immediate mox Xd, #imm64

64 bit register mox Xd, #imm64

New cards
39

How can functions be called?

Using the Branch and Link Instruction (bl)

New cards
40

What is the basis of a main routine in an Assembly Language Program

.global mainmain: stp x29, x30, [sp, 16]! (These 3 are save states) mov x29, sp

Code here ldp x29, x30, [sp], 16 (These two are restore states)ret

New cards
41

What does the ".global main" do?

  • Makes the label "main" visible to the linker- The main() is where execution always starts

New cards
42

What does "[sp,16]!" mean?

Allocations 16 bytes in stack memory (in RAM)

New cards
43

What does "stp x29, x30" mean?

Stores the contents of the pair of registers to the stack

New cards
44

"mov x29, sp"

  • Update FP to the current SP- FP may be used as a base adress in the routine

New cards
45

"ldp x29, x30, [sp], 16"

  • Loads the pair of registers from RAM- Restores the STate of the FP and LR registers

  • Deallocated 16 bytes of stack memory

New cards
46

Addition

add x20, x19, x21 x20 = x19 + x21

New cards
47

Multiplication

mul x20, x19, x21 x20 = x19 * x21

New cards
48

Subtraction

sub x20, x19, x21 x20 = x19 - x21

New cards
49

Multiply-Add

madd Wd, Wn, Wm, Wa Wd = Wa + (Wn * Wm)

New cards
50

Multiply-Subtract

msub Wd, Wn, Wm, Wa Wd = Wa - (Wn * Wm)

New cards
51

Multiply-Negate

mneg Wd, Wn, Wm Wd = -(Wn*Wm)

New cards
52

Division

Signed form sdiv Wd, Wn, Wm Wd = Wn/Wm Unsigned form udiv Wd, Wn, Wm Wd = Wn/Wm

New cards
53

How to print to standard Output

fmt: .string "This is a string"

adrp x0, fmt

add x0, x0, :lo12:fmt

bl printf

New cards
54

What is a branch instruction?

A branch instruction transfers control to another part of a program

New cards
55

What are Condition flags?

Are single-bit units in the CPU, record process state information, 0 means false and 1 means true

New cards
56

What are the 4 condition flags?

Z: true if result is Zero

N: true if result is Negative

V: true if result is overflows

C: true if result generates a carry out

New cards
57

How can you set condition flags?

Are set by instructions that end in "s" (short for set flags) Eg, subs, adds

New cards
58

Table for Conditions

NAME MEANING C Equivalent Flagseq equal == Z1ne not equal != Z0gt greater than > Z0 && NVge gt or equal >= NVlt less than < N!=Vle lt or equal <= ! (Z0 && N==V)

New cards
59

How are loops formed?

They are done by branching from the bottom of the loop to the top

New cards
60

Example of do loop

define(x_r, x19) mov x_r, 1 top: statements forming loop body add x_r, x_r, 1 cmp x_r, 10 b.le top

New cards
61

Example of while loop

define(x_r, x19) mov x_r, 0 test: cmp x_r, 10 b.ge done

statements forming body of loop

add x_r, x_r, 1 b test

New cards
62

Example of for loop

define (i_r, x19)

define (x_r, x20)

mov i_r, 10 // initialization

b test

top:

add x_r, x_r, i_r

// loop body

add i_r, i_r, 1

// increment

test:

cmp i_r, 20

// if i < 20 ..

b top

// branch to b (do ..)

New cards
63

What is the if Construct?

Is formed by branching over the statement body if the condition is not true

New cards
64

Example of If-Else Construct

o Eg: C code if (a > b) { c = a + b; d = c + 5; }

In assembly:

define (a_r, x19)

define (b_r, x20)

define (c_r, x21)

define (d_r, x22)

. . .

cmp a_r, b_r

//test

b.le next

// logical complement add c_r, a_r, b_r

// body

add d_r, c_r, 5

next:

statement after if-construct

New cards
65

What are binary numbers?

Are base 2 numbers

Use only the binary digits (bits) 0 and 1

Easy to encode on a computer

An N-bit register can hold 2^N bit patterns

New cards
66

How are unsigned integers encoded?

Using only binary numbers, range is 2^N - 1, where N is the number of bits

New cards
67

How are signed integers encoded?

  • Most commonly encoded using the two's complement representation Range: -2^N-1 to +2^N-1 -1 Negating a number is done by: - Taking the one's complement - Adding 1 to the result

  • All positive numbers will have a 0 in the left-most bit- All negative numbers will have a 1 in the left most bit

New cards
68

What are hexadecimal Numbers?

Are base 16 numbers 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 A 1010 B 1011 C 1100 D 1101 E 1110 F 1111

  • 0xF5A

New cards
69

What are Octal Numbers?

Are base 8 numbers

New cards
70

Different types of data table

A64 Keyword Size in Bits C Keyword byte 8 char halfword 16 short int word 32 int doubleword 64 long int, void *(pointer)quadword 128 N/A

New cards
71

What are bitwise logical instructions?

Manipulate one or more bits in a register

New cards
72

AND

is used for making bitmasks

  • E.g ANDing with 1111 0000 (0xF0) sets bits 0-3 to 0, but keeps the rest the same

New cards
73

ORR

can help you set bits (put a 1 for the bits you want to set)

E.g 1010 1010

orr 0011 0000

1011 1010

New cards
74

EOR

helps to toggle bits

  • E.g put a 1 in the position of the bits you want to switch 0101

  • eor 1111

  • 1010

New cards
75

Bit Clear (AND NOT)

allows you to clear bits

  • E.g set a 1 in the position of a bit you would like to set to 0

New cards
76

What is a logical shift left?

Whenever you would like to shift the bits to the left or multiply by a power of two Form: lsl Xd, Xn, Xm

New cards
77

What is logical shift right?

Form: lsr Xd, Xn, Xm Whenever you would like to shift bits to the right or divide by a power of two No remainder Does not work for negative signed integers

New cards
78

What is Arithmetic Shift Right?

Form: asr Xd, Xn, Xm Xn: bit pattern to be shiftedXm: shift count ASR preserves the sign when dividing by a power of two

New cards
79

What is Rotate Right?

Form: ror Xd, Xn, Xm Bit shifted out on the right are inserted on the left 32-bit form uses bits 0-31 only

New cards
80

What is Signed Extend Byte?

Form: sxtb Wd, Wn

  • Sign extends bit 7 in Wn to bits 8-31

New cards
81

What is Signed Extend Halfword

  • Form: sxth Wd, Wn

  • Sign-extends bit 15 in Wn to bits 16-31

New cards
82

What is signed extend word?

o Form (64-bit only): sxtw Xd, Wn

o Sign-extends bit 31 to bits 32-63

New cards
83

What is Unsigned Extend Byte

Unsigned Extend Byteo Form (32-bit only): uxtb Wd, Wn

o Zero-extends bits 8-31

New cards
84

What is Unsigned Extend Halfword?

o Form (32-bit only): uxth Wd, Wn

o Zero-extends bits 16-31

New cards
85

What is Modulus Arithmetic

  • Constrains number to the range 0 to M-1, where M is the modulus

    • CPUS normally do modulus arithmetic

New cards
86

Addition Binary Arithmetic

<p></p>
New cards
87

Subtraction Binary Arthmetic

Is done in the ALU by negating the subtrahend, and the adding

o Reuses the addition circuitry, thus minimizing hardware complexity

o 4-bit example: 7 -5 = 7 + (-5) = 2

0111

1011

+====

1 0010

carry out is ignored

New cards
88

What is the basis of Multiplication of binary numbers

A conditional addition

An arithmetic shift right

New cards
89

What is the stack memory?

Is space in RAM provided by the OS to store data for functions

New cards
90

How much addresses can it store?

2^64 or 0xFFFFFFFFFFFFFFFF

New cards
91

What can be stored into RAM

Byte (1), halfword (2), word (4), doubleword (8)

New cards
92

What is the heap?

The heap is used for dynamically allocated memory in a program

New cards
93

What is the stack pointer?

The stack pointer register always points to the top of the stack

New cards
94

How much should the stack be alligned by

Quadword alligned The address in SP must be evenly divisble by 16

New cards
95

What is the frame pointer?

  • Is used to point to local variables in a stack frame

  • A stack frame is pushed onto the stack when entering a function, must be at least 16 bytes long

New cards
96

What are stack variables

  • Are created by allocating extra space in the stack frame when entering a function

New cards
97

How do you read and write stack variables

o Eg: Write 42 to the first stack variable

. . .

mov w20, 42

str w20, [x29, 16] -> x29 (base address), 16 (offset)

. . .

o Eg: Read from the second stack variable

. . .

ldr w21, [x29, 20] -> x29 (base address), 20 (offset)

New cards
98

Load Register Instruction

Load Register

o 64-bit for: ldr Xt, addr

Xt: register to be loaded

Addr: expression specifying the address in memory to read from

o Loads register with 8 bytes read from RAM

o Eg: ldr x22, [x29, 56]

o 32-bit from: ldr Wt, addr

New cards
99

Load Byte

Load Byte

o Form (32-bit only): ldrb Wt, addr

o Loads 1 byte from RAM into low-order part of Wt, zero-extending high-order bits

New cards
100

Load Signed Byte

Load Signed Byte

o Form (32-bit): ldrsb Wt, addr

o Form (64-bit): ldrsb Xt, addr

o Loads 1 byte from RAM into low-order part of Wt or Xt, signextendinghigh-order bits

New cards
robot