1/84
Looks like no tags are added yet.
Name  | Mastery  | Learn  | Test  | Matching  | Spaced  | 
|---|
No study sessions yet.
uint8_t
Unsigned 8-bit type, same as unsigned char.
Carry flag
Set if the result of an addition exceeds the maximum value that can be represented in the given number of bits.
Borrow flag
Set if the result of a subtraction is negative.
Unsigned Byte
Range: 0 to 255, Storage Size: 1 byte, Powers of 2: 0 to 28-1.
Unsigned Halfword
Range: 0 to 65,535, Storage Size: 2 bytes, Powers of 2: 0 to 216-1.
Unsigned Word
Range: 0 to 4,294,967,295, Storage Size: 4 bytes, Powers of 2: 0 to 232-1.
Unsigned Double-word
Range: 0 to 18,446,744,073,709,551,615, Storage Size: 8 bytes.
Binary to Decimal Conversion
For example, 0101102 = 0×24 + 1×23 + 0×22 + 1×21 + 1×20 = 8 + 2 + 1 = 11.
Decimal to Binary Conversion
Example: 52 = 32 + 20 = 32 + 16 + 4 = 1000002 + 0100002 + 0001002 = 1101002.
Five-bit binary code
A binary representation that uses 5 bits.
Carry in addition
Occurs if the result exceeds the maximum value for the given bits (i.e., c > 2n-1).
Borrow in subtraction
Occurs if the result is less than zero.
ARM Cortex-M processors
On these processors, the carry flag and the borrow flag are physically the same flag bit in the status register.
Addition crossing boundary
If the traverse crosses the boundary between 0 and 2n-1, the carry flag is set on addition.
Subtraction crossing boundary
If the traverse crosses the boundary between 0 and 2n-1, the carry flag is cleared on subtraction.
Example of carry flag
In the case of uint8_t a = 255 and b = 2, c = a + b results in c being 1 0000 0001.
Example of borrow flag
In the case of uint8_t a = 1 and b = 2, c = a - b results in c being 1 1111 1111.
Bit weight
For bit i, the weight is 2i.
Data representation
The method of representing data in binary form.
Number systems
Includes binary, octal, decimal, and hexadecimal.
Hexadecimal representation
Uses base 16, represented with digits 0-9 and letters A-F.
Octal representation
Uses base 8, represented with digits 0-7.
Decimal representation
Uses base 10, represented with digits 0-9.
Unsigned Integer Representation
Natural representation of unsigned integer
ARM Carry
On ARM, Carry = NOT Borrow, for subtraction
Signed Integer Representation
Three ways to represent signed binary integers
Signed Magnitude
value= (-1)sign × Magnitude
One's Complement
α + ᾱ = 2ⁿ−1
Two's Complement
α + ᾱ = 2ⁿ
Range of Signed Integers
Range [−2ⁿ−1 + 1, 2ⁿ−1 −1] for Signed Magnitude and One's Complement; [−2ⁿ−1, 2ⁿ−1 −1] for Two's Complement
Zero Representation
Two zeroes (±0) for Signed Magnitude and One's Complement; One zero for Two's Complement
Unique Numbers
2ⁿ−1 for Signed Magnitude and One's Complement; 2ⁿ for Two's Complement
Signed Byte Range
Range -128 to +127; Powers of 2: -2⁷ to 2⁷-1
Signed Halfword Range
Range -32,768 to +32,767; Powers of 2: -2¹⁵ to 2¹⁵-1
Signed Word Range
Range -2,147,483,648 to +2,147,483,647; Powers of 2: -2³¹ to 2³¹-1
Signed Double-word Range
Range -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807
Two's Complement Weight
The weight of the sign bit is -2(n-1)
Convert to Negative
A number can be converted to its negative counterpart by: 1) bitwise NOT, and 2) plus one
Example of Two's Complement
Example 1: TC(3) Binary 0b00011 Decimal 3 Step 1: Invert every bit 0b11100 Step 2: Add 1 + 0b00001 Two's complement 0b11101 -3
Overflow in Addition
Overflow happens in addition if and only if positive + positive => negative or negative + negative => positive
Overflow in Subtraction
Overflow happens in subtraction if and only if positive - negative => negative or negative - positive => positive
Overflow Condition
Overflow cannot occur when adding operands with different signs or when subtracting operands with the same signs
8-bit Signed Addition Example
int8_t a, b, c; a = 127; b = 3; c = a + b; What is the value of c as signed decimal?
8-bit Signed Subtraction Example
int8_t a, b, c; a = -128; b = 2; c = a - b; What is the value of c as signed decimal?
Overflow flag for signed numbers
Indicates that the result of an operation has exceeded the range that can be represented with the given number of bits.
Two's complement
A method for representing signed integers in binary, where the most significant bit indicates the sign of the number.
Sign bit weight
The weight of the sign bit is negative, specifically -2^(n-1), where n is the total number of bits.
Overflow flag
A flag set by the ALU to indicate that an arithmetic operation has resulted in a value that cannot be represented within the given number of bits.
ALU
Arithmetic and Logic Unit, a digital circuit used to perform arithmetic and logic operations.
High-level languages
Programming languages that provide abstraction from the hardware, allowing programmers to write code without needing to manage hardware details.
Expression: 0100 + 0010
Results in 0110 with no carry or overflow.
Expression: 0100 + 0110
Results in 1010 with no carry but an overflow.
Expression: 1100 + 1110
Results in 1010 with a carry but no overflow.
Expression: 1100 + 1010
Results in 0110 with both a carry and an overflow.
Hardware adder for signed numbers
The same hardware adder designed for unsigned numbers can also correctly add signed numbers.
Simple Addition example
For unsigned addition: 23 + 6 = 29.
Signed Addition example
For signed addition: -9 + 6 = -3.
Unsigned number representation
If 11101 represents an unsigned number, then 11101 in decimal is 29.
Signed number representation
If 11101 represents a signed number, then 11101 in decimal is -3.
Subtraction hardware
The same hardware designed for subtraction works correctly for both signed and unsigned subtraction.
Minuend and subtrahend
In subtraction, the minuend is the number from which another number (the subtrahend) is to be subtracted.
Signed Integer Representation summary
The CPU and ALU do not differentiate between signed and unsigned types for addition and subtraction.
Condition Flags in ALU
The ALU sets up both the carry flag and the overflow flag, but it is the programmer's responsibility to interpret these flags.
Unsigned Subtraction
minuend - subtrahend
Difference
The result of subtraction
Cortex-M4 Condition Flags
Flags that indicate the result of arithmetic/logic operations: N (negative), Z (zero), V (overflow), C (carry).
N Flag
Indicates the result is negative.
Z Flag
Indicates the result is zero.
V Flag
Indicates signed overflow.
C Flag
Indicates unsigned overflow.
ASCII
American Standard Code for Information Interchange.
String Comparison
Strings are compared based on their ASCII values.
String Length
Determined by counting characters until the null character (NUL, ASCII value 0x00) is reached.
Convert to Upper Case
Changing lowercase letters to uppercase by adjusting their ASCII values.
Memory Address
The location in memory where data is stored.
Character Array
An array of characters, often used to store strings.
Null Terminator
A special character (ASCII value 0x00) that indicates the end of a string.
ADDS Instruction
An instruction that adds two registers and sets condition flags.
Subtraction Conversion
Subtraction can be converted to addition by inversion and plus-one.
Unsigned Multiplication Hardware
Works correctly for signed numbers if the product keeps the same number of bits as operands.
ASCII Character Set
A set of 128 characters represented by specific decimal and hexadecimal values.
Example of ASCII Values
For instance, 'A' is 65 in decimal and 41 in hexadecimal.
Pointer Dereference Operator
Used to access the value at the address pointed to by a pointer.
Array Subscript Operator
Used to access elements in an array using an index.
Loop Until NULL
A method to iterate through a string until the null character is encountered.