From da895f00cd7313d1be911b45c250dfbdf33897e6 Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Sat, 24 Apr 2021 18:19:37 +0200 Subject: [PATCH] added stack field to cpu --- riscemu/CPU.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/riscemu/CPU.py b/riscemu/CPU.py index ab6f2fd..6577359 100644 --- a/riscemu/CPU.py +++ b/riscemu/CPU.py @@ -49,6 +49,8 @@ class CPU: self.conf = conf self.active_debug = False # if a debugging session is currently runnign + self.stack: typing.Optional['riscemu.LoadedMemorySection'] = None + # setup MMU, registers and syscall handlers self.mmu = MMU(conf) self.regs = Registers(conf) @@ -87,9 +89,9 @@ class CPU: self.pc = le.run_ptr if self.conf.stack_size > 0: - stack = self.mmu.allocate_section("stack", self.conf.stack_size, MemoryFlags(False, False)) - self.regs.set('sp', stack.base + stack.size) - print(FMT_CPU + '[CPU] Allocated {} bytes of stack'.format(stack.size) + FMT_NONE) + self.stack = self.mmu.allocate_section("stack", self.conf.stack_size, MemoryFlags(False, False)) + self.regs.set('sp', self.stack.base + self.stack.size) + print(FMT_CPU + '[CPU] Allocated {} bytes of stack'.format(self.stack.size) + FMT_NONE) print(FMT_CPU + '[CPU] Started running from 0x{:08X} ({})'.format(le.run_ptr, le.name) + FMT_NONE) self.__run()