1
작은 배경 화면 : 이 문자열은 각 문자에 대해 ASCII 값에 키 (1-26)를 추가하고 문자열에 다시 배치하도록 설계된 응용 프로그램입니다. 유일한 문제는 null 문자 (beqz)에서 종료하도록 설계된 프로그램을 가지고있을 때에도 내 최종 문자가 항상 조작된다는 것입니다. 수 xzujw mfuud]MIPS 문제 해결 Null 종료 문자 감지
:
암호화 된 메시지 : 슈퍼 행복
가 키를 입력 : -
encrypt:
# store string address in $t0
la $t0, ($a0)
#store key in $t1
move $t1, $a1
# initialize index, $t2 to 0
add $t2, $zero, $zero
li $t4, 26
encrypt_loop:
# load the byte at index in $t3
lb $t3, ($t0)
# check if it's the end of the string
beqz $t3, encrypt_end
# also check if it's a space
beq $t3, 32, incr
# subtract to make a = 0 etc
addi $t3, $t3, -97
# add key
add $t3, $t3, $t1
# modulo to make sure that it isn't over 26
div $t3, $t4
mfhi $t3
# add 97 back to get it back to its position
addi $t3, $t3, 97
# store byte back where you found it
sb $t3, ($t0)
#la $a0, ($t3)
#jal _put_char
incr:
# increment address
la $t0, 1($t0)
#jump back to beginning of the loop
j encrypt_loop
예>
는 메시지를 입력 누구나이 점을 알 수있다. 코드는 마지막 문자를 조작하고 그것을 끝 브래킷으로 변경합니까? 감사.
문자열을 어떻게 지정하고 있습니까? 나를 위해 잘 작동하므로 사용중인 문자열이 null로 끝나지 않았다고 의심됩니다. –