added ebreak/scall aliases to sbreak/scall and replaced dbg with ebreak instruction

float_support
Anton Lydike 4 years ago
parent 0aa42d0d1c
commit 97d86108e8

@ -130,6 +130,7 @@ class CPU:
)
def instruction_addi(self, ins: 'LoadedInstruction'):
ASSERT_LEN(ins.args, 3)
dst = ins.get_reg(0)
src1 = ins.get_reg(1)
imm = ins.get_imm(2)
@ -250,23 +251,29 @@ class CPU:
self.pc = addr
def instruction_ret(self, ins: 'LoadedInstruction'):
ASSERT_LEN(ins.args, 0)
self.pc = self.regs.get('ra')
def instruction_ecall(self, ins: 'LoadedInstruction'):
self.instruction_scall(ins)
def instruction_ebreak(self, ins: 'LoadedInstruction'):
self.instruction_ebreak(ins)
def instruction_scall(self, ins: 'LoadedInstruction'):
ASSERT_LEN(ins.args, 0)
syscall = Syscall(self.regs.get('a7'), self.regs)
self.syscall_int.handle_syscall(syscall)
def instruction_break(self, ins: 'LoadedInstruction'):
INS_NOT_IMPLEMENTED(ins)
def instruction_sbreak(self, ins: 'LoadedInstruction'):
if self.conf.debug_instruction:
import code
code.interact(local=dict(globals(), **locals()))
def instruction_nop(self, ins: 'LoadedInstruction'):
pass
def instruction_dbg(self, ins: 'LoadedInstruction'):
if self.conf.debug_instruction:
import code
code.interact(local=dict(globals(), **locals()))
@staticmethod
def all_instructions():

@ -11,8 +11,8 @@ if __name__ == '__main__':
parser.add_argument('default_stack_size', type=int, help='Default stack size of loaded programs', default=None,
metavar='default-stack-size')
parser.add_argument('debug_instruction', type=bool, default=True, metavar='debug-instruction',
help='Adds the dbg instruction, which launches an interactive debuggin session, smilar to '
'a breakpoint.')
help='Switches to an interactive python interpreter when ebreak/sbreak instruction '
'is encountered. Otherwise these instructions are treated as nop.')
parser.add_argument('print_tokens', metavar='print-tokens', type=bool, help='Print tokens after tokenization',
default=False)

Loading…
Cancel
Save