I honestly don't fully know where to start with this program but this is what i have

Write a MIPS program which read one line at a time from console. For each line that you read, print two lines on the console: echo print of the line and types of individual characters on the line.
The character types are defined below:

Characters Type Comment
0 1 .. 9 1 Digits
A B .. Z a b .. z 2 Letters
* + - / 3 Operators
. ( ) , : 4 Delimiters
b 5 blank
# 6 End of the Line

For example, when a line of the input below

THISLOOP: LWU R2, 3 #

the output from the program will be like

THISLOOP: LWU R2, 3 #
222222224 222 2141 6

getline: 
	la	$a0, st_prompt		# Prompt to enter a new line
	li	$v0, 4
	syscall

	la	$a0, inBuf		# read a new line
	li	$a1, 80	
	li	$v0, 8
	syscall

	jr	$ra

	.data
inBuf:	.space	80
st_prompt:	.asciiz	"Enter a new input line. \n"


	.data
Tabchar: 	.word 'B', 5
 	.word '#', 6 
	.word '(', 4 
	.word ')', 4 
	.word '*', 3 
	.word '+', 3 
	.word ',', 4 
	.word '-', 3 
	.word '.', 4 
	.word '/', 3 

	.word '0', 1
	.word '1', 1 
	.word '2', 1 
	.word '3', 1 
	.word '4', 1 
	.word '5', 1 
	.word '6', 1 
	.word '7', 1 
	.word '8', 1 
	.word '9', 1 

	.word ':', 4 

	.word 'A', 2
	.word 'B', 2 
	.word 'C', 2 
	.word 'D', 2 
	.word 'E', 2 
	.word 'F', 2 
	.word 'G', 2 
	.word 'H', 2 
	.word 'I', 2 
	.word 'J', 2 
	.word 'K', 2
	.word 'L', 2 
	.word 'M', 2 
	.word 'N', 2 
	.word 'O', 2 
	.word 'P', 2 
	.word 'Q', 2 
	.word 'R', 2 
	.word 'S', 2 
	.word 'T', 2 
	.word 'U', 2
	.word 'V', 2 
	.word 'W', 2 
	.word 'X', 2 
	.word 'Y', 2
	.word 'Z', 2

	.word 'a', 2 
	.word 'b', 2 
	.word 'c', 2 
	.word 'd', 2 
	.word 'e', 2 
	.word 'f', 2 
	.word 'g', 2 
	.word 'h', 2 
	.word 'i', 2 
	.word 'j', 2 
	.word 'k', 2
	.word 'l', 2 
	.word 'm', 2 
	.word 'n', 2 
	.word 'o', 2 
	.word 'p', 2 
	.word 'q', 2 
	.word 'r', 2 
	.word 's', 2 
	.word 't', 2 
	.word 'u', 2
	.word 'v', 2 
	.word 'w', 2 
	.word 'x', 2 
	.word 'y', 2
	.word 'z', 2

Recommended Answers

All 2 Replies

After working on this project for 4 hours i finally understand input and output in mips... i couldnt replicate code on a piece of paper but i understand how it works, but this is my code so far, how would i implement the part of the program that prints out the individual type of character? I first have to access each individual character and then change that character into its type... any help once again would be greatly appreciated, I will be working on this throughout the night and probably tomorrow... here is my new and improved code... i just re did my program and took out the stuff i dont understand.

.data
Prompt: .asciiz "\n Please insert a string: "
Buffer: .space 60
Bye:	.asciiz "\n **** Adios Amigo - Have a good day****"
		.globl main
		.text
main:
		li $v0, 4 			# system call code for Print String
		la $a0, Prompt 		# load address of prompt into $a0
		syscall 			# print the prompt message
		li $v0, 8 			# system call code Read String
		la $a0, Buffer 		# $a0 is a pointer to an input buffer
		li $a1, 60 			# specifies the maximum length of input buffer
		syscall 			# read a string and store it into the buffer
		li $v0, 4 			# system call code for Print String
		la $a0, Buffer 		# load address of msg. into $a0
		syscall 			# print the string

End: 	li $v0, 4	 		# system call code for Print String
		la $a0, Bye 		# load address of msg. into $a0
		syscall 			# print the string
		li $v0, 10 			# terminate program run and
		syscall 			# return control to system
.data
	
Prompt: .asciiz "\n Please insert a string: "
Buffer: .space 60
Bye:	.asciiz "\n **** Adios Amigo - Have a good day****"

		.globl main
		.text
		
main:	li $v0, 4 			# system call code for Print String
		la $a0, Prompt 		# load address of prompt into $a0
		syscall 			# print the prompt message
		
		li $v0, 8 			# system call code Read String
		la $a0, Buffer 		# $a0 is a pointer to an input buffer
		li $a1, 60 			# specifies the maximum length of input buffer
# <-- NOT 60,  60-1  You need space for the terminator!
		syscall 			# read a string and store it into the buffer

# <--  You read string, how many characters? 59 is maximum length?
# Should you preclear the buffer with terminators?
		
		li $v0, 4 			# system call code for Print String
		la $a0, Buffer 		# load address of msg. into $a0
		syscall 			# print the string
		
# <-- Missing something here? Like parsing code?




 End: 	li $v0, 4	 		# system call code for Print String
 		la $a0, Bye 		# load address of msg. into $a0
 		syscall 			# print the string
 		
 		li $v0, 10 			# terminate program run and
 		syscall 			# return control to system
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.