Newbie Needs Help

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
MWM

Newbie Needs Help

Post 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
Khumba

RE:Newbie Needs Help

Post 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.
Brill

RE:Newbie Needs Help

Post by Brill »

Your copying the character to 0xb800. It should be 0xb8000.
Brill

RE:Newbie Needs Help

Post by Brill »

Oh wait, lalalala, real mode ;).
Khumba

Oops, try this

Post 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.
Post Reply