Hexadecimal code. Abstract: Program for converting a decimal number into binary and hexadecimal number systems Program for converting a decimal number into binary assembler

1. Basic number systems. Data declarations in assembler

Goal of the work: familiarizing students with number systems - binary, octal, hexadecimal; representation of data in computer memory, memory allocation directives.

Theoretical part

The smallest unit of information that can be stored in a computer is bit (eng. bit - bi nary digi t ), i.e. 0 or 1. A bit is an atom of information; it cannot be divided. Bits are grouped in groups of 8 to form a byte. The information manipulated by a computer is a string of binary numbers. From 8 bits, 256 combinations can be formed. These combinations are used to encode large and small letters, numbers, and special characters.

To measure information on a computer, the following quantities are used:

1 Kilobyte = 1 KB = 2 10 bytes = 1024 bytes;

1 Megabyte = 1 MB = 2 20 bytes = 1024 KB;

1 Gigabyte = 1 GB = 2 30 bytes = 1024 MB.

Number systems

A number system is a set of rules and numbers for representing numbers. For any positional number system, the number of digits to be represented is equal to the base of the number system, for example, for the binary system, the base is the number 2, therefore, to represent numbers, two digits 0 and 1 are needed, for the hexadecimal number system it is 0, 1, 2, ..., 9 , A, B, C, D, E, F, where the letters correspond to the values ​​10, 11, 12, 13, 14 and 15 respectively.

To distinguish between number systems, a letter is placed at the end of the number: B for binary, Q for octal, D for decimal, and H for hexadecimal. For a decimal number, D is not required.

If a number is written in the b-ary number system in the form

Nr(b) = C n C n-1 C n-2 … C 2 C 1 C 0 , D 1 D 2 D 3 … ,

then in the decimal number system its value can be represented as the sum of digits multiplied by the base of the number system to a power equal to the position number of the digit in the number (numbering starts from 0, from right to left):

Nr(10) = C n *b n +C n-1 *b n-1 +…+C 2 *b 2 +C 1 *b 1 +C 0 *b 0 +D 1 *b -1 +D 2 * b –2 +D 3 *b –3 +...

For example:

Let two binary numbers 11b, 1100011b be given. Let's convert these numbers to the decimal number system:

11b =1*2 1 +1*2 0 =3;

11100011b = 1*2 7 +1*2 6 +1*2 5 +0*2 4 +0*2 3 +0*2 2 +1*2 1 +1*2 0 = 227.

Let's look at examples of converting an octal number to the decimal number system:

11q = 1*8 1 +1*8 0 = 9;

210q =2*8 2 +1*8 1 +0*8 0 =136.

Example of converting hexadecimal numbers to decimal:

11h = 1*16 1 +1*16 0 =17;

CA0h= C*16 2 +A*16 1 +0*16 0 = 3232

To convert numbers from decimal system in binary or hexadecimal, integer division is used. The number is divided by the base of the number system until an indivisible remainder is obtained. The quotient obtained from division is again divided and the process ends when the quotient also becomes indivisible. The remainders obtained during division are written in reverse order. The diagram shows the conversion of the number 25 to the binary number system, as a result of which we obtain the number 11001b, as well as the conversion of the number 418 to the hexadecimal number system, as a result of which we obtain the number 1A2h, given that the number ten is A.

To convert numbers from the hexadecimal system to the binary system and vice versa, the following fact is used: each hexadecimal digit corresponds to a four-bit binary number and vice versa, as presented in the table. Consequently, when converting from the hexadecimal system to the binary system, it is necessary to write down its binary code for each hexadecimal digit, and when converting back, the binary number is divided from right to left into groups of four digits and the hexadecimal correspondence is written for them.

Table of correspondence between hexadecimal digits and binary numbers.

For example, let's convert the number 1FDh into binary representation:

1FDh = 0001-1111-1101b = 111111101b

Let's convert the binary number 1110100101b into hexadecimal representation: 0011-1010-0101b = 3A5.

Representation of integers in computer memory

The binary number system is used to represent information on a computer. To store integers, a strictly fixed number of bits is used: 8, 16, 32, 64. In n binary positions you can write a signed integer in the range from -2 n-1 to 2 n-1 -1. Positions are numbered from 0 to n-1 from right to left. For example, the number 67 in eight binary positions would be represented as 01000011b. Unsigned numbers can be represented in the range 0 to 2 n -1.

An integer can be stored in two's complement or two's complement form. To represent the sign of a number, a bit called the sign bit is used. It is in position n-1 and is the most significant bit of the number. For positive numbers this bit is zero, for negative numbers it is one.

Direct code used to store positive or unsigned numbers.

Additional code used to store negative numbers. To obtain a representation of a number in additional code First, the direct code of the modulus of the number is found, then its inverse code. The reverse code is obtained by inverting each digit in binary representation numbers: 0 is converted to 1, and 1 to 0. In the last step to reverse code 1 is added.

For example, to represent the number -65 we have:

01000001b direct number code +65

10111110b return code

10111111b additional number code -65

Two's complement code is used to replace the operation of subtracting integers with an addition operation with the number represented in the two's complement code. In this case, the processor does not need to perform the operation of subtracting integers.

Data types

BYTE. This data type occupies 1 byte (8 bits). Using this type, you can encrypt a signed integer in the range from -128 to +127 or an unsigned integer in the range from 0 to 255, any ASCII character that is also encoded as an integer. Definition Directive – D.B.(Define Byte).

WORD. This data type occupies 2 bytes (16 bits). To a variable of this type You can place an integer in the range -32768 to +32767 or 0 to 65535, two ASCII characters, or a relative memory address of type near. In this case, writing to memory is done as follows: the low part of the number is located at the low address, and the high part is located at the high address. This is true for other data types as well. For example, if the hexadecimal integer number 1234h is located at address 1000h, then the low-order part 34h will be located at address 1000h, and 12h will be located at address 1001h. Definition Directive – DW(Define word).

DWORD– 4 bytes (2 words) can hold a 32-bit signed or unsigned integer, a floating point number, a 32-bit memory address, or 4 ASCII characters. When storing an address, the segment address is located in the high two bytes and the offset is in the low two bytes of memory. Definition Directive – DD(Define Double word).

QWORD– 8 bytes. Can be a signed or unsigned integer, a number, or a double-precision floating-point number. Definition Directive – DQ(Define Quad).

TEN-BYTES– 10 bytes. Used to store data in main memory or coprocessor. Can be a packed BCD number, an extended integer number, or an extended floating point number. Definition Directive - D.T.(Define Ten bytes).

The general syntax for defining data is:

< Name> < type> < listvalues>

< Name> < type> < number>dup(expression),

Where Name– identifier, type– one of the memory allocation directives discussed above, list of values– a list that can contain character or numeric constants. It may also contain the symbol ? , if the value is undefined, or address - a variable name or label, a string of ASCII characters enclosed in quotes or apostrophes. Directive dup specifies the repetition of the values ​​defined by the expression specified <число> once. Expression can be a constant, constants combined by signs arithmetic operations, list of values ​​or symbol ? , if the value is undefined.

For example,

var_a db 2 dup (0, 3 dup (1)) ; equivalent to var_a db 0,1,1,1,0,1,1,1 var_b db 1, 2, 3, ?, ? adr_a dw var_a adr_b3 dd var_b+3

Let's determine the size of memory allocated for each of the following variables:

m1 db 4, 5, 1, 6; 4*1=4 bytes m2 db “xzyqw” ; 5*1=5 bytes m3 dw 12 dup(?) ; 12*2=24 bytes m4 dd 345h , 234h ; 2*4=8 bytes

m1 db 4, 5, 1, 6 ; 4*1=4 bytes m2 db “xzyqw” ; 5*1=5 bytes m3 dw 12 dup(?) ; 12*2=24 bytes m4 dd 345h, 234h ; 2*4=8 bytes

The total number of bytes allocated by these directives is 41 bytes. Variable m1 is located at relative address 00h, m2 – 04h, m3 – 09h, and m4 – 021h.

Individual tasks:

1. Convert decimal numbers to binary, hexadecimal and octal number systems:

1)42;31;113 5 )46;35;119 9 ) 49;30;103 13 )29;37;97
2 )45;81;89 6)66;25;110 10 )19;53;101 14 )21;87;98
3 )12;38;118 7 )17;63; 96 11)34;50;107 1 5) 28;45;130
4 )11;43;67 8 )13;69;88 1 2 )14;70;99 16)15;72;100

2. Convert hexadecimal numbers to binary:

1)A45;12;56B 5)7C;72EB;31DB 9)34A;6AB;9AD 13)2B9;6F1;81B
2)1EF3;5AB;46F 6)3EB;4D8;A61 10)5AB;79F;AB8 14)7CD;2A1;B53
3)A56;5E9;CDE 7)6A3;9D0;8BE 11)9A;4DE;EF7 15)10B;87F;CD9
4)3B8;DE1;BAE 8)BC;7F9;78A 12)AB;8E4;C17 16)38E;9C7;B89

3. Convert binary numbers to octal and hexadecimal number systems:

1) 00101011; 00100110;
01110011
5 ) 11110010; 01101010;
11111100;
9 ) 10000101; 11100010;
11001011
13 ) 00011101; 11111001;
00111101
2 ) 01100001; 01101110;
11110011
6) 00110110; 00111011;
10001100
10 ) 00011101; 01010110;
10110010
14 ) 00011100; 01001100;
01101110
3) 11100100; 01011100; 11000001 7 ) 11010010; 01001100; 11000111 11) 11100010; 10100001; 10001110 1 5 ) 10101001; 11010101; 111001100
4 ) 00001111; 10100101; 10010001 8 ) 11100000 11111000; 01000011 1 2 ) 10100101; 01101100; 11100001 16) 11100111; 01100101; 10110010;

4. Present the following numbers in complementary code:

1)-42;-31;-96 5)-46;-35;-94 9) -49;-30;-103 13)-29;-37;-97
2)-52;-41;-93 6)-66;-25;-85 10)-19;-53 ; -101 14)-21;-87;-98
3)-12;-38;-93 7)-17;-63;-99 11)-34;-50;-94 15)-28;-45;-95
4)-11;-43;-67 8)-13;-69;-88 12)-14;-70;-99 16)-15;-72;-89

5. The following definitions of variables are given:

1) a db 45,16,76,-6
bdb "abcd"
cdw 15 dup(0),3,3
d dd 345h
2) add 2.24
b db “aaa”,-8.23h,11101b
c db 6 dup(0), 45, 6
d dw -7.4Dh.8 dup(0)
3) a db “Salut”,10,13
b db -16,-20,13h,2 dup(0)
c dw 62.34,-15
d dd 456C9h,4567
4) a dd 92.45h,90,-54,-67
b db 10 dup(‘$’),10.13
c db “amdto”,10,13,’$’
d dw 5 dup(?),7,-80h
5) a db “lucrarea_1”,10,13
b db 2 dup(0)
c dw 38,-15,78,41,12
d dd 678EFh,3489,456
6) a db 12.24,”sss”
b db “ab”,-8.23h
c dd 6 dup(0),45
d dw -7.5 dup(0)
7) a db 35.53
b db 10 dup(‘ ’),10,13,“$”
c dw 5 dup(0)
d dd 555h
8) a db 34,6,3,-8,-2
b db “Hello”,‘$’
c dw 6 dup(0),‘$’,10,13
d dw -68.46h,7 dup(0)
9) a db 45.16
b db 5 dup(?),10,13,“$”
c dw 55 dup(0)
d dd 34567h
10) a db 76,87,92,45h
b db 20 dup(‘$’),10.13
c db “qwert”
d dw 10 dup(0)
11) add 78,34,67
b db “Resultat”,‘$’
c db 16 dup(0),‘$’,10,13
12) a db 73,74,75,77,78,-67
b db 15 dup(‘?’),10,13
cdd 777h
13) a db 24.76,-56
b db “abc”,11101b
c dd 45.4 dup(?)
d dw 4 dup(0),8,3
14) a db “testul_nr_2”,13,10
b db -18,-22,18h,2 dup(0)
c dw 81,-16,44,18
d dd 568ABh
15) add 87.45h,-9
b db 10 dup(?)
c db “test_1$”
d dw 4 dup(0),2,7
16) a db “Matematica”,10,13
b db 10,20h,2 dup(0)
c dw 60,30,-10,-20,-50
d dd 56789Bh

