如何在实模式下显示图像?

How to display images in real mode?

我正在学习操作系统。我已经了解了引导加载程序和内核。当我使用 XP OS 时,我突然想知道如何使用第二阶段引导加载程序在实模式下显示图像(比如 logo.jpg)。有可能这样做吗?

因为我以为开机显示的XP logo是实模式

那么,我该怎么做呢? 即:我的引导加载程序加载第二阶段,第二阶段应该加载图像文件并显示它。

我应该使用资源链接器还是什么?

语言:8086 汇编

谢谢

您可以使用中断 10h 与 BIOS 交互来控制视频卡。

维基百科:https://en.wikipedia.org/wiki/INT_10H
教程"Video Programming I":http://fleder44.net/312/notes/18Graphics/index.html

这是一个例子,取自this website (license):

Here is an example of MODE 12h video graphics with 4 plains using Write Mode 2. Simply draws a colorful line from (0,0) to (479,479) on the 640x480x16 screen. ; This code was assembled with NBASM

.model tiny
.code
.186

           org 100h

           mov  ax,0012h                ; set mode to 640x480x16
           int  10h

           mov  ax,0A000h
           mov  es,ax

           ; start line from (0,0) to (639,479)
           mov  word X,0001h            ; top most pixel (0,0)
           mov  word Y,0001h            ;
           mov  byte Color,00h          ; start with color 0
           mov  cx,480                  ; 480 pixels
DrawLine:  call putpixel                ; put the pixel
           inc  word X                  ; move down a row and inc col
           inc  word Y                  ;
           inc  byte Color              ; next color
           and  byte Color,0Fh          ; 00h - 0Fh only
           loop DrawLine                ; do it

           xor  ah,ah                   ; wait for key press
           int  16h

           mov  ax,0003                 ; return to screen 3 (text)
           int  10h

           .exit                        ; exit to DOS


; on entry X,Y = location and C = color (0-15)
putpixel   proc near uses ax bx cx dx

; byte offset = Y * (horz_res / 8) + int(X / 8)

           mov  ax,Y                    ; calculate offset
           mov  dx,80                   ;
           mul  dx                      ; ax = y * 80
           mov  bx,X                    ;
           mov  cl,bl                   ; save low byte for below
           shr  bx,03                   ; div by 8
           add  bx,ax                   ; bx = offset this group of 8 pixels

           mov  dx,03CEh                ; set to video hardware controller

           and  cl,07h                  ; Compute bit mask from X-coordinates
           xor  cl,07h                  ;  and put in ah
           mov  ah,01h                  ;
           shl  ah,cl                   ;
           mov  al,08h                  ; bit mask register
           out  dx,ax                   ;

           mov  ax,0205h                ; read mode 0, write mode 2
           out  dx,ax                   ;

           mov  al,es:[bx]              ; load to latch register
           mov  al,Color
           mov  es:[bx],al              ; write to register

           ret
putpixel   endp

X          dw 00h
Y          dw 00h
Color      db 00h

.end