second_binary.asm 1.24 KB
[BITS 16]
[org 0x8000]

JMP	short Start

print_string:   ; Expects null terminated message in si
	for_print_string_0:
		MOV 	al,[si]
		OR 		al,al
		JZ  	end_for_print_string_0
		INC 	si
		CALL 	print_char
		JMP 	for_print_string_0
	end_for_print_string_0:
	RETN

print_char:
	MOV 	ah,0x0E         ; Specifies that we want to write a character to the screen
	MOV 	bl,0x02         ; Specifies output text color.  Not required, but useful to know
	MOV 	bh,0x00         ; Page number.  Leave this alone.
	INT 	0x10            ; Signal video interrupt to BIOS
	RETN

execute_sector:
	PUSH	ebp
	MOV		ebp, esp
	PUSH	ax
	PUSH	bx
	PUSH	cx
	PUSH	dx
	MOV		ax, [10 + ebp]	; base address
	MOV		es, ax
	MOV 	al, [8 + ebp]	; num
	MOV		cl, [6 + ebp]	; offset
	MOV     ah, 2 			; Function read
    XOR     ch, ch 			; cylinder
    XOR		dh, dh 			; head
    MOV 	dl, 0x81 		; drive
    INT     0x13
    XOR		si, si
    PUSH	es
    PUSH	bx
	RETF

Start:
XOR 	ax, ax
MOV 	ds, ax
MOV		ax, 0x1000
MOV 	es, ax
XOR		bx, bx
for_start_0:
	MOV 	si, str
	CALL 	print_string
	PUSH	0x7c0; Base address, offset is 0
	PUSH	1 ; num
	PUSH	1 ; offset
	XOR		bx, bx;
	;CALL 	execute_sector
	;JMP 	for_start_0
	JMP	$

str: 	db 'Hi! I',0x27,'m the second binary!',0x0A,0x0D,0x00

TIMES 	510 - ($ - $$) db 0