Trouble printing things through BIOS

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
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Trouble printing things through BIOS

Post by earlz »

I'm trying to make a simple bootloader and I'm not seeing how this code is failing...

Code: Select all

section .text
[org 7C00]
;jmp 0x0:start ;incase there is some weird BIOSes out there... (can be removed when short on space)
start:
mov bx,start ;for self modifying code references.
mov ax,0
mov ds,ax
mov es,ax
mov ss,ax
mov ah,0x70
mov sp,ax ;0x7000

mov ax,0x0003
int 0x10 ;set video mode to 3, 80x25x16(colors) (8x8 text)

mov ah,0x0E
mov al,[str_hello]
int 0x10

;mov si,str_hello
;call _PrintString



nop
cli
hlt

str_hello:
db "Hello there!!",0
It is supposed to print a 'H' on the screen but instead I just get weird characters.

I've look at my previous code that is working and sniffed over this code and I'm not seeing anything that would cause it do behave this way... Maybe someone here can point out my noobish error
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Trouble printing things through BIOS

Post by Gigasoft »

It works here, if I just put 0x in front of the 7C00 and put a signature in it. Maybe the org isn't being recognized for some reason?

By the way, mov sp,0x7000 would be shorter than mov ah,0x70 followed by mov sp,ax. Or you could just have SP at 0 by leaving the mov sp,ax.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Re: Trouble printing things through BIOS

Post by earlz »

Gigasoft wrote:It works here, if I just put 0x in front of the 7C00 and put a signature in it. Maybe the org isn't being recognized for some reason?

By the way, mov sp,0x7000 would be shorter than mov ah,0x70 followed by mov sp,ax. Or you could just have SP at 0 by leaving the mov sp,ax.
eh, actually didn't think about that with the SP thing..

and apparently yasm has a bug where [org 7C00] will compile but goes to some unknown address... changing it to [org 0x7C00] fixed it... thanks!
Post Reply