【发布时间】:2023-04-08 12:08:01
【问题描述】:
我们被分配了计算机系统基础课程的作业。该程序的目标是以三种不同的方式显示无符号整数值:二进制、十进制和十六进制。我已经完成了二进制部分,十进制方法只需要除以 10 并打印结果。然而,对于十六进制,教授希望我们使用循环左移来实现它(以便执行左旋转)。
IE。
0010 1111 0000 1001
+ 0010 1111 0000 1001
--------------------
0101 1110 0001 0010
我们必须这样做 4x,然后应用掩码清除 [15:4] 中的所有位,以便打印出位 [3:0] 的 ascii 值。
这是我解决这个程序的算法。
;Loop 4 times -->initialization of for loop
;Begin For Loop
;Perform the left shift
;If the value after the left shift is performed has a carry of 1
;then add 1 to this value (the rotation)
;Otherwise if the value after the left shift is performed has a carry of 0
;Continue the value is already rotated
;Get the value of the number after the loop has completed
;Create a new loop that will go through the Digits
;Load R0 with the value of the digit that we land on
;Print that value to the screen
我遇到的问题是我不知道如何找到被移位数字的进位位。
例如:0000 0000 0001 1011 ----> bit[4] is the carry bit after the left shift
我不知道如何跟踪它以执行循环移位。 我试过了
的面具1000 0000 0000 0000
但我不这么认为 跟踪位 [15] 上未出现的任何进位位。
非常感谢您的帮助,这本书没有提供示例,而且我在网上找不到任何资源,我知道回答家庭作业问题通常是不受欢迎的,但我无能为力!现在是周末,所以我无法联系教授,而且作业很快就要到期了(不是最后一分钟,我从星期五开始就一直坚持这个 -_- )。
谢谢!
编辑:更多信息
数字是这样的:DIGITS .STRINGZ "0123456789ABCDEF" ;Digit_String
它将在 4 次旋转后取 [3:0] 的值,并确定要打印出哪个 ascii 字符。
【问题讨论】: