UTF-404

MIPS(4) 본문

컴퓨터 구조

MIPS(4)

UTF-404 2024. 3. 2. 22:25
728x90

💡 MIPS 프로그래밍 조건 사항

  • At first, understand what the following C code is about.
  • Then, write and submit MIPS program performing to meet the following C code’s Input & output.
  • The MIPS program doesn’t need to be exactly same as the C code, but Input/Output are same.

c code 화면

 

.data
prompt: .asciiz "Enter an int: "
result_msg: .asciiz "The result is: "

.text
.globl main
main:
    
    li $v0, 4
    la $a0, prompt
    syscall

    li $v0, 5
    syscall
    move $t0, $v0

    
    li $t1, 0

loop:
    
    beq $t0, $zero, done

    
    andi $t2, $t0, 1
    beqz $t2, bit_clear

    
    addi $t1, $t1, 1

bit_clear:
    
    srl $t0, $t0, 1
    j loop

done:
    
    li $v0, 4
    la $a0, result_msg
    syscall

    
    li $v0, 1
    move $a0, $t1
    syscall

  
    li $v0, 10
    syscall
728x90

'컴퓨터 구조' 카테고리의 다른 글

MIPS(3)  (0) 2024.03.02
MIPS(2)  (0) 2024.03.02
MIPS (1)  (0) 2024.03.02