mips

Why is QtSPIM telling me “Label is defined for the second time”?

泄露秘密 提交于 2021-02-19 01:06:12
问题 I am brand new to learning MIPS assembly code, and we got our first coding assignment. I am getting an error when I run my program (which is supposed to be a tester for another function we have to write) saying "spim: (parser) Label is defined for the second time on line 13 of file /home/jlr247/215_A2_work/jlr247-a2-A.s main: ^" The code I have is: .data .align 4 _arrA: .space 400 _arrB: .space 400 .text main: la $t0, _arrA #load base address of array A la $t1, _arrB #load base address of

Why is QtSPIM telling me “Label is defined for the second time”?

Deadly 提交于 2021-02-19 01:05:33
问题 I am brand new to learning MIPS assembly code, and we got our first coding assignment. I am getting an error when I run my program (which is supposed to be a tester for another function we have to write) saying "spim: (parser) Label is defined for the second time on line 13 of file /home/jlr247/215_A2_work/jlr247-a2-A.s main: ^" The code I have is: .data .align 4 _arrA: .space 400 _arrB: .space 400 .text main: la $t0, _arrA #load base address of array A la $t1, _arrB #load base address of

C array indexing in MIPS assembly?

為{幸葍}努か 提交于 2021-02-17 07:19:06
问题 Question: void swap (int v[], int k) { int temp; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; } My question is why does int v[] get added $t1 ? (whoever did this didn't even comment it so I'm assuming $a0 is v[] and $a1 is k ). Answer in mips: swap: sll $t1, $a1, 2 add $t1, $a0, $t1 lw $t0, 0($t1) lw $t2, 4($t1) sw $t2, 0($t1) sw $t0, 4($t1) jr $ra I know this is used to swap variables but what is it doing here, why is it adding v[] with k ? Isn't v[] a array of declared variables, how can you

Determine the length of a string in MIPS32

孤街浪徒 提交于 2021-02-17 05:43:05
问题 I'm trying to determine the length of an input string using buffer and memory allocation. So lets say I allocate some memory and read a string and store it into the buffer. Then how can I figure out how long the string is? 回答1: Count from the beginning until you find a null character (0). Something like: la $t0 string loop: lb $t1 0($t0) beq $t1 $zero end addi $t0 $t0 1 j loop end: la $t1 string sub $t3 $t0 $t1 #$t3 now contains the length of the string 来源: https://stackoverflow.com/questions

MIPS - Array in array index

好久不见. 提交于 2021-02-17 05:17:25
问题 What is the following C code in MIPS? f = A[B[i]] I'm told it can be done in 6 lines but can't quite figure out how. f is in $t0 , i is in $t3 , A[] is in $s0 , and B[] is in $s1 . All types are integer. The best I am able to think of is lw $t5, $t3($s0); # Doesn't work because lw syntax doesn't accept a register as an offset lw $t6, $t5($s1); sadd $t0, $t6, $zero Obviously this is wrong. How would i go about getting the correct offset for each line? Thanks. 回答1: There might be more efficient

中国自主处理器暗流涌动:我们有龙芯、飞腾...

丶灬走出姿态 提交于 2021-02-12 11:03:37
近年来,在核高基项目补贴和国家级集成电路产业投资基金的扶持下,国内从事高性能CPU设计的单位或公司数量也不断壮大,这当中有像龙芯、飞腾、申 威这样 拥有深厚技术底蕴的老牌IC设计单位,也有像宏芯、兆芯这样新秀;既有展讯这样的国有控股公司,也有海思这样的非国有制企业。 有人评价这是“百家争鸣、百花齐放”,也有人评价这是“重复建设、互相倾轧”。事实上,在眼花缭乱的设计单位和公司中,根据自主可控程度高低和市场化运营的难易,可以分为三种难度模式: 一种走独立自主路线,构建自己技术体系的Hard模式,其代表是龙芯、申威; 另一种是自己设计微结构,保障芯片安全可控,但依附于Wintel或AA体系,兼容其软件生态的Normal模式,其代表是飞腾、君正、众志; 最后一种是和大陆外厂商合作、合资,或者在软件和硬件方面完全依附于AA体系的Simple模式,前者的代表是兆芯、宏芯,后者的代表是海思、展讯。下面,我们就从三种难度模式的发展路线盘点国产CPU的技术路线和市场前景。 一、Hard模式发展路线 独立自主发展路线顾名思义在知识产权、发展路线选择权方面是完全由自己说了算,走自主路线有以下几个特点: 1、拥有自主发展权。 拥有自己的指令集,可以自主扩展指令集,在发展方向上可以自主选择。 例如龙芯就在获得Mips永 久授权的同时,自行扩展了148条loongEXT、5条loongVM指令

What is the purpose of the assembler and symbol table? What is at a symbol's address?

不羁的心 提交于 2021-02-11 18:07:14
问题 From my textbook: To produce the binary version of each instruction in the assembly language program, the assembler must determine the addresses corresponding to all labels. Assemblers keep track of labels used in branches and data transfer instructions in a symbol table. As you might expect, the table contains pairs of symbols and addresses. Why does it need a symbol table? If we have a symbol table with a label name and an address, what is the use of the address? What is at the address...

Data hazards and nops insertion

放肆的年华 提交于 2021-02-11 14:52:34
问题 Consider the following code sequence that is executed on a processor that doesnt supports stalls and only supports ALU-ALU forwarding : I1: lw $1, 40($6) I2: add $6, $2, $2 I3: sw $6, 50($1) I4: lw $5, -16($5) I5: sw $5, -16($5) I6: add $5, $5, $5 Now the only way to run this code on this processor is to insert nops . The solution is : I1: lw $1, 40($6) I2: add $6, $2, $2 I22: nop I3: sw $6, 50($1) I4: lw $5, -16($5) I44: nop I45: nop I5: sw $5, -16($5) I6: add $5, $5, $5 My question is why

Assembly MIPS %call16(printf)

巧了我就是萌 提交于 2021-02-10 14:57:56
问题 I have this code in Assembly. .data tabela: .word 4, 2, 10, 1, 6 print: .asciiz "The value is: %d\n" .text .globl programa programa: ######################## Do some stuff here. Value on $10 is -99 ######################## la $4,print move $5,$10 lw $25,%call16(printf)($28) jalr $25 This code will print: The value is: -99 I understand that: la $4,print Loads the address of the string to print on the first parameter of function call ($a0) move $5,$10 moves the value on register 10 (in this

Assembly MIPS %call16(printf)

て烟熏妆下的殇ゞ 提交于 2021-02-10 14:55:14
问题 I have this code in Assembly. .data tabela: .word 4, 2, 10, 1, 6 print: .asciiz "The value is: %d\n" .text .globl programa programa: ######################## Do some stuff here. Value on $10 is -99 ######################## la $4,print move $5,$10 lw $25,%call16(printf)($28) jalr $25 This code will print: The value is: -99 I understand that: la $4,print Loads the address of the string to print on the first parameter of function call ($a0) move $5,$10 moves the value on register 10 (in this