The art of assembly language-basic knowledge (II.)

Source: Internet
Author: User

Iv. understanding of the Directives

Instructions are "command", "command" to control the computer, step-by-step program to implement the program.
The format of the combined language is:
(In the downlink where the marked "[]", the table some instructions can be omitted)
[Pre-yuan] directive [intent to manipulate the yuan, the source start operation element]
1,": The following example is the use of the preceding element.
11 Paragraph name: the action element after the table should belong to this temporary front segment. Such as:
MOV AX,CS:BUF1
12 Definition: Represents the temporary definition of a subsequent buffer. BYTE PTR represents the data defined as a single character; Word PTR table double character data.
Regardless of the original definition of the buffer, any person who has a predecessor is subject to a provisional definition, such as:
ADD BYTE PTR BUF1,CL
In addition to defining the buffer length, the front element also indicates the distance,
JMP Short ABCD

2, Instructions:
11 Use Method:
1-1 registers to the registers, but limits the same length.
MOV AH,BL; to character
Xchg AX,BX; to two characters
1-2 registers to the buffer, or buffer to the register.
or Buf1,ax; BUF1 for buffers, WORD
ADD Cl,byte PTR BUF1
1-3 the value is between the register or the buffer.
TEST di,8000h
and SI,0FFH
SUB BYTE PTR buf1,3
★ Numeric value must not be used as the "purpose" action element
1-4 Place the address of the memory area in the register to transmit the contents of the address, or transfer the variable to call the data indirectly. This method is limited to the source deposit (SI), the final deposit (DI), the stack device (BP) and the dual-use device (BX). Such as:
MOV al,byte PTR [DI]
XOR [BP],DL
MOV Ax,[di][si]
MOV Ax,buf1[di]
JMP LAB1[BX]
1-5 execute the instruction itself, do not need the source start or the purpose to manipulate the element.
PUSH CS
POP DS
Call ABCD
JMP ABCD
Cli
STD
Lahf
Ret
1-6 executive count.
LOOP ABCD
REP MOVSB
SAL DL,CL
ROR ax,1
DEC BX
1-7 registers the special instruction.
Out Dx,al
MUL BUF1
DIV CX
Stosb
Lodsw
1-8 condition executor.
JNZ ABCD
JA ABCD
JCXZ ABCD
INT 10H
IRET

12 application functions can be divided into the following eight items:
2-1 data transfer: 1-1,1-2,1-3,1-4 is possible.
2-2 under the banner of control: 1-5 of those involved in the flag.
2-3 segment Address: 1-1, 1-2 possible.
2-4 Mathematical calculations: Depending on the instructions, the above items are available.
2-5 string Processing: 1-6, 1-7 functions.
2-6 Control conversion: 1-5.
2-7 condition execution: 1-8.
2-8 Interrupt Processing: 1-8.

3, operating elements: can be divided into registers, buffers and values (Immediate Data). Its writing style and habits from the front to the contrary, use caution, the rest of the details please refer to the Manual of the combined language.

Section II Working Environment

First, the system space

The memory area of the IBM pc is addressable by flip-chip (big endian), where the addressable value is from large to small, unlike the general common sense of a small but large (Little endian) approach.
Whatever the purpose of the original design, this idea of the contrary to people's habits brings great trouble to the language of composition. Not only beginners often puzzled, even I personally for many years with the graphics processing company, are ashamed. Each time in the process of graphics, must be the original picture on paper, the control of the detailed, to understand what is going on.
For example, if you have a graphic value in ax that you want to write into the memory location of DI, when you finish, Ax moves one to the right and then continues writing until Cx=0.
This is a very simple and often used action, but in the use of "flip", The trouble comes.
Assuming that the AX value is 4567H and Di points to the memory 2000H, flip-drop method is to put the value of Al into the 2000H memory unit, and then put AH into the 2001H memory unit. From a small to large point of view, this is equivalent to a 16-bit value 6745H in the 2000H.
This doesn't matter, because when you put AX back from the memory address 2000H, it still becomes 4567H. The problem is that when the 4567H becomes 6745H, the graph is reversed. The remedy is to exchange the AH and al before putting them in the memory area, and then swapping them back again. It's not a big deal, but it's a waste of two orders of time and space. For the extremely critical speed of the drawing display, to draw tens of thousands of points, the cumulative time is not a small view.
In addition, in writing programs, the effect of the graphic to be able to master, will have good results, like this every time around, the head fainted, naturally lost patience.
Now, 80386 CPU came out, and do not talk about the effect, the reader can imagine, the 32-bit 12345678H conversion to 78563412H how many formalities?
This painful formality is one of the reasons Americans are unwilling to use a combination of languages. In higher-order languages, a compiler does not seem to have a problem. But the need for efficiency is not worth the candle. Graphic function is one of the mainstream of computer today and in the future, because the designers have no foresight, leading to endless trouble.
The problem is more than that, IBM pc/at system space, in the theory of addressing, can have 1MB (temporarily do not need to consider memory expansion and EMS, etc.), but really can provide as a program execution space, but less than 600KB.

We also look at the arrangement of its system space:
0000H segment 0000H-007FH 128 characters, for 32 basic interrupts.
0008H segment 0000h-0380h 896 characters, for system management interruption.
0040H section 0000H-00FFH 256 characters, for basic program data.
0054H segment 0000h-9c00h about 34K characters, DOS program occupancy.
Only the first half of the -09000h section of the 00E1H segment is the space that the user can control, and then the system takes over:
The 09000H segment is used for DOS by the vicinity of 0a000h until 0FFFFH.
0a000h section, for VGA graphics display area.
0a800h segment, for EGA graphics display area.
0b000h segment, for the text state buffer, the screen processor 6845 is automatically managed.
0b800h segment, for graph morphological display area, screen processor 6845 automatic management.
0c000h section, to the 0d000h segment, the various machines are variable, for the EMS expansion of memory.

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.