MIPS Assembly Language: CS 5300 - Simple Statements - Prof. Stephen J. Allan, Study notes of Computer Science

An overview of simple statements in mips assembly language as taught in cs 5300. It covers topics such as write statements, print statements, assignment statements, and read statements. Students will learn how to use system calls for printing integers and characters, as well as reading characters and strings.

Typology: Study notes

Pre 2010

Uploaded on 07/30/2009

koofers-user-rc1
koofers-user-rc1 🇺🇸

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Simple Statements
CS 5300 - SJAllan Simple Statements 2
MIPS System Calls
10exit
$a0=integer11print_character
character in $v012read_character
$a0=buffer
$a1=length
8read_string
integer in $v05read_int
$a0=address of string4print_string
$a0=integer1print_int
ResultsArgumentsCall
Code
Service
The call code is placed in register $v0
pf3
pf4

Partial preview of the text

Download MIPS Assembly Language: CS 5300 - Simple Statements - Prof. Stephen J. Allan and more Study notes Computer Science in PDF only on Docsity!

Simple Statements

CS 5300 - SJAllan Simple Statements 2

MIPS System Calls

exit 10 print_character 11 $a0=integer read_character 12 character in $v

$a0=buffer $a1=length

read_string 8

read_int 5 integer in $v

print_string 4 $a0=address of string

print_int 1 $a0=integer

Call Arguments Results Code

Service

ƒ The call code is placed in register $v

CS 5300 - SJAllan Simple Statements 3

Write Statement

WriteStatement : WRITESY LEFTPARENSY Expression RIGHTPARENSY {writestatement($3);} | | WRITELNSY {writelnstatement();} ;

ƒ Notice that WriteStatement has no semantic value

CS 5300 - SJAllan Simple Statements 4

Print an Integer

li $v0, 1 # System call code for print_int li $a0, 5 # Integer to print syscall # Print it

CS 5300 - SJAllan Simple Statements 7

Null Statement

NullStatement : /* empty */ ;

ƒ This is a tough one to implement ƒ Can you figure it out?