When was assembler and machine language created? Assembly programming language Assembly language for different processors.


Programming language

Assembler is a low-level programming language, which is a format for recording machine commands that is convenient for human perception.

Assembly language commands correspond one to one to processor commands and, in fact, represent a convenient symbolic form of recording (mnemonic code) of commands and their arguments. Assembly language also provides basic programming abstractions: linking program parts and data through symbolically named labels and directives.

Assembly directives allow you to include blocks of data (described explicitly or read from a file) into a program; repeat a certain fragment a specified number of times; compile the fragment according to the condition; set the execution address of a fragment, change the values ​​of labels during the compilation process; use macro definitions with parameters, etc.

Each processor model, in principle, has its own set of instructions and a corresponding assembly language (or dialect).

Advantages and disadvantages

  • minimal amount of redundant code (use of fewer instructions and memory accesses). The result is greater speed and smaller program size.
  • large amounts of code, a large number of additional small tasks
  • poor code readability, difficult to support (debugging, adding features)
  • the difficulty of implementing programming paradigms and any other somewhat complex conventions, the difficulty of joint development
  • fewer available libraries, their low compatibility
  • direct access to hardware: I/O ports, special processor registers
  • the ability to write self-modifying code (i.e. metaprogramming, without the need for a software interpreter)
  • maximum “fit” for the desired platform (use of special instructions, technical features of hardware)
  • non-portability to other platforms (except binary compatible ones).

Syntax

There is no generally accepted standard for the syntax of assembly languages. However, there are de facto standards - traditional approaches that most assembly language developers adhere to. The main such standards are Intel syntax and AT&T syntax.

The general format for recording instructions is the same for both standards:

`[label:] opcode [operands] [;comment]`

An opcode is a direct mnemonic of instructions to the processor. Prefixes can be added to it (repetitions, changes in addressing type, etc.). The operands can be constants, register names, addresses in RAM, etc. The differences between the Intel and AT&T standards relate mainly to the order in which the operands are listed and their syntax for different addressing methods.

The mnemonics used are usually the same for all processors of the same architecture or family of architectures (among the widely known are mnemonics for Motorola, ARM, x86 processors and controllers). They are described in the processor specifications.

For example, the Zilog Z80 processor inherited the Intel i8080 instruction system, expanded it and changed the mnemonics (and register designations) in its own way. For example, I changed Intel's mov to ld. Motorola Fireball processors inherited the Z80 instruction system, cutting it down somewhat. At the same time, Motorola has officially returned to Intel mnemonics. and at the moment, half of the assemblers for Fireball work with Intel mnemonics, and half with Zilog mnemonics.

Directives

In addition to instructions, a program may contain directives: commands that are not translated directly into machine instructions, but control the operation of the compiler. Their set and syntax vary significantly and depend not on the hardware platform, but on the compiler used (generating dialects of languages ​​within the same family of architectures). The set of directives includes:

  • definition of data (constants and variables)
  • managing program organization in memory and output file parameters
  • setting the compiler operating mode
  • all kinds of abstractions (i.e. elements of high-level languages) - from the design of procedures and functions (to simplify the implementation of the procedural programming paradigm) to conditional constructs and loops (for the structured programming paradigm)
  • macros

Origins and criticism of the term "assembly language"

This type of language gets its name from the name of the translator (compiler) from these languages ​​- assembler (English assembler). The name of the latter is due to the fact that on the first computers there were no higher-level languages, and the only alternative to creating programs using assembler was programming directly in codes.

Assembly language in Russian is often called "assembler" (and something related to it "assembler"), which, according to the English translation of the word, is incorrect, but fits into the rules of the Russian language. However, the assembler itself (the program) is also called simply “assembler” and not “assembly language compiler”, etc.

The use of the term "assembly language" may also lead to the misconception that there is a single low-level language, or at least a standard for such languages. When naming the language in which a specific program is written, it is advisable to clarify what architecture it is intended for and what dialect of the language it is written in.

Syntax elements:

Examples:

Hello, World!:

Example for Intel x86 (IA32) versions

mov ax , cs mov ds , ax mov ah , 9 mov dx , offset Hello int 21h xor ax , ax int 21h Hello : db "Hello World !", 13, 10, "$"

Hello, World!:

Example for Amiga versions

move. l #DOS move . l 4. w , a6 jsr - $0198(a6) ; OldOpenLibrary move . l d0 , a6 beq . s. Out move. l #HelloWorld , d1 A ) moveq #13, d2 jsr - $03AE (a6 ) ; WriteChars B ) jsr - $03B4 ; PutStr move . l a6, a1 move. l 4. w , a6 jsr - $019E (a6 ) ; CloseLibrary. Out rts DOS dc. b "dos.library" , 0 HelloWorld dc . b "Hello World!" , $A , 0

Hello, World!:

Example for AtariST versions

move. l #helloworld , - (A7 ) move #9, - (A7 ) trap #1 addq . l #6, A7 move #0, - (A7 ) trap #1 helloworld : dc . b "Hello World !", $0d , $0a , 0

Hello, World!:

Example for Intel x86 (IA32) versions

NASM Linux, Intel syntax is used. Compilation and linking:

  • nasm –f elf –o hello.o hello.asm
  • ld -o hello hello.o

SECTION. data msg db "Hello , world !", 0xa len equ $ - msg SECTION . text global _start _start : ; Program entry point mov eax, 4; "write" system call mov ebx, 1 mov ecx, msg; Pointer to data mov edx, len; Number of data int 0x80 ; Kernel call mov eax, 1; "_exit" system call mov ebx , 0 ; Return 0 (everything is good) int 0x80 ; Calling the kernel

Hello, World!:

Example for PDP-8 versions

/ - comments.

/Hello World in assembler for DEC PDP - 8 * 200 hello , cla cll tls /tls sets the print flag. tad charac / creates index register dca ir1 / to receive characters tad m6 / set up counter for dca count / character input. next , tad i ir1 / get symbol. jms type / its type. isz count / do anything else? jmp next / no, enter another character hlt type , 0 / subroutine type tsf jmp . - 1 tls cla jmp i type charac , . / is used as the initial value of ir1. 310 / H 305 / E 314 / L 314 / L 317 / O 254 / , 240 / 327 / W 317 / O 322 / R 314 / L 304 / D 241 / ! m6 , - 15 count , 0 ir1 = 10 $

Hello, World!:

Example for PDP-11 versions

The program is written in the MACRO-11 macro assembler. To compile and run this program in the RT-11 OS, we command:

MACRO HELLO

ERRORS DETECTED: 0

LINK HELLO -- Link. RUN HELLO -- Launch

TITLE HELLO WORLD ; Name . MCALL. TTYOUT,. EXIT HELLO :: MOV #MSG , R1 ; Starting address of line 1$: MOVB (R1) + , R0 ; We get the next symbol BEQ DONE ; If zero, we exit the loop. TTYOUT ; Otherwise we print the symbol BR 1$ ; Repeat cycle DONE: . EXIT MSG: . ASCIZ /Hello, world!/; The line Hello, world! . END HELLO ; End of the HELLO program

Hello, World!:

Example for versions System/360, System/370

IBM System/360/370/390 Basic Assembler Language.

// EXEC ASSEMBLY START MAIN BALR 2, 0 USING *, 2 OPEN PRINT MVC BUF, HW PUT PRINT CLOSE PRINT EOJ HW DC CL132 "HELLO WORLD" BUF DS CL132 PRINT DTFPR IOAREA1 = BUF, DEVADDR = SYSLST, BLKSIZE = 132, * DEVICE = 3203 , CONTROL = YES , PRINTOV = YES END MAIN /* // EXEC LNKEDT // EXEC /* /&

Hello, World!:

Example for Apple II versions

* HELLO WORLD FOR 6502 APPLE ][ * ******************************** STROUT EQU $DB3A LDY #> HELLO LDA #< HELLO JMP STROUT HELLO ASC "HELLO WORLD !", 00

Hello, World!:

Example for PDP-10 versions

CHTTYO - All I/O is done using I/O channels. It's best to make symbolic names for the channels you use and start them with CH. Define these names using the MIDAS operator == .

CALL is a symbolic notation for calling a system call. Its format is .CALL.

OPEN opens an I/O channel for use. Requires two parameters - channel number and device name in SIXBIT.

LOSE %LSFIL is a system call that prints an I/O error message if it suddenly occurs.

IOT is a system call that actually handles I/O. As a parameter, you need to specify the channel and address containing the symbol code for output. For example, “H represents H.

TITLE PRINTHELLO A = 1 CHTTYO == 1 ; Output channel. START: ; Opening a TTY channel. . CALL [ SETZ ? SIXBIT/OPEN/[. UAO, CHTTYO]? [SIXBIT/TTY/] ((SETZ))] . LOSE %LSFIL . IOT CHTTYO ,[ "H ] ; Print HELLO WORLD character by character. . IOT CHTTYO ,[ "E ] . IOT CHTTYO ,[ "L ]. IOT CHTTYO ,[ "L ] . IOT CHTTYO ,[ "O ] . IOT CHTTYO ,[ ^M ] ; Newline character . IOT CHTTYO ,[ "W ] . IOT CHTTYO ,[ "O ]. IOT CHTTYO ,[ "R ] . IOT CHTTYO ,[ "L ]. IOT CHTTYO ,[ "D ] . VALUE ; Program, stop :) END START

Fibonacci numbers:

Example for MIPS32 versions

MARS emulator. MARS console output:

The Fibonacci numbers are: 1 1 2 3 5 8 13 21 34 55 89 144 -- program is finished running --

The program displays 15 Fibonacci numbers. The number of numbers can be changed in the .data section.

Data space: .asciiz " " head: .asciiz "The Fibonacci numbers are:\n" fib: .word 0 : 15 size : .word 15 .text main: la $t0 , fib la $t5 , size lw $t5 , 0 ($t5 ) li $t2 , 1 add.d $f0 , $f2 , $ f4 sw $t2 , 0 ($t0 ) sw $t2 , 4 ($t0 ) addi $t1 , $t5 , - 2 loop : lw $t3 , 0 ($t0 ) lw $t4 , 4 ($t0 ) add $ t2 , $t3 , $t4 sw $t2 , 8 ($t0 ) addi $t0 , $t0 , 4 addi $t1 , $t1 , - 1 bgtz $t1 , loop la $a0 , fib move $a1 , $t5 jal print li $v0 , 10 syscall print : add $t0 , $zero , $a0 add $t1 , $zero , $a1 la $a0 , head li $v0 , 4 syscall out : lw $a0 , 0 ($t0 ) li $v0 , 1 syscall la $a0 , space li $v0 , 4 syscall addi li $v0 , 1 la $a0 , ($t2 ) syscall la $a0 , string1 li $v0 , 4 syscall mult $t1 , $t2 mflo $ t1 li $v0 , 1 la $a0 , ($t1 ) syscall la $a0 , string2 li $v0 , 4 syscall addiu $t2 , $t2 , 1 beq $t2 , 16 , endloop j loop endloop: li $v0 , 10 syscall



Assembler (asm, assembler); from English assemble - assemble, mount) - a low-level programming language, an auxiliary program as part of the operating system for automatically translating the source program to be executed on a computer into machine language; type of translator. Assembly language concepts reflect the architecture of an electronic computer. Assembly is a symbolic form of machine language recording, the use of which simplifies the writing of machine programs. Different assembly languages ​​can be developed for the same computer. Unlike high-level languages, in which the problems of implementing algorithms are hidden from developers, assembly language is closely related to the computer's instruction system. The assembler provides access to registers, specification of addressing methods, and description of operations in terms of processor instructions. It may contain higher-level tools: built-in and defined macros corresponding to several machine instructions, automatic command selection depending on the types of operands, and tools for describing data structures.

Features of the assembler

An assembler is also a compiler that converts assembly language into machine language instructions. Another name for such a compiler is mnemonic code. It is designed to represent machine command codes in a convenient (mnemonic) form and ensures efficient use of system resources (processor, memory, peripherals). Mnemonic code is used in places where performance is required and the size of RAM is limited. Assembly language is also sometimes called the instruction system of the central processor.

Each processor architecture and each operating system has its own assembler. Cross assemblers allow you to assemble programs for another architecture or another operating system on machines with one architecture. The assembler provides access to registers, specification of addressing methods, and description of operations in terms of processor instructions. An assembler may contain high-level tools: built-in and defined macro instructions corresponding to several machine instructions, automatic command selection depending on the types of operands, and tools for describing data structures.

Assembly language commands correspond to processor commands and represent a symbolic form of writing commands and arguments. The assembly language provides the linking of program parts and data through labels, which is performed during assembly (an address is calculated for each label, after which each occurrence of the label is replaced by this address). Since microprocessor instruction systems differ, each processor has its own set of assembly language instructions and its own assembly compilers.

Typically, programs or sections of code are written in assembly language in cases where the developer needs to optimize performance (when creating drivers) and code size. Most compilers allow you to combine code written in different programming languages ​​in one program. This allows you to write complex programs using a high-level language without losing performance in time-critical tasks, using parts written in assembly language for them. Combination is achieved by inserting fragments in assembly language into the program text (special language directives) or writing procedures in assembly language. This method is used for simple data transformations, but it is not applicable in full assembly code with data and routines with many inputs and outputs that are not supported by high-level languages.

In this case, modular compilation is used, when each program file is compiled into an object module, which are then linked into a finished program. Object files are blocks of machine code and data, with undefined reference addresses to data and procedures in other object modules, as well as a list of their procedures and data. The linker collects the code and data of each object module into the program, calculates and fills cross-reference addresses between modules. During the linking process, the program is linked with static and dynamic libraries (which are archives of object files). With modular compilation, each object module of the program can be written in its own programming language and compiled with its own compiler (assembler).

1. When and by whom were counting and punching machines invented? What problems were solved on them?

2. What is an electromechanical relay? When were relay computers created? How fast were they?
3. Where and when was the first computer built? What was it called?
4. What was the role of John von Neumann in the creation of the computer?
5. Who was the designer of the first domestic computers?
6. On what elemental base were the first generation machines created? What were their main characteristics?
7. On what element base were the second generation machines created? What are their advantages compared to the first generation of computers?
8. What is an integrated circuit? When were the first integrated circuit computers created? What were they called?
9. What new areas of computer application have arisen with the advent of third-generation machines?
10. What is a microprocessor? When and where was the first microprocessor created?
11. What is a microcomputer and a personal computer?
12. What types of PCs are most common in the world?
13. What is a supercomputer?
14. What are PC cluster systems?
15. What are the features of fifth generation computers?

Name the first computing device. Abacus Calculator Adding machine Russian abacus What idea did he put forward in the middle

19th century English mathematician Charles Babbage?

The idea of ​​​​creating a program-controlled calculating machine with an arithmetic device, a control device, as well as an input and printing device

The idea of ​​creating a cell phone

The idea of ​​creating computer-controlled robots

In what year and where was the first computer based on vacuum tubes created?

1945, USA

1944, England

1946, France

On what basis were third generation computers created?

Integrated circuits

semiconductors

vacuum tubes

ultra-large-scale integrated circuits

What was the name of the first personal computer?

Name the central device of the computer.

CPU

System unit

power unit

Motherboard

The processor processes the information presented:

In decimal number system

In English

In Russian

In machine language (in binary code)

To enter numeric and text information, use

Keyboard

The scanner is used for...

For entering images and text documents into a computer

For drawing on it with a special pen

Moving the cursor on the monitor screen

Obtaining holographic images

10. What type of printer is appropriate to use for printing financial documents?

Matrix printer

Jet printer

Laser printer

What type of printer is appropriate to use for printing abstracts?

Matrix printer

Jet printer

Laser printer

What type of printer is appropriate to use for printing photos?

Matrix printer

Jet printer

Laser printer

Failure to comply with the sanitary and hygienic requirements of a computer can have a harmful effect on human health...

Cathode ray tube monitor

