Made with ScholarlyMake flashcards like these from your own notes
Question:What are the main components of a basic computer system?
Answer:1. Central Processing Unit (CPU) 2. System clock 3. Primary memory (Random Access Memory - RAM) 4. Secondary memory (Hard Disk Drive - HDD or Solid State Drives - SSD) 5. Peripheral input and output devices (e.g., keyboard, monitor) 6. Bus (transfers data between components)
Question:What is the function of the Central Processing Unit (CPU)?
Answer:The CPU is the brains of any computer system. It executes instructions (i.e., a program) and controls the transfer of data across the bus.
Question:What is the CPU typically contained on?
Answer:A single microprocessor chip. Examples include Intel Core i5 and Apple A7.
Question:What are the three main parts of a CPU?
Answer:1. Control Unit (CU) 2. Arithmetic Logic Unit (ALU) 3. Registers.
Question:What is the role of the Control Unit (CU)?
Answer:The CU directs the execution of instructions, loads an operation code (opcode) from primary memory into the Instruction Register (IR), decodes the opcode to identify the operation, transfers data between primary memory and registers if necessary, and directs the ALU to operate on data in registers if necessary.
Question:What operations does the Arithmetic Logic Unit (ALU) perform?
Answer:The ALU performs arithmetic and logical operations on data stored in registers, such as adding numbers or performing bitwise operations.
Question:What are registers in the context of a CPU?
Answer:Registers are binary storage units within the CPU that store bit patterns, which may include data (integers, floating point numbers), addresses (pointers), instructions, and status information.
Question:What are General-Purpose registers?
Answer:Used by a programmer to temporarily hold data and addresses
Question:What does the Program Counter (PC) contain?
Answer:The Program Counter (PC) contains the address of the currently executing instruction in memory and is incremented to execute the next instruction.
Question:What is the Status Register (SR)?
Answer:The Status Register (SR) contains information flags about the result of a previous instruction, such as overflow or carry.
Question:What is the system clock's purpose in a computer system?
Answer:The system clock generates a clock signal to synchronize the CPU and other clocked devices, coordinating operations on the rising or falling edges of a square wave at a particular frequency. Executing instructions at higher clock rates is more productive
Question:What is Primary Memory (RAM)?
Answer:Primary Memory, often called Random Access Memory (RAM), allows direct (non-sequential) access to data, is used to store program instructions and data variables, can be written to and read from, is volatile (data disappears when powered off), and consists of a sequence of addressable memory locations each typically being one byte long.
Question:What is the typical size of RAM in an iMac 2016 and Raspberry Pi original?
Answer:iMac 2016: 8 GB; Raspberry Pi original: 256 MB.
Question:What is the difference between von Neumann architecture and Harvard architecture regarding memory?
Answer:In von Neumann architecture, RAM contains both data and program instructions, while Harvard architecture uses separate memories for data and programs.
Question:What does Secondary Memory do?
Answer:Secondary Memory holds a computer's file system, stores files containing programs or data, is nonvolatile (contents persist through power cycles), and is usually embodied on a hard disk drive (HDD) or solid state drive (SSD).
Question:What are the benefits of Solid State Drives (SSD) over Hard Disk Drives (HDD)?
Answer:SSDs are faster, have no moving parts, and offer high reliability.
Question:What are Peripheral I/O Devices?
Answer:Peripheral I/O Devices allow communication between the computer and the external environment.
Question:What are examples of input devices?
Answer:Examples include keyboard, mouse, trackball, joystick, microphone, and scanner.
Question:What are examples of output devices?
Answer:Examples include monitor, printer, and speakers.
Question:What is the function of buses in a computer system?
Answer:Buses are sets of parallel data signal lines used to transfer information between computer components, subdivided into address, data, and control buses.
Question:What does the address bus do?
Answer:• Specifies a memory location in RAM (positive integer) or sometimes communicate to peripheral devices • Common sizes: 32 and 64 bits -> parallel bits
Question:What does the data bus do?
Answer:• Used for bidirectional data transfer • Common sizes: 32 and 64 bits
Question:What does the control bus do?
Answer:• Control or monitor devices connected to the bus, but hidden from the programmer • Read/write signal for RAM
Question:What does the expansion bus do?
Answer:• Makes it easy to connect additional I/O devices to the computer • May be connected to the computer's local bus
Question:In Accumulator Machines, where do operands for an instruction come from?
Answer:Operands come from the accumulator register (ACC) and from a single location in RAM, with ALU results always being put into the ACC.
Question:What is the significance of Load-store machines?
Answer:In Load-store machines, only load and store instructions can access RAM, while other instructions operate on specified registers in the register file.
Question:What is the difference between Accessing RAM and Registers?
Answer:Registers are more quickly accessed than RAM, making operations faster when using registers.
Question:What is the typical program sequence in CPU operations?
Answer:1. Load registers from memory. 2. Execute an instruction using 2 source registers, putting the result into a destination register. 3. Store the result back into memory.
Question:What is a Register File?
Answer:A Register File is a collection of registers on the CPU.
Question:Why should operations be performed on the CPU whenever possible?
Answer:Because it is where the register is located and there is no need to transfer across the bus.
Question:What does RISC stand for and what are its characteristics?
Answer:RISC stands for Reduced Instruction Set Computer. It uses simple instructions that can be executed in one machine cycle, reduces hardware complexity, enables faster clock rates resulting in faster execution, and makes programs larger and more complex.
Question:What was the original SPARC?
Answer:The original SPARC had no multiply instruction; multiplication was done using a repeated series of add-shift operations
Question:What is a key feature of machine instructions in RISC architectures?
Answer:Machine instructions are always the same size in bit length, making decoding simpler and faster.
Question:What does CISC stand for and what are its characteristics?
Answer:CISC stands for Complex Instruction Set Computer. It may have more complex instructions that take many cycles to execute, are provided for programmer convenience, and it slows down overall execution speed. The machine instructions vary in length and may be followed by immediate data, making decoding difficult and slow (1-15 bytes). Example on Intel Core 2: adding = 1 cycle, multiply = 5 cycles, and dividing = 40 cycles
Question:What is an instruction cycle?
Answer:The instruction cycle, also called the fetch-execute or fetch-decode-execute cycle. 1. Fetch the next series of instructions from RAM into the instruction register (IR). 2. Increment PC to point to the next instructions. 3. Decode the instruction, done by hardware behind the scenes. 4. If the instruction uses an operand in RAM, calculate its address. 5. Fetch the operand. 6. Execute the instruction. 7. If the instruction produces a result that is stored in RAM, calculate its address. 8. Store the result. Steps 4-5 and 7-8 are repeated if necessary
Question:What are opcodes?
Answer:Opcodes denote the operation and format of instruction (eg. mul, add, sub)
Question:What are operands?
Answer:The values to be used in an operation
Question:What are labels?
Answer:A symbol whose value is a specific address of the machine instruction. It can be used as a target in branch instructions
Question:What does an assembly language program consist of?
Answer:It consists of a series of statements, each corresponding to a machine instruction. The instructions are stored sequentially in memory and each instruction has a unique address. Optionally, a label can prefix any statement (ie. label: statement)
Question:What is the structure of an assembly language instruction statement?
Answer:Each statement consists of an opcode and a variable number of operands.
Question:What are pseudo-ops in assembly language?
Answer:Pseudo-ops are assembler directives that do not generate machine instructions but give the assembler extra information that may be required.
Question:What is the purpose of comments in assembly language?
Answer:Comments may be appended to the end of a statement to clarify the code and are important for understanding as assembly can be very complicated.
Question:What is the role of an assembler?
Answer:Assemblers translate assembly source code into machine code.
Question:What command is used to assemble ARMv8 source code using GNU assembler?
Answer:gcc myprogs -o myprog, which invokes the assembler and links the code producing an executable called myprog.
Question:What is the purpose of Macro Preprocessors in assembly language?
Answer:Macro Preprocessors allow a piece of text to be defined with a macro name, providing shorthand pieces of text that makes code more readable.
Question:What is macro expansion?
Answer:Wherever the macro is invoked, the text will be substituted inline
Question:What is m4 used for?
Answer:gcc (actually as) has limited support for macros. So, m4 is used instead before invoking gcc. (eg. m4 myprog.asm > myprog.s)
Question:What does ARM stand for in ARMv8A Architecture?
Answer:ARM stands for Advanced RISC Machine, originally Acorn RISC Machine.
Question:What type of machine is the ARMv8A Architecture?
Answer:The ARMv8A Architecture is a RISC and a Load/Store machine, using a von Neumann architecture for RAM. The register file contains 31 64-bit wide registers and most instructions manipulate the data in registers.
Question:What is AArch64 and in which instruction set is it used?
Answer:AArch64 uses the A64 instruction set and 64-bit registers.
Question:What is AArch32 used for?
Answer:AArch32 uses the A32 or T32 instruction sets and is provided for backwards compatibility with the older ARM and THUMB instruction sets using 32-bit registers.
Question:How many exception levels are there in ARMv8A?
Answer:There are 4 exception levels in ARMv8A.
Question:What is EL0 used for?
Answer:- EL0 is used for normal user applications with limited privileges - Restricted access to a limited set of instructions and registers and to certain parts of memory. - Most programs work at this level
Question:What is the purpose of EL1?
Answer:- EL1 is for the OS kernel. - It provides privileged access to instructions, registers, and memory - Accessed indirectly by user programs using system calls.
Question:What is EL2?
Answer:- EL2 is for a hypervisor. - It supports virtualization, where the computer hosts multiple guest operating systems, each on its own virtual machine.
Question:What is the function of EL3?
Answer:- EL3 is for low-level firmware - Includes the Secure Monitor.
Question:How many bit-wide general-purpose registers are in AArch64?
Answer:AArch 64 has 31 64 bit-wide general-purpose registers numbered from 0 to 30
Question:What is the naming convention for registers when using all 64 bits?
Answer:When using all 64 bits, use 'x' or 'X' before the number (e.g., x0, x1, x30). -> x stands for extend
Question:What is the naming convention for registers when using only the low-order 32 bits?
Answer:When using only the low-order 32 bits, use 'w' or 'W' before the number (e.g., w2, w29).
Question:What are x0 to x7 registers used for?
Answer:Registers x0 to x7 are used to pass arguments into a procedure and return results.
Question:What is the function of register x8?
Answer:Register x8 is the indirect result location register.
Question:What is the purpose of registers x9 to x15?
Answer:Registers x9 to x15 are temporary registers.
Question:What are registers x16 and x17 used for?
Answer:Registers x16 and x17 are intraprocedure call temporary registers.
Question:What is the function of register x29?
Answer:Register x29 is the frame pointer (FP) register.
Question:What is the purpose of register x30?
Answer:Register x30 is the procedure link register (LR).
Question:Which registers should you use for most of your work as per the text?
Answer:Use registers x19 to x28 for most work, as they are callee-saved registers and the value preserved by any function called.
Question:What is the stack pointer (SP)?
Answer:The stack pointer (SP) is used to point to the top of the runtime stack. - SP: 64- bit register used in A64 code -WSP: 32-bit register used in A32 code
Question:What is the zero register (XZR/WZR)?
Answer:- The zero register always gives a value of 0 when read from, while discarding any value written to it. - The XZR is 64 bits wide and WZR is 32 bits wide.
Question:What does the Program Counter (PC) do?
Answer:- The Program Counter (PC) holds the address of the currently executing instruction - Always 64 bits wide - Cannot be accessed directly as a named register, but rather indirectly changed by branch and other instructions. - It is used implicitly by PC - relative loads/stores and can be accessed in gdb using $pc.
Question:How many floating-point registers does ARMv8A have?
Answer:ARMv8A has 32 128-bit wide floating-point registers.
Question:ARMv8A's system registers
Answer:Has numerous system registers to set up how the machine operates, most of which are only accessible in EL1
Question:What does the A64 assembly language consist of?
Answer:A64 assembly language consists of statements with one opcode (e.g., add, multiply, subtract) and 0 to 4 operands.
Question:What is the general purpose of the operands in A64 assembly?
Answer:In general, the first operand is a destination register, and the others are source registers.
Question:What is an immediate value in A64 assembly language?
Answer:- An immediate value is a constant that may be used as the final source operand for some instructions. - A # symbol can prefix the intermediates but is optional. - Immediates are assumed to be decimal numbers unless prefixed with 0x, 0, or 0b
Question:What is an alias?
Answer:Aliases are instructions for other instructions and are provided for readability and convenience (eg. mov is an alias for add and orr if a 0 register is involved)
Question:What is 'bl'?
Answer:- 'bl' stands for Branch and Link and is used to call a function. - It can be a library function or your own function. - Arguments are put in x0 - x7 before the call - The return value is in x0
Question:What does the structure of a basic program look like in A64 assembly language?
Answer:.global main main: stp x29, x30, [sp, -16]! mov x29, sp ldp x29, x30, [sp], 16 ret
Question:What does ".global main" do?
Answer:.global main provokes a pseudo op, making the label "main" visible to the linker. The main() routine is where execution always starts
Question:What is '[sp, -16]!' ?
Answer:[sp, -16]! is the first sub-step, allocating 16 bytes in stack primary memory. It does so by pre-incrementing the SP register by -16
Question:What is 'stp x29, x30'?
Answer:stp x29, x30 is the second sub-step, storing the contents of the pair of registers to the stack. It saves the state of the registers used by calling code
Question:What is 'x29'?
Answer:x29 is the frame pointer register (FP)
Question:What is 'x30'?
Answer:x30 is the link register (LR)
Question:What does 'SP' point to in 'stp x29, x30'?
Answer:SP points to the location in RAM where we write to
Question:What does 'mov x29, sp' do?
Answer:mov x29, sp updates the FP to the current SP. FP may be used as a base address in the routine
Question:What does 'ldp x29, x30' do?
Answer:ldp x29, x30 loads the pair of registers from RAM, restoring the state of the FP and LR registers
Question:What does 'SP' point to in 'ldp x29, x30'?
Answer:SP points to the location in RAM where we read from
Question:What does '[sp], 16' do?
Answer:[sp], 16 deallocates 16 bytes of stack memory by post-incrementing SP by +16
Question:What does "ret" do?
Answer:ret returns control to calling code in OS, using the address in LR
Question:What does add x20, x20, 1 do?
Answer:• x20 = x20 + 1 • Uses 1 destination and 2 source operands • Can use 64-bit and 32-bit registers, or an immediate value for the second source operand
Question:What does sub x0, x1, x2 do?
Answer:• x0 = x1 - x2 • Uses 1 destination and 2 source operands • Can use 64-bit and 32-bit registers, or an immediate value for the second source operand
Question:What does mul Wd, Wn, Wm do?
Answer:• Multiplication • Uses 1 destination and 2/3 source registers • No immediate are allowed • Has a 32-bit and 64-bit form • Wd = Wn x Wm • Alias for: madd Wd, Wn, WM, wzr
Question:What does madd Wd, Wn, Wm, Wa do?
Answer:• Wd = Wa + (Wn x Wm) • Multiply-add • Has 64-bit and 32-bit variants
Question:What does msub Wd, Wn, Wm, Wa do?
Answer:• Wd = Wa - (Wn x Wm) • Multiply-subtract • Has 64-bit and 32-bit variants
Question:What does mneg Wd, Wn, Wm do?
Answer:• Wd = -(Wn x Wm)
Question:Division in ARMv8
Answer:- Uses 1 destination and 2 source registers - No immediate allowed - Does integer division, where the calculated quotient is an integer and any remainder is discarded (doesn't appear in any registers)
Question:How do you calculate the remainder (modulus)?
Answer:• numerator - (quotient x denominator) • msub is useful here
Question:What does sdiv Wd, Wn, Wm do?
Answer:• Wd = Wn/Wm • Operands are signed integers • 32-bit and 64-bit variants
Question:What does udiv Xd, Xn, Xm do?
Answer:• Xd = Xn/Xm • Unsigned integer operands
Question:What happens if division by zero is attempted in assembly instructions?
Answer:It does not generate an exception ( a trap); instead, it writes 0 to the destination.
Question:What is the function of 'printf' in C?
Answer:- It is used to print to standard output and is invoked with one or more arguments. - The first argument is the format string surrounded by " " and the rest correspond to placeholders in the string
Question:What is the purpose of branch instructions in assembly?
Answer:Transfers control to another part of a program (jump instructions), similar to 'goto' in C.
Question:What happens to the PC register during a branch instruction?
Answer:The PC register is not incremented, but is set to the computed address of the instruction. It corresponds to the value of its label.
Question:What is 'b label'?
Answer:An unconditional branch is always taken (always makes the jump)
Question:What are the condition flags in a CPU?
Answer:- They are single-bit units that store information about the result of an instruction, recording process state (PSTATE) information with 0 meaning false and 1 meaning true. - Condition flags are set by instructions that end in "s" (short for set flags)
Question:Name the four condition flags and their meanings.
Answer:- Z: True if the result is zero - N: True if the result is negative - V: True if the result overflows - C: True if the result generates a carry out.
Question:What does 'subs' instruction do?
Answer:Used to compare two registers
Question:What does 'cmp Xn, Xm' do?
Answer:• An alias for subs xzr, Xn, Xm • A more intuitive version of subs
Question:What is the purpose of conditional branch instructions?
Answer:- They use condition flags to make decisions on whether to branch or not. - Branch is taken (jumps to instruction at specified label) if a flag tests true - Control "drops through" to the next instruction if they flag tests false - Form: b.cc, where cc is the condition code
Question:What does the 'eq' flag represent?
Answer:• Equal • C equivalent: == • Flags: Z == 1
Question:What does the 'ne' flag represent?
Answer:• Not equal • C equivalent: != • Flags: Z ==0
Question:What does the 'gt' flag represent?
Answer:• Greater than • C equivalent: > • Flags: Z == 0 && N == V
Question:What does the 'ge' flag represent?
Answer:• Greater than or equal to • C equivalent: >= • Flags: N == V
Question:What does the 'lt' flag represent?
Answer:• Less than • C equivalent: < • Flags: N != V
Question:What does the 'le' flag represent?
Answer:• Less than or equal to • C equivalent: <= • Flags !(Z==0 && N==V)
Question:Which conditional codes are the logical compliment of each other?
Answer:• gt and le • ge and lt
Question:How are loops formed in assembly?
Answer:- Initialize a variable for the loop counter and compare it to the number of times the loop iterates - By branching from the bottom of the loop to the top as long as the counter < total number of iterations.
Question:What is a do loop?
Answer:A post-test loop where the test is at the very end, ensuring the loop body executes at least once.
Question:What is a while loop?
Answer:A while loop is a pretest loop where the execution of the loop body is not guaranteed.
Question:How can you optimize code?
Answer:- Moving the test to the end of the loop - Reduces the loop by one instruction - Branch matches the original C code - Must branch to the test the first time encountered, but still a pre-test loop
Question:How do you form a form loop?
Answer:Convert the equivalent while loop
Question:How is an if construct formed in Assembly?
Answer:- The if construct is formed by branching to skip over the statement body if the condition is not true. - Must use the logical complement: blt = bge, ble = bgt, beq = bne
Question:How is the if-else construct formed in Assembly?
Answer:- The if-else construct is formed by branching to the else part if the condition is not true, using the logical compliment. - If true, the code falls through to the if part and has an unconditional branch to the statement after the construct.
Question:What is the purpose of 'gdb'?
Answer:gdb (GNU Debugger) is a debugger that allows you to run a program under debugger control.
Question:What is the command to start a program under debugger control in gdb?
Answer:Use the command 'gdb myprogram' to start a program under debugger control.
Question:How do you set a breakpoint in gdb?
Answer:To set a breakpoint, type 'b label' (e.g., 'b main').
Question:What does the 'r' command do in gdb?
Answer:The 'r' command (run) is used to run your program, which will stop at the first breakpoint.
Question:What does the 'c' command do in gdb?
Answer:The 'c' command (continue) is used to continue execution to the next breakpoint or to the end of the program if no other breakpoints are set.
Question:What does the 'si' command do in gdb?
Answer:The 'si' command (single step instruction) executes the next instruction and steps into subroutines.
Question:What does the 'ni' command do in gdb?
Answer:The 'ni' command (next instruction) executes the next instruction but does not step into function calls; it proceeds until the function returns.
Question:How can you automatically show the current instruction when single stepping in gdb?
Answer:- Use 'display/i pc' to automatically show the current instruction when single stepping. - Done before running the program
Question:What command do you use to print the contents of a register in gdb?
Answer:Use 'p $reg' (e.g., 'p x19') to print the contents of a register.
Question:What format characters can you append to 'p $reg' in gdb?
Answer:- Signed decimal: p/d - Hexadecimal: p/x - Binary: p/t
Question:How do you quit gdb?
Answer:Use the command 'q' to quit gdb.
Question:What are binary numbers?
Answer:Base 2 numbers that use only the binary digits (bits) 0 and 1.
Question:How are binary numbers easy to encode on a computer?
Answer:They are easy to encode since only 2 states need to be distinguished.
Question:What voltages represent binary digits 0 and 1?
Answer:0 is represented by 0 V and 1 is represented by 3.3 V.
Question:How are binary numbers represented using paper tape or cards?
Answer:0 is represented as unpunched and 1 as punched.
Question:How are binary digits represented using toggle switches or bulbs?
Answer:0 is off and 1 is on.
Question:How many distinct bit patterns can an N-bit register hold?
Answer:2^N bit patterns. (eg. a 4-bit register can hold 16 distinct bit patterns)
Question:What is the range of an N-bit register?
Answer:0 to 2^n - 1, with no negative numbers
Question:What is two's complement representation?
Answer:Encodes signed integers in binary form, allowing for both positive and negative numbers to be represented.
Question:What is the range of N-bit signed integers using two's complement?
Answer:-2^(N-1) to + 2^(N-1) - 1
Question:What are the steps to negate a number in signed integers?
Answer:1. Take the ones complement (toggle all 0s to 1s and vice versa). 2. Add 1 to the result.
Question:Where is the signed bit located
Answer:In the left-most bit
Question:What is the sign bit for positive numbers?
Answer:It is 0 in the leftmost bit.
Question:What is the sign bit for negative numbers?
Answer:It is 1 in the leftmost bit.
Question:4-bit clock face
Answer:0 = 0000 1 = 0001 2 = 0010 3 = 0011 4 = 0100 5 = 0101 6 = 0110 7 = 0111 -8 = 1000 -7 = 1001 -6 = 1010 -5 = 1011 -4 = 1100 -3 = 1101 -2 = 1110 -1 = 1111
Question:What are Sign-magnitude and ones complement representations?
Answer:Rarely used because it has +0 and -0
Question:What are hexadecimal numbers?
Answer:Base 16 numbers that use the digits 0-9 and A-F, where uppercase or lowercase doesn't affect the program.
Question:How is each hex digit related to binary?
Answer: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
Question:What are octal numbers?
Answer:- Base 8 numbers that use the digits 0-7. - May be used as shorthand to denote bit patterns - Each digit corresponds to a 3-bit pattern
Question:What is the 'byte' size and keyword in C?
Answer:Size: 8 bytes C: char
Question:What is the 'halfword' size and keyword in C?
Answer:Size: 16 bytes C: short int
Question:What is the 'word' size and keyword in C?
Answer:Size: 32 bytes C: int
Question:What is the 'doubleword' size and keyword in C?
Answer:Size: 64 bytes C: long int, void (pointer)
Question:What is the 'quadword' size and keyword in C?
Answer:Size: 128 bytes C: N/A
Question:How do you denote unsigned integers in C?
Answer:By using the unsigned keyword.
Question:What are Bitwise Operations?
Answer:Bitwise Operations are operations that manipulate one or more bits in a register.
Question:What is the truth table for AND?
Answer:Truth table for AND: 0 AND 0 = 0 (false) 0 AND 1 = 0 (false) 1 AND 0 = 0 (false) 1 AND 1 = 1 (true) -> Both must be 1 to be true
Question:What is a bitmask?
Answer:Bitmasks "mask" out certain bits (sets to 0) except for certain bits (set to 1)
Question:What is the purpose of the ANDS instruction?
Answer:ANDS sets or clears the N and Z flags according to the results, with V and C always cleared.
Question:What is the alias for 'tst' instruction?
Answer:• tst is an alias for ands. • tst Xn, Xm • and xzr, Xn, Xm
Question:What is the truth table for Inclusive OR?
Answer:Truth table for Inclusive OR: 0 or 0 = 0 0 or 1 = 1 1 or 0 = 1 1 or 1 = 1 -> At least one must be 1 to be true
Question:What is the form for Inclusive OR?
Answer:• 64-bit form: orr Xd, Xn, Xm. • 32-bit and immediate forms also exist using W registers.
Question:What is 'mov' an alias of?
Answer:• mov is an alias for orr • mov Xd, Xm • orr Xd, xzr, Xm
Question:What is the truth table for exclusive or (eor)?
Answer:Truth table for eor: 0 eor 0 = 0 0 eor 1 = 1 1 eor 0 = 1 1 eor 1 = 0 -> One or the other, but not both
Question:What is the form for exclusive or?
Answer:• 64-bit form: eor Xd, Xn, Xm. • 32-bit and immediate forms also exist using W registers.
Question:What is the purpose of bit clear (BIC) instruction?
Answer:BIC is used to clear bits (set bits to 0). It is an AND NOT operation.
Question:What is the truth table for AND NOT?
Answer:Truth table for AND NOT: 0 and not 0 = 0 0 and not 1 = 0 1 and not 0 = 1 1 and not 1 = 0 -> do the "NOT" operation first
Question:What is the form of the AND NOT operation?
Answer:• 64-bit form: bic Xd, Xn, Xm • 32-bit form exists • immediate form does not exist
Question:What is the truth table for OR NOT operation?
Answer:Truth table for EOR NOT: 0 or not 0 = 1 0 or not 1 = 0 1 or not 0 = 1 1 or not 1 = 1 -> do the "NOT" operation first
Question:What is the form of the OR NOT operation?
Answer:• orn Xd, Xn, Xm • 32-bit form exists • immediate form does not exist
Question:What is the truth table for the NOT operation?
Answer:not 0 = 1 not 1 = 0
Question:How is the NOT operation implemented?
Answer:The NOT operation is implemented using mvn (move not)
Question:What is the form for mvn?
Answer:• 64-bit form: mvn Xd, Xm • 32-bit form exists • immediate form does not exist
Question:What is 'mvn Xd, Xm' an alias for?
Answer:mvn Xd, Xm is an alias for orn Xd, xzr, Xm
Question:What is the form for Logical Shift Left (LSL)?
Answer:• Form 64-bit: LSL Xd, Xn, Xm. • Xn = bit pattern to be shifted • Xm = shift count (positions to shift left by) • 32-bit and immediate forms exist
Question:What happens when you perform Logical Shift Left?
Answer:• 0 is shifted into the rightmost bit and bits that are shifted out are lost for good. • LSL is a quick way to do multiplication by a power of two.
Question:What is the form for Logical Shift Right (LSR)?
Answer:• Form 64-bit: LSR Xd, Xn, Xm. • Xn = bit pattern to be shifted • Xm = shift count (positions to shift right by) • 32-bit form exists, where 0 is inserted at bit 31 • immediate forms exist
Question:What happens when you perform Logical Shift Right?
Answer:• 0 is shifted into the leftmost bit and shifted out bits are lost for good. • LSR is a way to do division by a power of two, where any remainder is lost. • Does not work for negative signed integers (use ASR instead)
Question:What is the purpose of Arithmetic Shift Right (ASR)?
Answer:• ASR preserves the sign when dividing by a power of two • The sign bit is duplicated when shifting, which is called sign extension.
Question:What is the form of ASR?
Answer:• 64-bit form: asr, Xd, Xn, Xm • Xn: bit pattern to be shifted • Xm: shift count
Question:What is the Rotate Right Form?
Answer:• 64-bit form: ror Xd, Xn, Xm • Xn: bit pattern to be rotated • Xm: shift count • 32-bit form uses bits 0 - 31
Question:What happens during rotate right?
Answer:Bits shifted out on the right are inserted on the left
Question:What is Signed Extend Byte?
Answer:• 32-bit form: sxtb Wd, Wn • Sign-extends bit 7 in Wn to bits 8-31. • 64- bit form also exists
Question:What is Signed Extend Halfword?
Answer:• 32 bit form: sxth Wd, Wn • Sign-extends bit 15 in Wn to bits 16-31. • 64-bit form also exists (ie. sxth x19, w20)
Question:What is Signed Extend Word?
Answer:• Only 64-bit form: sxtw Xd, Wn • Sign-extends bit 31 to bits 32-63.
Question:What is Unsigned Extend Byte?
Answer:• Only 32-bit form: uxtb Wd, Wn • Zero-extends bits 8-31.
Question:What is Unsigned Extend Halfword?
Answer:• Only 32-bit form: uxth Wd, Wn • Zero-extends bits 16-31
Question:What is modulus arithmetic?
Answer:• Modulus arithmetic constrains numbers from 0 to M, where M is the modulus. • Typically don't by CPU's
Question:What is the result of a modulus operation on a CPU?
Answer:• The calculation results must fit into a fixed-sized register. • If n is the size in bits, then M = 2^n.
Question:What happens to carry outs in ordinary arithmetic instructions on a 4-bit CPU?
Answer:Any carry out is ignored when using ordinary arithmetic instructions.
Question:What does the instruction 'adds' or 'subs' do?
Answer:These instructions set the carry flag and can be used to do extended precision arithmetic.
Question:How can multibit numbers be summed together?
Answer:Multibit numbers can be summed together using a full adder for each bit.
Question:How is subtraction performed in the ALU?
Answer:• Subtraction is done by negating the subtrahend and then adding it to the first number; negate the second number then add it to the first • This reuses the addition circuitry, thus minimizing hardware complexity.
Question:The subs instruction (alias of cmp) sets the flags using these rules:
Answer:• N = (Xd<63> == 1) • Z = (Xd == 0) • V = ((Xn<63> & ~Xm<63> & ~Xd<63>) | (~Xn<63> & Xm<63> & Xd<63>))
Question:When does overflow occur in signed arithmetic?
Answer:Overflow occurs when the sign bits for Xn, Xm, and Xd are 1 0 0 or 0 1 1. * EXAMPLES IN NOTES LOOK AT THEM
Question:Unsigned Arithmetic
Answer:• Uses the same registers and hardware operations as signed arithmetic, but data is interpreted as unsigned numbers • When adding, a carry out (C == 1) indicates overflow.
Question:Unsigned Number branching conditions
Answer:• N and Z flags are ignored because they have no meaning for unsigned integers - Must use condition codes in conditional branches when comparing unsigned integers
Question:What is the meaning, C equivalent, and flag of the condition code eq?
Answer:• Meaning: equal • C equivalent: == • Flag: Z == 1
Showing the first 200 of 259 cards. Open All cards to see the rest.