[英]Adding two hex values in assembly language (EASy68K)
I want to create a program that adds two hex values together using ADD.B, ADD.W, and ADD.L and see what the differences are.我想创建一个使用 ADD.B、ADD.W 和 ADD.L 将两个十六进制值相加的程序,看看有什么区别。 I'm new to assembly programming, so I can't seem to get it quite right.我是汇编编程的新手,所以我似乎不太正确。 There are no errors, but when I run the program, no result is displayed.没有错误,但是当我运行程序时,没有显示任何结果。 There also doesn't seem to be any value stored in register D3.寄存器 D3 中似乎也没有存储任何值。 Can anyone tell me what I am doing wrong?谁能告诉我我做错了什么? Thanks a lot for any help.非常感谢您的帮助。
START ORG $1000 Program starts at loc $1000
MOVE $374D1FC4,D2 [D0] <- $374D1FC4
MOVE $F22C4663,D3 [D1] <- $F22C4663
ADD.B D2,D3 [D1] <- [D0] + [D1]
* ADD.W D2,D3 [D1] <- [D0] + [D1]
* ADD.L D2,D3 [D1] <- [D0] + [D1]
MOVE D3,R
* The following three instructions will display [R] to Output Window
* Task number 3 of trap #15 is to display D1.L as a signed decimal
MOVE R,D1 [D1] <- R
EXT.L D1 Extend sign bit to presreve the sign
MOVE #3,D0 Assign task number to [D0]
TRAP #15 Ask "OS" to perform the task
STOP #$2700 Stop execution
* Data section
R DS.W 1 int R;
END START
Easy68K gives you a hint about what the problem is when you try to run the program: "Address Error: Instruction at 1006 accessing address f22c4663" . Easy68K 会提示您尝试运行程序时出现的问题: “地址错误:1006 访问地址 f22c4663 处的指令” 。
These lines:这些线路:
MOVE $374D1FC4,D2 [D0] <- $374D1FC4
MOVE $F22C4663,D3 [D1] <- $F22C4663
should be changed to:应改为:
MOVE #$374D1FC4,D2 [D0] <- $374D1FC4
MOVE #$F22C4663,D3 [D1] <- $F22C4663
assuming that you wanted to load the immediate values $374D1FC4
and $F22C4663
.假设您想加载直接值$374D1FC4
和$F22C4663
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.