23 lines
572 B
Python
23 lines
572 B
Python
from . import CustomInstruction
|
|
|
|
class Printf(CustomInstruction):
|
|
"""
|
|
printf() function
|
|
"""
|
|
|
|
tick_count = 0
|
|
stdout_enabled = True
|
|
|
|
def run(self, update_program_counter=True):
|
|
if self.stdout_enabled:
|
|
format_str = self.get_arg(0)
|
|
args = tuple([self.get_arg(i) for i in range(1, self.argc())])
|
|
|
|
try:
|
|
print("[PRINTF]: {}".format(format_str % args))
|
|
except TypeError:
|
|
print("[PRINTF]: {}, {}".format(format_str, args))
|
|
|
|
|
|
super().run(update_program_counter)
|