assembly - 如何在 SMS32v50 汇编中将 BYTE 寄存器的值拆分为两个半字节?
问题描述
我从键盘得到一个 ASCII 值,例如在l
键盘上按下,所以 AL 中的值将是 4Ch。我想将此值拆分为两个单独的值。
所以,在这个例子中:4 和 C。
我使用的是 sms32v50 汇编代码。
解决方案
瞧:
JMP Start ; Skip past the data table
DB "0123456789ABCDEF" ; Hexadecimal characters
Start:
CLO ; Close unwanted windows.
Rep:
IN 00 ; Wait for key press - Store it in AL.
CMP AL,0D ; Was it the Enter key? (ASCII 0D)
JZ E ; Yes - end.
PUSH AL ; Save AL (restore it with POP)
SHR AL ; Isolate high nibble (four shifts)
SHR AL
SHR AL
SHR AL
ADD AL, 2 ; 02 is start address of data table
MOV AL, [AL] ; Copy data from table to AL
MOV [C0], AL ; Write character to VDU
POP AL ; Restore AL
AND AL, 0F ; Isolate low nibble
ADD AL, 2 ; 02 is start address of data table
MOV AL, [AL] ; Copy data from table to AL
MOV [C1], AL ; Write character to VDU
JMP Rep ; Repeat the procedure
E:
END
推荐阅读
- sql - sql 命令查找过去 6 个月内用户访问网站的平均次数
- php - 当我尝试在 linux 服务器中使用 php 写入文本文件时,追加模式正在工作,但写入模式不起作用
- mysql - MYSQL 更改枚举值
- javascript - 即使在 canplay 事件处理程序中,HTML 音频也无法设置 currentTime
- svn - svn diff:不支持混合目标类型
- android - 2D平面ARCore android上的对象
- c# - 更改年份减少日期
- python - 获取媒体:来自 rss 提要的缩略图 url
- swift - Swift:tableview 单元格更改宽度和位置
- r - 图片未显示在闪亮仪表板的信息框中