CSIT 230: ARM Assembly Language

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Listen to an AI-generated conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

Which ARM register is typically used for system calls, indicating the desired action to the OS?

  • R0
  • PC
  • R7 (correct)
  • LR

What does the acronym CPSR stand for in ARM architecture?

  • Control Program Status Register
  • Current Program Storage Register
  • Central Processing System Register
  • Current Program Status Register (correct)

Which register stores the memory address to return to after the function call is finished?

  • SP (Stack Pointer)
  • LR (Link Register) (correct)
  • PC (Program Counter)
  • R7

When does the Negative flag (N) in CPSR get set?

<p>When the most significant bit (MSB) of the calculation result is 1 (D)</p>
Signup and view all the answers

When is the Zero flag (Z) in the CPSR set?

<p>When the result of an operation is zero (B)</p>
Signup and view all the answers

In ARM assembly, what is the primary function of registers R0-R3?

<p>Passing arguments (inputs) into functions (A)</p>
Signup and view all the answers

What is the primary function of the SPSR register in ARM architecture?

<p>To save the contents of the CPSR during interrupts or exceptions (A)</p>
Signup and view all the answers

In ARM assembly, what is the result of the logical operation AND R2, R0, R1 if R0 = 0b1010 and R1 = 0b1100?

<p>R2 = 0b1000 (A)</p>
Signup and view all the answers

If register R0 contains the value 0xFF (0b11111111) and register R1 contains the value 0x0F (0b00001111), what will be the value of register R2 after the operation EOR R2, R0, R1?

<p>0xF0 (D)</p>
Signup and view all the answers

What is the result of the MVN R1, R0 instruction if R0 holds the value 0x00000001?

<p>R1 will be 0xFFFFFFFE (A)</p>
Signup and view all the answers

In ARM assembly, the instruction MVN R1, R0 is used to perform a bitwise NOT operation. If R0 = 0, what would be the decimal value of R1 after this operation?

<p>-1 (D)</p>
Signup and view all the answers

Which logical operation is not natively supported and requires two instructions to implement?

<p>NAND (A)</p>
Signup and view all the answers

What is the combined effect of the following ARM assembly instructions, assuming R0 = 1 and R1 = 1: AND R2, R0, R1 followed by MVN R2, R2?

<p>R2 = -2 (A)</p>
Signup and view all the answers

If R0 = 0b1100 and R1 = 0b1010, what is the value of R2 after the following instructions: AND R2, R0, R1 and MVN R2, R2?

<p>R2 = 0b0111 (C)</p>
Signup and view all the answers

In the context of ARM assembly, what does "native" support for a logical operation imply?

<p>The operation can be performed directly using a single instruction. (A)</p>
Signup and view all the answers

Given R0 = 0b1100 and R1 = 0b1010, what is the result of executing the following instructions: ORR R2, R0, R1 followed by MVN R2, R2?

<p>R2 = 0b0001 (B)</p>
Signup and view all the answers

Which of the following best describes the additional overhead introduced by using a non-native logical operation like NAND in ARM assembly?

<p>It adds one cycle because it requires an extra MVN instruction. (B)</p>
Signup and view all the answers

What is the result of EOR R2, R0, R1 followed by MVN R2, R2 if R0 = 0b1100 and R1 = 0b1010?

<p>R2 = 0b1001 (B)</p>
Signup and view all the answers

In ARM assembly, if R0 contains the value 5 and R1 contains the value 3, what will R2 contain after executing ANDS R2, R0, R1?

<p>1 (B)</p>
Signup and view all the answers

What would be the output, in decimal, of the following ARM code snippet?

MOV R0, #10
MOV R1, #3
EORS R2, R0, R1

<p>8 (B)</p>
Signup and view all the answers

Which URL provides access to an ARM emulator?

Signup and view all the answers

Which of the following registers in ARM assembly is used to hold the memory address of the next instruction to be executed?

