Package br.com.gmartins.simbler.instructions

Examples of br.com.gmartins.simbler.instructions.Instruction


     * This method identifies the kind of instruction and generates the respective data.
     * @return
     */
    private StringBuilder recognizeWord() {
        StringBuilder builder = new StringBuilder();
        Instruction instruction = null;
        try {
            instruction = getInstructionAt(linePosition);
        } catch (java.lang.IndexOutOfBoundsException ex) {
            //System.out.println("Falha ao recuperar instrução número " + linePosition);
            // Aqui poderia tentar chamar um "Silent Compile". Esse erro ocorre quando não consigo recuperar a instrução da linha, após da enter...
        }
        if (instruction != null) {
            if (isNumber()) {
                Value value = instruction.getValue();
                builder.append("<HTML>");
                builder.append("<center><b>Valor Numérico</b></center> ");
                builder.append("<br>");
                builder.append("<b>Binário:</b> ").append(value.toBinary());
                builder.append("<br>");
                builder.append("<b>Decimal:</b> ").append(value.toDecimal());
                builder.append("<br>");
                builder.append("<b>Hexadecimal:</b> ").append(value.toHex());
                builder.append("</HTML>");
            }

            if (isMemoryDealer()) {
                Instruction dest = getInstructionAt(instruction.getValue());

                // Ocorre quando o endereço após o @ não existe.
                if (dest == null) {
                    builder.append("<HTML>");
                    builder.append("<center><b>Endereço de Memória</b></center>");
                    builder.append("<br>");
                    builder.append("<b>Valor: Desconhecido</b>");
                    builder.append("</HTML>");
                    return builder;
                } else {
                    Value value = dest.getValue();
                    builder.append("<HTML>");
                    builder.append("<center><b>Endereço de Memória</b></center>");
                    builder.append("<br>");
                    builder.append("<b>Binário:</b> ").append(value.toBinary());
                    builder.append("<br>");
View Full Code Here


            this.panel.getCodeTextArea().replaceTextOfLine(size, "", 0, 2);
        }
    }

    private Instruction addVoidInstruction(int pos) {
        Instruction instruction = new Instruction(panel);
        instruction.setPosition(pos);
        instruction.setMnemonic(MnemonicsMap.getInstance().getMnemonicsMap().get("GeneralCommands"));
        // Coloca o valor "0" artificialmente
        instruction.setValue(ALU.decimal(0));
        instruction.setEmpty(true);
        instruction.getValue().setValueStartPosition(0);
        instruction.getValue().setValueEndPosition(0);
        return instruction;
    }
View Full Code Here

        FlagCatcher flagCatcher = new FlagCatcher(getMainPanel());

        if (RegexMatcher.matches(regex0, getCurrentInstruction().getLineCommand())) {
            // Pega o comando na posição definida pelo numero após o @
            Instruction dest = getInstructionAt(getCurrentInstruction().getValue());
            Value value = ALU.sub(getRegisters().getAx().getValue(), dest.getValue());
            // Faz a verificação do valor obtido e liga as flags necessárias
            flagCatcher.executeCheck(value);
        } else if (RegexMatcher.matches(regex1, getCurrentInstruction().getLineCommand())) {
            // Subtrai o valor definido no ADD com o valor atual de AX
View Full Code Here

        // REGEX[1] - "INC [ABCD]X"


        if (RegexMatcher.matches(regex0, getCurrentInstruction().getLineCommand())) {
            // Pega o comando na posição definida pelo numero após o @
            Instruction dest = getInstructionAt(getCurrentInstruction().getValue().toInteger());
            // Incrementa o valor em 1
            Value value = ALU.sum(dest.getValue(), ALU.decimal(1));
            // Substitui pelo novo valor
            dest.replaceValue(value, this.getMainPanel().getDataTypeInput().getDataType());
        } else if (RegexMatcher.matches(regex1, getCurrentInstruction().getLineCommand())) {
            // Incrementa o valor em 1
            Value value = ALU.sum(getCurrentInstruction().getRegister().getValue(), ALU.decimal(1));
            // Atribui o novo valor ao registrador especificado
            getCurrentInstruction().getRegister().setValue(value);
View Full Code Here

        // MATCHES INC AX, INC DX
        // REGEX[1] - "INC [ABCD]X"

        if (RegexMatcher.matches(regex0, getCurrentInstruction().getLineCommand())) {
            // Pega o comando na posição definida pelo numero após o @
            Instruction dest = getInstructionAt(getCurrentInstruction().getValue().toInteger());
            // Decrementa o valor em 1
            Value value = ALU.sub(dest.getValue(), ALU.decimal(1));
            // Substitui pelo novo valor
            dest.replaceValue(value, this.getMainPanel().getDataTypeInput().getDataType());
        } else if (RegexMatcher.matches(regex1, getCurrentInstruction().getLineCommand())) {
            // Decrementa o valor em 1
            Value value = ALU.sub(getCurrentInstruction().getRegister().getValue(), ALU.decimal(1));
            // Atribui o novo valor ao registrador especificado
            getCurrentInstruction().getRegister().setValue(value);
View Full Code Here

         */


        if (RegexMatcher.matches(regex0, getCurrentInstruction().getLineCommand())) {
            // Pega o comando na posição definida pelo numero após o @
            Instruction dest = getInstructionAt(getCurrentInstruction().getValue().toInteger());
            // Soma o valor definido no ADD com o valor atual de AX
            Value value = ALU.sum(getRegisters().getAx().getValue(), dest.getValue());
            // Define em AX o novo valor.
            getRegisters().getAx().setValue(value);
        } else if (RegexMatcher.matches(regex1, getCurrentInstruction().getLineCommand())) {
            // Soma o valor definido no ADD com o valor atual de AX
            Value value = ALU.sum(getRegisters().getAx().getValue(), getCurrentInstruction().getValue());
View Full Code Here

        return commandList;
    }

    public void executeCommand(int position) {

        Instruction mnemonic = this.getCommandList().get(position);
        if (mnemonic.getExecutable() != null) {
            mnemonic.getExecutable().execute();
        }

    }
View Full Code Here

        // MATCHES DIV AX, DIV DX
        //REGEX[2] - "DIV [ABCD]X"

        if (RegexMatcher.matches(regex0, getCurrentInstruction().getLineCommand())) {
            // Pega o comando na posição definida pelo numero após o @
            Instruction dest = getInstructionAt(getCurrentInstruction().getValue().toInteger());
            // Subtrai o valor definido no ADD com o valor atual de AX
            Value value = ALU.div(getRegisters().getAx().getValue(), dest.getValue());

            // Define em AX o novo valor.
            getRegisters().getAx().setValue(value);
        } else if (RegexMatcher.matches(regex1, getCurrentInstruction().getLineCommand())) {
            // Subtrai o valor definido no ADD com o valor atual de AX
View Full Code Here

        // MATCHES SUB AX, SUB DX
        //REGEX[2] - "SUB [ABCD]X"

        if (RegexMatcher.matches(regex0, getCurrentInstruction().getLineCommand())) {
            // Pega o comando na posição definida pelo numero após o @
            Instruction dest = getInstructionAt(getCurrentInstruction().getValue());
            // Subtrai o valor definido no ADD com o valor atual de AX
            Value value = ALU.sub(getRegisters().getAx().getValue(), dest.getValue());
            // Define em AX o novo valor.
            getRegisters().getAx().setValue(value);
        } else if (RegexMatcher.matches(regex1, getCurrentInstruction().getLineCommand())) {
            // Subtrai o valor definido no ADD com o valor atual de AX
            Value value = ALU.sub(getRegisters().getAx().getValue(), getCurrentInstruction().getValue());
View Full Code Here

        // REGEX[2] - "STORE [ABCD]X"


        if (RegexMatcher.matches(regex0, getCurrentInstruction().getLineCommand())) {
            // Pega o comando onde o valor deverá ser gravado
            Instruction dest = getInstructionAt(getCurrentInstruction().getValue());
            // Substitui o valor atual pelo valor de AX
            dest.replaceValue(getRegisters().getAx().getValue(), this.getMainPanel().getDataTypeInput().getDataType());
        } else if (RegexMatcher.matches(regex1, getCurrentInstruction().getLineCommand())) {
            // Pega o comando onde o valor deverá ser gravado
            Instruction dest = getInstructionAt(getCurrentInstruction().getRegister().getValue());
            // Substitui o valor atual pelo valor de AX
            dest.replaceValue(getRegisters().getAx().getValue(), this.getMainPanel().getDataTypeInput().getDataType());
        } else if (RegexMatcher.matches(regex2, getCurrentInstruction().getLineCommand())) {
            // Define no registrador especificado pelo STORE [ABC]X o valor atual de AX.
           
            getCurrentInstruction().getRegister().setValue(getRegisters().getAx().getValue());
        }
View Full Code Here

TOP

Related Classes of br.com.gmartins.simbler.instructions.Instruction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.