Table of Contents

Part 1

Entries

Entry 1: July 22, 2012

  1. What action or concept of significance, as related to the course, did you experience on this date?
    • I performed the first experiment yesterday. For the experiment, I wrote some code to see if using boolean arrays would have been faster for our project than using the char arrays that we did use. From the data I collected, it would have been faster, but not at a level of any significance.
  2. Why was this significant?
    • It wasn't incredibly significant, I just enjoyed tweaking something and seeing how it changed what we have been doing.
  3. What concepts are you dealing with that may not make perfect sense?
    • Some of the instructions have been challenging. I'm still working on the Add and Subtract with Carry, but nothing has been too big of an obstacle.
  4. What challenges are you facing with respect to the course?
    • Just trying to get everything up and running.

Entry 2: July 23, 2012

  1. What action or concept of significance, as related to the course, did you experience on this date?
    • I was researching some of the registers to provide more information for the Opus, and as I was reading up on the Stack Pointer, it occurred to me that I had the complete wrong impression of what it was. I thought that the Stack Pointer was used to keep track of information in the other registers. This is probably because the instructions I dealt with all just had registers transfer their data to the Stack Pointer.
  2. Why was this significant?
    • It certainly helps in understanding the architecture better. It may help when doing more instructions, but the revelation probably isn't incredibly significant, it is just good knowing more about the system.
  3. What concepts are you dealing with that may not make perfect sense?
    • Nothing new since yesterday.
  4. What challenges are you facing with respect to the course?
    • Just trying to get everything up and running Still.

Entry 3: August 6, 2012

- What action or concept of significance, as related to the course, did you experience on this date?

  1. Why was this significant?
  1. What concepts are you dealing with that may not make perfect sense?
  1. What challenges are you facing with respect to the course?

Entry 4: May Day, 2012

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

Remember that 4 is just the minimum number of entries. Feel free to have more.

asm Keywords

asm Keyword 1

Logic Operations: And, Or, Not, and Xor

Definition
The logical operators take either one(Not) or multiple(And, Or, Xor) arguments and compare the argument(s) and create a new output depending on the specific operator.
And operator will check to see if all of the given arguments have the value that is being checked for, and will return true if they do and false otherwise.
Not operator will check the argument and give the opposite corresponding value.
Or operator will check to see if any one or more of the given arguments have the value that is being checked for, and will return true if so or else false.
Xor operator will check to see if exactly one of the given arguments has the value that is being checked for, and will return true if so or else false.
We are using bit-wise versions of these operators to check multiple registers and create a new one based on whether or not the corresponding bits in the given registers adhere to the logical operator that is being implemented. See code for example!  
Demonstration

given Register reg1: 00011011 and Register reg2: 00011000 use the And operator to produce reg3.

reg1: 00011011

reg2: 00011000


reg3: 00011000

asm Keyword 2

Instruction Sets

Definition

Scripts or programs in an architecture that allow for quick manipulation of key components in said architecture. In this project, our instruction sets are used to perform quick manipulations of key registers.

Demonstration

The following is an instruction for loading a given value into the accumulator:

#!/bin/bash
#
#A9-Immediate instruction
#loads given value into Accumulator
#
#../../datamanip Load calls the java program Load.java
#../reg/a.reg is the register the value will be loaded to
#./checkZero a calls the checkZero script with accumulator as the argument
#./checkSign a calls the checkSign script with accumulator as the argument
 
java -cp ../../datamanip Load $1 ../reg/a.reg
./checkZero a
./checkSign a

Command-line example:

lab46:~$ cd src/project/sim/ops
lab46:~/src/project/sim/ops$ ./0xA9 0
asm Keyword 3

Binary and Hexadecimal Number Representation

Definition

Representing numbers in base 2 (binary) and base 16 (hexadecimal) as opposed to decimal (10) which is normally used. It should be noted that for base 16: 10 == A, 11 == B, 12 == C, 13 == D, 14 == E, 15 == F

Demonstration

Demonstration will be through simple examples: It will be in the form (number)base → /*convert to*/ (number)base

(10)10 –> (1010)2 –> (A)16

(73)10 –> (1001001)2 –> (49)16

(115)10 –> (1110011)2 –> (73)16

(159)10 –> (10011111)2 –> (9F)16

(256)10 –> (100000000)2 –> (100)16

asm Keyword 4

Data Representation

Definition

The different ways to represent data. Such as base choice, (binary or decimal for example), and whether or not it is signed. For this project, we are using signed binary. For negative values we are using two's complement as opposed to one's.

Demonstration

Demonstration of the chosen keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Code snippets 
 * Take in a value
 * convert to binary
 */
 
import java.util.Scanner;
 
public class BinaryConverter
{
     public static char [] bin;
 
     public static void main (String [] args)
     {
          Scanner value = new Scanner (System.in);
          System.out.println("Input a value.");
          int val = value.nextInt();
          System.out.print(twoComp(val));
     }
 
     public static char [] oneComp (int val)
     {
         val = Math.abs(val);
         twoComp(val);
         for (int k = 0; k < bin.length(); k++)
             {
               if (bin[k] == '0')
                   bin[k] = '1';
               else 
                   bin[k] = '0';
             }
       return bin;
     }
 
     //convert to two's comp
     public static char [] twoComp (int val)
     {
        String binary;
        if (val >= 0)
            {
              binary = Integer.toBinaryString(val);
              for (int k = 0; k < binary.length(); k++)
                   bin[k] = binary.charAt(k);
            }
        else 
            {
              bin = oneComp(val);
              increment();
            }
        return bin;
     }
 
     //increment the array
     public static void increment()
     {
          boolean check = true;
 
          for (int k = 7; k >= 0; k--)
          {
             if (check == true)
             {
                if (bin[k] == '0')
                {
                     bin[k] = '1';
                     check = false;
                }
                else 
                {
                    bin[k] = '0';
                    check = true;
                }
             }
          }
     }
}
asm Keyword 5

von Neumann vs Harvard architecture

Definition

Harvard and von Neumann are two prominent computer architectures used in modern computers.

Explanation

The Harvard and von Neumann architectures are both very popular and both have a cpu based system. The primary difference between these architectures is that von Neumann stores data memory and data instructions in the same space, while the Harvard architecture stores data memory and data instructions in separate spaces. This has a couple consequences:

  • Harvard is able to access both data and instructions simultaneously, since they are on different buses. This is not possible on von Neumann.
  • Harvard is able to have different bus sizes for the instructions and the data, while the von Neumann can not.

Both have advantages and disadvantages. For instance the Harvard architecture having separate spaces for instructions and data means that machines that run it need more physical space so as to keep them separate. However, this attribute is also advantageous in that simultaneous manipulation of instructions and data makes for a faster machine than can be achieved with a von Neumann architecture.

asm Keyword 6

Interrupts

Definition

Instructions or code that allow for quick changes in the instructions being executed.

Demonstration

An example of an Interrupt is the NOP (No Operation) instruction. The NOP instruction's only purpose is to increment the program counter.

# !/bin/bash
#
# INSTRUCTION:
#     0xEA - NOP instruction
#
# FUNCTION:
#     Increments the program counter.
#
# FLAGS FLIPPED:
#      None
#
 
PROGRAMCOUNTER="pc"      # The location of the program counter
 
java -cp ../../lib Increment ${PROGRAMCOUNTER}
 
exit 0
asm Keyword 7

Storage

Definition

Computers need to be able to recall previous instructions, and it is convenient for users to be able to frequently access media, or entertainment, or files that they want to put on the computer. To provide this function, computers are able to store information in memory. There are several different types of memory: ram, rom, and cache to name a few.

Demonstration

An example of using memory is saving a file that you are working on. E.G.- You are writing an essay for some reason, and you want to go to bed, so you save it so that you are able to shut off your computer and open it again at a later date.

asm Keyword 8

I/O

Definition

Input/Output refers to the process of interacting with a computing device by giving it parameters or instructions (input) and the machine executing the instructions and giving an answer or showing the result of the instructions (output).

Demonstration

My Demonstration will take the form of a simple program.

# Asks the user for his name and age,
# and prints out an interesting fact
 
prompt = '-->'
 
print "Hi, what is your name?"
name = raw_input(prompt)
 
print "Well, %s, is a nice name. How old are you?" % name
age = raw_input(prompt)
 
print """
So, your name is %s and you are %s years old.\nDid you know that Bears eat fish?\nWell they do.
""" % (name, age)
python nameandage.py
Hi, what is your name?
-->Tony
Well, Tony, is a nice name. How old are you?
-->20

So, your name is Tony and you are 20 years old.
Did you know that bears eat fish?
Well they do.

Experiments

Question

Would it have been at all faster to make the register boolean arrays instead of char arrays?

Resources

http://www.roseindia.net/java/master-java/java-data-types.shtml
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html=

Hypothesis

Based on the resources I have found that say booleans take up less memory and are faster to access, I believe that an array of boolean values would have been a faster alternative to char arrays.

Experiment

I will write java programs that will be clones except for using boolean arrays in one of the programs and char arrays in the other. The program will load an array and time how long it takes.

* Note that the difference in data types may require some differences in functions and register initializations.

Data

Boolean Results TIME: NanoSeconds

1st 2nd 3rd 4th 5th
1 46660 4200 3733 3267 3732
2 47127 4666 3733 3266 3733
3 44795 4666 3266 3733 3733
4 46194 4199 3733 3733 3733
5 45727 4200 3733 3733 4200
AVG: 46100.6 4386.2 3639.6 3546.2 3826.2
AVERAGE 12299.76

Char Results TIME: NanoSeconds

1st 2nd 3rd 4th 5th
1 45728 4200 3732 3733 3733
2 46195 3733 3732 3733 3733
3 46660 4666 3267 3733 3733
4 49461 4199 4200 4199 3733
5 46195 4666 3266 3266 3733
AVG: 46847.8 4292.8 3639.4 3732.8 3733
AVERAGE 12449.16
/*
 * Experiment for opus.
 * First program test.
 * Using char arrays.
 *
 *
 */
public class ExperimentChar
{
	public static char [] test = new char[8];
 
	public static void load(int val)
	{
		String binaryVal = Integer.toBinaryString(val);
		for(int x = 0; x < binaryVal.length(); x++)
			test[x] = binaryVal.charAt(x);
	}	
 
	public static long getTime(int val)
	{
		final long startTime = System.nanoTime();
		final long endTime;
		try {
  			load(val);
		} finally {
  			endTime = System.nanoTime();
			  }
		final long duration = endTime - startTime;
 
		return duration;		
	}
 
 
	public static void main(String [] args)
	{
		ExperimentChar experiment = new ExperimentChar();
		for(int k = 0; k <= 4; k ++)
			System.out.println("The time for the " + (k + 1) + " 
 
experiment was: " + experiment.getTime(k) + " nanoseconds.");
	}	
}
/*
 * Experiment for opus.
 * Second program test.
 * Using boolean arrays.
 *
 *
 */
public class ExperimentBool
{
	public static boolean [] test = new boolean[8];
 
	public static void load(int val)
	{
		String binaryVal = Integer.toBinaryString(val);
		for(int x = 0; x < binaryVal.length(); x++)
			if(binaryVal.charAt(x) == '1')
				test[x] = true;
			else 
				test[x] = false;
	}	
 
	public static long getTime(int val)
	{
		final long startTime = System.nanoTime();
		final long endTime;
		try {
  			load(val);
		} finally {
  			endTime = System.nanoTime();
			  }
		final long duration = endTime - startTime;
 
		return duration;		
	}
 
 
	public static void main(String [] args)
	{
		ExperimentBool experiment = new ExperimentBool();
		for(int k = 0; k <= 4; k ++)
			System.out.println("The time for the " + (k + 1) + " experiment was: " + experiment.getTime(k) + " nanoseconds.");
	}	
}

Analysis

Based on the data collected:

Conclusions

The boolean array did take less time to run, however it was only around a 100 nanosecond difference, so I do not believe that it would have actually affected the project.