Compilation procedure Wang Shuang-solution to experiment 9 (display problem)

Source: Internet
Author: User

The following is a question played by someone else. Some things are omitted. My environment is Windows XP

Experiment 9 programming based on materials
The "Welcome to MASM!" string is displayed in the middle of the screen in green, green, and white colors !".
MATERIALS:
In the memory address space, b8000h ~ Bffffh has a total space of 32 KB, which is a display buffer in 80*25 color character mode. Write Data to this address space, and the written content will immediately appear on the display.
In the 80*25 color character mode, the display can display 25 lines, each line has 80 characters, each character can have 256 attributes (background color, foreground color, flashing, highlighting, and other combinations of information ).
In this way, a character occupies two bytes in the display buffer, respectively storing the character ASCII code (low level) and attribute (high level ). In 80*25 mode, the content of a screen occupies 4000 bytes in the display buffer.
The display buffer is divided into eight pages, each page is 4 kb, the display can display any page content. Generally, the page 0th is displayed. That is, generally, b8000 ~ The 4000 bytes in b8f9f will appear on the screen.
Format of attribute Bytes:
7 6 5 4 3 2 1 0
BL (blinking) R (background) g (background) B (background) I (highlighted) R (foreground) g (foreground) B (foreground)

 

This question is very easy. No problem. My solution is:

Assume Cs: cseg, DS: Data
Data Segment
DB 'Welcome to MASM! '
Data ends
Cseg segment
Start:
MoV ax, Data
MoV ds, ax
MoV ax, 0b800h
MoV es, ax
MoV BX, 0f00h
MoV Si, 0
MoV CX, 16
S: mov Al, [Si]
MoV ES: [BX], Al
MoV Al, 02 h
MoV ES: [bx + 1], Al
Add Bx, 2
INC Si
Loop s


; System Call
MoV ax, 4c00h
Int 21 h
Cseg ends

End start

However, I cannot achieve my display purpose during debugging, and each time mov ES: [BX], ES: [BX] After Al is not modified. Later I found that the first line of the color character display buffer starts from the first line of the command line window. That is to say, each time I run the command during debugging, the screen will scroll up, which is equivalent to a clear screen, so my display will be cleared.

So the characters I want to display are located in 25 lines, so that the effect is displayed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.