Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 364 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why do we bother with CPU registers in assembly, instead of just working directly with memory?

#1
I have a basic question about assembly.

Why do we bother doing arithmetic operations only on registers if they can work on memory as well?

For example both of the following cause (essentially) the same value to be calculated as an answer:

Snippet 1

.data
var dd 00000400h

.code

Start:
add var,0000000Bh
mov eax,var
;breakpoint: var = 00000B04
End Start
<br>

Snippet 2

.code

Start:
mov eax,00000400h
add eax,0000000bh
;breakpoint: eax = 0000040B
End Start
<br><br>
From what I can see most texts and tutorials do arithmetic operations mostly on registers. Is it just faster to work with registers?
Reply

#2
Registers are accessed **way** faster than RAM memory, since you don't have to access the "slow" memory bus!
Reply

#3
Yes, it's much much much faster to use registers. Even if you only consider the physical distance from processor to register compared to proc to memory, you save a lot of time by not sending electrons so far, and that means you can run at a higher clock rate.
Reply

#4
Yes - also you can typically push/pop registers easily for calling procedures, handling interrupts, etc
Reply

#5
Registers are much faster and also the operations that you can perform directly on memory are far more limited.
Reply

#6
It's just that the instruction set will not allow you to do such complex operations:

add [0x40001234],[0x40002234]

You have to go through the registers.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through