Covered Topics

Please see the list of the topics I've covered. It's located near the bottom of the page. Thanks for stopping in!!

Monday, September 19, 2011

MIPS 32 Example Program using QtSPIM

A few nights ago, I got my first MIPS 32 program running in QtSPIM. Readers of this blog will recall my recent posts about MIPS-32 assembly language and the MIPS-32 SPIM emulator. I promised you a sample program and operational details - so here they are. Below is the code listing:

# http://inkarlslab.blogspot.com
# 09/16/2011
#
# A Demonstration of some simple MIPS instructions
# used to test QtSPIM.
#
#
#
# ori rt, rs, imm - Puts the bitwise OR of register rs and the
# zero-extended immediate into register rt => This is a
# trick for placing a constant into register rt.
#
# add rd, rs, rt - Puts the sum of registers rs and rt into register rd.
#
# sub rd, rs, rt - Puts difference of registers rs and rt into register rd.
#
# syscall - Register $v0 contains the number of the system
# call provided by QtSPIM - when $v0 is loaded with the value '10',
# this causes program to exit.
#
# It calculates 25 + 12, and 25 - 12.
#


.globl main # Make main global so you can refer to
# it by name in QtSPIM.

.text # This line tells the computer this is the
# text section of the program
# (No data contained here).

main: # Program actually starts here.
ori $t2, $0, 25 # Register $t2 gets 25
ori $t3, $0, 12 # Register $t3 gets 12
add $t4, $t2, $t3 # Register $t3 gets 25 + 12

sub $t5, $t2, $t3 # Register $t5 gets 25 - 12

ori $v0, $0, 10 # Sets $v0 to "10" so when syscall is executed, program will exit.
syscall # Exit.


This program loads constant values into two temporary registers $t2 and $t3, using the ori command.

Here is a handy list of MIPS-32 commands:
http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html

The MIPS-32 Register file contains 32 registers - each is 32 bits long. Here is a list of them and how they're used:
http://msdn.microsoft.com/en-us/library/ms253512%28v=vs.80%29.aspx

Now, back to the code:
The contents in $t2 and $t3 are added and that value gets stored in another register, $t4. Then the contents of $t3 are subtracted from the contents of $t2, then stored in $t5. After all the work is done, register $v0 is set to "10", which is the code for "EXIT". Then the program exits.

Here, in a nutshell, is how to quickly write a MIPS-32 program and run it in QtSPIM:

1) Write your program in a similar style as I have above. You can do this in any text editor. Save the file as YOUR_FILENAME.asm .

2) Start QtSPIM. Under the "simulator" menu, select "clear registers". You should see some values "zero out" in the "register window" along the left-hand side of the QtSPIM panel.

3) Under the "File" menu, select "load file". A file browser window will pop up - locate your .asm file and select it. The program should load into QtSPIM.

4) Under the "Simulator" menu, select "Run Parameters". Enter "0x00400024" - without the quotation marks, into the box entitled "address or label to start running program". This simply tells QtSPIM which line your code starts on, since there is other initialization code that appears whenever you start QtSPIM. That code ends with a syscall at address 0x00400020.

5) Under the "Registers" menu, select "decimal". This will display the values in your register as normal base 10 (decimal) numbers, which helps us to easily verify that the math is being done according to design.

6) Using the single-step button seen in the second picture below, step through the program. You can also use "F10" on your keyboard - you may find this more convenient. Each time you click the button, note what happens to the values in each of the registers in the left hand window, as well as the program counter.

Note, too, that both the program counter and the register address increments by 4; this makes sense because a MIPS-32 register is 32 bits, or 4 bytes, long. Gotta love it when real-world experience actually matches what's in the book :)

The sequence of pictures below show the program as I stepped through it.

Ready, get set ...

























Now, we start stepping through the program:


















As we step, the "ori" instructions load constants into the registers in preparation for some simple math.

Addition completed:



















Now, the subtraction just completed:



















Program finished running:


I would like to add that the creator of SPIM, Jim Larus, was of great help in answering my questions and emails during the installation of QtSPIM on my Fedora box. Mr. Larus is a true gentleman and has created a really cool and useful application - and I wanted to voice my appreciation for his efforts here.

Friday, September 9, 2011

SPIM In a LINUX Environment

In my last post I discussed MIPS 32 and the SPIM emulator for running MIPS 32 assembly code on your PC. Today I will briefly talk about how I got SPIM running in a LINUX environment. My earlier post is located at http://inkarlslab.blogspot.com/2011/09/spim-mips-32-bit-simulator.html

The problem I was having yesterday was in compiling SPIM on a Fedora system. I was getting this error message when running the makefile:

make: *** No rule to make target `../CPU/spim.h', needed by `spim.o'. Stop.

