0
BITS 16

start:
	mov ax, 07C0h		; Set up 4K stack space after this bootloader
	add ax, 288		; (4096 + 512) / 16 bytes per paragraph
	mov ss, ax
	mov sp, 4096

	mov ax, 07C0h		; Set data segment to where we're loaded
	mov ds, ax


	mov si, text_string	; Put string position into SI
	call print_string	; Call our string-printing routine

	


	text_string db 'This is my cool new OS!', 0


print_string:			; Routine: output string in SI to screen
	mov ah, 0Eh		; int 10h 'print char' function

.repeat:
	loadsb			; Get character from string
	cmp al, 0
	je .background_colors		; If char is zero, end of string
	int 10h			; Otherwise, print it
	jmp .repeat
	
.background_colors:
	mov ah,0Bh
	mov bh,0
	mov bl,02h
	int 10h
	jmp .cursor_pointer
	
.cursor_pointer:
	mov ah,2h		;set the value to "ah" to move the cursor pointer
	mov bh,0		;select page 
	mov dh,22		;set row position of the cursor
	mov dl,0		;set column position of the cursor
	int 10h			;tell bios "hey dude now we are done,take action!!!"
	jmp .character_write

.character_write:
	mov ah,9h
	mov al,65		;ascii value
	mov bh,0		;display page
	mov bl,5h		;display attribute
	mov cx,10		;display times
	int 10h
	jmp .cursor_pointer2

.cursor_pointer2:
	mov ah,2h		;set the value to "ah" to move the cursor pointer
	mov bh,0		;select page 
	mov dh,23		;set row position of the cursor
	mov dl,0		;set column position of the cursor
	int 10h			;tell bios "hey dude now we are done,take action!!!"
	jmp .character_read
	
.character_read:
	mov ah,00h		;remeber set the value to "ah" now you are going to read a keyboard input
	int 16h			;this interrupt is given to control keystrokes of keyboard
	jmp .print_input	;now lets print what we took as input

.print_input:
	mov ah,9h		;set the value to "ah" to print one character to std out
	mov bh,0		;set page number
	mov bl,5h		;set the color attribute of the font to be print
	mov cx,10		;set the value how many time the character in "al" should be print
	int 10h			;tell bios "hey dude now we are done,take action!!!"
	jmp .done
	
.done:
	ret

	times 510-($-$$) db 0	; fill up the rest part of the boot secotr with 0 s
	dw 0xAA55		; The standard PC boot signature

I'm writing a simple bootloader to get a key board input. but it gets some errors. i'm using QEMU as my emulator.please help me to find those errors

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Tight_Coder_Ex
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.