实模式汇编:在启动时没有INT指令的情况下将Char打印到屏幕上 [英] Real Mode Assembly: Print Char to Screen without INT Instruction on Boot

查看:63
本文介绍了实模式汇编:在启动时没有INT指令的情况下将Char打印到屏幕上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下站点编写引导扇区代码" 提供了示例代码系统启动时在屏幕上显示"A".从我一直在阅读的内容中,您不是必须使用INT操作码来让BIOS做某些事情吗?上面引用的站点中的以下代码如何在不使用中断的情况下工作?哪一部分代码实际上告诉硬件在屏幕上打印"A"?

The following site "Writing Boot Sector Code" provides a sample of code that prints 'A' to the screen when the system boots. From what I have been reading don't you have to use INT opcode to get BIOS to do certain things? How does the code below, from the site referenced above work without using interrupts? What portion of code actually tells the hardware to print 'A' to the screen?

有问题的代码:

.code16
.section .text
.globl _start
_start:
  mov $0xb800, %ax
  mov %ax, %ds
  movb $'A', 0
  movb $0x1e, 1
idle:
  jmp idle 


附加原始问题

如果我使用以下代码,BIOS调用是否会为我写入文本缓冲区?缓冲区从地址0xb800开始?

If I use the following code does the BIOS call write to the text buffer for me? The buffer starting at address 0xb800?

   # Author: Matthew Hoggan
   # Date Created: Tuesday, Mar 6, 2012
   .code16                        # Tell assembler to work in 16 bit mode (directive)
   .section .text
   .globl _start                  # Help linker find start of program
   _start:
       movb $0x0e,     %ah        # Function to print a character to the screen                 
       movb $0x00,     %bh        # Indicate the page number
       movb $0x07,     %bl        # Text attribute
       mov  $'A',      %al        # Move data into low nibble                   
       int  $0x10                 # Video Service Request to Bios                             
   _hang:                         
       jmp  _hang                 
       .end   

推荐答案

您的问题的直接答案:"movb $'A',0"行有效地完成了在屏幕上的打印(下面一行"movb $ 0" x1e,1指定应该是什么颜色.

Direct answer to your question: The line "movb $'A', 0" effectively completes the print to the screen (and the following line, "movb $0x1e, 1" specifies what color it should be).

更长的答案:视频硬件根据内存的内容绘制屏幕.在文本模式下,视频硬件根据内存段0xB800开始绘制.字节0处的内容定义了要在屏幕上第一个文本单元格上绘制的字符.下一个字节定义属性(前景颜色,背景颜色和闪烁状态).此模式在整个屏幕上重复(char-attr-char-attr).

Longer answer: The video hardware draws the screen based on the contents of memory. When in text mode, the video hardware starts drawing based on memory segment 0xB800. Whatever is at byte 0 defines the character to be drawn at the first text cell on the screen. The next byte defines the attributes (foreground color, background color, and blink status). This pattern repeats (char - attr - char - attr) throughout the entire screen.

因此,从技术上讲,我的直接回答是不正确的. 2个'movb'语句只是将要打印的字母'A'暂存.直到下一次硬件根据内存刷新显示时,才会打印"A".

So, technically, my direct answer wasn't true. The 2 'movb' statements simply stage the letter 'A' to be printed. 'A' is not printed until the next time hardware refreshes the display based on the memory.

这篇关于实模式汇编:在启动时没有INT指令的情况下将Char打印到屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