Chinaunix首页 | 论坛 | 博客
  • 博客访问: 19928
  • 博文数量: 2
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 31
  • 用 户 组: 普通用户
  • 注册时间: 2015-11-09 20:25
个人简介

RTFSC

分类: 嵌入式

2016-07-22 17:57:55

最近染指了一点MIPS架构的处理器,发现MIPS的ISA超级精简,感慨颇多啊,学院派的架构不禁让人有相见恨晚的感觉。吐槽一下MIPS的中文资料相比ARM真是凤毛麟角,有点疑问在中文博客论坛区真的不好找,希望龙芯能扛起MIPS大旗,真心盼望MIPS能在Imagination手里找到市场突破点。
之前看国外大学课程《微机原理》的视频都是拿MIPS说事,这真的是个不错的选择,因为MIPS架构的精简非常适合入门,想想现在国内课程大多数人第一次接触的指令往往都是8086或者8051,要把所有的指令分成1,2,3,n,......种字节,光是MOV和LEA就让我绕了一星期,更别提那各种各样的寻址方式,好麻烦的说。
说正题,MIPS的宏指令相对ARM多了不少,而且不同的汇编器肯定有自己特殊的宏指令,找了好久关于MIPS宏指令的文章,终于在这本书的附录里发现了一点系统化统计宏指令的东西,分享一下,同时推荐大家这本学习MIPS不错的书籍:
----《MIPS Assembly Language Programming》 Robert Britton 。
将宏指令的表格重新排版如下。
        Macro Instructions
