User Tools

Site Tools


opus:spring2012:dschoeff:asmpart1

asm Keywords

Logic Operations(AND, OR, XOR)

Definition

Logic operations are represented by logic gates in Computer Science. These gates perform Boolean operations, meaning they get input and produce a single output(usually represented as true(1), false(2)).

The AND operation can be represented by the following true table.

p q p AND q
T T T
T F F
F T F
F F F

A True will be returned iff both inputs are true. Otherwise, the returned value is false.

The OR operation can be represented by the following true table.

p q p OR q
T T T
T F T
F T T
F F F

OR returns False if both inputs are false. Otherwise, it returns true.

The XOR operation can be represented by the following true table.

p q p XOR q
T T F
T F T
F T T
F F F

A true is returned if the inputs are not equal. Otherwise a false is returned.

Demonstration

The following code is attributed to the Computer Organization class.

AND gate

#include "and.h"
 
bool AND::getX()
{
   bool tmp = false;
 
   if((A == true) && (B == true))
   {
      tmp = true;
   }
 
    return tmp;
}

OR gate

#include "or.h"
 
bool OR :: getX()
{
   bool tmp = false;
   if((A == true) || (B == true))
   {
      tmp = true;
   }
   return(tmp);
}

XOR gate

bool XOR::getX()
{
   bool tmp = true;
 
   if((A == B))
   {
      tmp = false;
   }
 
    return tmp;
}

Negated Logic Operations(NOT, NAND, NOR, XNOR)

Definition

Like the title says, Negated logic operations simply negate the output from their logic operator cousins. A NOT gate simply negates whatever input it gets. If it gets as input FALSE, it will output TRUE and vice versa. The other three logic operations can be made by sending there logic operator cousin through a NOT gate.

Demonstration

I will not bother demonstrating all the gates because I think that would be a waste of precious opus space but I think if you understand one of them you will understand the rest. I realize as I write this explanation of why I will not be demonstrating all the negated logic gates that I am wasting opus space in this explanation. Now that we've got that settled, I will demonstrate a NAND gate.

Remember that a NAND gate is a negated AND gate.

#include "nand.h"
 
NAND::NAND()
{
   myandgate = new AND();
   mynotgate = new NOT();
}
 
bool NAND::getX()
{
   bool tmp = true;
 
   myandgate -> setA(A);
   myandgate -> setB(B);
 
   tmp = myandgate -> getX();
 
   mynotgate -> setA(tmp);
 
   tmp = mynotgate -> getX();
 
   return(tmp);
}

The code above sends two inputs into an AND gate and gets an output. It then sends that output into a not gate and returns that Boolean value.

The other two negated logic gates work the same way.

Binary and Hexadecimal Number Representation

Definition

When we think of numbers, we think of 0 1 2 3 4 5 6 7 8 and 9. This is called a base 10(Decimal) number system. But what if instead of have 10 different symbols to represent values, we only had 2. This number system is called Binary. These two values are 0 and 1. Hexadecimal (base 16)on the other hand has 16 different symbols ( 0 1 2 3 4 5 6 7 8 9 A B C D E and F) that represent values.

Demonstration

