Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 打印BCD值(MASM)_Assembly_Masm_X86 16 - Fatal编程技术网

Assembly 打印BCD值(MASM)

Assembly 打印BCD值(MASM),assembly,masm,x86-16,Assembly,Masm,X86 16,我用中断1ah编写了一个代码,我做到了: mov al, ch and al, 0fh mov dl, al 现在,例如时间是“18:36”,它将打印小时,并且只打印8。因为我想让程序做这个。但是,我能做些什么来显示“1” 附言:我测试了掩蔽下半字节,但这不是我的答案。这是您需要在CH寄存器中打印小时数的代码 mov bl, cl ;Save-guard the minutes! mov dl, ch mov cl, 4 ;On 8086 you need to use CL shr

我用中断1ah编写了一个代码,我做到了:

mov al, ch
and al, 0fh
mov dl, al
现在,例如时间是“18:36”,它将打印小时,并且只打印8。因为我想让程序做这个。但是,我能做些什么来显示“1”


附言:我测试了掩蔽下半字节,但这不是我的答案。

这是您需要在
CH
寄存器中打印小时数的代码

mov bl, cl   ;Save-guard the minutes!
mov dl, ch
mov cl, 4    ;On 8086 you need to use CL
shr dl, cl   ;High nibble
add dl, 30h  ;Make character
mov ah, 02h  ;DOS PrintChar
int 21h
mov dl, ch
and dl, 0fh  ;Low nibble
add dl, 30h  ;Make character
mov ah, 02h  ;DOS PrintChar
int 21h

因为在8086上没有立即移位计数,所以必须使用
CL
寄存器。因此,有必要将
CL
寄存器中的分钟数移动到另一个寄存器,如
BL

您可以发布完整的代码吗?如果您确实在使用BCD值,您应该查看说明
AAA
AAD
AAM
AAS
。它们会“在…之后进行ASCII调整”。根据建议,您必须单独打印每个半字节。将上半部分移到下半部分,遮罩,添加“0”,打印字符。然后遮罩下半字节,添加“0”,打印。当然,您必须使用副本,因为第一个操作会损坏第二个数字。要进行冗余清除,如果
al
在BCD中包含
18
,则
1
位于高位,而
8
位于低位。您的
和al、0fh
等获得低半字节(8),但忽略了高半字节。您可以通过
shral,4
获得该值。0将通过
shr
移位到高位。您应该先打印该值,因为它是第一个数字。