Coding at a new level

This semester I am taking a class called Machine Organization and Assembly Language. What this amounts to is learning how to program on lower levels than Java and C++. Instead I am [currently] programing right to the hardware, or one level higher. It’s interesting and in some ways more difficult. While there is a lot to know in higher levels like Java, there is more you have to keep track of in Machine and Assembly. Right now we are using a pseudo architecture called “Pep/8” which is a simple ‘machine/OS’. It is not actually used, but servers on an academic level to illustrate.

Below is some code at first machine level and then assembler in Pep/8. The program reads in 2 single digit numbers and outputs a single digit answer. For example: 2+2 wouls yield 4, which 8+4 would yield 2. Achieve this, I checked to see if the sum was greater than 9, if so, subtract
10.

04 00 0B 00 00 00 00 00 00 00 0A 31 00 03 31 00 05 C1 00 03 71 00 05 E1 00 07 B1 00 09 08 00 29 C1 00 07 81 00 09 E1 00 07 39 00 07 00 zz

…What that results to in Assembly is:

pep8 assmbly

To give some perspective, in Java, it would look something like this…

{
//read in 2 ints, I and j
int sum= i + j;
if(sum >= 10){
sum= sum - 10;
}
System.out.print (sum);
}

…Later

Leave a Reply

Your email address will not be published. Required fields are marked *