【问题标题】:linux nasm move a value in AL up to AXlinux nasm 将 AL 中的值移动到 AX
【发布时间】:2012-10-14 06:10:11
【问题描述】:

我正在研究一种打印多位整数的方法,方法是重复将整数除以 10 并收集余数,然后打印它们。这是一个有问题的代码段:

除法:

    ; initial division
    mov ax, 111   ; number we want to print
    mov ch, 10    ; we divide by ten to siphon digits
    div ch        ; divide our number by 10

    ; al now has 11, ah has 1
    mov dh, ah ; save the remainder in dh
  1 mov bx, al ; these lines refill ax with the number to 
    mov ax, bx ; divide
    mov ch, 10 ; refill ch with the divisor
    div ch     ; al now has 1, ah now has 1

标有 1 的行有问题。我需要将 8 位寄存器 AL 中的值移动到 16 位寄存器 AX。我怎样才能在那里得到那个值以便我可以分割它?

【问题讨论】:

标签: linux assembly x86 nasm


【解决方案1】:

只需清除ah 寄存器即可。 ax 寄存器由它的高和低部分组成 - ah:al

这同样适用于bx (bh,bl) cx (ch,cl) 和 dx (dh,dl) 寄存器

【讨论】:

    猜你喜欢
    • 2015-02-12
    • 1970-01-01
    • 2013-02-17
    • 1970-01-01
    • 2020-02-01
    • 2016-09-11
    相关资源
    最近更新 更多