rv2fox: Understand .zero directive

This commit is contained in:
Ry 2023-02-07 00:47:03 -08:00
parent eec12a9e9a
commit 8b5d547107

View File

@ -68,6 +68,13 @@ class Emitter:
for d in data: for d in data:
self.write(f'data.{size} {d}') self.write(f'data.{size} {d}')
def zero(self, *data):
"""
Emit zeros
"""
for d in data:
self.write(f'data.fill 0, {d}')
def strz(self, *data): def strz(self, *data):
""" """
Emit null-terminated string Emit null-terminated string
@ -183,6 +190,8 @@ class Converter:
pass # ignore pass # ignore
elif m := re.fullmatch(r'word\s+([^\s]+)', line): elif m := re.fullmatch(r'word\s+([^\s]+)', line):
self.e.data(*m.groups()) self.e.data(*m.groups())
elif m := re.fullmatch(r'zero\s+([^\s]+)', line):
self.e.zero(*m.groups())
elif m := re.fullmatch(r'string\s+\"(.*)\"', line): elif m := re.fullmatch(r'string\s+\"(.*)\"', line):
self.e.strz(*m.groups()) self.e.strz(*m.groups())
elif m := re.fullmatch(r'asciz\s+\"(.*)\"', line): elif m := re.fullmatch(r'asciz\s+\"(.*)\"', line):