private void toggleBreakpoint() { try { int lineno = sourceTextarea.getLineOfOffset(sourceTextarea.getCaretPosition()) + 1; Character asmaddr = asmMap.src2bin(lineno); if (srcBreakpoints.contains(lineno)) { srcBreakpoints.remove(lineno); if (asmaddr != null) debugger.setBreakpoint(asmaddr, false); } else { srcBreakpoints.add(lineno); if (asmaddr != null) debugger.setBreakpoint(asmaddr, true); } sourceRowHeader.breakpointChanged(lineno); } catch (BadLocationException e1) { e1.printStackTrace(); } }
private void assemble() { Assembler assembler = new Assembler(); assembler.genMap = true; try { binary = new char[] {}; binary = assembler.assemble(sourceTextarea.getText()); cpu.upload(binary); memoryModel.fireUpdate(0, binary.length); asmMap = assembler.asmmap; for (Character addr : debugger.getBreakpoints()) { debugger.setBreakpoint(addr, false); } for (Integer breakpoint : srcBreakpoints) { Character addr = asmMap.src2bin(breakpoint); if (addr != null) { // TODO if null, mark breakpoint somehow debugger.setBreakpoint(addr, true); } } } catch (Exception ex) { JOptionPane.showMessageDialog( frame, "Compilation error " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); ex.printStackTrace(); } }