a) determine how many bytes are allocated by these directives;
b) determine the addresses where each of the variables is located.

Hexadecimal number system(also known as hexadecimal code) is a positional number system with an integer base of 16. The term hex (pronounced hex, short for English hexadecimal) is also sometimes used in the literature. The digits of this number system are usually used in Arabic numerals 0-9, as well as the first characters of the Latin alphabet A-F. The letters correspond to the following decimal values:

  • * A -10;
  • *B—11;
  • *C—12;
  • * D -13;
  • * E - 14;
  • * F - 15.

Thus, ten Arabic numerals, coupled with six Latin letters, make up the sixteen digits of the system.

By the way, on our website you can convert any text into decimal, hexadecimal, binary code using the Online Code Calculator.

Application. Hex code widely used in low-level programming as well as in various computer reference documents. The popularity of the system is justified by architectural solutions modern computers: They have a byte (consisting of eight bits) as the minimum unit of information - and the value of a byte is conveniently written using two hexadecimal digits. The byte value can range from #00 to #FF (0 to 255 in decimal notation) - in other words, using hexadecimal code, you can write any state of the byte, while there are no “extra” digits not used in the recording.

Encoded Unicode Four hexadecimal digits are used to record the character number. The RGB color notation (Red, Green, Blue) also often uses hexadecimal code (for example, #FF0000 is a bright red color notation).

A method for writing hexadecimal code.

Mathematical way of writing. In mathematical notation, the base of the system is written in decimal form as a subscript to the right of the number. The decimal notation of the number 3032 can be written as 3032 10, in the hexadecimal system this number will have the notation BD8 16.

In the syntax of programming languages. The syntax of different programming languages ​​sets differently the format for writing a number using hexadecimal code:

* The syntax of some varieties of assembly language uses the Latin letter “h”, which is placed to the right of the number, for example: 20Dh. If a number begins with a Latin letter, then a zero is placed in front of it, for example: 0A0Bh. This is done in order to distinguish values ​​using constants from constants. hexadecimal code;

* In other varieties of assembler, as well as in Pascal (and its variants, such as Delphi) and some Basic dialects, the prefix “$” is used: $A15;

* In HTML markup language, as well as in cascading CSS files, to indicate a color in RGB format with a hexadecimal notation, the prefix “#” is used: #00DC00.

How to convert hexadecimal code to another system?

Convert from hexadecimal to decimal. To perform a conversion operation from the hexadecimal system to the decimal system, you need to represent the original number as the sum of the products of the digits in the digits of the hexadecimal number and the power of the base.

Binary SS

hex SS

For example, you need to translate the hexadecimal number A14: it has three digits. Using the rule, we write it as a sum of powers with a base of 16:

A14 16 = 10.16 2 + 1.16 1 + 4.16 0 = 10.256 + 1.16 + 4.1 = 2560 + 16 + 4 = 2580 10

Converting numbers from binary to hexadecimal and vice versa.

A notebook table is used for translation. To convert a number from binary to decimal, you need to split it into separate tetrads from right to left, and then, using a table, replace each tetrad with the corresponding hexadecimal digit. Moreover, if the number of digits is not a multiple of four, then it is necessary to add the corresponding number of zeros to the right of the number so that the total number of binary digits becomes a multiple of four.

Table of notebooks for translation.

To convert from hexadecimal to binary, you need to perform the reverse operation: replace each digit with a tetrad from the table.

Binary SS

Octal SS

Example conversion from hexadecimal to binary: A5E 16 = 1010 0101 1110 = 101001011110 2

Example conversion from binary to hexadecimal: 111100111 2 = 0001 1110 0111 = 1E7 16

In this example, the number of digits in the original binary number was not four (9), so leading zeros were added for a total number of digits of 12.

Automatic translation. A quick conversion from the hexadecimal number system to one of the three popular systems (binary, octal and decimal), as well as the reverse conversion, can be performed using a standard calculator included with Windows OS. Open the calculator, select View -> Programmer from the menu. IN this mode you can set the number system used in this moment(see menu on the left: Hex, Dec, Oct, Bin). In this case, changing the current number system automatically produces a translation.

1. Introduction

2. General information about assembly language

3. Software part

· Program description

· Stages of development of assembly programs ___

· Program for converting decimal numbers into binary and hexadecimal number systems

4. References


Introduction

The tools that ensure the functioning of computer technology are divided into 2 parts: hardware and software.

The hardware includes the following devices:

· central processor;

· RAM;

· peripherals;

All of the above devices are built on integrated circuits (ICs).

An integrated circuit is a microelectronic product that performs certain conversion functions, has a high packing density of electrically interconnected elements and components, and represents a single whole in terms of the requirements for acceptance and operation testing.

An example of an IC are digital device circuits: registers, adders, half-adders, counters, encoders, decoders, etc.

The software part includes: a set of programs and rules with all related documentation, which allows you to use a computer to solve various problems.

A program is a complete sequence of machine commands or programming language operators that define a sequence of actions to solve a certain problem.

The task in our work is: converting a three-digit decimal number into binary and hexadecimal number systems. This task is implemented using assembly language. This low-level language uses symbolic (mnemonic) notations for machine instructions and addresses. The advantage of this language is: firstly, that programs written in it require significantly less memory; secondly, knowledge of this language and the resulting machine code gives an idea of ​​the machine's architecture, which is unlikely to be provided when working in a high-level programming language.


General information about assembly language

Symbolic assembly language can largely eliminate the disadvantages of machine language programming.

Its main advantage is that in assembly language all program elements are presented in symbolic form. Converting symbolic command names to their binary codes is the responsibility of special program– an assembler that frees the programmer from labor-intensive work and eliminates the inevitable errors.

Symbolic names entered when programming in assembly language usually reflect the semantics of the program, and the abbreviation of commands reflects their main function. For example: PARAM – parameter, TABLE – table, MASK – mask, ADD – addition, SUB – subtraction, etc. etc. Such names are easy for a programmer to remember.

For programming in assembly language, it is necessary to have complex tools than for programming in machine language: you need computer systems based on a microcomputer or PC with a set peripheral devices(alphanumeric keyboard, character display, float drive and printing device), as well as resident or cross-programming systems for the required types of microprocessors. Assembly language allows you to effectively write and debug much more complex programs than machine language (up to 1 - 4 KB).

Assembly languages ​​are machine-oriented, i.e., dependent on the machine language and structure of the corresponding microprocessor, since in them each microprocessor instruction is assigned a specific symbolic name.

Assembly languages ​​provide a significant increase in programmer productivity compared to machine languages ​​and at the same time retain the ability to use all software-available hardware resources of the microprocessor. This enables skilled programmers to write programs that run in less time and occupy less memory than programs written in a high-level language.

In this regard, almost all programs for controlling input/output devices (drivers) are written in assembly language, despite the presence of a fairly large range of high-level languages.

Using assembly language, the programmer can set the following parameters:

mnemonics (symbolic name) of each microprocessor machine language command;

a standard format for lines of a program written in assembly language;

a format for specifying different addressing methods and command options;

format for specifying character and integer constants in various systems calculus;

pseudo-commands that control the process of assembling (translating) a program.

In assembly language, a program is written line by line, that is, one line is allocated for each command.

For microcomputers built on the basis of the most common types of microprocessors, there may be several variants of assembly language, but usually one is widely used in practice - this is the so-called standard assembly language. In what follows, we will consider standard assembly languages.

Each line of a program written in assembly language contains four fields:

LABEL CODE OPERAND COMMENT

The LABEL field is optional; it marks the address of the memory cell in which the first byte of the marked command is located. Labels are used as transition addresses for control transfer commands, and thanks to their presence, the programmer can not operate with absolute addresses, but use symbolic addresses, which is much more convenient. The label can be one to six characters long, the first of which must be a letter. Many assemblers allow labels of any length, but only the first six characters are recognized. The label must not contain spaces or punctuation marks. In some assemblers, the last character of the label must be followed by a colon.

In a label field, each label must be defined only once, but references to it can be used as many times as necessary. Otherwise, the assembler will issue a diagnostic message about the multiply defined label.

The CODE field contains the symbolic name of the command or pseudo-command to be executed. The mnemonic for most commands is an abbreviation of sentences in English that characterize their main function.

For example:

MOV (MOVE) - transfer, forward

ADD (ADDITION) - addition

SUB (SUBSTRACT) - subtraction

LDA (LOAD DIRECT

ACCUMULATOR) - direct loading

INR (Battery INSCREMENT

REGISTER) - register increment

REGISTER) register decrement

Command mnemonics are assembler keywords, and if they are not included in the set of valid mnemonics, the assembler reports an invalid command.

The OPERAND field is usually defined depending on the instruction code field. It may contain one or more operands, separated by commas, or it may contain no operands for those instructions that operate on internal working registers.

An operand is an expression containing mnemonic notation, constants, and operators.

The simplest operands contain one mnemonic or one constant.

The identifiers of internal working registers, labels and the current value of the program counter can be used as a mnemonic.

Constants can be represented in different number systems.

Software part

Description programs

In this work, we will look at one of the ways to convert a number from the decimal system to binary and hexadecimal using Assembly language. Before creating a program, we will consider in detail what steps need to be taken for this, that is, in other words, we will write an algorithm for solving our problem. In order for a computer to process data, it needs to enter this data, which means the first step in solving our problem will be entering a number. The second step in the work will be to display a message about the entered number. After this, we convert the decimal number to the binary system and display our number in binary equivalent on the screen. The next step is to convert the number to the hexadecimal equivalent and the last step is a loop that allows you to continue entering a new decimal number. Now let's put all the points together:

1. Entering a number from the keyboard.

2. Display a message about the entered number.

3. Converting a number to its binary equivalent.

4. Display a binary number.

5. Converting a number to hexadecimal.

6. Display a hexadecimal number.

7. Cycle (shall we continue?) if YES then point 1, otherwise point 8

8. Exit the program.

This is the algorithm of a natural language program.

stages of development of assembler programs

1. Statement of the problem. Includes a meaningful description of the problem and development of the algorithm.

2. Development of program text.

3. Entering text into the computer. The text of the program in mnemonic codes is entered into the computer using any text editor. This also creates a text File with the extension *.ASM.

4. Compilation or assembly. Conversion in progress text file with *.ASM extension into an object file containing a program in machine code with *.OBJ extension. Also at this stage a program listing can be created. A file with the extension *.LST, which contains basic information about the program, as well as a Cross-Reference File with the extension *.CRF. At this stage, the program text is checked for errors. Assembly is carried out using the TASM.EXE translator program (ASM.EXE - in assembler, MASM.EXE - in macro assembler). TASM [options] *.ASM [,] - command for performing translation. If one comma is specified in the command, then the Listing File is Generated. TASM has two options: /ZI and /N. They are called: TASM.

5. Layout. At this stage, a relocatable program is created that can be loaded into any memory area. Saved in a File with the extension *.EXE or *.COM. To do this, use TLINK.exe (for the macro assembler LINK.EXE). The options are /T and /X.

6. Execution and Debugging (DEBUG).

7. Entering the machine code of the program into ROM (may be missing) Now we will look at the block diagram of our program, that is, the ordered actions.


; PROGRAM FOR CONVERTING A DECIMAL TO; BINARY AND HEXADECIMAL SYSTEMS; CUMULATIONS

;Data segment

;Conversion table“digit – ASCII-code

tabl_ascii db "0123456789abcdef"

;____________________________________________________________________

;Conversion table“ASCII-code - number

db 0,1,2,3,4,5,6,7,8,9

db 0ah,0bh, 0ch, 0dh, 0eh, 0fh

;____________________________________________________________________

;Reservation and initialization of variables in memory

x_ascii db 20h dup(?)

t1 db 0dh,0ah,"Enter a number and press Enter"

db 0dh, 0ah, "$"

t2 db 0dh,0ah,"You have entered a number”,0dh,0ah "$"

t3 db 0dh, 0ah, "In binary it looks like this"

t4 db 0dh, 0ah, "In hexadecimal like this"

db 0dh, 0ah, "$"

buf db 16 dup(?),"$"

t5 db 0dh,0ah, "Shall we continue the process? (Y/N)?"

;____________________________________________________________________

; Code segment

;Main procedure

d: lea dx, t1

;Procedure for entering a decimal number

;Procedure for displaying a decimal number

r1: mov dl,

; Converting a number (decimal) to binary

v1: mul si

;Procedure for displaying a binary number

; Procedure for converting a number (binary) to hexadecimal

; and display it on the screen

Notes :

Below are the commands used in the program:

sub– binary subtraction. Subtracts the contents of the second operand from the first operand

Mnemonics:sub< operand 1>,< operand 2>

call– procedure call. Transfers control to a procedure whose address is specified by the operand; after the procedure is completed, execution continues with the command following the call command

Mnemonics: call< procedure name>

ret– return to procedure

shr– move logically to the right

xor– exclusive OR

Mnemonics:xor<операнд 1>,<операнд 2>

lea– download EA

Mnemonics:lea reg,<операнд>

push– include in stack

Mnemonics: push< operand>

pop– retrieve from stack

Mnemonics: pop<операнд>

mov– forward

Mnemonics:mov< receiver>,<источник>

inc– increase by 1

Mnemonics:inc<операнд>

dec– decrease by 1

Mnemonics: dec< operand>

stosb– forwards connections to the al or ax register pointed to by the di register

loop– a command to organize a loop with a counter, also short transitions (127b) the command decreases the value of the counter cx, without changing any flags, if the connection cx > 0, then the transition to the given label is carried out, otherwise the loop ends.

Mnemonics: loop< label>

.CODE– opens a code segment

. DATA-- opens a data segment

.STACK N– defines the segment stack(a); Segment closing directives are not used in this case; N – shows the size of stack(a) in bytes

Note : When using such directives, the ds register is initialized as follows: mov ax,@data

mov ds,ax

assume is not used in this case

Bibliography

1. "I am an assembly language for IBM PC and programming" graduate School 1992.

2. “IBM Personal Computer and MS-DOS Operating System” Radio and Communications 1991.

3. Ilyushechkin V.N., Kostin A.E., Khokhlov M.M. “System software”, M., “Higher School”, 1987

4. Norton P., Souhe D. “Assembly language for the IBM PC”, M., Publishing House “Computer”, 1993

Hello! There is this line:

Var BD 2,2,3,3,4,4; 223344 decimal 6-digit number in unpacked format with increased accuracy(ASCII format)

How can I convert this number 223344 into hexadecimal number? I found this code that converts from single-digit and two-digit decimal numbers to sixteen-digit ones:

; Var. 17. Rear 1. Write a subroutine to convert some array of decimals; ASCII bytes. to an array of BCD bytes. Use this subroutine to process two arrays; Use the stack to pass parameters. Name Program ; Description of constants; Description of variables Data segment x1 db 2h db 1h db 3h db 1h db 4h db 1h ; numbers in ASCII format y1 db 3 dup (?) ; array in BCD format x2 db 8h ;98 db 9h db 5h ;95 db 9h db 7h ;87 db 8h db 2h ;92 db 9h ; array dec. ASCII bytes Y2 db 4 dup (?) ; array dec. BCD bytes Data ends Stack SEGMENT DW 16 dup(?) StkTOp LABEL word Stack ends Code SEGMENT ASSUME CS: Code, DS: Data, ES: Data, SS: Stack ; The subroutines abc proc push bp mov bp, sp are described here. snap to the top of the stack mov cx, ; reading parameters from the stack (number of numbers) mov di, ; address of variable Y1 mov si, ; address of variable X1 M1: mov al, +1 ; load the first number in ASCII format shl ax, 1 ; shift by 4 digits to the right shl ax, 1 shl ax ,1 shl ax, 1 or al, ;restore the number that you remembered mov , al ; write the number in BCD format inc si ; move to another number inc si inc di ; modify the BCD address - numbers dec cx ; reduce the number of numbers jnz M1 ; if they haven’t run out, then go to M1 pop BP ret 6 abc endp ; Main program Start: mov AX, Data mov DS, AX mov ES, AX mov Ax, Stack mov SS, AX mov SP, offset StkTop ; load the parameters onto the stack according to the task conditions mov ax, offset x1 ; load the address of the first array push ax mov ax, offset Y1 ; load the address of the result push ax mov ax, 3 ; number of numbers push ax call abc ; subroutine call mov ax, offset x2 ; load the address of the second array push ax mov ax, offset Y2 ; load the address of the result push ax mov ax, 4 ; number of numbers push ax call abc ; calling the subroutine code ends end start