Copy Link
Add to Bookmark
Report

The assembler

The last click Issue 2

eZine's profile picture
Published in 
the last click
 · 2 Dec 2022

I give here a very general explanation to allow the neophyte to understand the codes used in the virus's tutorial. If you wish to program in assembler, I advise you to consult other more complete zines.

1. definition

Assembler is the closest language to machine language, which is why it is called a low-level language.

It is true that assembler is a relatively difficult language to learn because its form and instructions are very different from our spoken language. However, if you put a little effort into it, you will quickly notice that it is based on a rather simple logic.

This introductory course on assembler is obviously here to complement the course on virus programming, but assembler can be useful in many other applications, such as replacing certain lines of code from another higher-level language in a program to make it run faster. Moreover, since assembler is closer to machine language, it will later allow you to perform operations that are difficult to perform with other languages.

To be comfortable with this language, it may be useful to be well informed about DOS and how it works.

Now, let's go.

2. concept of registers

Their knowledge and use is essential in assembler. What you will see here is a simplified approach to registers.

You can think of registers as drawers in which you can store values, variables, etc. Just as you can have a drawer for your socks, you will have a register for a certain type of value. These registers are divided into two parts: the upper part H and the lower part L.

Here are the main registers:

  • ax: Comprising ah + al. This is the input/output register and mathematical operations.
  • bx: Comprising bh + bl. It is the register used as a pointer.
  • cx: Including ch + cl. It is used a lot for loops.
  • bx: Comprising dh + dl. It is very similar to bx.

Dividing the registers in two is an important concept. Basically when you have a value of type 1B5C to store in ax, ah will contain 1B and al will contain 5C. It is important to know that the registers are 16 bits, and that they store numbers from 0 to 65535 or -32768 to 32768.

There are also other registers: the segment registers. I will devote a complete part to them a little later because their use can be difficult and risky.

For the moment, just consider them as subdivisions of the memory in which different information is stored such as the code (CS register), the data (DS and ES registers), the addresses of the subroutines to be called (SS register).

Finally, you will find the index registers and the pointers:

  • SI, the source index which is often used with DS for block move instructions.It is an internal pointer to the segment.
  • DI, the destination index which is used as an internal pointer to ES.

I think you can see what a register is by now.this approach is still very vague and very general, but it is enough for now.

3. the instructions

-mov Operand 1, Operand 2:
ex : mov ax,10h.
mov allows to place or move the content of operand 2 in operand 1. it can be used with addresses, registers or values. In this example, we place the value 10h in ax.

-int value:
ex: int 21h.
This instruction generates an interrupt. In this example, we call the DOS. However, an interrupt includes several functions that we define in ah et al.

-jmp address:
ex: jmp 0B20h.
Unconditional jump. This instruction returns to the address 0B20h. However, there are about thirty jumps.

-CALL procedure:
ex: CALL ROUT1
This instruction calls a procedure, a routine.

-jc address:
Jump in case of transport. Returns to the specified address if CF = 1.

RET:
Marks the end of a subroutine. Returns to the main program.

-xchg operand 1, operand 2:
Exchange the values of the 2 operands.

-xor operand 1, operand 2:
Exclusive OR between the two operands.

-db 'Chaine ascii':
Declare Byte. Declaration of a character string.

That's it. I have only put here the instructions that are in the source codes of the Virus part. The other instructions will come later.

Bye.

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT