1
0

Added minor functionality,

This commit is contained in:
Jon Michael Aanes 2015-12-16 02:09:04 +01:00
parent f564b27fa6
commit 53d45414f8
2 changed files with 12 additions and 6 deletions

View File

@ -96,11 +96,17 @@ class Emulator:
for line in iter(source_text.splitlines()):
index = self.processSourceLine(line, index)
def setStack (self, *stack_list):
i = 0
def setStack (self, *stack_list, **kwargs):
"""
Sets various stack elements, starting from 0 and going up.
Automatically sets rsp. This can be disabled by passing set_rsp=False.
"""
i = -1
for element in stack_list:
self.stack[i] = element
i += 1
self.stack[i] = element
if (not 'set_rsp' in kwargs) or kwargs['set_rsp']:
self.setRegs(rsp=i)
def setRegs (self, **reg_dict):
for reg_name, reg_val in reg_dict.iteritems():

View File

@ -60,10 +60,10 @@ if __name__ == "__main__":
printf("Running for fib({})", a)
# Setup
emu = infernal.Emulator(fib_prog)
emu = infernal.Emulator(fib_prog) #infernal.Emulator(fib_iter_prog)
painter = infernal.TikzPainter()
emu.setStack("junk...","calling eip")
emu.setRegs( rip = 0, rbp = 'old bp', rsp = 1, rdi = a )
emu.setStack("junk...", "calling eip")
emu.setRegs( rip = 0, rbp = 'old bp', rdi = a )
painter.drawState(emu)
for line_nr in emu: