2012-10-14 20 views
3

我正在通过将整数除以10来打印多个数字整数并收集剩余部分,然后将其打印出来。下面是有问题的代码段:linux nasm将AL中的值移动到AX

鸿沟:

; 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。我怎样才能在那里获得价值,这样我就可以分开它?

+0

又见['movsx' ](http://faydoc.tripod.com/cpu/movsx.htm)和['movzx'](http://faydoc.tripod.com/cpu/movzx.htm)说明。 – DCoder

回答

3

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

这同样适用于bx(BH,BL)cx(CH,CL)和dx(DH,DL)寄存器

+0

谢谢!很棒。 – Progrmr