Is the “MOV” command in Assembly allocate memory?

I notice that MOV must copy and overwrite data to and from registers, but if there is no data in any other register, MOV moves a byte of a certain size from RAM to the register to hold it temporarily, or how does it work exactly?

To clarify my question, let's say I use:

MOV AL, 0x10; 

In this case, where are the "digits" of the digit "10" that are moved to the 8-bit register?

Is it transferred from RAM to AL in the form of eight bits for storage, or is it "10" bytes, just a number of a notepad that is not in memory?

I do not understand this, and it would be surprising if someone could straighten it out.

My problem is that I need to know where and how much memory is used, and how and what exactly refers to it (and the textbooks do not allow this).

+4
source share
5 answers

Guessing the mental block: it is important to understand that RAM contains code and data. The value 0x10 comes from the code. It was encoded in machine code instructions by assembler. This code was loaded by the operating system into the operating system when it began to execute your code.

It is noteworthy that this is not a variable, the instruction will always load 0x10, regardless of the state of your program. Other parts of RAM store data that you specified in your build program. Like the .data and .stack sections. But this specific instruction does not use otherwise.

Addition to a possible confusion: it should not be in RAM. On embedded systems without an operating system or boot disk, code is often written to ROM. The processor does not care about this, it simply reads the bytes from the memory bus, using the EIP register (instruction pointer) to tell the memory subsystem which bytes it needs.

+6
source

your code lives in RAM i.e. bytes that represent MOV AL, 0x10; , 0x10 is part of the instruction, it is not stored separately. As a rule, it will not come from RAM at the time of execution, and the pipeline of instructions to the CPU, CPU extracts instructions from RAM into its pipelines, as it sees fit.

for a great free online build book try http://cs.smith.edu/~thiebaut/ArtOfAssembly/artofasm.html

Chapter 4 covers memory addressing http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH04/CH04-1.html

There are many concepts that will help you understand, addressing memory in all its forms and how to work with the processor architecture may seem complicated at first glance, but it will gradually begin to feel when you try to do something.

+4
source

I believe that the primary memory of your device / machine is RAM. Thus, basically your application will exist there at runtime (for example, after starting this application from the hard drive, it will load into the device’s memory). By the way, all binary commands executed for the processor are now in RAM.

To simplify this, say, the processor will start reading memory from the very first cells, for example, 0, try to figure out what to do with it, and after completion will go to the next one, which is 1 in this case, etc.

Now let's say mov al, 0x10 is 0xAABB in our imaginary processor. In physical memory, 0xAA stored at cell number 20 and 0xBB at 21 . Our processor is still busy reading the stream. When it reaches memory at 20 , in this case the binary value 0xAA will be loaded. By the way, in our processor documentation, this means Fill AL with the following data . The following data in our case is 0xBB , so the processor will do this.

As you can see:

  • here, in our example, everything exists in RAM (at runtime), including executable instructions, data, etc.
  • The CPU reads it from RAM and will try to do everything that is supposed / necessary to do so that
  • As you noticed, mov al, 0x10 not allocated at runtime , but everything was hard-coded by the compiler and stored in an executable file (for example)
  • So, this imaginary 0xBB exists in RAM, but you cannot change it at runtime. Again, keep in mind that it was also not created at run time, it was just loaded into RAM at run time

Hope this helps you figure out which is better.

+2
source

assembly instruction

 mov al, 0x10 

equals 0xb010 in binary format

 mov al, 0xff 

equals 0xb0ff

if you are on windows you can click start-run-debug and in the debug window write

 a [Enter] mov al, ff [Enter] [Enter] 

this change mov al, ff to binary

and then you can see 0xb0ff by ..

 u 100 [Enter] a mov al, ff 

means “build” mov al, ff and save to current location (maybe 0x100)

u 100 means “parse” the location 0x100

+1
source

managing memory in different pieces, for example. code and data, if there are no technical, special differences or application of its use?

0
source

All Articles