Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method to realize the display function of assembly language?

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is the realization method of assembly language display function". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what is the way to realize the display function of assembly language"?

Question 1

In the middle of the screen, the strings "Welcome to masm!" are displayed with green background, red green background, and blue white background.

Analysis:

1 how to determine the position of characters to be displayed

In the color character mode of 80'25, the buffer is displayed in the B8000H~BFFFFH total 32KB space of the memory address.

In this mode, the monitor can display 25 rows and 80 columns

So there are 80 characters in a line, occupying a total of 160bytes. Each character's low byte stores the character's ASCII code, and the high byte stores the character's color attribute.

The offset 0000009F corresponds to the first line on the monitor.

The offset 0A00~13F0 corresponds to the second line on the monitor;. And so on.

Determine the starting position of three lines of characters on each line

Because the display is in the middle of the screen, which requires a total of 32 bytes and a row of 160 bytes in the screen, the starting byte is (160-32) / 2 = 64

Determine which line of three lines of characters is on the screen

Because there are 25 lines in the screen, if you want to display 3 lines of strings with 160 strings on one line, the first line begins with (25-3) / 2 * 160 = 6E0H

The start of the second line is 6E0H + 160 = 780H

The beginning of the third line is 780H + 160 = 820H

2 how to determine the color attribute of the character to be displayed

The color attribute of each character occupies one byte, and each bit represents a different color attribute, then there are 256 color attributes.

Format of attribute bytes:

7 (6 54) 3 (2 1 0)

BL (R G B) I (R G B)

Flicker background highlight foreground

Green background black: 0 0100 000 B (20H)

Green background red: 0 0100 0 100B (42H)

White background blue: 0 111 0 001B (71H)

Assume cs:code,ds:datadata segment db 'Welcome to masquerade' Data ends code segmentstart: mov ax,data mov ds,ax mov bx,0; ds:bx points to mov ax,0B800H mov es,ax at the beginning of the segment Set the starting position of the display memory space mov si,64; set the string in the middle of the line mov cx,16 Set the number of loops to the length of the string s: mov al,ds: [bx] mov ah,20H Set the start position and color of the first line mov es: [si+6E0H], ax mov ah,42h Set the start position and color of the second line mov es: [si+780H], ax mov ah,71h Set the start position and color of the third line mov es: [si+820H], ax inc bx; set the offset add si,2 of the string Set the write location for the next loop loop s mov ax,4c00h int 21h code endsend start question 2:

Design a subroutine that enables the caller to determine the location, content and color of the display

Analysis:

Function to be implemented: display a string that ends with 0 at the specified location and with the specified color

The specified parameters: line number-dh (value range 0: 24), column number-dl (value range: 0: 79). The value range is mainly based on the size of the display screen.

Color-cl,ds:si points to the first address of the string

Assume cs:code,ds:datadata segment db 'Welcome to masquerade Magi 0data ends code segmentstart: mov dh,8 mov dl,3 mov cl,2 mov ax,data mov ds,ax mov si,0 Ds:si points to the first address of the segment call show_str mov ax,4c00h int 21h show_str: mov ax,0B800H mov es,ax Es points to the segment address mov ax,160 dec dh mul dh mov dh,0 dec dl add dl,dl add ax,dx mov di that shows the memory space Ax Set the di to point to the offset address of the string to display: mov ah,cl show: mov cx,ds: [si] jcxz ok Set to exit mov al,ds: [si] mov es: [di], ax add di,2 inc si loop show ok: retfcode ends end start when the character 0 is encountered. I believe that you have a deeper understanding of "assembly language display function implementation method", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report