简体   繁体   English

BX有副作用吗?

[英]BX side effects?

EDIT: I'm sorry, I've made a newbie mistake, and have been changing the value of BX myself! 编辑:对不起,我犯了一个新手错误,并一直在改变BX的价值! :) Thanks anyway. :) 不管怎么说,还是要谢谢你。

I'm having fun with NASM and MBR, and for some reason the BX register gets set to "some" value, even though I'm not writing to it (only reading). 我很喜欢NASM和MBR,由于某种原因,即使我没有写BX寄存器(只是读取),BX寄存器也被设置为“某个”值。

Why is that so? 为什么? I'm sure I'm missing something obvious, but I can seem to find any tutorials that would explain this behaviour. 我确定我缺少明显的东西,但似乎可以找到任何可以解释这种行为的教程。

Code in question: 有问题的代码:

partfun:
    mov bx, 01beh ; store a starting address to BX
                  ; I will increment it later
    mov cx, 0

    mov al, bl ; BX changes here already, I think!
    mov al, bh 
   ; do something with AL here

.loop:
    mov al, [bx]    
    ; do something with AL here

    add bx, 16 ;BX is 0110h now, not 01ceh, as I would expect!
               ;I wish to increment the stored value (address) by 16

    inc cx
    cmp cx, 4
    jl .loop

    ret

You can access bl is the lower 8 bits of the 16 bit bx , and bh is the higher 8 bits. 您可以访问bl是16位bx的低8位,而bh是高8位。

So by changing bl you're changing bx also. 因此,通过更改bl也可以更改bx

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

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