I have stored specific data on memory location 0x4000. I wanted to pass a byte from there to memory location 0xb800 so that the data is printed in the screen. The problem arises when I try to store in 0xb800:0 what would be my first byte that I assume is in 0x4000:0. The code I used as example is below:
mov ax, 0xb800
mov es, ax
mov byte [es:0], 'A'
This compiles fine and runs perfectly, but what I’m trying to adapt throws an “invalid segment override” error on NASM. Here is my non working code:
mov ax, 0xb800
mov es, ax
mov byte [es:0], byte [0x4000:0]
Is it possible to get a single byte from 0x4000:[offset] and feed it to 0xb800:[offset] by using ES segment? If so, how?
You can do this, but you can’t do it in a single instruction like you have. You’ll need to use another segment register, such as
ds, plus an intermediate register (alhere):Note that if you’ve got
dspointed somewhere else, then you’ll have consider that too (such as by saving and restoring it).