In order to start learning about Java bytecode, you first need to understand one key thing - the stack.
A stack is sort of like... a stack of plates. In order to use a plate, you always grab one from the top of the stack; likewise, in order to store a plate, you always put one on the top. You're not some sort of magician either, sorry; you are always going to use the top-most part of the stack. The Java Virtual Machine, which runs the Java bytecode is stack-oriented.
- Wikipedia article on stacks
Most bytecodes use the top-most part of the stack as arguments. I will explain each type of bytecode more thoroughly, but for now I'm going to use the bytecodes
If you can't quite grasp the concept yet, look at the Wikipedia article on stacks, or leave a question.
Before this instruction, you had a positive 5 on the top of the stack, after the instruction, you now have a negative 5 on the top of the stack. This is how most bytecodes work. There are some that require other byte values, such as
More explanation over these bytecodes will come soon. If you have any questions, don't hesitate to leave a question below (or any other comments, advice, if I wrote something incorrectly, etc), I will happily reply!
Expect another post soon.
No comments:
Post a Comment