Machine language is a system of instruction sets. This set of instructions, called machine code, is data that the computer's CPU can interpret directly. Machine code is sometimes referred to as native code. The term emphasizes a certain programming language or library, which is related to the platform.
Machine language is a set of machine instructions that can be directly recognized and executed by a computer expressed in binary code. It is the computer's designer who gives the computer's operating functions through the computer's hardware structure.
A cpu command system, also known as the cpu machine language. It is a set of 1 and 0 sequences that the cpu can recognize. Programming in machine language is to select appropriate instructions from a practical cpu instruction system to form a series of instructions.
An instruction is a statement of a machine language. It is a group of meaningful binary codes. The basic format of an instruction is, for example, an operation code field and an address code field. The operation code indicates the operation nature and function of the instruction, and an address code is given. The address of the operand or operand.
To write a program in machine language, the programmer must first memorize the meaning of all instruction codes and codes of the computer used. When programming a program, the programmer has to deal with the storage allocation and input/output of each instruction and each data, and also keep in mind what state the unit of work used in each step of the programming process is. This is a very tedious job. The time it takes to write a program is often tens or even hundreds of times the actual running time. Moreover, the compiled programs are full of 0 and 1 instruction codes, which are poorly intuitive and error-prone. With the exception of computer manufacturer professionals, the vast majority of programmers are no longer learning machine language.
The machine language is understood and used by the microprocessor to control its operating binary code.
The 8086-to-Pentium machine language instruction can be from 1 byte to 13 bytes in length.
Although machine language seems complicated, it is regular.
There are as many as 100,000 machine language instructions. This means that you cannot list all of these categories.
example:
1, the instruction part of the sample
0000 stands for LOAD
0001 represents storage (SET)
. . .
2, the register part of the sample
0000 represents register A
0001 represents register B
. . .
3, the memory part of the sample
000000000000 represents memory with address 0
000000000001 represents memory with address 1
000000001000 represents memory with address 16
100000000000 represents 2^11 memory
4, integration example
0000,0000,000000001000 stands for LOADA,16
0000,0000,000000000001 stands for LOADB,1
0000,0001,000000001000 stands for STOREB, ​​16
0000,0001,000000000001 represents STOREB,1
Machine language defects1. A lot of complicated and trivial details hamper the programmers so that they cannot have more time and energy to engage in creative labor and perform tasks that are more important to them. Such as ensuring the correctness and efficiency of the program.
2. Programmers must not only control the overall design of the program, but also go deep into each part until the details of the implementation. Even intellectually sophisticated programmers often miss out on each other and make mistakes repeatedly. Therefore, the compiled programs have poor reliability and long development cycles. .
3. Since the thinking and expression of programming in machine language are very different from people's habits, only programmers who have been trained for a long time can be competent, making the program design highly rewarding.
4. Because its written form is all "secret" code, it is poor in readability and inconvenient for communication and cooperation.
5. Because it is heavily dependent on a specific computer, it is poor in portability and poor in reusability.
These drawbacks caused the computer application at the time not to be quickly promoted.
After the assembly language program written in assembly language instruction is input into the computer, the computer cannot recognize and execute it. It must be translated by the assembly program provided by the machine into a program composed of machine language instructions before it can be executed by the computer. Usually this translation work does not have to be intervened by humans. This section only briefly introduces the composition of machine language instructions so that readers can perform similar conversion work in real-world applications (real-time control).
The 8086/8088 machine language instruction is a variable-byte instruction, and one instruction can be composed of 1 to 7 bytes, so the instruction format is more flexible. Its format is as follows:
Where opcode is the opcode field; d indicates the operation direction; S indicates sign extension; W indicates operand width; mod is used to distinguish between register or memory addressing; reg register encoding; r/m register or memory; disp- Low displacement low bit; disp-high displacement high bit; data-low immediate low bit; data-high immediate high bit.
The format gives 1~6 bytes. If the instruction shows that the specified segment spans the prefix, it is represented in a machine language instruction by a byte that is placed before the instruction. The format is as follows:
Among them, 001 and 110 are segment prefix flags; SEG specifies one of four segment registers, 00 is ES, 01 is CS, 10 is SS, and 11 is DS.
1, the machine code representation of the operation code
The operation code generally occupies 7~2 bits of the first byte, but the operation code of some instructions occupies 7~1 bits of the first byte, and may even occupy 5~3 bits of the second byte as an expansion operation. code.
In most opcodes, certain bits are often used to indicate certain information. For example, the W bit in the first byte is used to indicate whether the instruction operates on byte (W=1) or on byte (W=0). In a two-operand instruction, the d-bit specification register is used for the destination operand (d=1) or for the source operand (d=0). In addition, in the immediate addressing mode instruction, the S bit represents sign extension. If the immediate number is 8 bits, but it is required to expand to 16 bits, the S bit is 1. The use of the S and W bits in the immediate addressing mode instruction indicates:
2. Addressing machine language representation
In addition to the number of bits occupied by the operation code in the instruction, other bits are used to represent the address of the operand or operand. The 8086/8088 uses an addressing mode byte to indicate the addressing mode of the operand, which is usually the second byte of the machine instruction.
The reg field in the second byte indicates that the addressing mode is a register mode. In the case of a two-operand instruction, a register is specified jointly by reg and the W bit in the first byte as one of the two operands. Operands. Registers designated by the Reg and W bits jointly are shown in Table 6-4-1.
The mod field in the second byte is combined with the r/m field to determine the addressing mode for the other operand. among them:
When Mod=00, it is the memory addressing mode without byte shift. The exact addressing mode is specified by the r/m field. When r/m=110, the direct addressing mode is specified. At this time, the instruction is followed by a 16-bit shift amount D16 to indicate the offset address of the operand.
Mod=01 is a memory addressing method with one byte of displacement. The exact addressing mode is specified by the r/m field. The displacement byte is a signed number, so its range is -128~+127. When the memory address is calculated using this shift amount D8, it will be sign-extended to 16 bits.
Mod=10 is the memory addressing mode with two shift bytes. The exact addressing mode is specified by the r/m field. The first offset byte is the lower 8 bits of the offset and the second offset byte is the upper 8 bits of the offset. This 16-bit displacement is also a signed number, so its range is -32768~+32767. Mod=11 is the register addressing mode. The r/m field indicates the register, which is also the W bit of the first byte to determine a register. The use of the Mod field in conjunction with the r/m field to determine the addressing mode is given in Table 6-4-2.
1.compiledmachinelanguageinstruction
Compiled machine language instructions
2. Aphraseoftenassociatedwithamacroinstruction, whereonesourcelanguageinstructionisconvertedtoseveralmachinelanguageinstructions.
A term commonly associated with macros is the conversion of a source language instruction into a number of machine language instructions.
3.asinglecomputerinstructionthatresultsinaseriesofinstructionsinmachinelanguage.
A single computer instruction can cause a series of machine language instructions.
4.Areportpreparedbyaprocessorwhichshowsthecodingasoriginallywritten,anycommentsthatmayhavebeenwritten,andthemachinelanguageinstructionsproduced.
A report produced by the processor that shows the original written code, comments, and generated machine language instructions.
5.Asingleinstructioninprogramminglanguagethatresultsinaseriesofinstructionsinmachinelanguage.
A command in a computer programming language that can form a series of instructions in a machine language
6.Assembler: Aprogamming languageinwhichonemnemonicsourcestatementiscodedforeachmachine-levelinstruction.
Assembly language: A programming language in which each mnemonic source statement corresponds to a machine instruction.
7.Anassemblerlanguageprogrammerwritesonemnemonicinstructionforeachmachine-levelinstruction.
Assembly language programmers write a mnemonic instruction for each machine instruction.
8.machine-independentcommandlanguage
Machine-independent command language
9.Aprogramthattranslatesinstructionswritteninahighlevelprogramminglanguageintomachinelanguage.
A program that translates instructions written in high-level programming languages ​​into machine language.
10.Aprogramminglanguagewhoseinstructionsareexpressedinsymbolsconvenienttohumansratherthaninmachinelanguage.
A programming language that uses a human-friendly symbol to represent various instructions without using machine language.
11.Aprogramthattranslatesaninstructionintoamachinelanguageandexecutesitbeforeproceedingtothenextinstruction.
The interpreter translates instructions into machine language and completes the program before executing the next instruction
12.(computerscience)aprogramthatdecodesinstructionswritteninahigherorderlanguageandproducesamachinelanguageprogram.
(Computer science) Produces machine language programs using decoded instruction programs written in higher command languages.
13.Otherprogramsthentranslatetheinstructionsintomachinelanguageforthecomputertouse.
Then translate the program into instructions into a machine language for use by the computer.
14.Theprocesswherebyadigitalcomputertranslatestheinstructionsofaprogramwritteninahigh-levellanguageintotheirmachinelanguageequivalents.
The digital computer thereby translates the instructions in a program written in a high-level language into the processing of an equivalent machine language program.
15.Assemblylanguageisactuallyacommand-basedredivsentationoftheactualinstructionsthatyourcomputer'sprocessorruns.
Assembly language is actually a command-form notation of the instructions that your computer processor actually runs.
16.Acomputer-orientedlanguagewhoseinstructionsconsistonlyofcomputerinstructions.
A computer-oriented language whose instructions consist only of computer instructions.
17.Abasicorfundamentalunit,oftenreferringtothelowestofamachineinstructionorlowestunitoflanguagetranslation.
A basic unit or basic unit, often referring to the lowest level of machine instructions or the lowest unit of language translation.
18.Asoftwaredevelopmenttoolthattranslateshuman-readableassemblylanguageprogramsintomachine-languageinstructionsthattheprocessorcanunderstandandexecute.
A software development tool that translates human-readable assembly language programs into machine instructions that the processor can understand and run.
CIXI LANGUANG PHOTOELECTRIC TECHNOLOGY CO..LTD , https://www.cxblueray.com