This code serves as a built-in function library of Mx Language of Compiler Project of ACM Honored Class
Built by Ficos 16/5/2 All rights reserved.
All test passed.
- fix a bug in
func_parseInt, where the previous version cannot parse negative integer (but this situation does not appear in any test cases) - add
func__stringLeq,func__stringGeq,func__stringNeqandfunc__stringLarge - Now when calling
func__toStringandfunc__stringConcatenateyou don't need to save any register other than$v0,$v1(if you used them) - you don't need to call "
_buffer_init" function before entering the source main function!!!
1.func__getInt will read input until \n, for I call MIPS sysfunc indeed.
- Just paste all of this in front of your MIPS code
FunctionName | args
--------------|--------
- func__print |
$a0: the string - func__println |
$a0: the string - func__getString |---
- func__getInt |---
- func__toString |
$a0: the integer - func__string.length |
$a0: the string - func__string.substring |
$a0: the string,$a1: left pos(int),$a2: right pos(int) - func__string.parseInt |
$a0: the string - func__string.ord |
$a0: the string,$a1: pos(int) - func__array.size |
$a0: the array - func__stringConcatenate |
$a0: left string,$a1: right string - func__stringIsEqual |
$a0: left string,$a1: right string - func__stringLess |
$a0: left string,$a1: right string - func__stringLeq |
$a0: left string,$a1: right string - func__stringGeq |
$a0: left string,$a1: right string - func__stringNeq |
$a0: left string,$a1: right string - func__stringLarge |
$a0: left string,$a1: right string
- args placed in
$a0,$a1,$a2 - return in
$v0 - follow the MIPS calling convention, be careful on regs when calling these functions
- all used regs are presented in the front of the function
-
string object is simply a register contains the initial address of the string
-
front of every initial address of a string are a word containing the length of the string e.g.
.data .word 6 str: .asciiz "hello\n" .align 2 -
every string ends with
'\0', which is not counted in the length
- front of every initial address of a array are a word containing the size of the array