90 likes | 224 Vues
This document provides an overview of fundamental logic instructions used in computer organization, specifically the AND, OR, and XOR operations. It explains how the AND instruction clears specific bits while preserving others, the OR instruction sets bits, and the XOR instruction inverts bits with the use of masks. The document also includes programming questions that involve declaring data, reading binary input (up to 16 bits), and outputting the contents of BX in hexadecimal format, emphasizing practical applications of these logic instructions.
E N D
CS 206D Computer Organization Lab4 CS 111
Logic Instructions Logic instructions CS 111
Logic instructions • ANDdestination, source • ORdestination, source • XORdestination, source • NOTdestination CS 111
AND CS 111 • The AND instruction can be used to clearspecific Destination bits while preserving the others. • A zeromask bit clears the corresponding Destination bit • A onemask bit preserves the corresponding destination bit.
OR CS 111 The OR instruction can be used to setspecific Destination bits while preserving the others. A one mask bit sets the corresponding Destination bit A zero mask bit preserves the corresponding Destination bit.
XOR CS 111 • The XOR instruction can be used to invertspecific Destination bits while preserving the others. • A onemask bit inverts the corresponding Destination bit • A zeromask bit preserves the corresponding Destination bit.
Programming questions – q 1 • Declare data and display prompt message CS 111
Programming questions – q 1 (Cont.) • Read binary number • We assume that the input characters are either ‘1’ , ‘0’ or carriage return. And at most 16 bits are input. CS 111
Programming questions – q 1 (Cont.) • Output the content of BX in HEX. CS 111