首页 > 代码库 > 第一次互评作业:MIPS汇编程序设计
第一次互评作业:MIPS汇编程序设计
1 .data 2 3 string1: .asciiz "*\n" 4 5 6 bstring: .asciiz 7 "Alpha ","Bravo ","China ","Delta ","Echo ","Foxtrot ", 8 "Golf ","Hotel ","India ","Juliet ","Kilo ","Lima ", 9 "Mary ","November ","Oscar ","Paper ","Quebec ","Research ", 10 "Sierra ","Tango ","Uniform ","Victor ","Whisky ","X-ray ", 11 "Yankee ","Zulu " 12 13 boffset: .word 14 0,7,14,21,28,34,43,49,56,63,71, 15 77,83,89,99,106,113,121,131, 16 139,146,155,163,171,178,186 17 18 19 nstring: .asciiz 20 "zero ", "First ", "Second ", "Third ", "Fourth ", 21 "Fifth ", "Sixth ", "Seventh ","Eighth ","Ninth " 22 23 noffset: .word 24 0,6,13,21,28,36,43,50,59,67 25 26 27 sstring: .asciiz 28 "alpha ","bravo ","china ","delta ","echo ","foxtrot ", 29 "golf ","hotel ","india ","juliet ","kilo ","lima ", 30 "mary ","november ","oscar ","paper ","quebec ","research ", 31 "sierra ","tango ","uniform ","victor ","whisky ","x-ray ", 32 "yankee ","zulu " 33 34 soffset: .word 35 0,7,14,21,28,34,43,49,56,63,71, 36 77,83,89,99,106,113,121,131, 37 139,146,155,163,171,178,186 38 39 40 41 .text 42 43 loop: 44 45 li $v0,12 46 syscall 47 48 move $t2,$v0 49 50 move $t0,$t2 51 li $t1,63 52 beq $t0,$t1,exit 53 54 move $t0,$t2 55 li $t1,122 56 bgt $t0,$t1,other 57 58 move $t0,$t2 59 li $t1,48 60 blt $t0,$t1,other 61 62 move $t0,$t2 63 li $t1,57 64 ble $t0,$t1,number 65 66 move $t0,$t2 67 li $t1,65 68 blt $t0,$t1,other 69 70 move $t0,$t2 71 li $t1,90 72 ble $t0,$t1,big 73 74 move $t0,$t2 75 li $t1,97 76 blt $t0,$t1,other 77 78 #print Lower case letters 79 80 addi $t0,$t0,-97 81 la $t1,soffset 82 sll $t0,$t0,2 83 add $t0,$t0,$t1 84 lw $t1,($t0) 85 la $t0,sstring 86 add $t0,$t0,$t1 87 move $a0,$t0 88 li $v0,4 89 syscall 90 j loop 91 92 other: 93 94 la $a0,string1 95 li $v0,4 96 syscall 97 j loop 98 99 number: 100 101 addi $t0,$t0,-48 102 la $t1,noffset 103 sll $t0,$t0,2 104 add $t0,$t0,$t1 105 lw $t1,($t0) 106 la $t0,nstring 107 add $t0,$t0,$t1 108 move $a0,$t0 109 li $v0,4 110 syscall 111 j loop 112 113 #print Upper case letters 114 big: 115 116 addi $t0,$t0,-65 117 la $t1,boffset 118 sll $t0,$t0,2 119 add $t0,$t0,$t1 120 lw $t1,($t0) 121 la $t0,bstring 122 add $t0,$t0,$t1 123 move $a0,$t0 124 li $v0,4 125 syscall 126 j loop 127 128 exit: 129 130 li $v0,10 131 syscall
第一题的算法文字描述:
调用系统功能输入数据
转换数据
(1) 如果输入的是字母(A~Z,区分大小写)或数字(0~9),则将其转换成对应的英文单词
(2) 若输入的不是字母或数字,转换成“*”,
每输入一个字符,即时转换并在屏幕上显示,
支持反复输入,直到按“?”键结束程序。
对应的伪码:
1 if(n<=122) 2 if(n>=48) 3 if(n<=57) 4 goto number 5 if(n<65) 6 goto ‘*‘ 7 else 8 if(n<=90) 9 goto big 10 if(n<97) 11 goto ‘*‘ 12 if(n>=97) 13 goto small 14 else 15 goto ‘*‘ 16 else 17 goto ‘*‘
第一次互评作业:MIPS汇编程序设计
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。