All the files were there and apparently in their proper folders, ...

I am still in communication with someone in attempt to get that figured out. The person helping me suggested I try installing the pre-compiled Debian binary. So I downloaded the 32-bit Debian file for QtSPIM from the following link:

SPIM MIPS Simulator Homepage - You can find more information and LINUX versions by going here.
http://spimsimulator.sourceforge.net/

I next unpacked it with the GNOME "File Roller" tool and extracted everything to the "SPIM" directory I had created earlier. Basically that's it. There are two ways to run QtSPIM from this installation.
Suppose you installed your "SPIM" directory in your home directory:

1) On the command line, simply navigate to the "SPIM" directory, then to "/usr", then to "/bin". NOTE that these /usr and /bin directories are NOT the same ones as are in your UNIX file system! Once you are in /bin, type qtspim to start the application, or

2) locate the SPIM/usr/bin folder via the GNOME desktop and click on the QtSPIM executable.



As you can see, QtSPIM is now running on a Fedora system. Having never tried to install a Debian executable on Fedora, I thought this was pretty cool.

Thursday, September 8, 2011

Obtaining Parts and Supplies During The Great Recession

Most normal people are feeling some effects of the current economic mess, even if they are still employed. Given the war being actively waged upon the American middle class, many folks are having more and more trouble finding money to just pay for day to day needs - much less the parts to build or create new projects.

Plato (427 BC - 347 BC) said that "necessity is the mother of invention". During the 1930's - the Great Depression - folks built their own radios and other projects from whatever they could find around. Grandpa's "oatmeal box radio" is but one example. During WW2, prisoners of war actually built functioning crystal radios using razor blades, scrap wire and other bits and pieces they found. Here in my lab, I too have embraced some of the ways of my grandparents' generation. During the past year I have learned of a couple ways to quickly and efficiently recover components intact from used PC boards. This has already saved me considerable funds - some of which I have been able to invest in those few specialty parts that I could not find in my gleanings.

From two dead CDROM drives removed from computers I have salvaged the lasers, motor drives, and a few other semiconductor devices. I have set the laser diodes aside for future use in an experimental "free space" optical communications system. From a 56K modem card I salvaged all the parts I needed to make a telephone line interface for conference calls. Ham operators take note - the 600 ohm line transformer out of a modem works great in a phone patch circuit. Why pay $10 - $20 plus shipping for this component? Also on the modem card were the MOV surge suppressor devices, high voltage capacitors, ... needed to interface with telephone lines.

Computer power supplies yield transformers, bridge rectifiers, resistors, low and high voltage electrolytic caps, and assorted semiconductor devices. Even the metal case can be reused for certain projects - especially if looks aren't critical.

A dead computer can yield fans, heat sinks, connectors, and some surface-mount components. The case can be salvaged for the metal.

TV sets, VCRs, stereo components, home appliances and personal electronic devices yield all sorts of good, useful electronic and mechanical parts. High voltage experimenters and builders of small Tesla coils will likely want the flyback transformers and high voltage capacitors from TVs and CRT-type computer monitors. Get 'em now - these parts will become scarce in the next few years as flat screen monitors and TVs take over.

So, before you hand your old computer, TV, or any other appliances to be scrapped or recycled, check and see if there's something you could salvage off it and use before throwing it away. Those parts will either end up in a landfill or melted down anyway - so why not reuse them yourself?

SPIM: MIPS 32-Bit Simulator

SPIM is a simulator that allows one to run programs in MIPS assembly language on one's own PC. Many college courses in computer architecture and engineering teach MIPS assembly language as part of the curriculum. MIPS stands for Microprocessor without Interlocked Pipeline Stages, and is an example of a RISC (Reduced Instruction Set Computer) architecture. MIPS is used in lots of embedded microprocessors, video game systems, some desktop workstations such as DEC (Digital Equipment Corporation) and SGI (Silicon Graphics, Inc.), and many other applications. MIPS based chips can be found in hand held computers and cell phones. There are both 32 bit and 64 bit versions of MIPS.

This semester, I am taking a computer hardware and architecture course and am getting prepared for our first MIPS 32 programming assignment. We will be using SPIM. SPIM is written by James Larus. You can find more information and downloads at the links below:

SPIM Sourceforge Project Page - You can download the Windows version conveniently here.
http://sourceforge.net/projects/spimsimulator/

SPIM MIPS Simulator Homepage - You can find more information and LINUX versions by going here.
http://spimsimulator.sourceforge.net/

From my understanding of the documentation, the more recent versions of SPIM are apparently called "QtSPIM".

