Unformatted text preview:

Chapter 6 Conditional ProcessingTopics32-Bit Intel Processor ArchitectureBoolean and Comparison InstructionsBoolean and Comparison Instructions ContinuedSlide 6Boolean and Comparison Instructions Continued The AND InstructionSlide 8Boolean and Comparison Instructions Continued The OR InstructionSlide 10Boolean and Comparison Instructions Continued The XOR InstructionSlide 12Slide 13Slide 14Boolean and Comparison Instructions Continued The CMP InstructionConditional JumpsSlide 17Slide 18Conditional Jumps ContinuedConditional Jump Examples ContinuedSlide 22Slide 23Conditional LoopsConditional Loops ContinuedSlide 26High-Level Logic StructuresHigh-Level Logic Structures ContinuedSlide 29Slide 30Slide 31Slide 32Slide 33Slide 34Slide 35Review QuestionsReview Questions ContinuedCSC 20601/14/19 1Chapter 6 Conditional ProcessingInstructor: James HutchinsonCSC 20601/14/19 2TopicsBoolean and Comparison InstructionsConditional JumpsConditional LoopsHigh-Level Logic StructuresReview QuestionsCSC 20601/14/19 332-Bit Intel Processor Architecture EAX EBX ECX EDX EBP ESI EDI ESP ECS EDS ESS EESALU Flag RegisterEIPAddr RegisterB BusA BusData BusAddr BusCSC 20601/14/19 4Boolean and Comparison InstructionsAssembler Language is designed specifically for a particular computer architecture.Very efficient processing of binary values using bitwise operations. Has a special set of instructions to perform bitwise comparisons:AND InstructionOR InstructionNot InstructionXOR InstructionNEG InstructionTEST an CMP InstructionsThis group of instructions allows an assembler language program to perform Boolean operations.The flag register is used to record the results of the calculation or comparison.CSC 20601/14/19 5Boolean and Comparison InstructionsContinuedThe Flag Register.Definition: A 16 or 32 bit register that indicate the status of the last ALU operation.The zero, carry, and sign flags are used to show the results of ALU operations.The zero flag is set (equal 1) when the result of an ALU operation is zero.The carry flag is set (equal 1) when the last ALU operation is too large for the destination or when a subtraction requires a borrow.The sign flag is set when the high ordered bit of the destination is set.The overflow flag is set when a signed arithmetic operation generates a result that is out of range.In the 80386 and later processors, the flag register can be either 16 or 32 bits wide. In the 8086, 8088, and 80286 the flag register is 16-bits wide only.CSC 20601/14/19 6Boolean and Comparison Instructions ContinuedThe AND Instruction.Definition: Performs a bitwise (Boolean) AND operation between each bit in the source and destination operands. The results is stored in the destination operand.Operation: The results is one iff the same bit in the source and destination operands are set (equal 1).General Form: AND Destination, SourceWhere: Source can be either a register, or a memory location. Destination is either a register, or memory location, or immediate data.Source Destination Destination 0 0 0 0 1 0 1 0 0 1 1 1Operation of the AND instructionCSC 20601/14/19 7Boolean and Comparison Instructions ContinuedThe AND InstructionApplications.Clear a register to zero: and cx, 0 ; sets cx = 0Clear particular bits and var1, 0f0h ; clears the low order 4-bitsMask Processing and al,01111111 ; clears the high ordered bit.Example: Clearing the keyboard status bit.Push ds ;save dsmov ax, 40hmov ds, ax ;set ds to BIOS data areamov bx, 17h ;point to keyboard flagand byte ptr [bx], 0DF ; turn lock offpop ds ; restore DS registerCSC 20601/14/19 8Boolean and Comparison Instructions ContinuedThe OR Instruction.Definition. The OR instruction performs a bitwise compare of the source and destination operands. The results of the compare is equal to 1 if either the source or the destination has a one in a particular position.Operation: The results or an OR is equal to 1 if either bit is equal 1.General Form: OR destination, sourceWhere: destination is either a register or memory location source is either a register, a memory location or immediate data.Source Destination Destination 0 0 0 0 1 1 1 0 1 1 1 1Operation of the OR Instruction0 OR 0 = 00 OR 1 = 11 OR 0 = 11 OR 1 = 1CSC 20601/14/19 9Boolean and Comparison Instructions ContinuedThe OR InstructionApplications.Determining if a value is equal to zero: or al, al ; The flags are affectedIf the ZF = 1 after the instruction, al must contain a zero value. Setting Status Bit Values.;Set the capslock feature on the keyboard to onPush ds ; Save the DS registermov ax, 40hmov ds, ax ;set DS to BIOS Data areamov bx, 17h ;keyboard flag byteor byte ptr [bx], 40h ;Turn Caps Lock onpop ds ;Restore the DS register with its original contentsCSC 20601/14/19 10Boolean and Comparison Instructions ContinuedThe XOR (Exclusive OR) Instruction.Definition: Performs a bitwise exclusive OR operation between each bit of the source and destination operands. Operation: The results of the operation is equal to 1 iff a bit in the destination is not equal to the same bit in the source. The results of the operation is stored in the destination.General Form: XOR destination, sourceWhere: Destination is either a register or memory location. Source can be either a register, memory location, or immediate data.Source Destination Destination 0 0 0 0 1 1 1 0 1 1 1 0Operation of the XOR Instruction0 XOR 0 = 00 XOR 1 = 11 XOR 0 = 11 XOR 1 = 0CSC 20601/14/19 11Boolean and Comparison Instructions ContinuedThe XOR InstructionApplicationReversing Bits. XOR SI, 0FFFFh ; reverse each bit in the SI registerIf SI = 1A4f h or 0001101001001111b, then after the instruction execute SI = 1110010110110000b or E5B0h0001 1010 0100 1111 SI before executionxor 1111 1111 1111 11111110 0101 1011 1111 SI after executionClear a register or memory location. XOR AX, AX ; clears AXXOR VAR1, VAR1CSC 20601/14/19 12Boolean and Comparison Instructions ContinuedThe NOT Instruction.Definition: A single operand instruction that reverses each bit in the operand, changing all ones to zeros and zeros to ones. The results in the operation is stored in the operand.General Form: NOT


View Full Document

NOVA CSC 206 - Conditional Processing

Download Conditional Processing
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 Conditional Processing 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 Conditional Processing 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?