arm实验例题分享.docxVIP

  • 23
  • 0
  • 约2.14千字
  • 约 12页
  • 2022-04-20 发布于广西
  • 举报
arm 实验例题 D B . END 例 4.3 利用跳转表实现分支转移。寄存器 R1、R2 中有两个数,若 R0 为 0 则求 R1 与 R2 的和, 若 R0 为 1 则求 R1 与 R2 的差。结果存储在 R0 中C 语言代码 int DoAdd (int a,int b) { return a+b; } int DoSub (int a,int b) { return a-b; } void main() { int R0=0; int R1=3; int R2=2; int(* arithfunc) (); swith(R0) { case0: arithfunc = DoAdd; R0=arithfunc (R1,R2); break; case1: arithfunc = DoSub; R0=arithfunc (R1,R2); break; default: break; } while (1); } 汇编.S 文件 AREA example3, CODE,READONLY; num EQU 2 ENTRY Start  MOV R0,#0 MOV R1,#3 MOV R2,#2 BL function B . function CMP R0,#num MOVHS PC,LR ADR R3,JumpTable LDR PC,[R3,R0,LSL #2] ; ;

文档评论(0)

1亿VIP精品文档

相关文档