简体   繁体   English

emu8086无法在模拟器屏幕上打印数字

[英]emu8086 can't print numbers on emulator screen

i'm trying to display the result of multiplying two numbers on the emulator screen of emu8086, when i use small 8 bits numbers, the result is printed fine when i run the code, but with 16bits numbers i get 0 on the emulator screen, i'm not sure it something is wrong with my code or the emulator it self, i'm totally new to assembly, and i've been trying to solve it for the past hour, that's my code 我试图在emu8086的仿真器屏幕上显示两个数字相乘的结果,当我使用小的8位数字时,在运行代码时结果可以很好地打印,但是在16位数字的情况下,我在仿真器屏幕上得到0,我不确定我的代码或模拟器本身有什么问题,我是汇编的新手,并且在过去的一个小时里我一直在尝试解决它,这就是我的代码

    include 'emu8086.inc' 
    name "multiply_two_16_bit_numbers"

    org 100h

    mov ax, 512   ; 
    mov bx, 512   ;

    mul bx 

    call print_num

    ret
    DEFINE_PRINT_NUM
    DEFINE_PRINT_NUM_UNS
    end

hope you guys could help me please, thanks. 希望你们能帮助我,谢谢。

Note that 512*512=262144=40000h, which is a 32 bit number with the low 16 bits being zero and that's presumably what you get printed. 请注意,512 * 512 = 262144 = 40000h,这是一个32位数字,低16位为零,这大概就是您要打印的内容。 This form of the mul instruction puts the top 16 bits of the result into register dx , you should find 4 there. 这种形式的mul指令将结果的前16位放入寄存器dx ,您应该在那里找到4。 If you want to print the whole result, you will of course need a 32 bit printing function, and you'll have to pass the arguments properly. 如果要打印整个结果,则当然需要32位打印功能,并且必须正确传递参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM