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

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

View Full Document Right Arrow Icon
Erik Jonsson School of Engineering and Th U i it f T t D ll Computer Science The University of Texas at Dallas Syscall 8 Syscall 8 allows ASCII character input from the keyboard. Syscall 8 uses three registers : $a0 – starting address in memory to store string $a1 – character length (max. number of characters to be input) $v0 – (as usual) holds the system call number (8) $v0 (as usual) holds the system call number (8) To load $a0: Load $a0 with the address of first byte of memory storage area. E l “l $ 0 b ff ” (“b ff dd l b l f th fi t b t f Example: “la $a0, buffer,” (“buffer” = address label of the first byte of storage space ) Reserve the storage area with “.space” directive: Example: buffer: space 36 (reserves and labels 36 bytes in memory © N. B. Dodge 09/09 Lecture #14: MIPS Shift, Rotate, and Decision-Support Instructions 1 Example: buffer: .space,36 (reserves and labels 36 bytes in memory and clears to 0)
Image of page 1

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

View Full Document Right Arrow Icon
Erik Jonsson School of Engineering and Th U i it f T t D ll Computer Science The University of Texas at Dallas Syscall 8 (2) To load $a1: li $a1,number – Desired character length $a1 (e.g., li $a1,36) Warning : If [$a1] > reserved memory area, the program can overwrite other data declared in the program! If less than that number in $a1 is input, the “Enter” key must be pressed. If input number = [$a1], input automatically ends . Note: To assure a null-terminated character string, declare a larger reserved area than is actually needed. That is: buffer: .space 37 (if max. character number = 36) A typical complete syscall 8 would look like this: la $a0, buffer li $a1, 36 li $v0, 8 “Buffer” is the label of the reserved space in memory. 36 = max. character number (memory space in buffer). Normal form of a syscall © N. B. Dodge 09/09 Lecture #14: MIPS Shift, Rotate, and Decision-Support Instructions 2 syscall Normal form of a syscall.
Image of page 2
Erik Jonsson School of Engineering and Th U i it f T t D ll Computer Science The University of Texas at Dallas Shift and Rotate Instructions It is often necessary to perform manipulations of data words in the computer other than normal logical or arithmetic operations. Such operations might include: Re-arrangement of bytes in a word “Quick” divide or multiply by 2, 4, or any number = 2 ± n “Masking” -- making certain only parts of a word are visible so that they can be examined or tested Elimination of certain bit fields of a word (which can also be done by logical instructions in some cases) Shift and rotate instructions facilitate these sorts of data manipulations. © N. B. Dodge 09/09 Lecture #14: MIPS Shift, Rotate, and Decision-Support Instructions 3
Image of page 3

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

View Full Document Right Arrow Icon
Erik Jonsson School of Engineering and Th U i it f T t D ll Computer Science The University of Texas at Dallas The “Logical” Left Shift (sll) Assume that we wish to multiply a 32-bit number by a power of 2 in a MIPS register, (or perhaps we wish to rearrange bits of the data word): Multiplying by 2 n
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern