Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gmmastros on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot display image from bootsector

Status
Not open for further replies.

Sulfurik

Programmer
May 28, 2005
4
Okay, the following program works fine if compiled into an EXE file, however it does not when loaded as a bootsector.

It's supposed to display an image, but it only displays a green screen with lines of garbled pixels (the lines are different on each computer I try it on, so the image isn't loaded at all into memory):

Code:
bits 16
org   7C00h

start:
	; Set up the stack
	cli		; Don't use interrupts
	mov ax, 7B0h	; Make stack start at 7C00h-256 = 7B00h
	mov ss, ax
	mov sp, 256	; Make it 256 bytes
	mov ax, cs	; Set the data segment
	mov ds, ax
	xor ax, ax
	mov es, ax
	sti		; Do use interrupts
	
	mov ax, 13h	; Set video mode
	int 10h		; Call video interrupt
			; to enter that mode
	
	; Write the palette...
	mov dx, 3C8h	; Tell the video card that
	xor al, al	; we want to write the
	out dx, al	; palette (port 3C8h)
	
	inc dl		; Increment DL by one
	
	mov dx, 3C8h	; Port 3C8h: Write palette
	xor al, al	; Make AL zero
	out dx, al	; Send data to port
	inc dl		; Increment DL by one
	mov di, Pal	; Move the palette into DI
	mov cx, 256*3	; Let CX store the data size
	rep outsb	; Copy the palette
	
	; Write the image...
	push Pic	; Copy image data to DS
	pop ds
	xor si, si
	
	push 0A000h	; Video buffer is in ES
	pop es
	xor di, di
	
	mov cx, 320*200	; Size of data is in CX
	rep movsw	; Perform the moving
	
	; Loop forever...
	.hang: jmp .hang

; Fill program up until 510 bytes
times 510 - ($ - $$) db 0

; Boot sector identifier (2 bytes)
	dw	0xAA55

; Include the image
Pal: incbin "foo.raw.pal"
Pic: incbin "foo.raw"

; Fill the rest of the disk image with zeros
EOF equ ($ - start)
SizeInSectors equ ((EOF - EOF % 512) / 512 + 1)
;times (2880*512 - ($ - $$)) db 0
times (SizeInSectors * 512) - ($ - $$) db 0

Help? Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top