<p>PC (B)</p>
Signup and view all the answers

The Carry flag (C) in CPSR is set when?

<p>Unsigned overflow occurs (result &gt; 32 bits). (C)</p>
Signup and view all the answers

The Overflow flag (V) in the CPSR is set when?

<p>Signed overflow occurs. (B)</p>
Signup and view all the answers

Assume R0 = 5. What will R1 contain after the following is run?

MVN R1, R0

<p>-6 (B)</p>
Signup and view all the answers

Registers R4-R6 are typically for?

<p>Local variables within functions (A)</p>
Signup and view all the answers

What will R2 contain after the following code block is executed, if R0 = 1 and R1 = 0?

ORR R2, R0, R1

<p>1 (B)</p>
Signup and view all the answers

Given R0 = 0b1010 and R1 = 0b1100, what is R2 after executing the instruction AND R2, R0, R1?

<p><code>0b1000</code> (A)</p>
Signup and view all the answers

If register R0 = 0b11110000 and register R1 = 0b11111111, what is the value of register R2 after executing the following assembly instruction? ANDS R2, R0, R1

<p><code>0b11110000</code> (B)</p>
Signup and view all the answers

In ARM assembly, which instruction performs a bitwise exclusive OR operation?

<p>EOR (D)</p>
Signup and view all the answers

Assume that R0 = 0b11001100 and R1 = 0b10101010. What value will R2 have after executing the following instruction?

EOR R2, R0, R1

<p><code>0b01100110</code> (C)</p>
Signup and view all the answers

In ARM assembly, what does the instruction MVN generally do?

<p>Performs a bitwise NOT operation on a register. (C)</p>
Signup and view all the answers

Given R0 = 0x5 and R1 = 0xA, what will be the value of R2 after the following instructions are executed?

ORR R2, R0, R1
MVN R2, R2

<p>-11 (C)</p>
Signup and view all the answers

Which of the following logical operations is not directly supported as a native instruction in ARM assembly?

<p>NAND (A)</p>
Signup and view all the answers

If a logical operation is not natively supported in ARM assembly, what is needed to implement it?

<p>Two or more ARM instructions, usually involving <code>MVN</code>. (A)</p>
Signup and view all the answers

What type of overhead is usually associated with implementing a non-native logical operation in ARM assembly?

<p>An added cycle to account for usage of the <code>MVN</code> instruction. (B)</p>
Signup and view all the answers

Which of these snippets of code is an implementation of NOR in ARM? Assume R0 and R1 are input and R2 is the output.