LCD monitor

Plasma panels

When you turn off your computer, all information is erased from...

Random access memory

Hard drive

laser disk

In what computer device is information stored?

External memory;

CPU;

The optical tracks are thinner and placed more densely on...

Digital video disc (DVD disc)

Compact disk (CD-disk)

Input devices include...

Output devices include...

Keyboard, mouse, joystick, light pen, scanner, digital camera, microphone

Speakers, monitor, printer, earphone

Hard drive, processor, memory modules, motherboard, floppy disk

The program is called...

A computer program can control the operation of a computer if it is...

In RAM

On a floppy disk

On hard drive

On CD

Data is...

The sequence of commands that a computer executes while processing data

Information presented in digital form and processed on a computer

Data that has a name and is stored in long-term memory

The file is...

Text printed on a computer

Information presented in digital form and processed on a computer

A program or data that has a name and is stored in long-term memory

When quickly formatting a floppy disk...

The disk directory is being cleared

All data is erased

Disk defragmentation in progress

The disk surface is being checked

When fully formatting a floppy disk...

all data is erased

a full disk scan is performed

The disk directory is being cleaned

the disk becomes system

In a multi-level hierarchical file system...

Files are stored in a system that is a system of nested folders

Files are stored in a system that is a linear sequence

History of the development of computer technology:

1. Name the first computing device.
1) Abacus
2) Calculator
3) Arithmometer
4) Russian abacus

2. What idea was put forward by the English mathematician Charles Babbage in the mid-19th century?
1) The idea of ​​​​creating a program-controlled calculating machine with an arithmetic device, a control device, as well as an input and printing device
2) The idea of ​​​​creating a cell phone
3) The idea of ​​​​creating computer-controlled robots
3. Name the first computer programmer.
1) Ada Lovelace
2) Sergey Lebedev
3) Bill Gates
4) Sofya Kovalevskaya

4. In what year and where was the first computer based on vacuum tubes created?
1) 1945, USA
2) 1950, USSR
3) 1944, England
4) 1946, France

5. On what basis were third generation computers created?
1) Integrated circuits
2) semiconductors
3) vacuum tubes
4) ultra-large-scale integrated circuits

6. What was the name of the first personal computer?
1) Apple II
2) IBM PC
3) Dell
4) Corvette
Computer structure........................15
1. Name the central device of the computer.
1) Processor
2) System unit
3) Power supply
4) Motherboard
2. How is physical information recorded and transmitted to a computer?
1) numbers;
2) using programs;
3) is represented in the form of electrical signals.

3. The processor processes the information presented:
1) In the decimal number system
2) In English
3) In Russian
4) In machine language (in binary code)
4. To enter numeric and text information, use
1) Keyboard
2) Mouse
3) Trackball
4) Handle
5. The most important characteristic of coordinate input devices is resolution, which is usually 500 dpi (dot per inch (1 inch = 2.54 cm)), which means...
1) When you move the mouse one inch, the mouse pointer moves 500 points
2) When moving the mouse 500 points, the mouse pointer moves one inch
6. The scanner is used for...
1) For entering images and text documents into a computer
2) To draw on it with a special pen
3) Moving the cursor on the monitor screen
4) Obtaining holographic images
Output devices................................21
1. What type of printer is appropriate to use for printing financial documents?
1) Dot matrix printer
2) Inkjet printer
3) Laser printer
2. What type of printer is appropriate to use for printing abstracts?
1) Dot matrix printer
2) Inkjet printer
3) Laser printer

1. What type of printer is appropriate to use for printing photos?
1) Dot matrix printer
2) Inkjet printer
3) Laser printer
2. Failure to comply with the sanitary and hygienic requirements of the computer can have a harmful effect on human health...
1) Cathode ray tube monitor
2) Liquid crystal monitor
4) Plasma panels
3. A device that provides recording and reading of information is called...
1) Disk drive or storage device