seq. Name Brief Actual Code Space/Time Description
1 abs Rd, Rs Absolute Value addu Rd, $0, Rs
bgez Rs, 1
sub Rd, $0, Rs
3/3
2 beqz Rs, Label Branch if Equal to Zero beq Rs, $0, Label 1/1
3 bge Rs, Rt, Label Branch if Greater than or Equal slt $at, Rs, Rt 2/2
beq $at, $0, Label
2/2 If Reg.File[Rs] > = Reg.File[Rt] branch to Label
Used to compare values represented in the two's complement number system.
4 bgeu Rs, Rt, Label Branch if Greater than or Equal Unsigned sltu $at, Rs, Rt
beq $at, $0, Label
2/2 If Reg.File[Rs] > = Reg.File[Rt] branch to Label
Used to compare addresses (unsigned values).
5 bgt Rs, Rt, Label Branch if Greater Than slt $at, Rt, Rs
bne $at, $0, Label
2/2 If Reg.File[Rs] > Reg.File[Rt] branch to Label
Used to compare values represented in the two's complement number system.
6 bgtu Rs, Rt, Label Branch if Greater Than Unsigned sltu $at, Rt, Rs
bne $at, $0, Label
2/2 If Reg.File[Rs] > Reg.File[Rt] branch to Label
Used to compare addresses (unsigned values).
7 ble Rs, Rt, Label Branch if Less Than or Equal slt $at, Rt, Rs
beq $at, $0, Label
2/2 If Reg.File[Rs] < = Reg.File[Rt] branch to Label
Used to compare values represented in the two's complement number system.
8 bleu Rs, Rt, Label Branch if Less Than or Equal Unsigned sltu $at, Rt, Rs 
beq $at, $0, Label
2/2 If Reg.File[Rs] < = Reg.File[Rt] branch to Label
Used to compare addresses (unsigned values).
9 blt Rs, Rt, Label Branch if Less Than slt $at, Rs, Rt 
bne $at, $0, Label
2/2 If Reg.File[Rs] < Reg.File[Rt] branch to Label
Used to compare values represented in the two's complement number system
10 bltu Rs, Rt, Label Branch if Less Than Unsigned sltu $at, Rs, Rt
bne $at, $0, Label
2/2 If Reg.File[Rs] < Reg.File[Rt] branch to Label
Used to compare addresses (unsigned values).
11 bnez Rs, Label Branch if Not Equal to Zero bne Rs, $0, Label 1/1
12 b Label Branch Unconditional bgez $0, Label 1/1
13 div Rd, Rs, Rt Divide bne Rt, $0, ok
break $0
ok: div Rs, Rt
mflo Rd
4/41
14 divu Rd, Rs, Rt Divide Unsigned bne Rt, $0, ok
break $0
ok: divu Rs, Rt
mflo Rd
4/41
15 la Rd, Label Load Address lui $at, Upper 16-bits of Label 
ori Rd, $at, Lower 16-bits of Label
2/2
Used to initialize pointers
16 li Rd, value Load Immediate lui $at, Upper 16-bits of value
ori Rd, $at, Lower 16-bits of value
2/2 Initialize registers with negative constants and values greater than 32767.
17 li Rd, value Load Immediate ori Rt, $0, value 1/1 Initialize registers with positive constants less than 32768.
18 move Rd, Rs Move addu Rd, $0, Rs 1/1
19 mul Rd, Rs, Rt Multiply mult Rs, Rt
mflo Rd
2/33
20 mulo Rd, Rs, Rt Multiply (with overflow exception) mult Rs, Rt
mfhi $at
mflo Rd
sra Rd, Rd, 31
beq $at, Rd, ok
break $0
ok: mflo Rd
7/37
21 mulou Rd, Rs, Rt Multiply Unsigned (with overflow exception) multu Rs, Rt 
mfhi $at
beq $at, $0, ok
ok: break $0
mflo Rd
5/35
22 neg Rd, Rs Negate sub Rd, $0, Rs 1/1 Two's complement negation. An exception is generated when there
is an attempt to negate the most negative value: 2,147,483,648.
23 negu Rd, Rs Negate Unsigned subu Rd, $0, Rs 1/1
24 nop Nop or $0, $0, $0 1/1
25 not Rd, Rs Not nor Rd, Rs, $0 1/1 A bit-wise Boolean complement.
26 rem Rd, Rs, Rt Remainder bne Rt, $0, 8
break $0
div Rs, Rt
mfhi Rd
4/40
27 remu Rd, Rs, Rt Remainder Unsigned bne Rt, $0, ok
break $0
ok: divu Rs, Rt
mfhi Rd
4/40
28 rol Rd, Rs, Rt Rotate Left Variable subu $at, $0, Rt
srlv $at, Rs, $at
sllv Rd, Rs, Rt
or Rd, Rd, $at
4/4 The lower 5-bits in Rt specifys the shift amount.
29 ror Rd, Rs, Rt Rotate Right Variable subu $at, $0, Rt
sllv $at, Rs, $at
srlv Rd, Rs, Rt
or Rd, Rd, $at
4/4
30 rol Rd, Rs, sa Rotate Left Constant srl $at, Rs, 32-sa
sll Rd, Rs, sa
or Rd, Rd, $at
3/3
31 ror Rd, Rs, sa Rotate Right Constant sll $at, Rs, 32-sa
srl Rd, Rs, sa
or Rd, Rd, $at
3/3
32 seq Rd, Rs, Rt Set if Equal beq Rt, Rs, yes
ori Rd, $0, 0
beq $0, $0, skip
yes: ori Rd, $0, 1
skip:
4/4
33 sge Rd, Rs, Rt Set if Greater Than or Equal bne Rt, Rs, yes
ori Rd, $0, 1
beq $0, $0, skip
yes: slt Rd, Rt, Rs
skip:
4/4
34 sgeu Rd, Rs, Rt Set if Greater Than or Equal Unsigned bne Rt, Rs, yes 
ori Rd, $0, 1
beq $0, $0, skip
yes: sltu Rd, Rt, Rs
skip:
4/4
35 sgt Rd, Rs, Rt Set if Greater Than slt Rd, Rt, Rs 1/1
36 sgtu Rd, Rs, Rt Set if Greater Than Unsigned sltu Rd, Rt, Rs 1/1
37 sle Rd, Rs, Rt Set if Less Than or Equal bne Rt, Rs, yes
ori Rd, $0, 1
beq $0, $0, skip
yes: slt Rd, Rs, Rt
skip:
4/4
38 sleu Rd, Rs, Rt Set if Less Than or Equal Unsigned bne Rt, Rs, yes 
ori Rd, $0, 1
beq $0, $0, skip
yes: sltu Rd, Rs, Rt
skip:
4/4
39 sne Rd, Rs, Rt Set if Not Equal beq Rt, Rs, yes
ori Rd, $0, 1
beq $0, $0, skip
yes: ori Rd, $0, 0
skip:
4/4
40 ulh Rd, 3(Rs) Unaligned Load Halfword Unsigned lb Rd, 4(Rs) 
lbu $at, 3(Rs)
sll Rd, Rd, 8
or Rd, Rd, $at
4/4
41 ulhu Rd, 3(Rs) Unaligned Load Halfword lbu Rd, 4(Rs)
lbu $at, 3(Rs)
sll Rd, Rd, 8
or Rd, Rd, $at
4/4
42 ulw Rd, 3(Rs) Unaligned Load Word lwl Rd, 6(Rs)
lwr Rd, 3(Rs)
2/2
43 ush Rd, 3(Rs) Unaligned Store Halfword sb Rd, 3(Rs)
srl $at, Rd, 8
sb $at, 4(Rs)
3/3
44 usw Rd, 3(Rs) Unaligned Store Word swl Rd, 6(Rs) 
swr Rd, 3(Rs)
2/2

阅读(3017) | 评论(0) | 转发(1) |
0

上一篇: U-Boot from the thousand and one nights .0000

下一篇:没有了

给主人留下些什么吧!~~