1313
1414import os
1515import re
16- from . import asmlex , basic
16+
1717import src .ply .yacc as yacc
18+ import src .api .utils
19+
20+ from src import outfmt
21+ from src .api import errmsg
1822
19- from .asmlex import tokens # noqa
20- from .asm import AsmInstruction , Error
2123from src .ast import Ast
2224from src .ast .tree import NotAnAstError
2325from src .api .debug import __DEBUG__
2426from src .api .config import OPTIONS
2527from src .api .errmsg import error
2628from src .api .errmsg import warning
2729from src .api import global_ as gl
28- import src .api .utils
2930from src .libzxbpp import zxbpp
30- from .. import outfmt
31+
32+ from . import asmlex , basic
33+ from .asmlex import tokens # noqa
34+ from .asm import AsmInstruction , Error
35+
3136
3237LEXER = asmlex .Lexer ()
3338
@@ -144,6 +149,8 @@ def bytes(self):
144149 return tuple ([0 ] * N ) # ??
145150
146151 args = self .argval ()
152+ if args [1 ] > 255 :
153+ errmsg .warning_value_will_be_truncated (self .lineno )
147154 num = args [1 ] & 0xFF
148155 return tuple ([num ] * args [0 ])
149156
@@ -165,7 +172,10 @@ def argval(self):
165172 return [None ]
166173
167174 if self .asm in ('DEFB' , 'DEFS' , 'DEFW' ):
168- return tuple ([x .eval () if isinstance (x , Expr ) else x for x in self .arg ])
175+ result = tuple ([x .eval () if isinstance (x , Expr ) else x for x in self .arg ])
176+ if self .asm == 'DEFB' and any (x > 255 for x in result ):
177+ errmsg .warning_value_will_be_truncated (self .lineno )
178+ return result
169179
170180 self .arg = tuple ([x if not isinstance (x , Expr ) else x .eval () for x in self .arg ])
171181 if gl .has_errors :
0 commit comments