problem with printing on screen

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
User avatar
aztex
Member
Member
Posts: 30
Joined: Sun Mar 02, 2008 8:15 am

problem with printing on screen

Post by aztex »

i could not print on the screen using interrupt 10 when i am in real,mode..
help me..!!! :x
User avatar
nekros
Member
Member
Posts: 391
Joined: Wed Mar 05, 2008 9:10 pm
Contact:

Post by nekros »

As I said post your code, we are not psychic.
Working On:Bootloader, RWFS Image Program
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
User avatar
nekros
Member
Member
Posts: 391
Joined: Wed Mar 05, 2008 9:10 pm
Contact:

Post by nekros »

are you writing a bootloader? If you are loaded by grub try this:

Code: Select all

texmem: dd 0xB8000;text memory
cline: dd 0xB8000;current line
color: db 0x0A;green

kputc:;put a char on the screen
cmp al,"$"
je bnline
mov ebx,[texmem]
mov ah,[color]
mov [ebx],al
inc ebx
mov [ebx],ah
inc ebx
mov [texmem],ebx
jmp kpute
bnline:
mov eax,[cline]
add eax,0xA0
mov [cline],eax
mov [texmem],eax
kpute:
ret

kputs:;put a string on the screen
lodsb
or al,al
jz kpdone
call kputc
jmp kputs
kpdone:
ret
esi is the addr of the string to print. Your lucky that I'm in a giving mood :lol:
Working On:Bootloader, RWFS Image Program
Leviathan: http://leviathanv.googlecode.com
Kernel:Working on Design Doc
User avatar
aztex
Member
Member
Posts: 30
Joined: Sun Mar 02, 2008 8:15 am

Post by aztex »

I use bochs emulator... this is the code...
org 0x7c00

bits 16

Start:

xor al,al
mov al,'A'
mov bx,0
mov bl,3
mov ah,0x0e
int 0x10
cli
hlt
times 510 - ($-$$) db 0

dw 0xAA55
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Post by 01000101 »

I thought only some BIOS's leave the interrupts enabled post-bios?

have you tried putting a STI before your code?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

at the very least, set up a stack before using it.
"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 ]
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Post by egos »

Code: Select all

org 0x7c00 

bits 16 

Start: 

mov al,'A' 

mov bx,0x0003
mov ah,0x0e 
int 0x10 
jmp $

times 510 - ($-$$) db 0 
dw 0xAA55
Here is code which I use in real mode

Code: Select all

@@:             mov     bx, 0007h
                mov     ah, 0Eh
                push    si
                int     10h
                pop     si
                inc     si
output_string:  mov     al, [si]
                and     al, al
                jg      @b
                ret
User avatar
xyjamepa
Member
Member
Posts: 397
Joined: Fri Sep 29, 2006 8:59 am

Post by xyjamepa »

You should do something like this...

Code: Select all

;----------------------------------------------------------------------
; Simple boot program that prints the letter 'H'
;  and then hangs

;----------------------------------------------------------------------
	org 0x7c00	; This is where BIOS loads the bootloader


; Execution begins here
entry:
	jmp short begin ; jump over the DOS boot record data





; --------------------------------------------
;  Boot program code begins here
; --------------------------------------------
; boot code begins at 0x003E
begin:
	mov	ah, 0x0  ; Function to print a character to the screen
	mov	al, 'H'		; Which character to print
	mov	bl, 7		; color/style to use for the character
	int	0x10		; print the character

hang:
	jmp	hang		; just loop forever.

;---------------------------------------------

size	equ	$ - entry
%if size+2 > 512
  %error "code is too large for boot sector"
%endif
	times	(512 - size - 2) db 0

	db	0x55, 0xAA		;2  byte boot signature
assemble it with nasm,like this...

Code: Select all

nasmw h.asm –o h.bin
if you have a programe called bootable
you can write this to a boot sector of a floppy ,like this...

Code: Select all

bootable h.bin a:
google to download it...
Also you can use Debug programe which comes with Dos

Code: Select all

debug

-n h.bin

-l 0
-w 0 0 0 1
becareful this will destroy all data on your floppy disk.

Thanx.
The man who follows the crowd will usually get no further than the crowd.
The man who walks alone is likely to find himself in places
no one has ever been before.
Post Reply