网站大量收购独家精品文档,联系QQ:2885784924

MIPS汇编语言备课讲稿.ppt

  1. 1、本文档共31页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
MIPS Assembly Language CPSC 321 Computer Architecture Andreas Klappenecker MIPS Assembly Instructions add $t0, $t1, $t2 # $t0=$t1+$t2 sub $t0, $t1, $t2 # $t0=$t1-$t2 lw $t1, a_addr # $t1=Mem[a_addr] sw $s1, a_addr # Mem[a_addr]=$t1 Assembler directives .text assembly instructions follow .data data follows .globl globally visible label = symbolic address Addressing modes lw $s1, addr # load $s1 from addr lw $s1, 8($s0) # $s1 = Mem[$s0+8] register $s0 contains the base address access the address ($s0) possibly add an offset 8($s0) Load and move instructions la $a0, addr # load address addr into $a0 li $a0, 12 # load immediate $a0 = 12 lb $a0, c($s1) # load byte $a0 = Mem[$s1+c] lh $a0, c($s1) # load half word lw $a0, c($s1) # load word move $s0, $s1 # $s0 = $s1 Control Structures Assembly language has very few control structures: Branch instructions if cond then goto label Jump instructions goto label We can build while loops, for loops, repeat-until loops, if-then-else structures from these primitives Branch instructions beqz $s0, label if $s0==0 goto label bnez $s0, label if $s0!=0 goto label bge $s0, $s1, label if $s0=$s1 goto label ble $s0, $s1, label if $s0=$s1 goto label blt $s0, $s1, label if $s0$s1 goto label beq $s0, $s1, label if $s0==$s1 goto label bgez $s0, $s1, label if $s0=0 goto label if-then-else structures if ($t0==$t1) then /* blockA */ else /* blockB */ beq $t0, $t1, blockA j blockB blockA: … instructions of then block … j exit blockB: … instructions of else block … exit: … subsequent instructions … repeat-until loop repeat … until $t0$t1 loop: … instructions of loop … ble $t0, $t1, loop # if $t0=$t1 goto loop Other loop structures are similar… Exercise: Derive templates for various loop structures System calls load argument registers load call code syscall li $a0, 10 # load argument $a0=10 li $v0, 1 # call code to print integer syscall #

您可能关注的文档

文档评论(0)

yuzongxu123 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档