EDIT:
I’m sorry, I’ve made a newbie mistake, and have been changing the value of BX myself! 🙂
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).
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
blis the lower 8 bits of the 16 bitbx, andbhis the higher 8 bits.So by changing
blyou’re changingbxalso.