Home | | Computer Architecture | Computer Architecture: Logical and Control Operations

Chapter: Computer Architecture : Overview & Instructions

Computer Architecture: Logical and Control Operations

Examining characters within a word, each of which is stored as 8 bits, is one example of such an operation.

LOGICAL OPERATIONS


Although the first computers operated on full words, it soon became clear that it was useful to operate on fields of bits within a word or even on individual bits. Examining characters within a word, each of which is stored as 8 bits, is one example of such an operation. It follows that operations were added to programming languages and instruction set architectures to simplify, among other things, the packing and unpacking of bits into words. These instructions are called logical operations.



CONTROL OPERATIONS

 

What distinguishes a computer from a simple calculator is its ability to make decisions. Based on the input data and the values created during computation, different instructions execute. Decision making is commonly represented in programming languages using the if statement, sometimes combined with go to statements and labels. MIPS assembly language includes two decision-making instructions, similar to an if statement with a go to. The first instruction is

 

beq register1, register2, L1

 

This instruction means go to the statement labeled L1 if the value in register1 equals the value in register2. The mnemonic beq stands for branch if equal.

 

The second instruction is

bne register1, register2, L1

 

It means go to the statement labeled L1 if the value in register1 does not equal the value in register2. The mnemonic bne stands for branch if not equal. These two instructions are traditionally called conditional branches.

 

Case/Switch statement

 

Most programming languages have a case or switch statement that allows the programmer to select one of many alternatives depending on a single value. The simplest way to implement switch is via a sequence of conditional tests, turning the switch statement into a chain

of if-then-else statements.

 

Sometimes the alternatives may be more efficiently encoded as a table of addresses of alternative instruction sequences, called a jump address table, and the program needs only to index into the table and then jump to the appropriate sequence. The jump table is then just an array of words containing addresses that correspond to labels in the code.

 

To support such situations, computers like MIPS include a jump register instruction (jr), meaning an unconditional jump to the address specified in a register. The program loads the

appropriate entry from the jump table into a register, and then it jumps to the proper address using a jump register.


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Computer Architecture : Overview & Instructions : Computer Architecture: Logical and Control Operations |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.