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
What are the two sub-steps in a step for multiplication?
A conditional addition
An arithmetic shift right
How many bits does the product require? And why?
Twice as many as those for source registers because the result is put into 2 concatenated registers
If the original multiplier is negative, which step is needed?
Subtract the multiplicand from the high-order part of the result (i.e. from the product register)
4-bit example of multiplication
How is division carried out?
Can be done using an iterated procedure similar to manual long division
When is extended precision arithmetic used?
How is it archived?
Is used when you need more than 64 bits of precision
Archived using 2 or more registers to represent a number e.g. 192-bit unit uses 3 registers x19 x20 x21
What is the procedure to adding extended precision numbers together?
Which instructions use the C flag when adding?
The adc and adcs instructions