Docsity

Understanding Microprocessor Instructions: Boolean Ops, Data Testing, Shift & Rotate, Slides of Microprocessor and Interfacing

Partial preview of the text

Download Understanding Microprocessor Instructions: Boolean Ops, Data Testing, Shift & Rotate and more Slides Microprocessor and Interfacing in PDF only on Docsity!

Lecture Overview

  • Basic Instruction Set
    • The Logical instructions to perform Boolean operations
    • The Data Testing
    • The Shift and Rotate instructions
  • REF: Chapter 3 and the appendix that details the instructions.

The Logical Instructions

  • Instructions to perform Boolean operations on data
  • Instructions for AND NOT and OR operation

AND operation and masking

  • Masking is keeping only those bits you are interested in. The reaming bits are “masked” out.
  • Example
  • ANDA #$0F Keep the lower 4 bits of accum A
    • If the A accumulator contains a value of $
    • Then this operation is A 0011 0100
    • AND-ed with 0000 1111
    • giving 0000 0100

OR operation

  • Description: OR the A (or B) accumulator with the operand of the instruction
  • CC effects: N Z set per result
  • Forms: ORA (opr) ORB(opr)
    • And can be immediate mode or a memory location
    • ORAA #$FF What does this do?
    • ORAB #$00 What does this do?

The NOT or invert operation

  • Description: Can complement a complete byte in an accumulator or memory. This is a bitwise complement.
  • CC effect: N V set per data, V cleared, C set
  • Forms: COMA COMB COM (opr)

Examples

  • Example instructions Accum A has val $1C Memory $D val $2F
  • (a) ANDA $D
  • (b) EORA $D
  • (c) ORAA $D

Bit test

  • Description: Compare the operand with the accumulator contents and set the CC bits. Performs a bitwise logical AND.
  • CC effects: N Z eval V cleared
  • Forms: BITA (opr) BITB (opr)
  • If operand is equal to accumulator Z is set
  • See Appendix A of text for a complete description

Clear and set bits in memory

  • Description: Set or Clear bits in memory according to a mask given in the instruciton.
  • CC effects: N Z V cleared
  • Forms: BSET (opr) (mask) BCLR (opr) (mask)
  • Example BSET $0035 $
    • Performs a logical OR of the contents of location $
    • With $09 and puts the result back in the location.
    • This example will set bits 0 and 3 of the data byte.

The effect of shift and rotates

  • What do the instructions do?

What is the real effect of

  • Arithmetic shifts?
    • Do arithmetic shifts have the effect of multiplicaiton?
  • Unique aspects of logical shifts
  • Can also do double shifts

Example of use

  • Interesting data manipulation

Example of use

  • Exchange the upper and lower nibbles of a byte in memory.