4. When you turn off the computer, all information is erased from...
4) RAM
5) Hard drive
6) Laser disk
7) Floppy disks
13. In what computer device is information stored?
1) External memory;
2) monitor;
3) processor;
2. Optical tracks are thinner and placed more densely on...
1) Digital video disc (DVD disc)
2) Compact disk (CD - disk)
3) Floppy disk
3. On which disk is information stored on concentric tracks on which magnetized and non-magnetized areas alternate?
1) On a floppy disk
2) On CD
3) On DVD

4. Input devices include...

1) Hard drive, processor, memory modules, motherboard, floppy disk
5. Output devices include...
1) Keyboard, mouse, joystick, light pen, scanner, digital camera, microphone
2) Speakers, monitor, printer, earphone
3) Hard drive, processor, memory modules, motherboard, floppy disk
6. A program is called...

7. A computer program can control the operation of a computer if it is located...
1) In RAM
2) On a floppy disk
3) On the hard drive
4) On a CD
8. Data is...
1) The sequence of commands that the computer executes during data processing
2) Information presented in digital form and processed on a computer
3) Data that has a name and is stored in long-term memory
9. A file is...
1) Text printed on a computer
2) Information presented in digital form and processed on a computer
3) A program or data that has a name and is stored in long-term memory

10. When quickly formatting a floppy disk...
1) The disk directory is being cleaned
2) All data is erased
3) The disk is being defragmented
4) A check is carried out according to

Assembler

Assembler― low-level programming language. The language gets its name from the word assembler - assembler. It arose back in the 50s. as a symbolic analogue of machine language.
Assembler commands correspond one to one to processor commands and, in fact, represent a convenient symbolic form for writing commands and arguments. Also, the assembler provides linking of program parts and data through labels, which is performed during assembly (an address is calculated for each label, after which each occurrence of the label is replaced with this address).
Since microprocessor instruction systems vary, each processor has its own set of assembly language instructions.
Using assembler you can write programs that are impossible or very difficult to write in other programming languages. For example: key generators (keygen), system monitors, hardware drivers or even operating systems.
High-level languages ​​("C", "Pascal", "Delphi", etc.) do not provide reliable control over data flows, memory addresses or processor registers, and they were all developed for a specific type of operating system, while assembler can to become the same assembler, but working on a platform unknown to science, and making programs for this same platform.
Programs in assembler, in contrast to programs written in high-level languages, are ten times smaller and run ten times faster. An example is the MenuetOS operating system, which is written in Flat Assembler and fits on one floppy disk (1.44 MB), and the kit includes application programs, such as: a backlit assembly code editor, working with the file system, 3D screensavers, a number of games, image viewer, Flat Assembler compiler, terminal, CD player and much more. The advantage is that it can be quickly downloaded from the Internet (even with a low connection speed).
Nowadays, most software professionals develop in high-level languages ​​such as Pascal or C, which are easier to write programs, but the most powerful and efficient software is written entirely or partially in assembly language.

Literature
1. Peter Abel - Assembler. Language and programming for IBM PC - M., 1999.

Assembler

Assembler(from the English assembler - assembler) - a compiler of the source text of a program written in assembly language into a program in machine language.
Like the language itself, assemblers are typically specific to a particular architecture, operating system, and variant of language syntax. At the same time, there are multi-platform or even universal (more precisely, limited-universal, because it is impossible to write hardware-independent programs in a low-level language) assemblers that can run on different platforms and operating systems. Among the latter, one can also distinguish a group of cross-assemblers capable of collecting machine code and executable modules (files) for other architectures and operating systems.
Assembly may not be the first or the last step on the path to obtaining an executable program module. Thus, many compilers from high-level programming languages ​​produce the result in the form of an assembly language program, which is further processed by the assembler. Also, the result of assembly may not be an executable, but an object module containing disparate blocks of machine code and program data, from which (or from several object modules) an executable file can later be obtained using a link editor.
Special memory cells located directly in the processor. Working with registers is much faster than working with RAM cells, so registers are actively used both in assembly language programs and in high-level language compilers.
The names of the registers come from their purpose:

EAX/AX/AH/AL (accumulator register) - battery;
EBX/BX/BH/BL (base register) - base register;
ECX/CX/CH/CL (counter register) - counter;
EDX/DX/DH/DL (data register) - data register;
ESI/SI (source index register) - source index;
EDI/DI (destination index register) - receiver (recipient) index;
ESP/SP (stack pointer register) - stack pointer register;
EBP/BP (base pointer register) - stack frame base pointer register.

String Processing Commands
To work with strings, or chains of characters or numbers (i.e., simply put, with arrays of arbitrary data), MP provides a number of special commands:
movs - forwarding a string;
cmps - comparison of two strings;
seas - search in a string for a given element;
lods - loading the accumulator (AL or AX registers) from a line;
stos - writing a string element from the accumulator (AX or AL registers).

Advantages

· Assembly language allows you to write the fastest and most compact code possible for a given processor.
· Speed ​​of operation - due to optimization of the computational algorithm and/or more rational access to RAM (for example, if all source data is stored in processor registers, then unnecessary access to the OP can be eliminated), data redistribution, table calculation of functions;
· Code volume (including due to the effective use of intermediate results). Reducing the amount of code also often increases the speed of program execution.
· Ensuring maximum use of the specific capabilities of a particular platform, which also allows you to create more efficient programs, including less resource-intensive ones.
· When programming in assembly language, direct access to the hardware is possible, and, in particular, input/output ports, processor registers, etc. In many operating systems, direct access from application programs to write to registers of peripheral equipment is blocked for the reliability of system operation and the exception of " freezes."
· Assembly language is often used to create hardware drivers and operating system kernels when timing coordination of peripheral devices with the central processor is important.
· Assembly language is used to create BIOS "firmware".
· Using assembly language, machine-dependent compiler routines and high-level language interpreters are often created, and platform compatibility is also implemented.
· Using a disassembler program, you can understand the algorithms of the program under study in the absence of listing in a high-level language, studying only machine codes, but in complex non-trivial programs this is very, very labor-intensive.

Flaws
· Due to the machine orientation ("low" level) of assembly language, it is more difficult for a person to read and understand a program in it compared to high-level programming languages; the program consists of too “small” elements - machine commands; accordingly, programming and debugging become more complicated, labor intensity and the likelihood of introducing errors increase.
· Increased programmer skill is required to produce high-quality code: code written by an average programmer in assembly language usually turns out to be no better or even worse than the code generated by an optimizing compiler for comparable programs written in a high-level language.
· A program in a high-level language can be recompiled with automatic optimization for the features of the new target platform, while a program in assembly language on a new platform can lose its speed advantage without manual rewriting of the code.
· As a rule, fewer available libraries compared to modern industrial programming languages.
· There is no portability of programs to computers with a different architecture and command system.

Compatibility
A program designed for one type of assembler cannot be compiled in another without radical rework or automatic conversion! But even among assemblers of “their” type, there is confusion, inconsistency and many differences: in keywords, in listing design rules, in supplied libraries and header files, etc. Unless compatibility is explicitly stated, the program should be translated by those and only those assembler for which it is intended. Otherwise, get ready for alterations (that is, for adaptation). Differences often appear in the most unexpected places. Some assemblers understand that "mov eax, x" is the same as "mov eax,[x]", some do not. They stumble and throw an error. But nothing yet! It’s much worse when the translator silently interprets this construction as “mov eax, offset x”, which is not the same thing at all! So when transferring a program you have to be very, very careful.

Operating system compatibility. Programs targeting MS-DOS are not only not transportable, but also unportable. They are characterized by direct interaction with hardware, accessible in NT only from the kernel level, not to mention the fact that 16-bit code is called from 32-bit applications only through DPMI, and even then not without tricks.

Thus, before translating an assembly program, it is necessary to identify which translator and operating system it is intended for! With assembly fragments snatched from their “native” context, it’s even worse. Let's say that some article describes an interesting anti-debugging technique and provides assembly code, but does not say how to integrate it into your program. A familiar situation, isn't it? Direct broadcasting is impossible - the broadcaster swears wildly, but says nothing.

Assembling the program