For example, lets take the decimal number 45. Since this is base 10, the 4 is in the 10^1 place and the 5 is in the 10^0 place and can be represented as (4 * 10^1) + (5 * (10^0) = 45. Representing 45 in binary is different now because there is only two symbols to represent the number. In binary the first placeholder from the right is the 2^0 place followed by 2^1 place and so on. Therefore to represent 45 in binary we have to start with the 2^5 (32) place. Since 32 goes into 45 we place a 1 in that position and subtract 32 from 45 giving us 13. Since 13 doesn't go into the next position(2^4 = 16), we place a 0 in that position and move to the next one. Since 13 goes into 8(2^3) we place a 1 in the position and subtract 8 from 13 giving us 5. We move onto the next position which is (2^2) a see if 5 goes into that. Since it does we place a 1 in that position and subtract 4 from 5 giving us 1 left. Now we look at the 2^1 position and see that 1 does not goes into 2, we place a zero in that position and move onto the final position which is 2^0. Since 1 goes evenly into 1 we place a 1 in the 2^0 position and we are done. We get in binary is 101101 which is equal to 45 in decimal.

To represent 45 in hexadecimal we must look at the place holders for base 16. The rightmost place holder is 16^0 followed by 16^1 and so on. For example 10 in hexadecimal is equal to 16 in decimal. This is because ((1 * 10^1) + (0 * 10^0) = 10). Therefore, the hexadecimal equivalent of 45 is 2D( where D represents 13).

von Neumann vs. Harvard architecture

Definition

von Neumann computer architecture is based around a Central Processing Unit, interaction with a memory device that contains both the instructions and data and sending/receiving data through input/output.

Harvard architecture has physically separate storage and signal pathways for instructions and data.

When you compare these two different architectures, the biggest difference is how the CPU functions. With the von Neumann architecture, the CPU “can be either reading an instruction or reading/writing data from/to the memory. Both cannot occur at the same time since the instructions and data use the same bus system. (Wikipedia)”. Whereas a Harvard computer architecture allows for simultaneous instruction/data reading/writing.

Demonstration

The following pictures show diagrams of how these different architectures work.

Harvard architecture

von Neumann architecture where the memory contains both the data and the instructions

Fetch-Execute Cycle

Definition

The fetch-execute cycle “is the basic operation cycle of a computer. It is the process by which a computer retrieves a program instruction from its memory, determines what actions the instruction requires, and carries out those actions. This cycle is repeated continuously by the central processing unit (CPU), from bootup to when the computer is shut down” (Wikipedia).

The fetch-execute cycle is basically how the computer functions. It starts by retrieving instructions, determine what those instructions mean, and then doing whatever those instructions say.

Demonstration

This picture shows the fetch execute cycle.

Storage

Definition

Computers storage refers to the way computers retain data. Storage comes in several different forms but when broken down, there are two main types of storage. The first type is called volatile storage. Volatile storage requires constant power for it to retain the data it stores. Volatile storage is typically seen in the computers Random Access Memory.

The other main type of storage is non-volatile storage. Unlike volatile storage, non-volatile storage does not require constant power to retain its data. The most common types of non-volatile storage are flash memory, optical storage and magnetic storage.

Demonstration

The following diagram shows how storage functions in the operation of a computer.

Subroutines

Definition

A subroutines(also know as functions, methods, etc…) is a block of code that is used to perform a certain task. This task is usually a task that needs to be repeated. This is useful because having to rewrite that portion of code over and aver again would waste time and space. Instead, a subroutine can be written to perform a certain task. Every time that task needs to be done, we say that you call the function. Once you call the function, the program goes to where the function is in memory and performs the task. Once that is done it either returns a value or if it is a void function it does not return anything.

Demonstration

/*
 * This program uses a function to find the avererage of three numbers
*/
#include<stdio.h>
 
int average(int,int,int);
 
int main()
{
   int a = 1;
   int b = 5;
   int c = 10;
   int ave = 0;
 
   ave = average(a,b,c);
 
   printf("The average of the %d, %d, and %d, is = %d\n",a,b,c,ave);
 
   return 0;
}
int average(int x, int y, int z)
{
   return((x + y + z)/3);
}

Writing a function that finds the average would be useful if you need to find alot of averages.

I/O

Definition

Input/Ouput is how the computer communicates with the outside world.

Common input devices are keyboards, mice, scanners, etc. This is how a user can communicate with the computer.

Common output devices are display monitors and printers. This is how the computer communicates with the user.

Computers are also able to communicate back and forth to each other though I/O. They do do this using NIC's and modems.

Demonstration

I'm not sure just how to demonstrate this keyword but I was thinking that even looking a command line would work.

Through the keyboard I can type a set of characters into the command line and hit enter(me communicating with the computer). It then processes that command and outputs it answer(the computer communicating with me).

lab46:~$ whoami
dschoeff
lab46:~$

asm Objective

asm Objective

Familiarity with the organization of a computer system.

Definition

This objective will require a knowledge of how computers function. This includes memory, storage, processing and I/O to name a few.

Method

I will start to gain a familiarity with the organization of a computer system by reading, writing up keywords, performing experiments and more reading.

Measurement

This is an ongoing process through out the semester. Refer to the keywords I have defined and demonstrated above. Also look at the experiments I have tested.

Analysis

Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.

  • How did you do? I would say i am off to a good start. The class CPU simulator is coming along rather nicely and I am up to date with all my keywords
  • Is there room for improvement? Most definitely.
  • Could the measurement process be enhanced to be more effective?Not that I am aware of.
  • Do you think this enhancement would be efficient to employ?
  • Could the course objective be altered to be more applicable? How would you alter it?It seems rather broad at the moment. Possibly if its scope was narrowed a bit it could be more easily understood.
opus/spring2012/dschoeff/asmpart1.txt · Last modified: 2012/03/01 21:36 by dschoeff