Page 1 of 1

writing to screen using register to define effective adrress

Posted: Fri Feb 08, 2008 4:19 pm
by suthers
When i use the following code to write to the screen:

Code: Select all

mov bx, 0B8140h    
mov byte [ds:bx], 'T'
add bx, 1     
mov byte [ds:bx], 1Bh
It assembles with the warning: word value exceeds bounds.
What would be a suitable alternative that would allow it to work.
Thanks in advance,
Jules

Posted: Fri Feb 08, 2008 4:50 pm
by jerryleecooper
YOu are putting more data in bx than it can contain. It's no time for the omega point yet.
put 0xb814 into ds and 0 into bx.
segment addresses are << 4 to the other addresses.
Sorry for my poor english, English, I mean.

Posted: Fri Feb 08, 2008 4:52 pm
by pcmattman
Assuming real mode and therefore real mode segment interpretation:

Code: Select all

push ds
mov ds,0b800h
mov bx, 0140h
mov byte [ds:bx], 'T'
add bx, 1
mov byte [ds:bx], 1Bh
pop ds
Linear = seg << 4 + offset.

In Pmode, you can just use eax ;).

Edit: Added pop ds to the code snippet.

Posted: Fri Feb 08, 2008 6:20 pm
by suthers
Yah, I should of said that i was in protected mode.
Thanks i just used eax to store the address
Jules

Posted: Mon Feb 11, 2008 6:32 am
by jal
[quote="pcmattman"]

Code: Select all

mov ds,0b800h
This should of course be

Code: Select all

mov ax, 0b800h
mov ds, ax
as mov ds does not take an immediate values as operand.


JAL

Posted: Mon Feb 11, 2008 7:10 am
by Dex
You could also use

Code: Select all

mov   byte [ds:0xB8140], "T"
mov   byte [ds:0xB8141], 1Bh

Posted: Mon Feb 11, 2008 3:09 pm
by pcmattman
jal: True, but I didn't want to just give away the answer as easily as that ;).