Nasm,引导加载程序切换前景色和背景色
嘿,我正在使用 nasm 虚拟机等编写引导加载程序。无论如何,我使用 vram 来显示由 s、d、f、g 键触发的背景和字体颜色变化。 S 切换字体颜色和背景颜色。我知道如何做到这一点,但我不知道正确的方法。 vram 设置为 2 个字节,第一个是字符,第二个是其属性。这些是背景颜色,然后是字符颜色。所以我需要拿走这些并切换它们。这将切换字体颜色和背景颜色。我实际上如何用代码来做到这一点?
; s key
;///////////////////////////////////////////////////////////
.s:
mov bx,0xb800 ;direct video memory access 0xB8000
mov es,bx
xor bx,bx ;es:bx : 0xb8000
mov dh,0 ;row from 0 to 24
mov dl,0 ;col from 0 to 79
.loops1:
inc bx
mov byte [es:bx], 0ah ;attribute
inc bx
inc dl
cmp dl,80 ;col 0-79
jne .loops1
mov dl,0
inc dh
cmp dh,25 ;row 0-24
jne .loops1
jmp .kbin
第二个问题: 我使用这个循环来检测按键,我如何将这些按键更改为 Ctrl + 键。
.kbin:
mov ah,10h ;Read from keyboard
;ah scan code, al ascii char
int 16h
cmp al, 53h ;uppercase s
je .s
cmp al, 73h ;lowercase s
je .s
cmp al, 44h ;uppercase d
je .d
cmp al, 64h ;lowercase d
je .d
cmp al, 46h ;uppercase f
je .f
cmp al, 66h ;lowercase f
je .f
cmp al, 47h ;uppercase g
je .g
cmp al, 67h ;lowercase g
je .g
jmp .kbin
谢谢。
Hey some im writing a bootloader using nasm a virtual machine ect. Anyhow, im using vram to display background and font color changes triggered by keys s, d, f, g. S switches the color of the font with the background color. I know how this can be done but i do not know the proper way. vram is setup as so 2 bytes the first is the character, the second is its attributes. These are background then character color. So i need to take these and switch them. That would switch the font color and the background color. How do i actually do it with code?
; s key
;///////////////////////////////////////////////////////////
.s:
mov bx,0xb800 ;direct video memory access 0xB8000
mov es,bx
xor bx,bx ;es:bx : 0xb8000
mov dh,0 ;row from 0 to 24
mov dl,0 ;col from 0 to 79
.loops1:
inc bx
mov byte [es:bx], 0ah ;attribute
inc bx
inc dl
cmp dl,80 ;col 0-79
jne .loops1
mov dl,0
inc dh
cmp dh,25 ;row 0-24
jne .loops1
jmp .kbin
Second question:
Im using this loop to detect key's how could i change these keys to Ctrl + key.
.kbin:
mov ah,10h ;Read from keyboard
;ah scan code, al ascii char
int 16h
cmp al, 53h ;uppercase s
je .s
cmp al, 73h ;lowercase s
je .s
cmp al, 44h ;uppercase d
je .d
cmp al, 64h ;lowercase d
je .d
cmp al, 46h ;uppercase f
je .f
cmp al, 66h ;lowercase f
je .f
cmp al, 47h ;uppercase g
je .g
cmp al, 67h ;lowercase g
je .g
jmp .kbin
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该这样做:
对于第二个,使用函数 2 for int 16h。
是的,并获取一些文档。也许您会喜欢技术:http://www.intel-assembler.it/portale/5/A-desktop-assembler-utility-program/A-desktop-assembler-utility-program.asp
This should do it:
For the second, use function 2 for int 16h.
Yeah, and get some documentation. Maybe you'll like Tech: http://www.intel-assembler.it/portale/5/A-desktop-assembler-utility-program/A-desktop-assembler-utility-program.asp