Page 1 of 1

Newbie Needs Help

Posted: Tue Oct 15, 2002 11:00 pm
by MWM
Hello, I am having a small problem that is giving me fits.  I am in the very
early stages of OS development and am trying to create a small program to display an "A" to my screen by using a  declared variable.

Here is what my code looks like:

[BITS 16]
LETTER DB 'A'

mov AX, 0xb800
mov ES, AX

mov BX, LETTER
mov AH, BYTE [BX]

mov BYTE [ES:0x0f9c], AH

pause:
jmp pause
ret

times 510-($-$$) db 0
dw 0xAA55

When  I run this program the result is that a symbol that resembles an upside-down pi is printed to the screen.  I cannot figure out what I am doing wrong. Any help is greatly appreciated.

Thank you
MWM

RE:Newbie Needs Help

Posted: Tue Oct 15, 2002 11:00 pm
by Khumba
If you are using NASM then "MOV BX, LETTER" will set BX to the address of LETTER. What you want is "MOV BX, [LETTER]", which sets BX to what's in LETTER.

RE:Newbie Needs Help

Posted: Wed Oct 16, 2002 11:00 pm
by Brill
Your copying the character to 0xb800. It should be 0xb8000.

RE:Newbie Needs Help

Posted: Wed Oct 16, 2002 11:00 pm
by Brill
Oh wait, lalalala, real mode ;).

Oops, try this

Posted: Wed Oct 16, 2002 11:00 pm
by Khumba
Sry, your MOV BX, LETTER was right, but I've noticed something else: having LETTER DB 'A' at the beginning of your code executes the 'A', which translates to an INC CX instruction. I'd move that to the bottom (below ret). Otherwise, the code runs fine on my computer.