Binary Arithmetic Flashcards
What is the range for Modulus Arithmetic?
0 to M-1 Where M is the modulus
Calculation results must fit into a fixed-size register If n is the size in bits, then M = __?
M = 2^n E.g. M is 16 for a 4-bit register
Unsigned integers range from _ to _
0 to 15 (0000 to 1111)
9 + 8 with arithmetic instructions
Which flag do adds and subs set?
What can it be used for?
The Carry flag
Can be used to do extended precision arithmetic
Rules for adding single bits
What are the rules implemented by a full adder circuit?
How is subtraction carried out?
Which part of the CPU does the subtracting?
It is done in the ALU by negating the subtrahend (what is subtracted) and adding it
It reuses the addition circuitry, thus minimizing hardware complexity
Which flags do the signed branch instructions use?
N, Z, V flags
N = (Xd<63> == 1)
Z = (Xd == 0)
V = ((Xn<63> & -Xm<63> & -Xd<63>) | (-Xn<63> & Xm<63> & Xd<63>))
Which instruction sets the flags using these rules?
subs (alias of cmp)
When does overflow occur?
When the sign bits for Xn, Xm, and Xd are:
1,0,0
or
0,1,1
Signed Number Branching Conditions example
What does one interpret the data as in unsigned arithmetic?
unsigned integers
When adding, which flag indicates overflow?
a carry out (C= 1)
Unsigned Number Branching Conditions Table
Must use these condition codes in conditional branches when comparing integers