S
S
sbudyakov2017-08-16 22:27:19
Programming
sbudyakov, 2017-08-16 22:27:19

What is command bitness?

Explain, please, to a beginner - what determines the bitness of the Assembler commands?
What is the difference between 16-bit commands and 32-bit ones?
I used to think that the bitness of an instruction is determined by the bitness of the operands. But recently I found a list of commands that are described in the book ("Cortex Core - ARM MH. Complete Guide", p.62) as 32-bit, but work with 16-bit operands.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Saboteur, 2017-08-17
@sbudyakov

The bitness of an instruction is how many bits (usually bytes) it takes.
Depending on the architecture of the processor, the instruction can be executed in one cycle, if the processor capacity allows it, or in several cycles.
On an 8-bit "pseudo-processor", we can assume, for example, such commands
Put a 16-bit value in the AX register (two instructions)
mov AX, 0xFFFF (3 bytes)
lea 0x1234, AX (3 bytes)
Put a 16-bit value at a 16-bit address (one command)
lea 0x1234, 0xFFFF (5 bytes)
1) From the point of view of logic - in the first case there are 2 commands, in the second one command - that is, it seems like the second case should work twice as fast.
2) From the point of view of an 8-bit processor, in the first case we have 6 cycles, in the second 5 cycles, that is, not twice, but 20% faster.
3) From the point of view of the logic of a 16-bit processor, the number of cycles is less, but
in the first case 3 bytes - two cycles + 3 bytes - two more cycles, 4 cycles in total
in the second case 5 bytes - 3 cycles in total. 25% faster
4) From the point of view of the logic of a 32-bit processor, the number of cycles is even less, while
in the first case 3 bytes + 3 bytes - 2 cycles
, in the second case 5 bytes - 2 cycles, there is no difference.
The examples above are exaggerated.

T
Therapyx, 2017-08-17
@Therapyx

here is a good script, what you need on the 10th page
users.ece.utexas.edu/~valvano/EE345M/Arm_EE382N_4.pdf Chew
everything for a long time, and it's already night))
but about 16 bit instructions. It's more about Thumb instructions set.
here - https://stackoverflow.com/questions/10638130/what-... here are the pros, cons, etc.)
And here is a good example:
ARM:

mov r3, #0
loop
 subs r0, r0, r1
 addge r3,r3,#1
 bge loop
 add r2, r0, r1

=> 5 * 4 bytes = 20 bytes.
And now the same on Thumb
mov r3, #0
loop
 add r3, #1
 sub r0, r1
 bge loop
 sub r3, #1
 add r2,r0,r1

=> 6 * 2 bytes = 12 bytes.

S
svolch, 2017-08-17
@svolch

Once upon a time, processors only manipulated 4-bit registers
Then 8-bit ones
Then 16-bit ones
Then 32-bit ones (somewhere left, in particular on smartphones, most)
Now 64-bit ones (on desktops everywhere already, only appears on smartphones)
The point is that numbers , which the processor can, for example, add up - how many bits are there.
That is, if you have a 16-bit operation, and you need to add 100,000 + 12,000 - where the first number is already beyond 16 bits - then you can only do it in parts, in 2 stages, in 2 operations.
First the lower ranks, and then the older ones.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question