State Budgetary and Educational Institution

Item: Informatics

Essay

Subject: History of programming languages.

Assembler.

Completed: 8th grade student,

secondary school No. 1467

Sorokin Nikolay

Supervisor: Tsvetkova Oksana Mikhailovna

Introduction

With the increase in the volume of calculations, the first portable calculating instrument appeared - “Abacus”.

At the beginning of the 17th century, the need for complex calculations arose. calculating devices were required that could perform a large volume of calculations with high accuracy. In 1642, the French mathematician Pascal designed the first mechanical calculating machine, the Pascalina.

In 1830, the English scientist Babage proposed the idea of ​​the first programmable computer(“Analytical Engine”). It had to be powered by steam, and the programs were encoded onto punch cards. It was not possible to implement this idea, since it was not possible to make some parts of the machine.

The first one implemented the idea of ​​Hollerith punch cards. He invented a machine for processing census results. In his machine, he was the first to use electricity for calculations. In 1930, the American scientist Bush invented the differential analyzer - the world's first computer.

The second revolution gave a big impetus to the development of computer technology. World War. The military needed a computer, which became the Mark-1 - the first in the world digital computer, invented in 1944 by Professor Aiknam. It used a combination of electrical signals and mechanical drives. Dimensions: 15 X 2.5 m, 750,000 parts. She could multiply two 23-bit numbers in 4 seconds.

In 1946, a group of engineers commissioned by the US military department created the first electronic computer, the Eniak. Performance: 5000 addition operations and 300 multiplication operations per second. Dimensions: 30 m long, volume – 85 m3, weight – 30 tons. 18,000 el. were used. lamps

The first machine with a chronic program - "Edsak" - was created in 1949, and in 1951 they created the machine "

Univac” is the first serial computer with a chronic program. This machine was the first to use magnetic tape for recording and storing information.

What is a programming language for?

Computers appeared in our world a long time ago, but only recently have they begun to be used so intensively in many areas of human life. Just ten years ago it was rare to see any Personal Computer- they existed, but they were very expensive, and not even every company could have a computer in its office. And now? Now every third home has a computer, which has already deeply entered the lives of the inhabitants of the house themselves.

The very idea of ​​creating artificial intelligence appeared a long time ago, but only in the 20th century did it begin to be put into practice. First there were huge computers, which were often the size of a huge house. Using such machines, as you yourself understand, was not very convenient. But what can you do? But the world did not stand at one place of evolutionary development - people changed, their habitat changed, and with it the technologies themselves changed, becoming more and more improved. And computers became smaller and smaller in size until they reached the size they are today.

But a person also needs to somehow communicate with the machine - after all, who needs an uncontrollable machine? At first, people communicated with computers using punched cards. Punch cards are small cards with rows of numbers printed on them. The computer had a “disk drive” into which the cards themselves were inserted and with the help of small needles it made holes on the numbers. Few people enjoyed such communication - after all, it is not very convenient to carry around heaps of punched cards, which had to be thrown away after one use.

But, like other technologies, the process of human communication with artificial intelligence has undergone some changes. Now a person conducts his conversation with a computer using a keyboard and mouse. This is quite convenient and sometimes even brings pleasure to the person.

Modern computers represent one of the most significant achievements of human thought, the influence of which on the development of scientific and technological progress can hardly be overestimated. The areas of application of computers are constantly expanding. This is greatly facilitated by the spread of personal computers, and especially microcomputers.

Over the time since the 50s, the digital computer has evolved from a “magical”, but at the same time expensive, unique and overheated pile of vacuum tubes, wires and magnetic cores into a small machine - a personal computer - consisting of millions of tiny semiconductor devices, which are packaged in small plastic boxes.

As a result of this transformation, computers began to be used everywhere. They manage the work cash registers, monitor the operation of car ignition systems, keep track of the family budget, or are simply used as an entertainment complex... But this is only a small part of the capabilities of modern computers. Moreover, the rapid progress of semiconductor microelectronics, which represents the basis of computer technology, indicates that the current level of both the computers themselves and the areas of their application is only a weak semblance of what will come in the future.

Computers are beginning to touch the lives of every person. If you get sick, and if you are sent to a hospital, then once you get there, you will find yourself in a world where people's lives depend on computers (in some modern hospitals you will even meet more computers than the patients themselves, and this ratio will grow over time, outweighing number of patients). Gradually, they are trying to introduce the study of computer technology into school curricula as a compulsory subject, so that a child can know the structure and capabilities of computers from a fairly early age. And in schools themselves (mainly in the West and in America), computers have been used for many years to maintain educational documentation, and now they are used in the study of many academic disciplines that are not directly related to computer technology. Even in elementary schools, computers are being introduced to teach elementary mathematics and physics courses. Microprocessors themselves are no less widespread than computers - they are built into kitchen stoves, dishwashers and even watches.

Games built on microprocessors have become very widespread. Today, the gaming industry occupies a very large part of the market, gradually displacing other entertainment for children. But it is very harmful for a child’s body to sit for hours at a monitor and desperately press keys, since the child may develop a kind of illness - when he has only one thing on his mind - the computer, and nothing else. Children with this disease usually become aggressive if their access to games is limited. Such children immediately lose any desire to do something that is not related to the computer and that is not interesting to them - so they begin to abandon their studies, which leads to not very good consequences.

Already now computers can clearly pronounce various phrases, phrases, play music, etc. A person can now write down some words, sentences and even musical compositions on his computer so that the computer can then play them back at any designated time.

Computers can also interpret spoken language as signals, but they have to perform great job by deciphering what was heard, if the form of communication is not strictly established. After all, the same person can pronounce the same command in several ways, and all the time this command will sound differently; and in the whole world there are billions of people, and everyone pronounces the same command several times different ways. Therefore, at this time it is quite difficult to create a computer that will be controlled using a human voice. Many companies are trying to solve these problems. Some companies are taking small steps towards this goal, but still these steps are still almost imperceptible.

But the speech recognition problem is part of a larger problem called pattern recognition. If computers can recognize patterns well, they will be able to analyze x-rays and fingerprints, as well as many other tasks. useful features(They are already sorting letters now). It should be noted that the human brain copes well with pattern recognition even in the presence of various noises and distortions, and research in this area, aimed at bringing the corresponding computer capabilities closer to human abilities, seems very promising. If computers can recognize speech well enough and respond to it in verbal form, then it will probably be possible to enter programs and data into them in this form. This will allow you to literally tell the computer what it should do and listen to its opinion on this matter, provided, of course, that the instructions given to it are clear, do not contain contradictions, etc.

Oral communication with computers will make it easier to program it, but the unsolved problem remains in what language to communicate with it. Many offer English for these purposes, but it does not have the accuracy and unambiguity necessary from the point of view of a computer and the programs executed in it. Much has already been done in this area, but much remains to be done.

We often complain that other people don't understand us; but so far, personal computers themselves are not able to fully understand us, or understand what we want to say at a glance. And for some period of time we will have to be content with machines that simply follow our instructions, executing them “with millimeter precision.”

To communicate with computers, back in the days of punch cards, programmers of that time used a programming language very similar to modern Assembly. This is a language where all commands received by the computer are written in detail using special words and icons (?).

Nowadays, programming languages ​​are increasingly used high level, which are much easier to work with than with Assembly, since in them one word can replace several commands at once. And besides, most high-level programming languages ​​in the names of commands used when communicating with a computer use equivalents named in English language, which naturally makes programming easier. But they have one drawback compared to languages ​​like Assembler - in Assembler, all commands coming from the program are clearly distributed in the computer’s memory, taking up free space, thereby significantly improving speed; and high-level languages ​​do not know how to do this, and accordingly lose speed of program execution. And in our world today, everyone knows that: “Time is money.”

Although, for now, a computer is inferior to a person in terms of creative activity, because the machine is not yet endowed with such qualities that could help it create something new that was not entered into its memory by the person himself.

Most people seem to consider the terms "computer" and "computer hardware" synonymous and associate them with physical hardware, such as a microprocessor, display, disks, printers, and other devices that attract people's attention when a person sees computer. While these devices are important, they are only the tip of the iceberg. At the initial stage of use modern computer we are not dealing with the computer itself, but with a set of rules, called programming languages, in which the actions that the computer must perform are specified. Important programming language is emphasized by the fact that the computer itself can be considered as a hardware interpreter of a specific language, which is called machine language. To ensure efficient operation of the machine, machine languages ​​have been developed, the use of which presents certain difficulties for humans. Most users do not experience these inconveniences due to the presence of one or more languages ​​designed to improve human-machine communication. The flexibility of a computer is manifested in the fact that it can execute translator programs (generally called compilers or interpreters) to convert programs from user-oriented languages ​​into machine language programs. (In turn, even the programs, games, system shells themselves are nothing more than a fairly simple translator program, which, as it works or plays, uses its commands to access “computer insides and outsides,” translating its commands into machine languages And all this happens in real time.)

Machine languages, assembly languages ​​and

high level languages

Programmers write programs in a variety of programming languages, some of which are directly understandable by the computer, while others require an intermediate translation step. The hundreds of languages ​​available can be classified into three general types:

1. Machine languages

2. Assembly languages

3. High level languages.

Each computer can only understand its own machine language, which is natural language specific computer. It is closely related to its hardware. Machine languages ​​generally consist of sequences of numbers (usually zeros and ones) that are instructions to perform single elementary operations. Machine languages ​​are machine dependent, i.e. a particular machine language can only be used with a certain type of computer. Machine languages ​​are inconvenient for human comprehension.

As computers became more widespread, it became obvious that programming in machine languages ​​hampers the development of computer technology, is very slow, and is too much for most programmers. Instead of a sequence of numbers directly understandable to the computer, programmers began to use English abbreviations to represent elementary operations, which formed the basis of assembly languages. To convert programs written in such languages ​​into machine language, translator programs called assemblers. The conversion occurred at a speed equal to the speed of the computer. With the advent of assembly languages, the use of computers expanded significantly, but large numbers of instructions were still required to implement even the simplest problems. To speed up the programming process, high-level languages ​​were developed in which to perform complex actions it is enough to write one statement. Programs for converting a sequence of statements in a high-level language into machine language are called compilers. In high-level languages, instructions written by programmers often look like plain English text using common mathematical symbols.

One of the high-level languages ​​is the C programming language.

History of the C language

The c language has its origins in two languages, BCPL and B. In 1967, Martin Richards developed BCPL as a language for writing systems software and compilers. In 1970, Ken Thompson used B to create early versions of the UNIX operating system on the DEC PDP-7 computer. in both BCPL and B, variables were not divided into types - each data value occupied one word in memory and the responsibility for distinguishing, for example, between integers and real numbers fell entirely on the shoulders of the programmer.

The C language was developed (based on B) by Dennis Ritchie of Bell Laboratories and was first implemented in 1972 on the DEC PDP-11 computer. C gained fame as the language of the UNIX OS. Today, almost all major OS were written in C and/or C++. Two decades later, C is available on most computers. It is independent of hardware.

In the late 70s, C evolved into what we call "traditional C". In 1983, the American National Computer and Information Processing Standards Committee established a unified standard for this language.

Conclusion

Based on this abstract, we can conclude that our lives are completely permeated computer technologies. It won't be long before computers will be installed everywhere where human presence is needed. But without certain knowledge, communication with a computer will be impossible. And in order to make it work for you you need to know it tongue-tongue programming.

List of used literature

1. Tom Swan “Mastering Turbo Assembler”, Dialectika, Kyiv, 1996

2. Berezin B.I., Berezin S.B. “Beginner programming course”, Dialogue MEPhI, Moscow, 1996

3. Lectures by Nina Viktorovna Komleva on the subject “Programming languages ​​and translation methods”

4. H.M. Deitel, How to program in C, Binom Publishing House, Moscow, 2000.

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 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

extra large 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 used

Keyboard

The scanner is used for...

To enter images into a computer and text documents

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...

Electronic monitor ray tube

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

HDD, processor, memory modules, motherboard, floppy disk

The program is called...

Computer program can control the operation of the computer if it is located...

IN random access memory

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

At quick formatting 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

produced full check disk

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 it is recorded and transmitted physical information on 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

Programming language

Assembler - programming language low level, 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 in this 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 paradigm structured programming)
  • 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 English translation words are incorrect, but fit 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 specify 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 ] ; Symbol new line. 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




First, let's understand the terminology.

Machine code– a system of commands of a specific computer (processor), which is interpreted directly by the processor. The command is typically an integer that is written to a processor register. The processor reads this number and performs the operation that corresponds to this command. This is popularly described in the book How to become a programmer.

Low level programming language(low-level programming language) is a programming language that is as close as possible to programming in machine codes. Unlike machine codes, in a low-level language each command is associated not with a number, but with an abbreviated name of the command (mnemonic). For example, the ADD command is short for ADDITION. Therefore, using a low-level language greatly simplifies writing and reading programs (compared to programming in machine code). A low-level language is processor-specific. For example, if you wrote a program in a low-level language for a PIC processor, you can be sure that it will not work with an AVR processor.

High level programming language is a programming language that is as close as possible to the human language (usually English, but there are programming languages ​​in national languages, for example, the 1C language is based on Russian). The high-level language is practically not tied to a specific processor or operating system (unless specific directives are used).

Assembly language is a low-level programming language in which you write your programs. Each processor has its own assembly language.

Assembler- This special program, which converts (compiles) the source code of your program, written in assembly language, into an executable file (EXE or COM file). To be precise, creating an executable file requires additional programs, not just assembler. But more on that later...

In most cases they say “assembler” and mean “assembly language”. Now you know that these are different things and it’s not entirely correct to say that. Although all programmers will understand you.

IMPORTANT!
Unlike high-level languages, such as Pascal, BASIC, etc., EACH ASSEMBLY has its own ASSEMBLY LANGUAGE. This rule fundamentally distinguishes assembly language from high-level languages. In most cases, you can compile the source code of a program (or simply “source code”) written in a high-level language using different compilers for different processors and different operating systems. It will be much more difficult to do this with assembler sources. Of course, this difference is almost not noticeable for different assemblers that are intended for the same processors. But the fact of the matter is that for EACH PROCESSOR there is ITS OWN ASSEMBLY AND ITS OWN ASSEMBLY LANGUAGE. In this sense, programming in high-level languages ​​is much easier. However, you have to pay for all the pleasures. In the case of high-level languages, we may encounter such things as larger executable file size, worse performance, etc.


In this book, we will only talk about programming for computers with Intel (or compatible) processors. In order to test the examples given in the book in practice, you will need the following programs (or at least some of them):

  1. . Good program, especially for beginners. Includes a source code editor and some other useful things. Works on Windows, although programs are written under DOS. Unfortunately, the program costs money (but it's worth it))). For details, visit http://www.emu8086.com.
  2. – Turbo Assembler from Borland. You can create programs for both DOS and Windows. It also costs money and is currently no longer supported (and Borland no longer exists). In general, it's a good thing.
  3. – Assembler from Microsoft(stands for MACRO assembler, and not Microsoft Assembler, as many uninitiated people think). Perhaps the most popular assembler for Intel processors. Still supported today. Conditionally free program. That is, if you buy it separately, it will cost money. But it is available for free to MSDN subscribers and is included in the software package Visual Studio from Microsoft.
  4. - assembler from Watcom. Like all others, it has advantages and disadvantages.
  5. - has modest capabilities, but has a big plus - it is included in the standard Windows set. Look for it in the WINDOWS\COMMAND or WINDOWS\SYSTEM32 folder. If you don’t find it, then in other folders of the WINDOWS directory.
  6. It is also advisable to have some. Dosovsky won't hurt either file manager, for example Volkov Commander (VC) or Norton Commander (NC). They can also be used to view the hexadecimal codes of a file, but cannot be edited. Free hex editors there are quite a lot on the Internet. Here is one of them: McAfee FileInsight v2.1. The same editor can be used to work with program source codes. However, I prefer to do it with the following editor:
  7. Text editor. Required for writing the source code of your programs. I can recommend free editor PSPad, which supports many programming languages, including Assembly language.
All programs (and sample programs) presented in this book have been tested to work. And it is these programs that are used to implement the example programs given in this book.

And further - source, written, for example, for Emu8086, will be slightly different from code written, for example, for TASM. These differences will be discussed.

Most of the programs given in the book were written for . Firstly, because this assembler is the most popular and is still supported. Secondly, because it comes with MSDN and Microsoft's Visual Studio suite. And thirdly, because I am the proud owner of a licensed copy of MASM.

If you already have any assembler that is not included in the list above, then you will have to figure out its syntax yourself and read the user manual to learn how to work with it correctly. But general recommendations, given in this book, will be valid for any (or almost any) assemblers.