【发布时间】:2015-03-13 16:52:35
【问题描述】:
我在 i8086 汇编器中编写了一些代码,应该将 80x25 图像放入 VRAM 并在屏幕上显示。
entry start
start:
mov di,#0xb800 ; Point ES:DI at VRAM
mov es,di
mov di,#0x0000
mov si,#image ; And DS:SI at Image
mov cx,#0x03e8 ; Image is 1000 bytes
mov bl,#0x20 ; Print spaces
; How BX is used:
; |XXXX XXXX XXXXXXXX|
; ^^^^^^^^^ BL contains ascii whitespace
; ^^^^ BH higher 4 bits contain background color
; ^^^^ BH lower 4 bits contain unused foreground color
img_loop:
seg ds ; Load color
mov bh,[si]
seg es ; Write a whitespace and color to VRAM
mov [di],bx
add di,#2 ; Advance one 'pixel'
sal bh,#4 ; Shift the unused lower 4-bits so that they become background color for the 2nd pixel
seg es
mov [di],bx
add di,#2
add si,#1
sub cx,#1 ; Repeat until 1 KiB is read
jnz img_loop
endless:
jmp endless
image:
GET splash.bin
问题是我无法让 as86 汇编器包含图像文件中的二进制数据。我查看了the man page,但找不到任何有效的方法。
如果我尝试构建上面的代码,它不会给我任何错误,但是链接器生成的输出文件大小只有 44 字节,所以显然它没有费心放入 1000 字节的图像。
有人可以帮我吗?我做错了什么?
【问题讨论】: