Page 1 of 1
printting on the screen in 16-bit real mode
Posted: Thu Jul 04, 2013 4:49 am
by cfny1234
I've been printting some text on screen successfully by using BIOS int 0x10,
and now I'm following the tutorial (wiki.osdev.org/Babystep4) to print something on the screen in real mode by editing the video memory at (0xb8000), but it seems not working for me.
Here is my code:
Code: Select all
[org 0x7c00]
start:
mov ax, 0xb800
mov es, ax
xor di, di
mov al, 'X'
mov ah, 0xf
stosw ; I've also tried mov [es:si], ax
jmp $
times 510-($-$$) db 0
dw 0xaa55
there is nothing printted out on the screen. And then I tried to read the value in address (0xb8000), it always give me zeros, seems I cannot write to that address correctly....
can anyone help please?
thanks!
Re: printting on the screen in 16-bit real mode
Posted: Thu Jul 04, 2013 5:57 am
by Combuster
The code looks fine although es:si isn't the same as es:di. Some emulators are somewhat picky with instruction counts between video writes and rendering them.
Which emulator are you using?
Re: printting on the screen in 16-bit real mode
Posted: Thu Jul 04, 2013 6:12 am
by cfny1234
thanks for replies.
although es:si isn't the same as es:di
and thanks for correction. I think that is only a typing mistake.
I'm using nasm to build the code, and bochs for testing
Something wrong with bochs??
thanks!
Re: printting on the screen in 16-bit real mode
Posted: Thu Jul 04, 2013 6:22 am
by Combuster
Emulators have optimisations that are designed to not redraw the entire screen when individual pixels changes - that would be a waste of time. Rather, they typically have cases where updates are skipped even though they are necessary.
Two things:
- check if your version is the latest one
- if that's the case, try replacing the stosw with something like
Re: printting on the screen in 16-bit real mode
Posted: Thu Jul 04, 2013 6:26 am
by iansjack
If the code looks right but doesn't produce the expected results than an obvious possibility is that it isn't being run. Debuggers are great for checking that sort of error.
You could also always try a different emulator.
Re: printting on the screen in 16-bit real mode
Posted: Thu Jul 04, 2013 7:37 am
by cfny1234
thanks for quick replies!
Two things:
- check if your version is the latest one
- if that's the case, try replacing the stosw with something like
Code:
mov ecx, 0x100
cld
rep stosw
1. Mine is the lastest version (2.6.2)
2. I've replaced stosw with the code you given, it still doesn't work for bochs
But then I tried VirtualBox instead, it worked magically
Re: printting on the screen in 16-bit real mode
Posted: Thu Jul 04, 2013 8:05 am
by AJ
Hi,
Did you compile Bochs yourself? Has something gone wrong with the compilation? What BIOS/Video BIOS are you using?
There are loads of people using Bochs for this kind of basic code and it seems to be working, so the problem is likely to be something unusual about your setup [waits for the bug reports to start flooding in from others with the same issue....].
Cheers,
Adam
Re: printting on the screen in 16-bit real mode
Posted: Thu Jul 04, 2013 9:43 am
by cfny1234
Oops! I've made a stupid mistake!
Actually the code WORKS on bochs, but it change the very first charator on the bochs screen (where "Plex86/Bochs VGABios (PCI) 0.7a..........." locate), which is completely ignored by me......
I just thought that is some bochs message and not part of my VM's screen LOL
Re: printting on the screen in 16-bit real mode
Posted: Thu Jul 04, 2013 11:43 am
by AJ
Locked to prevent ensuing flamefest...