DOC PREVIEW
NMT EE 308 - EE 308 Review Exam 1

This preview shows page 1-2-20-21 out of 21 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 21 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 21 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 21 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 21 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 21 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

EE 308 Spring 2011 Review Exam 1 • Numbers – Decimal to Hex (signed and unsigned) – Hex to Decimal (signed and unsigned) – Binary to Hex – Hex to Binary – Addition and subtraction of fixed-length hex numbers – Overflow, Carry, Zero, Negative bits of CCR • Programming Model – Internal registers – A, B, (D = AB), X, Y, SP, PC, CCR • Addressing Modes and Effective Addresses – INH, IMM, DIR, EXT, REL, IDX (Not Indexed Indirect) – How to determine effective address • Instructions – What they do - Core Users Guide – What machine code is generated – How many cycles to execute – Effect on CCR – Branch instructions – which to use with signed and which with unsigned • Machine Code – Reverse Assembly • Stack and Stack Pointer – What happens to stack and SP for instructions (e.g., PSHX, JSR) – How the SP is used in getting to and leaving subroutines • Assembly Language – Be able to read and write simple assembly language program – Know basic assembler directives – e.g., equ, dc.b, ds.w Flow chartsEE 308 Spring 2011 Binary, Hex and Decimal Numbers (4-bit representation) Binary Hex Decimal 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Binary to Unsigned Decimal: Convert Binary to Unsigned Decimal 1111011 2 1 x 26 + 1 x 2 5 + 1 x 2 4 + 1 x 2 3 + 0 x 2 2 + 1 x 2 1 + 1 x 2 0 1 x 64 + 1 x 32 + 1 x 16 + 1 x 8 + 0 x 4 + 1 x 2 + 1 x 1 123 10 Hex to Unsigned Decimal Convert Hex to Unsigned Decimal 82D6 16 8 x 163 + 2 x 162 + 13 x 161 + 6 x 160 8 x 4096 + 2 x 256 + 13 x 16 + 6 x 1 33494 10EE 308 Spring 2011 Unsigned Decimal to Hex Convert Unsigned Decimal to Hex Division Q R Decimal Hex 721/16 45/16 2/16 45 2 0 1 13 2 1 D 2 721 10 = 2D1 16 Signed Number Representation in 2’s Complement Form: If the most significant bit (MSB) is 0 (most significant hex digit 0−7), then the number is positive. Get decimal equivalent by converting number to decimal, and use the positive (+) sign. Example for 8−bit number: 3A 16 −> + ( 3 x 161 + 10 x 160 ) 10 + ( 3 x 16 + 10 x 1 ) 10 + 58 10 If the most significant bit is 1 (most significant hex digit 8−F), then the number is negative. Get decimal equivalent by taking 2’s complement of number, converting to decimal, and using negative (−) sign. Example for 8−bit number: A316 −> - (5D) 16 - ( 5 x 161 + 13 x 160 ) 10 - ( 5 x 16 + 13 x 1 ) 10 - 93 10EE 308 Spring 2011 One’s complement table makes it simple to finding 2’s complements To take two’s complement, add one to one’s complement. Take two’s complement of D0C3: 2F3C + 1 = 2F3D One’s complement One’s complementEE 308 Spring 2011 Addition and Subtraction of Binary and Hexadecimal Numbers Setting the C (Carry), V (Overflow), N (Negative) and Z (Zero) bits How the C, V, N and Z bits of the CCR are changed N bit is set if result of operation is negative (MSB = 1) Z bit is set if result of operation is zero (All bits = 0) V bit is set if operation produced an overflow C bit is set if operation produced a carry (borrow on subtraction) Note: Not all instructions change these bits of the CCR Addition of Hexadecimal Numbers ADDITION: C bit set when result does not fit in word V bit set when P + P = N or N + N = P N bit set when MSB of result is 1 Z bit set when result is 0 7A AC +52 +72 ----- ------ CC 1E C: 0 C: 1 V: 1 V: 0 N: 1 N: 0 Z: 0 Z: 0EE 308 Spring 2011 Subtraction of Hexadecimal Numbers SUBTRACTION: C bit set on borrow (when the magnitude of the subtrahend is greater than the minuend V bit set when N - P = P or P - N = N N bit set when MSB is 1 Z bit set when result is 0 7A 2C -5C -72 ----- ------ 1E BA C: 0 C: 1 V: 0 V: 0 N: 0 N: 1 Z: 0 Z: 0EE 308 Spring 2011 Programming ModelEE 308 Spring 2011 Addressing Modes and Effective Addresses The Inherent (INH) addressing mode Instructions which work only with registers inside ALU ABA ; Add B to A (A) + (B) → A 18 06 CLRA ; Clear A 0 → A 87 The HC12 does not access memory - There is no effective address The Extended (EXT) addressing mode Instructions which give the 16−bit address to be accessed LDAA $1000 ; ($1000) → A B6 10 00 Effective Address: $1000 STAB $1003 ; (B) → $1003 7B 10 03 Effective Address: $1003 Effective address is specified by the two bytes following op codeEE 308 Spring 2011 The Direct (DIR) addressing mode Direct (DIR) Addressing Mode Instructions which give 8 LSB of address (8 MSB all 0) LDAA $20 ; ($0020) → A 96 20 Effective Address: $0020 STX $21 ; (X) → $0021:$0022 5E 21 Effective Address: $0021 8-LSB of effective address is specified by byte following op code The Immediate (IMM) addressing mode Value to be used is part of instruction LDAA #$17 ; $17 → A B6 17 Effective Address: PC + 1 ADDA #10 ; (A) + $0A → A 8B 0A Effective Address: PC + 1 Effective address is the address following the op code The Indexed (IDX, IDX1, IDX2) addressing mode Effective address is obtained from X or Y register (or SP or PC) LDAA 0,X ; Use (X) as address to get value to put in A A6 00 Effective address: contents of X INC 2,X− ; Post−decrement Indexed ; Increment the number at address (X), ; then subtract 2 from X 62 3E Effective address: contents of XEE 308 Spring 2011 INDEXED ADDRESSING MODESEE 308 Spring 2011 Relative (REL) Addressing Mode The relative addressing mode is used only in branch instructions. Branch instruction: One byte following op code specifies how far to branch Treat the offset as a signed number; add the offset to the address following the current instruction to get the address of the instruction to branch to (BRA) 20 35 PC + 2 + 0035 → PC (BRA) 20 C7 PC + 2 + FFC7 → PC PC + 2 − 0039 → PC Long branch instruction: Two bytes following op code specifies how far to branch Treat the offset as an …


View Full Document

NMT EE 308 - EE 308 Review Exam 1

Documents in this Course
Load more
Download EE 308 Review Exam 1
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view EE 308 Review Exam 1 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view EE 308 Review Exam 1 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?