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



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

因为我认为在启动过程中显示的XP标志是真实模式。

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

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

语言:8086汇编

感谢

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

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

以下是一个示例,取自本网站(许可证):

以下是使用写入模式2的4个平面的模式12h视频图形的示例。只需在640x480x16屏幕上画一条从(0,0)到(479479)的彩色线。;此代码是用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

最新更新