보람찬 코기의 개발자 블로그
article thumbnail
반응형

대학교 2학년 2학기 '컴퓨터공학' 강의를 수강했고, 끝맺음도 잘하였다.

복습 겸 기초 언어인 어셈블리어를 복습하고자 작성하였다.

 

과제 1

당신의 아래를 따라 밉스 프로그램을 작성해야 한다

  1.  당신의 프로그랩은 "Please, type a number"라는 문장으로 정수를 입력하라는 요청을 한다
  2. 입력된 정수에 10을 곱한다.
  3. 결과를 출력하라 (입력 값 * 10)에 "The result is xxx"의 형식으로

1.  Result

<bash />
.data studentid: .asciiz "What is your Student ID: " # Problem Requirements-start idblank: .space 20 prompt: .asciiz "Please, type a number: " result: .asciiz "The results is " #Problem Requirements-result enter: .asciiz "\n" .text main: li $v0,4 la $a0,studentid syscall li $a1, 20 la $a0, idblank li $v0,8 syscall li $v0,4 la $a0,prompt syscall li $v0,5 syscall move $t0,$v0 mul $t1,$t0,10 li $v0,4 la $a0,result syscall li $v0,1 move $a0,$t1 syscall li $v0, 4 la $a0, enter syscall li $v0,10 syscall

#HW1 , Run on Qtspim

 

line 1의  .data는 static data를 쓰는 공간으로 변수 선언 필드이다.

line 7의  .text는 수행하고자 하는 코드를 쓰는 필드이다.

 

li $v0, "변수"의 경우 System call로 수행을 돕는 문법이다.

"변수" Number 수행 내용 "변수" Number 수행 내용
1 int 형 출력 6 float형 입력
2 float형 출력 7 double형 입력
3 double형 출력 8 string형 입력
4 string형 출력 9 sbrk(메모리 할당시)
5 int형 입력 10 exit(종료)

 

 

 

https://pururing-log.tistory.com/44

mips의 문법은 이 블로그에서 잘 설명해두었기에 링크 참조.

 

[MIPS] QtSpim 기본 문법

주석 opcode .data vs .text Register System Call 1. 주석 코드의 앞에 #을 쓰면 주석 처리를 할 수 있습니다. 2. opcode opcode는 operations code의 약자로 어떤 연산을 수행할 것인가를 알려줍니다. ① Artithmetic Instru

pururing-log.tistory.com

 

반응형
profile

보람찬 코기의 개발자 블로그

@BoChan

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!