mips

MIPS学习笔记(1)

那年仲夏 提交于 2020-02-07 20:19:27
文章目录 开头 指令与立即数 数据传输指令 MIPS基本决策机制 乘除法指令 算术溢出 位运算指令 移位指令 开头 CISC(Complex Instruction Set Computing) RISC(Reduced Instruction Set Computing) MIPS是RISC的典型代表 RISC基本策略: 指令字长:所有指令长度都是1个字(32位) 寻址模式:基址+偏移量 访存:load与store 主流ISA: Intel 80x86 —— PC、服务器 ARM(Advanced RISC Machine)—— 手机、平板 PowerPC —— 航空电子设备、网络设备…… 寄存器: 被内置于CPU中 速度极快(<1ns) 数量少 指令与立即数 MIPS内的寄存器: 数量为32个(编号为0~31) 宽度为32位 无正负 表示方法:$x(0<=x<=31) MIPS指令的一般性语法格式: op dst, src1, src2 ​ op:指令的基本功能 ​ dst:保存结果的寄存器 ​ src1:第一个操作数; src2:第二个操作数 加法操作: add dst, src1, src2 减法操作: sub dst, src1, src2 每条指令只有一种操作,每行一个指令 注释语句以“ # ”开始 0号寄存器($0 / $zero) :0的专属寄存器,其值恒为零

qemu mips调试

こ雲淡風輕ζ 提交于 2020-02-07 00:24:28
查看模块支持的列表: qemu-system-mipsel -device help 查看mips支持的板 qemu-system-mipsel -M help mipsel 文档说明: https://blog.csdn.net/D_R_L_T/article/details/79534896 调试说明: https://coderdock.com/2017/04/29/VirtualBoard/虚拟开发板-Qemu调试uboot/ https://blog.csdn.net/hejinjing_tom_com/article/details/47108381 mips调试命令: qemu-system-mipsel -m 256M -nographic -kernel /home/nfs/u-boot-mt7688-P1806A/u-boot -gdb tcp::1234 -S 来源: https://www.cnblogs.com/hzijone/p/11615358.html

mips调试

一笑奈何 提交于 2020-02-07 00:22:39
0x01 环境搭建 由于我们通常的操作系统指令集都是x86的,所以无法跑MIPS程序。这时候就需要装QEMU来模拟,QEMU通过源码编译较为复杂,我们又没有特殊的需求,所以直接使用ubuntu的APT进行安装即可。 sudo apt install qemu 由于MIPS架构有两种——大端MIPS和小端MIPS。所以,我们需要确定这个程序是大端MIPS还是小端MIPS。 qemu-mips xxx #大端 qemu-mipsel xxx #小端 远程调试MIPS程序,所以要加上-g 端口参数,qemu-mipsel -g 1234 baby_mips,此时用IDA pro就可以通过Remote GDB Server来调试这个MIPS程序。 0x02 反编译 为了方便我们了解key比对函数的功能,我们可以需要对MIPS进行反编译,目前可以反编译MIPS程序的工具有两个。 Retdec JEB-mips Retdec有在线反编译网址,retdec.com,也可以通过python api接口使用,比较方便,需要注册获得YOUR-API-KEY,注意retdec-python包需要在python3环境下运行 py 3 -m pip install retdec-python python用法 from retdec.decompiler import

PHP的MIPS交叉编译(CC=mipsel-openwrt-linux-uclibc-gcc,LD=mipsel-openwrt-linux-uclibc-ld)

試著忘記壹切 提交于 2020-02-07 00:21:01
物联网内存吃紧,跑JVM这种内存大户肯定吃不消. 要跑还是跑C实现的服务,比如Nginx+PHP+SQLite. 比如一些家用无线路由器,系统是Linux发行版OpenWrt,内存只有64MB到128MB,单核580MHz. 而PHP内置HTTP服务器和SQLite数据库,在无线路由器里对外提供HTTP服务丝毫没有问题. 交叉编译PHP也很简单: cd /opt/miwifi/src/php-7.1.5 CC=mipsel-openwrt-linux-uclibc-gcc \ AR=mipsel-openwrt-linux-uclibc-ar \ LD=mipsel-openwrt-linux-uclibc-ld \ RANLIB=mipsel-openwrt-linux-uclibc-ranlib \ STRIP=mipsel-openwrt-linux-uclibc-strip \ ./configure \ --host=mipsel-openwrt-linux-uclibc \ --prefix=/opt/miwifi/php/7.1 \ --enable-cli \ --disable-cgi \ --disable-fpm \ --disable-phpdbg \ --disable-all \ --with-sqlite3 \ --with-pdo-sqlite \

