Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Cannot display image from bootsector

Cannot display image from bootsector

Cannot display image from bootsector

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):


bits 16
org   7C00h

    ; 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.
Replies continue below

Recommended for you

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close