<pre><code> ORR R2, R0, R1 MVN R2, R2 ``` (B) </code></pre>
Signup and view all the answers

What actions does the CPSR, or Current Program Status Register, perform?

<p>Holds the processor state and flags (D)</p>
Signup and view all the answers

What actions does the LR, or Link Register, perform?

<p>Stores the memory address the program should return to after a function call is finished (B)</p>
Signup and view all the answers

Flashcards

Assembly Language

A low-level programming language using mnemonic codes to represent machine instructions.

Emulator

A program that emulates the behavior of another system allowing software to run in a different environment.

Registers

Memory locations inside the CPU for quick access during program execution.

R0-R3

Registers used to pass input values into functions.

Signup and view all the flashcards

R4-R6

Registers used to store local variables within functions.

Signup and view all the flashcards

R7

Register used for system calls, signaling the OS for specific actions.

Signup and view all the flashcards

LR (Link Register)

Stores the return address after a function call.

Signup and view all the flashcards

PC (Program Counter)

Holds the address of the next instruction to be executed.

Signup and view all the flashcards

CPSR (Current Program Status Register)

Register containing status flags that reflect the current program state.

Signup and view all the flashcards

SPSR (Saved Program Status Register)

Used to save the CPSR's contents during interrupts or exceptions.

Signup and view all the flashcards

CPSR

32-bit register that holds processor state and flags.

Signup and view all the flashcards

N (Negative)

Flag set when a result is negative; MSB of result is 1.

Signup and view all the flashcards

Z (Zero)

Flag set when a result is zero.

Signup and view all the flashcards

C (Carry)

Flag set during unsigned overflow; result > 32 bits.

Signup and view all the flashcards

V (Overflow)

Flag set during signed overflow, indicating incorrect sign after an operation.

Signup and view all the flashcards

AND

Logical AND operation.

Signup and view all the flashcards

ORR

Logical OR operation.

Signup and view all the flashcards

EOR

Logical XOR operation.

Signup and view all the flashcards

MVN

Logical NOT operation.

Signup and view all the flashcards

AND + MVN

NAND operation (AND + NOT).

Signup and view all the flashcards

ORR + MVN

NOR operation (OR + NOT).

Signup and view all the flashcards

EOR + MVN

XNOR operation (XOR + NOT).

Signup and view all the flashcards

Study Notes

  • CSIT 230 Computer Systems is taught within the School of Computing at Montclair State University by Dr. Prince Waqas Khan.
  • Assembly Language (ARM) is to be studied.
  • An emulator can be accessed at cpulator.01xz.net.

ARM Emulator

  • Registers are memory locations inside the CPU used for quick access during program execution.
  • R0-R3 are used to pass arguments (inputs) into functions.
  • R4-R6 are used to store local variables within functions.
  • R7 is used specifically for system calls, telling the operating system what action the program wants to perform, such as exiting.
  • LR (Link Register) stores the memory address the program should return to after a function call is finished.
  • PC (Program Counter) holds the memory address of the very next instruction the CPU will execute.
  • CPSR (Current Program Status Register) contains status flags about the program's current state, like the results of recent calculations if a result was zero or negative.
  • SPSR (Saved Program Status Register) is used to save the CPSR's contents when an interrupt or exception occurs, so the system can restore the state afterward.
  • CPSR is a 32-bit register holding processor state and flags.

Flags

  • N (Negative) means the result is negative and the MSB of result is 1.
  • Z (Zero) means result is zero and Result = 0
  • C (Carry) means unsigned overflow and Result is greater than 32 bits.
  • V (Overflow) means signed overflow and Incorrect sign after operation

Logical Operations

  • Logical operations work on all bits found in (32-bit registers in ARM).
  • #0xFF = 0b11111111 (8 bits set)
  • #1 = 0b00000001 (only LSB set).

Logical Operations

  • AND: AND
  • ORR: OR
  • EOR: XOR
  • MVN: NOT
  • AND + MVN: NAND
  • ORR + MVN: NOR
  • EOR + MVN: XNOR
  • AND, ORR, EOR, BIC, MVN are native.
  • NAND/NOR/XNOR require 2 instructions.
  • Extra MVN adds 1 cycle (minor overhead in most cases).

MVN

  • ARM's MVN behaves differently due to two's complement representation and 32-bit registers.
  • MVN R1, R0 gives -2 When R0=1
  • Binary Representation:
  • RO = 1 → 0x00000001 (32 bits)
  • MVN performs a bitwise NOT:
  • NOT(0x00000001) = 0xFFFFFFFE
  • 0xFFFFFFFE in two's complement = -2 (signed integer).
  • NOT(1) = 0, but ARM works on all 32 bits, not just the LSB.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

ARM Assembly Syntax and Instructions
39 questions

ARM Assembly Syntax and Instructions

CharismaticSerpentine5245 avatar
CharismaticSerpentine5245
ARM Assembly Instructions Quiz
45 questions

ARM Assembly Instructions Quiz

AmusingRoentgenium2222 avatar
AmusingRoentgenium2222
Assembly Coding and ARM Architecture
45 questions
SCC.131: ARM Assembly Serialization
30 questions
Use Quizgecko on...
Browser
Browser