문제
요약 이 프로젝트의 목표는 부동 소수점의 소프트웨어 에뮬레이션을 구현하는 것입니다 밉의 32 비트(단 정밀도)부동 소수점 숫자에 대한 추가.
입력/출력 프로그램은 사용자에게 두 개의 부동 소수점 숫자를 묻는 메시지를 표시합니다.그러면 합계를 계산하고 표시합니다.여기에 네 개의 실행(당신은 단지 필요)에서 입력/출력 예입니다 실행 실행 당 한 번 프롬프트):
부동 소수점 값 입력:1 부동 소수점 값 입력:1 2.000000000000000000
부동 소수점 값 입력:2.2 부동 소수점 값 입력:1.4 3.599999904632568400
해결해야 할 문제 여기에 몇 가지 문제가 있습니다: 음수 값을 어떻게 처리합니까 정규화 알고리즘은 어떻게 작동합니까 단어 내에서 비트 필드에 액세스하는 가장 쉬운 방법은 무엇입니까?
*이 프로젝트에 대한 부동 소수점 지침을 사용할 수 없습니다!!*
나는 정수에서 동일한 작업을 수행하지만,그들을 사용하지 않고 부동 소수점에 도움이 필요했다!.데이터 세인트 1:."\\\\\\\\\\\ 성 2:.첫 번째 정수:" 세인트 3:.두 번째 정수:" 성 4:.아시즈의 대답은:" 세인트 5:.아시즈--------------------------------\" 성 6:.아스키즈
.text
main:
사용자가 첫 번째 정수를 입력하도록 프롬프트
la $a0,st2 # Put the address of the string in $a0
li $v0, 4
syscall
li $v0, 5 # Code for input integer
syscall
move $s1, $v0 #storing first integer in s1
사용자가 첫 번째 정수를 입력하도록 프롬프트
la $a0,st3 # Put the address of the string in $a0
li $v0, 4
syscall
li $v0, 5 # Code for input integer
syscall
move $s2, $v0 #storing second integer in s2
정수 추가
add $s0,$s2,$s1 #add and store in t3
결과 표시
la $a0,st4 #text to display
li $v0,4
syscall
li $v0,1 #for printing int
move $a0,$s0 # move s0 to a0 to print s0
syscall
la $a0,st1
li $v0,4
syscall
임시 레지스터 이동
move $t3,$s0
move $t2,$s2
move $t1,$s1
바이너리로 인쇄 할 첫 번째 번호 카운터
li $s5,32 # set up counter
loop1:
rol $t1,$t1,1 #roll the bit left by on bit high to low
and $t0,$t1,1 #mask off low bit
add $t0,$t0,48 #combine t0 with 48 to form 1 or 0
move $a0,$t0 #output ascii character
li $v0,11
syscall
li $t5,1
sub $s5,$s5,$t5 #decrement counter
bne $s5,$zero,loop1 #keep loop if not zero
라인 인쇄
la $a0,st6
li $v0,4
syscall
이진수의 두 번째 숫자에 대한 카운터
li $s5,32
loop2:
rol $t2,$t2,1 #roll the bit left by on bit high to low
and $t0,$t2,1 #mask off low bit
add $t0,$t0,48 #combine t0 with 48 to form 1 or 0
move $a0,$t0 #output ascii character
li $v0,11
syscall
li $t5,1
sub $s5,$s5,$t5 #decrement counter
bne $s5,$zero,loop2 #keep loop if not zero
점선 인쇄
la $a0,st5 #line
li $v0,4
syscall
이진 결과 카운터
li $s5,32
loop:
rol $t3,$t3,1 #roll the bit left by on bit high to low
and $t0,$t3,1 #mask off low bit
add $t0,$t0,48 #combine t0 with 48 to form 1 or 0
move $a0,$t0 #output ascii character
li $v0,11
syscall
li $t5,1
sub $s5,$s5,$t5 #decrement counter
bne $s5,$zero,loop #keep loop if not zero
프로그램 닫기
li $v0,10 #close the program
syscall
.끝 메인
해결책
1-부동 소수점 숫자를 나타 내기 위해 754 를 사용하십시오. 2-지수를 추가,다음 지수를 증가 할 필요가 있는지 확인,유효 숫자를 추가 3-음수 부호 처리(2 의 보완,첫 번째 비트는 부호를 나타냅니다)
이것은 아주 쉬운 문제이며 위의 의견에 동의,난 그냥 당신이 좋은 힌트를 사용할 수 있다고 생각 행운을 빕니다!
다른 팁
.data
st1: .asciiz "\nIn binary:\n"
st2: .asciiz "\nEnter 1st Integer:"
st3: .asciiz "\nEnter 2nd Integer:"
st4: .asciiz "\nYour answer is: "
st5: .asciiz "\n--------------------------------\n"
st6: .asciiz "\n"
.text
main:
사용자가 첫 번째 정수를 입력하도록 프롬프트
la $a0,st2 # Put the address of the string in $a0
li $v0, 4
syscall
li $v0, 5 # Code for input integer
syscall
move $s1, $v0 #storing first integer in s1
사용자가 첫 번째 정수를 입력하도록 프롬프트
la $a0,st3 # Put the address of the string in $a0
li $v0, 4
syscall
li $v0, 5 # Code for input integer
syscall
move $s2, $v0 #storing second integer in s2
정수 추가
add $s0,$s2,$s1 #add and store in t3
결과 표시
la $a0,st4 #text to display
li $v0,4
syscall
li $v0,1 #for printing int
move $a0,$s0 # move s0 to a0 to print s0
syscall
la $a0,st1
li $v0,4
syscall
임시 레지스터 이동
move $t3,$s0
move $t2,$s2
move $t1,$s1
바이너리로 인쇄 할 첫 번째 번호 카운터
li $s5,32 # set up counter
loop1:
rol $t1,$t1,1 #roll the bit left by on bit high to low
and $t0,$t1,1 #mask off low bit
add $t0,$t0,48 #combine t0 with 48 to form 1 or 0
move $a0,$t0 #output ascii character
li $v0,11
syscall
li $t5,1
sub $s5,$s5,$t5 #decrement counter
bne $s5,$zero,loop1 #keep loop if not zero
라인 인쇄
la $a0,st6
li $v0,4
syscall
이진수의 두 번째 숫자에 대한 카운터
li $s5,32
loop2:
rol $t2,$t2,1 #roll the bit left by on bit high to low
and $t0,$t2,1 #mask off low bit
add $t0,$t0,48 #combine t0 with 48 to form 1 or 0
move $a0,$t0 #output ascii character
li $v0,11
syscall
li $t5,1
sub $s5,$s5,$t5 #decrement counter
bne $s5,$zero,loop2 #keep loop if not zero
점선 인쇄
la $a0,st5 #line
li $v0,4
syscall
이진 결과 카운터
li $s5,32
loop:
rol $t3,$t3,1 #roll the bit left by on bit high to low
and $t0,$t3,1 #mask off low bit
add $t0,$t0,48 #combine t0 with 48 to form 1 or 0
move $a0,$t0 #output ascii character
li $v0,11
syscall
li $t5,1
sub $s5,$s5,$t5 #decrement counter
bne $s5,$zero,loop #keep loop if not zero
프로그램 닫기
li $v0,10 #close the program
syscall
.끝 메인