The LINUX downloads there appear to cater to Debian and Ubuntu users. I am currently in the process of finding out what is available for those of us who use Fedora and other distros. Last night I attempted to compile SPIM directly from the source code onto my Fedora system, but to no avail. There is a problem with the makefile that I am currently trying to resolve. I have contacted some people about it, so as soon as I find out what is going on with that I'll post it here. Meanwhile, in the interest of quickly getting something going for the class, I loaded QtSPIM to my Windows VISTA partition from the first of the two links shown above. Here is a screenshot:



Note there are two windows open. One is the "console" window that shows any results or dialogs when the program runs. The "Qt" window shows you your source code, registers, and other relevant information.

This promises to be quite an interesting semester. Will write more as things progress.

Monday, September 5, 2011

More on Making a PVC Pipe Archery Bow

Regular readers of this blog will recall the piece I wrote about my experimental PVC archery bow. I wanted to see if one could actually produce a longbow type archery bow easily and cheaply using PVC. Between family, school, and other demands I have not gotten out to shoot it yet. See my previous post here:
http://inkarlslab.blogspot.com/2011/06/homemade-pvc-pipe-archery-bow.html

While doing some research a couple weeks ago I stumbled upon this interesting you-tube video. It details how to make a PVC bow that is considerably more elaborate than the one I made and wrote about. It's owner claims 60 pounds draw weight - quite respectable, in my opinion.

http://themanscave.com/hunting-outdoors/pvc-bow/

There are plenty of sites online that deal with PVC as a cheap and readily available material for making archery bows. Here is a quick distillation of what I have learned:

USE EYE PROTECTION when shooting ANY archery bow!! Any bow made of any material could potentially break. This could cause eye injury, depending on where the pieces fly. I've also heard of strings breaking and swatting people in the face, too.

1) While PVC will work, it does NOT have the speed or the "snap" of wood or fiberglass. In other words, when the string is released, a PVC bow of a given design and draw weight will take slightly longer to return to the relaxed position. Thus it will not produce as much arrow velocity as other materials.

2) PVC will develop a "memory", or "take a set", if it is left strung all the time. Thus, one should always unstring the bow when not in use.

3) On ANY "traditional" style bow, you want a brace height of 6" - 7". The brace height is the measurement between the string and the handle - in this case as measured at the middle of the bow. I should adjust mine by shortening the string slightly; the brace height is about 4.5".

4) The "composite" design of "Themancave's" bow offers the advantage of better speed due to the fiberglass rod core. Doing as he said by using a 1/2" pipe slipped inside a 3/4" pipe might also help protect against breakage - though I'd use soap or lanolin instead of petroleum based oil as the assembly lubricant.

5) If you paint PVC as "Themanscave" did, beware that the solvents in the paint will eat into the PVC and weaken it somewhat. Krylon and Rust-Oleum both make a spray primer for PVC. This primer is supposed to help the paint bind to the PVC. I'm currently using that on my own PVC projects to hopefully avoid the paint flaking I've experienced in the past.

6) As I mentioned in my previous post on this topic, PVC gets quite brittle at temperatures below the mid 40's Fahrenheit. So don't try to shoot it in cold weather. PVC also degrades due to UV exposure - so don't leave your PVC bow exposed to sunlight when not in use. Painting your bow will protect it from UV exposure, but as I mentioned above the paint itself will weaken the material slightly.

While PVC does have certain disadvantages as pointed out above, it can be a viable way to obtain a bow quite cheaply and easily, and also might prove to be a useful emergency technology in a survival situation.

If any readers have made and used a PVC bow, I'd love to hear from you. In a future post I plan to cover simple "home and hardware store" materials to use for making bowstrings.

Sunday, September 4, 2011

Some Insight Into The Mindset of GNOME3 Developers

I have written about the GNOME3 desktop environment in a couple recent posts. Richard Jones, a computer programmer, wrote a short blog piece about GNOME3 today. He posted a link to an actual conversation between Owen Taylor (from Red Hat) and two GNOME developers. Definitely an interesting and eye-opening 10 minutes of reading for any GNOME user.

http://rwmj.wordpress.com/2011/09/04/more-gnome-3-inanity/


My $ 0.02:
What I come away with from Mr. Jones's and Mr. Taylor's posts is the GNOME developers are basically focused on how THEY use GNOME; they are not necessarily mindful of how the rest of us work within the environment.

College business and marketing professors have taught that businesses who ignored indicators of what the market wanted and was buying did so to their own peril. Personal experience and observations in the real world bear this out - one does NOT need a degree in business to figure this out.

Having taken computer programming classes in college, I can attest to the level of thinking acuity required to produce a piece of software. Building something as complex as an entire GUI environment - like GNOME - is no small feat. My hat's off to anyone who can do it.

These guys aren't stupid - I just hope they get the wax out of their ears, and soon.