Wang Shuang "assembly Language" (third edition) Experiment 9 analysis

Source: Internet
Author: User

Brief introduction

Please compare books with the topic

Code
Assume cs:codedata segment db ' Welcome to masm! ' DB 02h,24h,71h; Required three colors corresponding to 16 binary code data endsstack segment db (0); can also be the following definition method:; DW 8 DUP (0) stack endscode segmentstart:; Sets the data segment, and DS:BX points to the first cell of the data segment;        That is, the content of DS:[BX] is the content of the first cell of the data segment MOV Ax,data mov ds,ax; Set the display buffer segment MOV ax,0b800h; set the start cache MOV es,ax; set the stack segment MOV ax,stack mov ss,ax mov sp,10h; point to the top of the stack; initial A three register mov bx,780h; Line from 12-14 lines (note: Counting starting from line 1th) MOV si,10h; The offset of the color, three cycles each time; Add 1h point to the next color mov cx,3; Three cycles change line S:mov ah,ds:[si]; color beforehand stored in AH in the push CX push SI mov cx,16; 16 Cycles change the column MOV si,64; The meaning of the SI here is how many columns; Why start with the 64 column?; (1) string is 32 bytes, 16 bytes ascll code, 16 byte attribute;    (2) Each row has 160 columns, then the remaining 160-32=128 are blank;   To make the string centered, the left and right side of the string are displayed;        should be 64 bytes (128/2), and the number of columns is counted from 0,    ; So the 64 bytes on the left is 0-63, so here the offset is a. mov di,0 S0:mov al,ds:[di]; Converts the characters in a date field to an incoming ES in MOV es:[ Bx+si],al; Low store character mov Es:[bx+si+1],ah;                High storage color add si,2; display buffer character ASCII offset of 2 add di,1;d ATA segment character offset, each with 1 loop s0        Pop si pop cx, LIFO, first out stack si, then stack cx add si,1h; point to Next color add bx,0a0h; point to Next line 160=0a0h Loop s mov ax,4c00h int 21hcode endsend start
Results

Compile, link, execute to get the results we want.

Wang Shuang "assembly Language" (third edition) Experiment 9 analysis

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.