Stacks in MIPS. What is the purpose of 4 in addi $sp,$sp,-4?

。_饼干妹妹 提交于 2020-02-03 10:38:53
问题 I am studying a MIPS code that uses procedure but I can not understand what is the purpose of stack (sp) and frame pointer (fp). For example the code I study have this below. It prints the all the numbers before the number you entered, e.g. 3. 3,2,1,0 and shows how much stack size it used. In this example it used 16. I changed the -4 to -8 and I got an error. However, I noticed some other codes that uses -8 . The question is what am I missing? proc: addi $sp,$sp,-4 # sw $ra,0($sp) # push $ra

Port MARS MIPS code to work on eight bit CPU simulator ( sms32v50 )

谁都会走 提交于 2020-01-30 13:08:28
问题 How can i change my code to make it work on sms32v50? .data #storing data startmsg: .asciiz "Pick a number between 1 and 100.\n\n" guessmsg: .asciiz "Enter your guess\n" tooHigh: .asciiz "Your guess is too high.\n\n" tooLow: .asciiz "Your guess is too low.\n\n" wingame: .asciiz "You have guessed the number. Well done!\n\n" .text #start of program start: jal random add $t0, $zero, $a0 # store random number $a0 in $t0 li $v0, 4 # print string la $a0, startmsg syscall ###########################

Printing the x char in a string (MIPS)

我是研究僧i 提交于 2020-01-30 02:37:13
问题 My program is supposed to do the following: -Getting continiously an integer from the user (x), -printing the character at the x position in the string. -The program exits when the user inputs 0. .text .globl __start __start: li $s3,20 #string length start: li $v0,5 syscall move $s0,$a0 #integer now in $a0 beq $s0,$zero,exit li $s1,0 #counter is 0 la $s2,str #address of string now is $s2 loop:lbu $t1,0($s2) #choosing char of string addi $s1,1 #increment counter by 1 addi $s2,1 #next char beq

(MIPS) How to perform floating point operations only using addition and subtraction

懵懂的女人 提交于 2020-01-25 08:16:08
问题 I'm tasked with trying to find the value of a certain mathematical expression without using multiplication or division: f =(0.1×A^4) -(0.2×B^3) + (0.3×C^2) -(0.4×D) . I have to use subroutines to help with the calculations. I'm currently trying to find the first term and I am lost right now. This is what I have so far: .data prompt: .asciiz "Enter 4 integers for A, B, C, D respectively: \n" newLine: .asciiz "\n" f_output: .asciiz "f= " g_output: .asciiz "g= " .text main: li $v0, 4 #displaying

MIPS Assembly while loop

我的梦境 提交于 2020-01-25 00:31:05
问题 I am currently learning MIPS and while doing some exercises I came across one which is to write the Fibonacci sequence first in Java then convert it to MIPS Assembly. I only can use beq , bne and slt My Java code is the following: int n = 50; F_MAX v int t1 = 0; int t2 = 1; int sum = 0; while(t1 <= n) { System.out.print(t1 + " ") sum = t1 + t2 t1 = t2 t2 = sum; } Meaning that if n = 50 if should print all the numbers before 50 (0; 1; 1; 2; 3; 5; 8; 13; 21; 34) My MIPS Assembly code is: la $s0

Loop through an array MIPS Assembly

爷,独闯天下 提交于 2020-01-23 08:32:18
问题 I'm working on a program which loops through an array of 10 numbers. The first 9 elements have values higher than 0, the 10th has a value of 0. The loop should break when the 0 is encountered. i=0; while(A[i]!=0) { A[i]=A[i]+1; i++; } I know I can use 'beq' to break the loop if the value of the register is equal to 0. However I don't know enough about manipulating values in the memory. It's my first time using MIPS and you'll see it's a mess. If you can't fix it for me, can you give me some