Qtspim을 설치하여 일부 MIPS 명령을 시험해 보았습니다. 필자는 ".asm"확장자로 저장된 몇 개의 텍스트 파일을 몇 가지 명령으로 작성했습니다. 여기에 하나는 다음과 같습니다Qtspim (MIPS 에뮬레이터) 추가 코드가 표시됩니까?
.text
.globl main
main:
addi $t0, $zero, 3
addi $t1, $zero, 5
add $t2, $t0, $t1
li $v0, 10
syscall
을 그러나, 나는 Qtspim에서 "재 초기화 및 파일로드"명령을하려고 할 때, 프로그램의 "텍스트"섹션에 표시 텍스트 내 텍스트 파일에 해당하지 않습니다. 내 코드가 중간에 있지만 내 파일에없는 EXTRA 코드가 잔뜩 있습니다. 왜 이런거야? 나는 그것을 어떻게 든 로딩하고 있습니까? 이 다른 코드는 모두 무엇입니까?
User Text Segment [00400000]..[00440000]
[00400000] 8fa40000 lw $4, 0($29) ; 183: lw $a0 0($sp) # argc
[00400004] 27a50004 addiu $5, $29, 4 ; 184: addiu $a1 $sp 4 # argv
[00400008] 24a60004 addiu $6, $5, 4 ; 185: addiu $a2 $a1 4 # envp
[0040000c] 00041080 sll $2, $4, 2 ; 186: sll $v0 $a0 2
[00400010] 00c23021 addu $6, $6, $2 ; 187: addu $a2 $a2 $v0
[00400014] 0c100009 jal 0x00400024 [main] ; 188: jal main
[00400018] 00000000 nop ; 189: nop
[0040001c] 3402000a ori $2, $0, 10 ; 191: li $v0 10
[00400020] 0000000c syscall ; 192: syscall # syscall 10 (exit)
[00400024] 20080003 addi $8, $0, 3 ; 2: addi $t0, $zero, 3
[00400028] 20090005 addi $9, $0, 5 ; 3: addi $t1, $zero, 5
[0040002c] 01095020 add $10, $8, $9 ; 4: add $t2, $t0, $t1
[00400030] 3402000a ori $2, $0, 10 ; 5: li $v0, 10
[00400034] 0000000c syscall ; 6: syscall
Kernel Text Segment [80000000]..[80010000]
[80000180] 0001d821 addu $27, $0, $1 ; 90: move $k1 $at # Save $at
[80000184] 3c019000 lui $1, -28672 ; 92: sw $v0 s1 # Not re-entrant and we can't trust $sp
[80000188] ac220200 sw $2, 512($1)
[8000018c] 3c019000 lui $1, -28672 ; 93: sw $a0 s2 # But we need to use these registers
[80000190] ac240204 sw $4, 516($1)
[80000194] 401a6800 mfc0 $26, $13 ; 95: mfc0 $k0 $13 # Cause register
[80000198] 001a2082 srl $4, $26, 2 ; 96: srl $a0 $k0 2 # Extract ExcCode Field
[8000019c] 3084001f andi $4, $4, 31 ; 97: andi $a0 $a0 0x1f
[800001a0] 34020004 ori $2, $0, 4 ; 101: li $v0 4 # syscall 4 (print_str)
[800001a4] 3c049000 lui $4, -28672 [__m1_] ; 102: la $a0 __m1_
[800001a8] 0000000c syscall ; 103: syscall
[800001ac] 34020001 ori $2, $0, 1 ; 105: li $v0 1 # syscall 1 (print_int)
[800001b0] 001a2082 srl $4, $26, 2 ; 106: srl $a0 $k0 2 # Extract ExcCode Field
[800001b4] 3084001f andi $4, $4, 31 ; 107: andi $a0 $a0 0x1f
[800001b8] 0000000c syscall ; 108: syscall
[800001bc] 34020004 ori $2, $0, 4 ; 110: li $v0 4 # syscall 4 (print_str)
[800001c0] 3344003c andi $4, $26, 60 ; 111: andi $a0 $k0 0x3c
[800001c4] 3c019000 lui $1, -28672 ; 112: lw $a0 __excp($a0)
[800001c8] 00240821 addu $1, $1, $4
[800001cc] 8c240180 lw $4, 384($1)
[800001d0] 00000000 nop ; 113: nop
[800001d4] 0000000c syscall ; 114: syscall
[800001d8] 34010018 ori $1, $0, 24 ; 116: bne $k0 0x18 ok_pC# Bad PC exception requires special checks
[800001dc] 143a0008 bne $1, $26, 32 [ok_pc-0x800001dc]
[800001e0] 00000000 nop ; 117: nop
[800001e4] 40047000 mfc0 $4, $14 ; 119: mfc0 $a0 $14 # EPC
[800001e8] 30840003 andi $4, $4, 3 ; 120: andi $a0 $a0 0x3 # Is EPC word-aligned?
[800001ec] 10040004 beq $0, $4, 16 [ok_pc-0x800001ec]
[800001f0] 00000000 nop ; 122: nop
[800001f4] 3402000a ori $2, $0, 10 ; 124: li $v0 10 # Exit on really bad PC
[800001f8] 0000000c syscall ; 125: syscall
[800001fc] 34020004 ori $2, $0, 4 ; 128: li $v0 4 # syscall 4 (print_str)
[80000200] 3c019000 lui $1, -28672 [__m2_] ; 129: la $a0 __m2_
[80000204] 3424000d ori $4, $1, 13 [__m2_]
[80000208] 0000000c syscall ; 130: syscall
[8000020c] 001a2082 srl $4, $26, 2 ; 132: srl $a0 $k0 2 # Extract ExcCode Field
[80000210] 3084001f andi $4, $4, 31 ; 133: andi $a0 $a0 0x1f
[80000214] 14040002 bne $0, $4, 8 [ret-0x80000214]; 134: bne $a0 0 ret # 0 means exception was an interrupt
[80000218] 00000000 nop ; 135: nop
[8000021c] 401a7000 mfc0 $26, $14 ; 145: mfc0 $k0 $14 # Bump EPC register
[80000220] 275a0004 addiu $26, $26, 4 ; 146: addiu $k0 $k0 4 # Skip faulting instruction
[80000224] 409a7000 mtc0 $26, $14 ; 148: mtc0 $k0 $14
[80000228] 3c019000 lui $1, -28672 ; 153: lw $v0 s1 # Restore other registers
[8000022c] 8c220200 lw $2, 512($1)
[80000230] 3c019000 lui $1, -28672 ; 154: lw $a0 s2
[80000234] 8c240204 lw $4, 516($1)
[80000238] 001b0821 addu $1, $0, $27 ; 157: move $at $k1 # Restore $at
[8000023c] 40806800 mtc0 $0, $13 ; 160: mtc0 $0 $13 # Clear Cause register
[80000240] 401a6000 mfc0 $26, $12 ; 162: mfc0 $k0 $12 # Set Status register
[80000244] 375a0001 ori $26, $26, 1 ; 163: ori $k0 0x1 # Interrupts enabled
[80000248] 409a6000 mtc0 $26, $12 ; 164: mtc0 $k0 $12
[8000024c] 42000018 eret ; 167: eret