The prepared text is the source data for special programs called assemblers. The task of assemblers is to convert program text into the form of binary instructions that can be executed by a microprocessor. If syntax errors are detected, the resulting code will not be generated. The process of creating an executable file occurs in two stages:

Asm --> .obj --> .exe/.dll/.com

At the first stage (.asm --> .obj), intermediate object code files with the .obj extension are obtained from the assembly file by compilation (additional inc files can be used). A file with the .obj extension contains optimized machine code, provided there are no syntax or semantic errors. If errors are detected in the source file with an assembly language program, the programmer is given a list of detected errors, in which the errors are indicated with the line number in which they were found. The programmer cycles through editing and compiling steps until all errors in the source file are eliminated. At this stage, it is already possible to obtain a finished program, but most often it is missing some components. If the compiler for some reason (the path to such a file is incorrectly specified or the file is missing) cannot find the inc file, then a warning is issued and the obj file will not be received.

Assembly, as a rule, takes place in two steps. During the first pass, mnemonic commands, decimal numbers and symbols are translated into the corresponding machine codes, how much space each command takes up is calculated, the detected names entered by the user (constants, labels, variables), their type and numeric value are recorded in the table. The same table records from which addresses the procedures begin, the addresses of labels, the addresses of the beginning/end of segments, etc.; on the second pass, the addresses of the beginning of procedures are substituted, and the names of labels are replaced with addresses.

As a result of assembly, a so-called “object file” is obtained. As an additional feature, the assembler can create a program listing file.

Typically, to obtain object code files, you need to run the appropriate assembler program (the ML.EXE program from Microsoft and TASM.EXE from Borland), specifying the name of the file with the program text on the command line.

This form of invocation is the minimum required. In addition to the name of the text file, it is necessary to specify assembly options. For more information about assembly program options, consult the documentation for those programs.

Program layout

The next stage (.obj --> .exe/.dll/.com) is called linking or linking and serves to replace the symbolic names used by the programmer with real addresses.

Compare the hexadecimal contents of the OBJ and EXE file you have. The EXE file contains the same sequence of bytes as the OBJ file. But besides this, there is also: the name of the assembled file, the assembler version, the “proper name” of the segment, and so on.

This is “service” information intended for those cases when you want to assemble your executable file from several. When developing large applications, the source text usually consists of several modules (files with source texts), because storing all the texts in one file is inconvenient and difficult to navigate.

Each module is compiled separately into a separate file with object code. Each of these files contains its own code/data/stack segments, which then need to be combined into one. And we need to get only one executable file - with a single code/data/stack segment. This is exactly what LINK does: it completes the definition of address links and combines, if necessary, several program modules into one. And this one is executable for us.

In addition, to our modules we need to add machine code for subroutines that implement various standard functions (for example, calculating the mathematical functions SIN or LN). Such functions are contained in libraries (files with the standard .LIB extension), which are either supplied with the compiler or created independently. Therefore, the preparation process necessarily includes an assembly stage, when all unknown addresses of shared variables or functions are determined during separate assembly.

The process of combining object modules into one file is carried out by a special linker or assembler program (LINK.EXE program from Microsoft and TLINK.EXE from Borland), which links object modules and machine code of standard functions, finding them in libraries, and generates a workable output application - executable code for a specific platform.

Executable code is a complete program with a COM, DLL, or EXE extension that can be run on a computer running the operating system for which the program was created. The name of the executable file will be given by the name of the first .OBJ file. To link, you need to type in the command line:

link prog1.obj prog2.obj or tlink prog1.obj prog2.obj

The contents of the object file are parsed by the linker. It determines whether the program contains external links, that is, whether the program contains instructions for calling procedures located in one of the object module libraries (link libraries). The linker finds these references in the object file, copies the necessary procedures from the libraries, combines them together with the object file, and creates an executable file. As an additional feature, the linker can create a cross-reference file containing the outline of the resulting executable.

Sources used
1. https://ru.wikipedia.org/
2. http://natalia.appmat.ru/
3. http://www.codenet.ru/
4. http://wasm.ru/
5. Norton P., Souhe D. Assembly language for the IBM PC. M.: Computer, 1992.







2024 gtavrl.ru.