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.
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:
[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!
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?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
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
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
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.
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
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....].
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