Displaying text without interrupts

拥有回忆 提交于 2019-12-24 05:51:12

问题


I am trying to make my own boot-loader. As I will not have any interrupts when I change from 16bit to 32 bit mode, I will not be able to use int 10h.

Here is the code I have so far:

org 0x7c00            ; add to offsets
xor ax, ax            ; make it zero
mov ds, ax            ; ds=0
mov ss, ax            ; stack starts at 0

cld

mov ax, 0xb800        ; Ax = address of video memory
mov es, ax
xor di, di
call print            ; call thr print function

hang:
   jmp hang           ; constanly loop

print:
  mov si, msg         ; load msg into si
  mov cx, 4
  mov ah, 07h

printchar:
  lodsb               ; Hear we load a letter from si
  stosw
  loop printchar      ; if not end of msg, go back to printchar
  ret                 ; return

msg    db    'test'   ; msg = 'test'

times 510-($-$$) db 0 ; make sure file is 510 bytes in size
dw 0xaa55             ; write boot signiture

And compiled with nasm:

nasm -f bin bootloader.asm -o myos.hdd

I have put comments in the lines I understand. What I don't understand is the usage of the video memory. Could someone explain this to me and show me where to find the documentation?

I have searched the internet but cannot find the documentation.


回答1:


I think I get it now.

mov cx, 4 is the length of the message. "test" is four bytes long.

mov ah, 07h is setting the colour data. 0 = black, 7 = light grey.
First number is the background colour, second number is the text colour.
This means that the character to be printed will be light grey on a black background.

Thank you to everyone who helped.



来源:https://stackoverflow.com/questions/52643208/displaying-text-without-interrupts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!