Created
November 3, 2015 14:32
-
-
Save montycheese/a60ec5b45c8e8e6f468e to your computer and use it in GitHub Desktop.
map a char freq in MIPS assembly lang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.data | |
str1: .asciiz "Enter String: " | |
#.align 2 | |
getc: .asciiz "Enter char: " | |
#.align 2 | |
ret: .asciiz "Character <ch> occurs in string <string> <n> times" | |
buffer: .space 100 #space to store our string | |
L1: .space 2 #space for our char | |
L2: .space 4 #space for our char’s frequency in string | |
.text | |
.globl main | |
main: la $a0, str1 #print string to terminal stored at str1 | |
li $v0, 4 #send string to stdout | |
syscall | |
li $v0, 8 #read string from stdin | |
la $a0, buffer #load byte space into addr | |
li $a1, 100 #create byte space for string | |
move $t0, $a0 #save string to t0 | |
syscall | |
la $a0, ret #load string to print results | |
li $v0, 4 #send to stdout | |
syscall | |
la $a0, buffer #reload byte space to primary addr | |
move $a0, $t0 #primary address = t0 address (load pointer) | |
li $v0, 4 #print out string | |
syscall | |
li $v0, 10 #kill program | |
syscall | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment