[英]Problem while making assembly bootloader, that writes all the background colors to the video memory
I would like to make a simple bootloader, that writes all the background colors to next lines on the screen.我想做一个简单的引导加载程序,将所有背景 colors 写入屏幕的下一行。
The problem is, that it only changes the color of the first line to black and the second line to blue, while it should display all 16 colors .问题是,它只会将第一行的颜色更改为黑色,将第二行的颜色更改为蓝色,而它应该显示所有 16 个 colors 。 I think, that there is something wrong with loop1: , but I don't know what.
我认为loop1:有问题,但我不知道是什么。
Useful informations:有用信息:
My code (fasm assembly):我的代码(fasm 程序集):
format binary
use16
org 0x7c00
mov ax,0xb800
mov es,ax
mov bx,0
mov al,0
mov ah,0x0f
mov cx,160
loop1:
call procedure1
add ax,0x1000
add cx,160
cmp ah,0xff
jl loop1
call procedure1
mov cx,4000
mov ah,0x0f
call procedure1
jmp $
procedure1:
mov word [es:bx],ax
add bx,2
cmp bx,cx
jl procedure1
ret
times 510-($-$$) db 0
dw 0xaa55
You are leaving loop1
when ah
is not less than 0xff
anymore.当
ah
不再小于0xff
时,您将离开loop1
。
The term less/greater is used in x86 assembly when signed numbers are compared.比较有符号数时,在 x86 程序集中使用术语“小于/大于”。 Number
0xff
treated as signed 8bit integer has the value -1
and ah
as signed byte (-128..+127), starts at 0x0f + 0x10 = 0x1f
.数字
0xff
被视为带符号的 8 位 integer 具有值-1
和ah
作为带符号字节 (-128..+127),从0x0f + 0x10 = 0x1f
开始。 And 31 < -1
is false on the first iteration, so loop1
is abandoned after the first call procedure1
.并且
31 < -1
在第一次迭代时为假,因此loop1
在第一次call procedure1
后被放弃。
When comparing unsigned numbers we use term below/above .在比较无符号数时,我们使用术语below/above 。 Instead of
jl loop1
use jb loop1
.而不是
jl loop1
使用jb loop1
。 Similary in procedure1:
replace jl procedure1
with jb procedure1
. procedure1 中的相似之处
procedure1:
将jl procedure1
替换为jb procedure1
。 ( https://www.felixcloutier.com/x86/jcc ) ( https://www.felixcloutier.com/x86/jcc )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.