João Reis
João Reis

Reputation: 1

Difference between iload with '_' and without

I hava a question about the iload instruction of jasmin. Is it correct to do iload 1 or it has to be iload_1? Or when is a number between 1 and 3 we have to use the '' and the others we have to not use the ''?

I m generating jasmin code. First i tried every iload intruction with '', but it didn't work. Then I tried every instruction without '', and it also didn't work.

Upvotes: 0

Views: 114

Answers (1)

Thomas Kläger
Thomas Kläger

Reputation: 21570

The Java byte code contains a generic iload instruction that takes a value from 0 to 255 as argument (and therefore the encoding is 2 bytes).

For compacter byte code it contains 4 special instructions iload_0 to iload_3 that have a fixed argument (0 to 3) and are encoded in only one byte.

Similar patterns exist for several other byte code instructions.

The iload instructions are described in the JVM specification (https://docs.oracle.com/javase/specs/jvms/se17/html/jvms-6.html#jvms-6.5.iload). On that page you will also find descriptions for all the other byte code instructions.

Upvotes: 2

Related Questions