Package br.com.gmartins.simbler.instructions.value

Examples of br.com.gmartins.simbler.instructions.value.Value


            //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>");
                    builder.append("<b>Decimal:</b> ").append(value.toDecimal());
                    builder.append("<br>");
                    builder.append("<b>Hexadecimal:</b> ").append(value.toHex());
                    builder.append("</HTML>");
                    builder.append("</HTML>");
                    return builder;
                }
View Full Code Here


* @author Guilherme
*/
public class ALU {

    private static Value finalValue(int number) {
        Value value = new Value(number + "", DataType.DECIMAL);
        // Se o valor for igual a zero, liga o flag Zero
        if (number == 0) {
            value.setZero(true);
        }
        // Se o valor for menor que zero, ou for "Zero negativo" (-0) - Liga o Flag Signal
        if (number < 0) {
            value.setSignal(true);
        }
        // Se o valor for maior que 127, ou menor que -127, liga o flag overflow
        if (number > 127) {
            value.setOverflow(true);
        } else if (number < -127) {
            value.setOverflow(true);
        }
        return value;
    }
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

            Value value = ALU.sub(getRegisters().getAx().getValue(), getCurrentInstruction().getValue());
            // Faz a verificação do valor obtido e liga as flags necessárias
            flagCatcher.executeCheck(value);
        } else if (RegexMatcher.matches(regex2, getCurrentInstruction().getLineCommand())) {
            // Subtrai o valor do registrador definido em ADD com o valor de AX
            Value value = ALU.sub(getRegisters().getAx().getValue(), getCurrentInstruction().getRegister().getValue());
            // Faz a verificação do valor obtido e liga as flags necessárias
            flagCatcher.executeCheck(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());
            // 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

        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

        MATCHES NOT
         */

        if (RegexMatcher.matches(regex0, getCurrentInstruction().getLineCommand())) {
            // Soma o valor definido no ADD com o valor atual de AX
            Value value = getRegisters().getAx().getValue();
            // Define em AX o novo valor.
            getRegisters().getAx().setValue(ALU.not(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());
            // Define o novo valor no AX
            getRegisters().getAx().setValue(value);
        } else if (RegexMatcher.matches(regex2, getCurrentInstruction().getLineCommand())) {
            // Soma o valor do registrador definido em ADD com o valor de AX
            Value value = ALU.sum(getRegisters().getAx().getValue(), getCurrentInstruction().getRegister().getValue());
            // Define o novo valor em AX
            getRegisters().getAx().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());
            // 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
            Value value = ALU.div(getRegisters().getAx().getValue(), getCurrentInstruction().getValue());

            // Define o novo valor no AX
            getRegisters().getAx().setValue(value);
        } else if (RegexMatcher.matches(regex2, getCurrentInstruction().getLineCommand())) {
            // Subtrai o valor do registrador definido em ADD com o valor de AX
            Value value = ALU.div(getRegisters().getAx().getValue(), getCurrentInstruction().getRegister().getValue());
            // Define o novo valor em AX
            getRegisters().getAx().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());
            // 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());
            // Define o novo valor no AX
            getRegisters().getAx().setValue(value);
        } else if (RegexMatcher.matches(regex2, getCurrentInstruction().getLineCommand())) {
            // Subtrai o valor do registrador definido em ADD com o valor de AX
            Value value = ALU.sub(getRegisters().getAx().getValue(), getCurrentInstruction().getRegister().getValue());
            // Define o novo valor em AX
            getRegisters().getAx().setValue(value);
        }

    }
View Full Code Here

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

        if (RegexMatcher.matches(regex0, getCurrentInstruction().getLineCommand())) {
            // Pega o valor do registrador AX
            Value value1 = getRegisters().getAx().getValue();
            // Pega o valor do comando na posição definida pelo numero após o @
            Value value2 = getInstructionAt(getCurrentInstruction().getValue()).getValue();
            // Faz o "AND" e define em AX
            getRegisters().getAx().setValue(ALU.and(value1, value2));
        } else if (RegexMatcher.matches(regex1, getCurrentInstruction().getLineCommand())) {
            // Pega o valor do registrador AX
            Value value1 = getRegisters().getAx().getValue();
            // Pega o valor da instrução atual
            Value value2 = getCurrentInstruction().getValue();
            // Faz o "AND" e define em AX
            getRegisters().getAx().setValue(ALU.and(value1, value2));
        } else if (RegexMatcher.matches(regex2, getCurrentInstruction().getLineCommand())) {
            // Pega o valor do registrador AX
            Value value1 = getRegisters().getAx().getValue();
            // Pega o valor do registrador da instrução
            Value value2 = getCurrentInstruction().getRegister().getValue();
            // Faz o "AND" e define em AX
            getRegisters().getAx().setValue(ALU.and(value1, value2));
        }

    }
View Full Code Here

TOP

Related Classes of br.com.gmartins.simbler.instructions.value.Value

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.