Jump to content

Bytecode

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 64.80.176.20 (talk) at 20:16, 23 September 2002 (Byte Codes). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Fundamentally, computers perform fairly granular atomic actions. That is to say, they do lots of tiny little steps to accomplish a much larger task, the same way that you do lots of little steps (multiplying and subtracting and borrowing and comparing) to compute long division.

A computer is said to perform operations. Each operation is assigned a numeric code. These codes are called an Opcode. Since humans are terrible at memorizing lots of similar numeric codes, mnemonics are used as a textual abbreviation. It's much easier to remember ADD than it is 05, for instance.

Opcodes operate on registers, values in memory, values stored on the stack, i/o ports, the bus, etc. They are used to perform arithmetic operations and move and change values. Operands are the things that Opcodes operate on.

Byte codes are another term for opcodes, especially when they are used to describe higher level constructs as is the case with the Java Language's JVM (Java Virtual Machine). For instance, byte code 1A might be the "iconst_2" instruction which pushes the number 2 on the stack. This is a slightly higher level of abstraction, than opcodes, which might need to load the number 2 into a register, and then push the register's value on the stack.

Also of interest are p-codes, which are just like byte codes, but may be physically larger than a single byte and may vary in size (much like Opcodes do). They work at very high levels, such as "print this string" and "clear the screen". Both BASIC and some versions of Pascal use p-codes.