RosettaCodeData/Task/String-matching/MIPS-Assembly/string-matching-2.mips

42 lines
795 B
Plaintext

main:
la $a0,MyString
la $a1,Test1 ;this code was recompiled 5 times, testing a different string each time.
jal InString
nop
jal Monitor
nop
shutdown:
nop ;Project 64 will detect an infinite loop and close the ROM if I don't have this nop here.
b shutdown
nop
MyString: ;this was loaded into $a0
.ascii "abcdefghijklmnopqrstuvwxyz"
.byte 0
.align 4
;each of these was loaded into $a1 individually for testing
Test1:
.ascii "abc" ;InString returned 0
.byte 0
.align 4
Test2:
.ascii "xyz" ;InString returned 0x17 (decimal 23)
.byte 0
.align 4
Test3:
.ascii "def" ;InString returned 3
.byte 0
.align 4
Test4:
.ascii "z",0 ;InString returned 0x19 (decimal 25)
.byte 0
.align 4
Test5:
.ascii "1",0 ;InString returned 0x1A (decimal 26)
.byte 0
.align 4