Lecture 16

Lecture 16 - Th The University of Texas at Dallas Erik...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Erik Jonsson School of Engineering and h U i it f T t D ll Computer Science The University of Texas at Dallas Developing a Program in SPIM This lecture follows up the two development examples in Lecture 15 with a longer, more complex loop program. Lecture 18 will feature a nal exercise in program development, and the following class period final exercise in program development, and the following class period will include an extended class programming exercise. The purpose of these three extended “how-to” sessions is to courage every student to ive into the programming process encourage every student to dive into the programming process . While classroom lecture can familiarize students with assembly language instructions and simple examples of instruction sequences, eep in mind that e only way to learn programming is to program keep in mind that the only way to learn programming is to program . One of the hardest things to do when learning programming is to “get into the mindset” of doing the programs . s we go through this lecture remember that the techniques included © N. B. Dodge 09/09 Lecture #16: SPIM Programming Example 1 As we go through this lecture, remember that the techniques included here are only valuable if you apply them immediately .
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Erik Jonsson School of Engineering and h U i it f T t D ll Computer Science The University of Texas at Dallas Programming Problem The desired program is defined as follows: The program will take keyboard input for a specific decimal number. It will convert the decimal number to a hexadecimal number. The program will then print out the result on the SPIM simulated console. This is a slightly modified version of the program in Waldron (former textbook): Chapter 7, Section 7.4, “AN EXAMPLE PROGRAM.” © N. B. Dodge 09/09 Lecture #16: SPIM Programming Example 2
Background image of page 2
Erik Jonsson School of Engineering and h U i it f T t D ll Computer Science The University of Texas at Dallas Analysis A program to convert a decimal number to the uivalent hexadecimal number and print out the equivalent hexadecimal number and print out the result must do the following: 1. Input the number from the keyboard. 2. Convert the decimal number to a hexadecimal number. 3. Convert each digit of the hex number to the ASCII symbol for that number (since printout with syscall 12 is only decimal). 4. Store the ASCII code for each hex digit in a byte string (could also print out character-by-character using syscall 11). . utput the hexadecimal umber using syscall 4. © N. B. Dodge 09/09 Lecture #16: SPIM Programming Example 3 5. Output the hexadecimal number using syscall 4.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Erik Jonsson School of Engineering and h U i it f T t D ll Computer Science The University of Texas at Dallas Analysis (2) There is some good news: SPIM routinely converts characters input from the keyboard into yp y the binary value of the number, which it stores in $v0.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 31

Lecture 16 - Th The University of Texas at Dallas Erik...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online