我对这个问题感到有点惭愧,但是如何在汇编程序中输出一个字节的值? 假设我在AL寄存器中有数字62。我的目标是8086.似乎只有中断可以输出它的ascii值。
编辑:谢谢Nick D,这就是我想要的。为了回答几个问题,我实际上使用的是模拟器,emu8086。该代码将用于使用过时设备的工厂中的小应用程序(即它是一个秘密)。
使用Nick D的想法,解决方案看起来有点像这样:
compare number, 99 jump if greater to over99Label compare number, 9 jump if greater to between9and99Label ;if jumps failed, number has one digit printdigit(number) between9and99Label: divide the number by 10 printascii(quotient) printascii(modulus) jump to the end over99Label: divide the number by 100 printascii(quotient) store the modulus in the place that between9and99Label sees as input jump to between9and99Label the end: return
它适用于无符号字节:)
答案 0 :(得分:2)
// pseudocode for values < 100
printAscii (AL div 10) + 48
printAscii (AL mod 10) + 48
将值转换为字符串表示并打印它。
答案 1 :(得分:1)
我目前无法访问汇编程序进行检查,并且语法会因您使用的汇编程序而有所不同,但这仍然可以传达这个想法。
FOUR_BITS: .db '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' ; If ebx need to be preserved do so push ebx ; Get the top four bits of al mov bl, al shl bl, 4 ; Convert that into the ASCII hex representation mov bl, [FOUR_BITS + bl] ; Use that value as a parameter to your printing routine push bl call printAscii pop bl ; Get the bottom four bits of al mov bl, al and bl, 0xF ; Convert that into the ASCII hex representation mov bl, [FOUR_BITS + bl] ; Use that value as a parameter to your printing routine push bl call printAscii pop bl