Page 1 of 1

problem with printing on screen

Posted: Fri Mar 21, 2008 2:07 pm
by aztex
i could not print on the screen using interrupt 10 when i am in real,mode..
help me..!!! :x

Posted: Fri Mar 21, 2008 2:54 pm
by nekros
As I said post your code, we are not psychic.

Posted: Fri Mar 21, 2008 3:01 pm
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:

Posted: Sat Mar 22, 2008 1:44 am
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

Posted: Sat Mar 22, 2008 5:25 am
by 01000101
I thought only some BIOS's leave the interrupts enabled post-bios?

have you tried putting a STI before your code?

Posted: Sat Mar 22, 2008 6:39 am
by Combuster
at the very least, set up a stack before using it.

Posted: Sat Mar 22, 2008 6:55 am
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

Posted: Sat Mar 22, 2008 8:36 am
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.