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()):
|
for line in iter(source_text.splitlines()):
|
||||||
index = self.processSourceLine(line, index)
|
index = self.processSourceLine(line, index)
|
||||||
|
|
||||||
def setStack (self, *stack_list):
|
def setStack (self, *stack_list, **kwargs):
|
||||||
i = 0
|
"""
|
||||||
|
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:
|
for element in stack_list:
|
||||||
self.stack[i] = element
|
|
||||||
i += 1
|
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):
|
def setRegs (self, **reg_dict):
|
||||||
for reg_name, reg_val in reg_dict.iteritems():
|
for reg_name, reg_val in reg_dict.iteritems():
|
||||||
|
|
|
@ -60,10 +60,10 @@ if __name__ == "__main__":
|
||||||
printf("Running for fib({})", a)
|
printf("Running for fib({})", a)
|
||||||
|
|
||||||
# Setup
|
# Setup
|
||||||
emu = infernal.Emulator(fib_prog)
|
emu = infernal.Emulator(fib_prog) #infernal.Emulator(fib_iter_prog)
|
||||||
painter = infernal.TikzPainter()
|
painter = infernal.TikzPainter()
|
||||||
emu.setStack("junk...", "calling eip")
|
emu.setStack("junk...", "calling eip")
|
||||||
emu.setRegs( rip = 0, rbp = 'old bp', rsp = 1, rdi = a )
|
emu.setRegs( rip = 0, rbp = 'old bp', rdi = a )
|
||||||
|
|
||||||
painter.drawState(emu)
|
painter.drawState(emu)
|
||||||
for line_nr in emu:
|
for line_nr in emu:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user