我正在研究一种通过将整数反复除以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中.我怎样才能在那里获得该价值,以便进行划分?

解决方法:


只需清除ah寄存器即可. ax寄存器由高低部分​​组成-ah:al

bx(bh,bl)cx(ch,cl)和dx(dh,dl)寄存器也是如此

标签: linux, x86, assembly, nasm

相关文章推荐

添加新评论,含*的栏目为必填