Lines Matching refs:instruction

32      * This exception is thrown when an attempt is made to generate an illegal instruction.
141 throw new IllegalStateException("adding label to non-label instruction");
154 throw new IllegalStateException("adding compare bytes to non-JNEBS instruction");
160 * @return size of instruction in bytes.
192 throw new IllegalStateException("instruction grew");
198 * Assemble value for instruction size field.
207 * Assemble first byte of generated instruction.
231 * Generate bytecode for this instruction at offset {@link offset}.
259 * size of the immediate field, because there is only one length field in the instruction
279 // Calculate distance from end of this instruction to instruction.offset.
365 * Set version of APF instruction set to generate instructions for. Returns {@code true}
373 private void addInstruction(Instruction instruction) {
377 mInstructions.add(instruction);
396 Instruction instruction = new Instruction(Opcodes.LABEL);
397 instruction.setLabel(name);
398 addInstruction(instruction);
403 * Add an unconditional jump instruction to the end of the program.
406 Instruction instruction = new Instruction(Opcodes.JMP);
407 instruction.setTargetLabel(target);
408 addInstruction(instruction);
413 * Add an instruction to the end of the program to load the byte at offset {@code offset}
417 Instruction instruction = new Instruction(Opcodes.LDB, register);
418 instruction.setUnsignedImm(offset);
419 addInstruction(instruction);
424 * Add an instruction to the end of the program to load 16-bits at offset {@code offset}
428 Instruction instruction = new Instruction(Opcodes.LDH, register);
429 instruction.setUnsignedImm(offset);
430 addInstruction(instruction);
435 * Add an instruction to the end of the program to load 32-bits at offset {@code offset}
439 Instruction instruction = new Instruction(Opcodes.LDW, register);
440 instruction.setUnsignedImm(offset);
441 addInstruction(instruction);
446 * Add an instruction to the end of the program to load a byte from the packet into
451 Instruction instruction = new Instruction(Opcodes.LDBX, register);
452 instruction.setUnsignedImm(offset);
453 addInstruction(instruction);
458 * Add an instruction to the end of the program to load 16-bits from the packet into
463 Instruction instruction = new Instruction(Opcodes.LDHX, register);
464 instruction.setUnsignedImm(offset);
465 addInstruction(instruction);
470 * Add an instruction to the end of the program to load 32-bits from the packet into
475 Instruction instruction = new Instruction(Opcodes.LDWX, register);
476 instruction.setUnsignedImm(offset);
477 addInstruction(instruction);
482 * Add an instruction to the end of the program to add {@code value} to register R0.
485 Instruction instruction = new Instruction(Opcodes.ADD);
486 instruction.setSignedImm(value);
487 addInstruction(instruction);
492 * Add an instruction to the end of the program to multiply register R0 by {@code value}.
495 Instruction instruction = new Instruction(Opcodes.MUL);
496 instruction.setSignedImm(value);
497 addInstruction(instruction);
502 * Add an instruction to the end of the program to divide register R0 by {@code value}.
505 Instruction instruction = new Instruction(Opcodes.DIV);
506 instruction.setSignedImm(value);
507 addInstruction(instruction);
512 * Add an instruction to the end of the program to logically and register R0 with {@code value}.
515 Instruction instruction = new Instruction(Opcodes.AND);
516 instruction.setUnsignedImm(value);
517 addInstruction(instruction);
522 * Add an instruction to the end of the program to logically or register R0 with {@code value}.
525 Instruction instruction = new Instruction(Opcodes.OR);
526 instruction.setUnsignedImm(value);
527 addInstruction(instruction);
532 * Add an instruction to the end of the program to shift left register R0 by {@code value} bits.
535 Instruction instruction = new Instruction(Opcodes.SH);
536 instruction.setSignedImm(value);
537 addInstruction(instruction);
542 * Add an instruction to the end of the program to shift right register R0 by {@code value}
546 Instruction instruction = new Instruction(Opcodes.SH);
547 instruction.setSignedImm(-value);
548 addInstruction(instruction);
553 * Add an instruction to the end of the program to add register R1 to register R0.
556 Instruction instruction = new Instruction(Opcodes.ADD, Register.R1);
557 addInstruction(instruction);
562 * Add an instruction to the end of the program to multiply register R0 by register R1.
565 Instruction instruction = new Instruction(Opcodes.MUL, Register.R1);
566 addInstruction(instruction);
571 * Add an instruction to the end of the program to divide register R0 by register R1.
574 Instruction instruction = new Instruction(Opcodes.DIV, Register.R1);
575 addInstruction(instruction);
580 * Add an instruction to the end of the program to logically and register R0 with register R1
584 Instruction instruction = new Instruction(Opcodes.AND, Register.R1);
585 addInstruction(instruction);
590 * Add an instruction to the end of the program to logically or register R0 with register R1
594 Instruction instruction = new Instruction(Opcodes.OR, Register.R1);
595 addInstruction(instruction);
600 * Add an instruction to the end of the program to shift register R0 left by the value in
604 Instruction instruction = new Instruction(Opcodes.SH, Register.R1);
605 addInstruction(instruction);
610 * Add an instruction to the end of the program to move {@code value} into {@code register}.
613 Instruction instruction = new Instruction(Opcodes.LI, register);
614 instruction.setSignedImm(value);
615 addInstruction(instruction);
620 * Add an instruction to the end of the program to jump to {@code target} if register R0's
624 Instruction instruction = new Instruction(Opcodes.JEQ);
625 instruction.setUnsignedImm(value);
626 instruction.setTargetLabel(target);
627 addInstruction(instruction);
632 * Add an instruction to the end of the program to jump to {@code target} if register R0's
636 Instruction instruction = new Instruction(Opcodes.JNE);
637 instruction.setUnsignedImm(value);
638 instruction.setTargetLabel(target);
639 addInstruction(instruction);
644 * Add an instruction to the end of the program to jump to {@code target} if register R0's
648 Instruction instruction = new Instruction(Opcodes.JGT);
649 instruction.setUnsignedImm(value);
650 instruction.setTargetLabel(target);
651 addInstruction(instruction);
656 * Add an instruction to the end of the program to jump to {@code target} if register R0's
660 Instruction instruction = new Instruction(Opcodes.JLT);
661 instruction.setUnsignedImm(value);
662 instruction.setTargetLabel(target);
663 addInstruction(instruction);
668 * Add an instruction to the end of the program to jump to {@code target} if register R0's
672 Instruction instruction = new Instruction(Opcodes.JSET);
673 instruction.setUnsignedImm(value);
674 instruction.setTargetLabel(target);
675 addInstruction(instruction);
679 * Add an instruction to the end of the program to jump to {@code target} if register R0's
683 Instruction instruction = new Instruction(Opcodes.JEQ, Register.R1);
684 instruction.setTargetLabel(target);
685 addInstruction(instruction);
690 * Add an instruction to the end of the program to jump to {@code target} if register R0's
694 Instruction instruction = new Instruction(Opcodes.JNE, Register.R1);
695 instruction.setTargetLabel(target);
696 addInstruction(instruction);
701 * Add an instruction to the end of the program to jump to {@code target} if register R0's
705 Instruction instruction = new Instruction(Opcodes.JGT, Register.R1);
706 instruction.setTargetLabel(target);
707 addInstruction(instruction);
712 * Add an instruction to the end of the program to jump to {@code target} if register R0's
716 Instruction instruction = new Instruction(Opcodes.JLT, Register.R1);
717 instruction.setTargetLabel(target);
718 addInstruction(instruction);
723 * Add an instruction to the end of the program to jump to {@code target} if register R0's
727 Instruction instruction = new Instruction(Opcodes.JSET, Register.R1);
728 instruction.setTargetLabel(target);
729 addInstruction(instruction);
734 * Add an instruction to the end of the program to jump to {@code target} if the bytes of the
742 Instruction instruction = new Instruction(Opcodes.JNEBS, register);
743 instruction.setUnsignedImm(bytes.length);
744 instruction.setTargetLabel(target);
745 instruction.setCompareBytes(bytes);
746 addInstruction(instruction);
751 * Add an instruction to the end of the program to load memory slot {@code slot} into
759 Instruction instruction = new Instruction(Opcodes.EXT, register);
760 instruction.setUnsignedImm(ExtendedOpcodes.LDM.value + slot);
761 addInstruction(instruction);
766 * Add an instruction to the end of the program to store {@code register} into memory slot
774 Instruction instruction = new Instruction(Opcodes.EXT, register);
775 instruction.setUnsignedImm(ExtendedOpcodes.STM.value + slot);
776 addInstruction(instruction);
781 * Add an instruction to the end of the program to logically not {@code register}.
784 Instruction instruction = new Instruction(Opcodes.EXT, register);
785 instruction.setUnsignedImm(ExtendedOpcodes.NOT.value);
786 addInstruction(instruction);
791 * Add an instruction to the end of the program to negate {@code register}.
794 Instruction instruction = new Instruction(Opcodes.EXT, register);
795 instruction.setUnsignedImm(ExtendedOpcodes.NEG.value);
796 addInstruction(instruction);
801 * Add an instruction to swap the values in register R0 and register R1.
804 Instruction instruction = new Instruction(Opcodes.EXT);
805 instruction.setUnsignedImm(ExtendedOpcodes.SWAP.value);
806 addInstruction(instruction);
811 * Add an instruction to the end of the program to move the value into
815 Instruction instruction = new Instruction(Opcodes.EXT, register);
816 instruction.setUnsignedImm(ExtendedOpcodes.MOVE.value);
817 addInstruction(instruction);
822 * Updates instruction offset fields using latest instruction sizes.
827 for (Instruction instruction : mInstructions) {
828 instruction.offset = offset;
829 offset += instruction.size();
873 for (Instruction instruction : mInstructions) {
874 if (instruction.shrink()) {
881 for (Instruction instruction : mInstructions) {
882 instruction.generate(bytecode);