简体   繁体   English

制作程序集引导加载程序时出现问题,它将所有背景 colors 写入视频 memory

[英]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:有用信息:

  • I am writing directly to the text video memory, starting from address 0xb8000, using method described in this forum post .我直接写到文字视频memory,从地址0xb8000开始,使用本论坛帖子中描述的方法。
  • I am using flat assembler 1.73.27 for Windows (fasm assembler).我正在为 Windows(fasm 汇编器)使用平面汇编器 1.73.27
  • I am testing my program on real computer (booting from usb), not an emulator.我正在真实计算机上测试我的程序(从 USB 启动),而不是模拟器。
  • I am not including any photos, because of this post .由于这篇文章,我不包括任何照片。

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 具有值-1ah作为带符号字节 (-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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM