EE357Unit6_ControlStructures_Notes

EE357Unit6_ControlStructures_Notes - Condition Codes...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 © Mark Redekopp, Al rights reserved EE 357 Unit 6 Compare and Branch Instructions Branch Translation © Mark Redekopp, Al rights reserved Condition Codes (Flags) Processor performs tests on the result of each instruction 5 tests w/ results stored as 1=true/0=false in SR (Status Reg.) – X = eXtended Flag • Used for _______________________ • Usually set the same as the _______ – N = Negative Flag • Tests if the result is negative • Just a ________________________ – Z = Zero Flag • Tests if the result is equal to 0 – V = 2’s complement oVerflow Flag • Set if p+p=n or n+n=p – C = Carry Flag (Unsigned Overflow Flag) • Set if (___________________) or (______________________) © Mark Redekopp, Al rights reserved Instructions & Condition Codes Different instructions affect the condition codes differently Refer to instruction data sheets for instruction-specific effects General effects guidelines are as follows X N Z V C MOVE - * * 0 0 ADD/SUB/CMP * or - * * * * LSx/ASx * * * 0 * Logic - * * 0 0 Branches/Jumps - - - - - *= Set according to traditional or instruction-specific definition - = Unaffected (unchanged from previous value) 0 = Cleared to 0 1 = Set to 1 © Mark Redekopp, Al rights reserved Condition Code Examples Instruction D0 X N Z V C MOVE.L #0x7fffffff,D0 ADDI.L #0x80000001,D0 SUBI.L #0x80000000,D0
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 © Mark Redekopp, Al rights reserved LSx and Asx Instructions C and X flags are set with the _________________ N and Z are set normally V = 0 Right Logical/Arithmetic Shift C,X C,X Left Logical/Arithmetic Shift 1 1 0 0 0 1 0 1 C,X Initial Value Shifted by 3-bits 0 0 1 1 0 0 0 1 0 1 C,X © Mark Redekopp, Al rights reserved LSL and LSR Instructions MOVE.L #0xF0000003,D2 MOVE.L #3,D3 LSR.L #1,D2 LSL.L D3,D2 F000 0003 D2 X N Z V C - 1 0 0 0 Left Shift by 3-bits - 0 0 0 0 1111 0000 0000 0000 0000 0000 0000 0011 C,X 1100 0000 0000 0000 0000 0000 0000 1000 Right Shift by 1-bit 0111 1000 0000 0000 0000 0000 0000 0001 C,X D2 = 0x78000001 D2 = 0xC0000008 © Mark Redekopp, Al rights reserved ASL and ASR Instructions MOVE.L 0x80000003,D2 MOVE.L #1,D3 ASR.L #5,D2 ASL.L D3,D2 8000 0003 D2 X N Z V C - 1 0 0 0 Left Shift by 1-bit - 0 0 0 0 1000 0000 0000 0000 0000 0000 0000 0011 C,X 1111 1000 0000 0000 0000 0000 0000 0000 Right Shift by 5-bits 1111 1100 0000 0000 0000 0000 0000 0000 C,X D2 = 0xFC000000 D2 = 0xF8000000 © Mark Redekopp, Al rights reserved Extended Precision Arithmetic • Used to add/subtract numbers greater ______ _______________ • We can only add/subtract 32-bit chunks with one instruction, but somehow need to communicate the _____________ between the chunks • ______________________ stored in X flag • Use _____________ to add X flag in addition to the 2 operands
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

EE357Unit6_ControlStructures_Notes - Condition Codes...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online