Added minor functionality,
This commit is contained in:
parent
f564b27fa6
commit
53d45414f8
12
infernal.py
12
infernal.py
|
@ -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():
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user