3.19.2007

I thought you guys might be interested to see part of what I do for my Organization, Architecture, and Assembly Language class. This is a program in assembly language that accepts two integers, and multiplies them manually, instead of using any built-in function. Assembly language is one step away from machine code, which the actual processor inside the computer can read. To show you what that looks like, I have translated the red bolded command below into machine code.
In hexidecimal notation, it would be 0x0251A024
In binary notation, it would be 00000010010100011010000000100100
Or, going the other direction, to a more sophisticated language, the green italicized part of the assembly code would be the following in pseudocode, which is much closer to languages like c++ or java:

int mult (int a, int b){
if (a == 0 || b == 0){
return 0;

}else if (a[0] == '0'){
return (mult (a<<1,>>1);

}else {
return (a + mult(a<<1,>>1);

}

}


And here is the actual assembly code:
[The weird lines across the page are a result of me using an easy way to indent lines in html...it is really kind of a pain to do it right, and evidently this website makes lines when I use that method]

#Lab 6
#Jonathan Gerrans

#Data Memory Section
.data
enterint: .asciiz "Please enter two integers: "
ans: .asciiz "The answer is: "
error: .asciiz "Error! Overflow!"
.align 2


#Program Memory Section
.text
.globl main




main:
li $v0, 4
la a0, enterint
syscall
li $v0, 5 #read in values
syscall
li $v1, 5
syscall
addi $s0, $zero, 0x00000001 #mask
addi $s1, $zero, 0x80000000 #mask2
move $s2, $v0
move $s3, $v1
move $s6, $zero
addi $s7, $zero, 0x00000020

overflow1:
addi $s6, $s6, 0x00000001 #overflow check
and $s4, $s2, $s1
sll $s2, $s2, 1
beq $s4, $zero, overflow1


overflow2;
addi $s6, $s6, 0x00000001 #overflow part two
and $s5, $s3, #s1
sll $s3, $s3, 1
beq $s5, $zero, overflow2
bgt $s6, $s7, error #print overflow error
add $a0, $zero, $v0 #first value
add $a1, $zero, $v1 #second value

jal mult
j end



mult:
beq $a0, $zero, return #if $a0 is zero, then return .
beq $a1, $zero, return #if $a1 is zero, then return .
and $t0, $a1, $v0 #check if first bit is a zero
bne $t0, $zero, notzero
sll $a0, $a0, 1 #shift a0 left one
srl $a1, $a1, 1 #shift a1 right one
jal mult #recurse
j return


notzero:
add $v0, $v0, $a0
sll $a0, $a0, 1 #shift a0 left one
srl $a1, $a1, 1 #shift a1 right one
jal mult #recurse


return: jr $ra

error:
li $v0, 4
la $a0, error
syscall
li $v0, 11 # ENDLINE
li $a0, 10
syscall
j main


end:
li $v0, 4 #Print the result
la $a0, ans
syscall
li $v0, 1
lw $a0, $v0
syscall
li $v0, 11 # ENDLINE
li $a0, 10
syscall
j main


This is so much fun!

3.16.2007

Florida Tour Pics

Yes, yet another picture post...but since there are 118 pictures this time, I won't put them in this blog...I have them in a Picasa web album, and the link is here.
These are the pictures from the I Cantori tour to Florida that I went on over spring break.
Enjoy!
P.S. Pictures are best viewed in slideshow mode! :)

3.05.2007

Imagination

"Imagination is more important than knowledge...knowledge is limited, but imagination encircles the world. To see with one's own eyes, to feel and judge without succumbing to the suggestive power of the fashion of the day, to be able to express what one has seen and felt in a trim sentence or even in a cunningly wrought word...is that not glorious? When I examine myself and my methods of thought, I come close to the conclusion that the gift of imagination has meant more to me than my talent for absorbing absolute knowledge."
- Albert Einstein

3.04.2007

Yesterday, Barry and I went into the Great Smoky Mountain National Forest, and hiked up LeConte, a 6,593 foot peak. It is one of the highest peaks in the area, and offers some extrordinary views, both from the top, and throughout the hike.


A bridge over a clear stream, on the way to the trailhead.


The trail follows an amazingly clear stream for the first part of the hike.



Along the way, there is a cool rock archway, which the path leads through.








We crossed the stream many times.


Excellent views abounded.



We came to a rather large overhanging rock face, and espied many icicles hanging off the lip.





One had to be careful, since the trail passed right through the dripline, and every so often, a big chunk of ice would break off and tumble to the ground.


A tree in the dripline also displayed the solid form of H2O in a spectacular fashion.


The overhang made for a feeling of being in a large cave.



Icicles.



The trail



We wanted to hike to this little protrusion, but didn't have enough time, probably because I was taking so many pictures.



Near the summit, we came upon a veritable village of cabins, each one with an excellent view of the surrounding vista.




At the summit


It was so windy that when I put my arms up, i nearly fell on my face from the sudden effect of the extra sail footage.


Barry wisely keeps his arms down.

3.01.2007

Maps

Most of you probably haven't noticed the new addition at the bottom of the page...
I thought it might be interesting to see the maps for some of you who have done a lot of traveling, so if you have time to do that, it would be fun!
It only takes five minutes or so!