diff --git a/.gitignore b/.gitignore index 0b39f1637..13995e649 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,6 @@ dist/ examples/*.bin examples/*.tzx scratch/ -.coverage/ +.coverage htmlcov/ build/ diff --git a/src/api/errmsg.py b/src/api/errmsg.py index 20eb85ec8..4020a1ce4 100644 --- a/src/api/errmsg.py +++ b/src/api/errmsg.py @@ -19,7 +19,7 @@ __all__ = ['error', 'warning'] -def msg_output(msg): +def msg_output(msg: str) -> None: if msg in global_.error_msg_cache: return @@ -27,13 +27,13 @@ def msg_output(msg): global_.error_msg_cache.add(msg) -def info(msg): +def info(msg: str) -> None: if OPTIONS.Debug < 1: return OPTIONS.stderr.write("info: %s\n" % msg) -def error(lineno, msg, fname: Optional[str] = None): +def error(lineno: int, msg: str, fname: Optional[str] = None) -> None: """ Generic syntax error routine """ if fname is None: @@ -51,7 +51,7 @@ def error(lineno, msg, fname: Optional[str] = None): global_.has_errors += 1 -def warning(lineno, msg, fname: Optional[str] = None): +def warning(lineno: int, msg: str, fname: Optional[str] = None) -> None: """ Generic warning error routine """ if fname is None: @@ -62,7 +62,7 @@ def warning(lineno, msg, fname: Optional[str] = None): global_.has_warnings += 1 -def warning_implicit_type(lineno, id_, type_=None): +def warning_implicit_type(lineno: int, id_: str, type_: str = None): """ Warning: Using default implicit type 'x' """ if OPTIONS.strict: @@ -75,19 +75,19 @@ def warning_implicit_type(lineno, id_, type_=None): warning(lineno, "Using default implicit type '%s' for '%s'" % (type_, id_)) -def warning_condition_is_always(lineno, cond=False): +def warning_condition_is_always(lineno: int, cond: bool = False): """ Warning: Condition is always false/true """ warning(lineno, "Condition is always %s" % cond) -def warning_conversion_lose_digits(lineno): +def warning_conversion_lose_digits(lineno: int): """ Warning: Conversion may lose significant digits """ warning(lineno, 'Conversion may lose significant digits') -def warning_empty_loop(lineno): +def warning_empty_loop(lineno: int): """ Warning: Empty loop """ warning(lineno, 'Empty loop') @@ -99,7 +99,7 @@ def warning_empty_if(lineno): warning(lineno, 'Useless empty IF ignored') -# Emmits an optimization warning +# Emits an optimization warning def warning_not_used(lineno, id_, kind='Variable'): if OPTIONS.optimization > 0: warning(lineno, "%s '%s' is never used" % (kind, id_)) @@ -109,7 +109,7 @@ def warning_not_used(lineno, id_, kind='Variable'): # Syntax error: Expected string instead of # numeric expression. # ---------------------------------------- -def syntax_error_expected_string(lineno, _type): +def syntax_error_expected_string(lineno: str, _type: str): error(lineno, "Expected a 'string' type expression, got '%s' instead" % _type) @@ -117,16 +117,15 @@ def syntax_error_expected_string(lineno, _type): # Syntax error: FOR variable should be X # instead of Y # ---------------------------------------- -def syntax_error_wrong_for_var(lineno, x, y): - error(lineno, "FOR variable should be '%s' instead of '%s'" % - (x, y)) +def syntax_error_wrong_for_var(lineno: str, x: str, y: str): + error(lineno, "FOR variable should be '%s' instead of '%s'" % (x, y)) # ---------------------------------------- # Syntax error: Initializer expression is # not constant # ---------------------------------------- -def syntax_error_not_constant(lineno): +def syntax_error_not_constant(lineno: int): error(lineno, "Initializer expression is not constant.") @@ -134,7 +133,7 @@ def syntax_error_not_constant(lineno): # Syntax error: Id is neither an array nor # a function # ---------------------------------------- -def syntax_error_not_array_nor_func(lineno, varname): +def syntax_error_not_array_nor_func(lineno: int, varname: str): error(lineno, "'%s' is neither an array nor a function." % varname) @@ -142,7 +141,7 @@ def syntax_error_not_array_nor_func(lineno, varname): # Syntax error: Id is neither an array nor # a function # ---------------------------------------- -def syntax_error_not_an_array(lineno, varname): +def syntax_error_not_an_array(lineno: int, varname: str): error(lineno, "'%s' is not an array (or has not been declared yet)" % varname) @@ -150,7 +149,7 @@ def syntax_error_not_an_array(lineno, varname): # Syntax error: function redefinition type # mismatch # ---------------------------------------- -def syntax_error_func_type_mismatch(lineno, entry): +def syntax_error_func_type_mismatch(lineno: int, entry): error(lineno, "Function '%s' (previously declared at %i) type mismatch" % (entry.name, entry.lineno)) @@ -158,7 +157,7 @@ def syntax_error_func_type_mismatch(lineno, entry): # Syntax error: function redefinition parm. # mismatch # ---------------------------------------- -def syntax_error_parameter_mismatch(lineno, entry): +def syntax_error_parameter_mismatch(lineno: int, entry): error(lineno, "Function '%s' (previously declared at %i) parameter mismatch" % (entry.name, entry.lineno)) @@ -166,14 +165,14 @@ def syntax_error_parameter_mismatch(lineno, entry): # Syntax error: can't convert value to the # given type. # ---------------------------------------- -def syntax_error_cant_convert_to_type(lineno, expr_str, type_): +def syntax_error_cant_convert_to_type(lineno: int, expr_str: str, type_: str): error(lineno, "Cant convert '%s' to type %s" % (expr_str, type_)) # ---------------------------------------- # Syntax error: is a SUB not a FUNCTION # ---------------------------------------- -def syntax_error_is_a_sub_not_a_func(lineno, name): +def syntax_error_is_a_sub_not_a_func(lineno: int, name: str): error(lineno, "'%s' is SUBROUTINE not a FUNCTION" % name) @@ -187,19 +186,19 @@ def syntax_error_undeclared_type(lineno: int, id_: str): # ---------------------------------------- # Cannot assign a value to 'var'. It's not a variable # ---------------------------------------- -def syntax_error_cannot_assign_not_a_var(lineno, id_): +def syntax_error_cannot_assign_not_a_var(lineno: int, id_: str): error(lineno, "Cannot assign a value to '%s'. It's not a variable" % id_) # ---------------------------------------- # Cannot assign a value to 'var'. It's not a variable # ---------------------------------------- -def syntax_error_address_must_be_constant(lineno): +def syntax_error_address_must_be_constant(lineno: int): error(lineno, 'Address must be a numeric constant expression') # ---------------------------------------- # Cannot pass an array by value # ---------------------------------------- -def syntax_error_cannot_pass_array_by_value(lineno, id_): +def syntax_error_cannot_pass_array_by_value(lineno: int, id_: str): error(lineno, "Array parameter '%s' must be passed ByRef" % id_) diff --git a/src/api/global_.py b/src/api/global_.py index 32f881569..cdc06a4a0 100644 --- a/src/api/global_.py +++ b/src/api/global_.py @@ -67,7 +67,7 @@ # ---------------------------------------------------------------------- # The current filename being processed (changes with each #include) # ---------------------------------------------------------------------- -FILENAME = '(stdin)' # name of current file being parsed +FILENAME: str = '(stdin)' # name of current file being parsed # ---------------------------------------------------------------------- # Global Symbol Table diff --git a/src/api/utils.py b/src/api/utils.py index a9dc64cee..76d7fad2d 100644 --- a/src/api/utils.py +++ b/src/api/utils.py @@ -15,6 +15,7 @@ from typing import Callable from typing import IO from typing import Iterable +from typing import Union from . import constants from . import global_ @@ -168,14 +169,14 @@ def get_final_value(symbol: symbols.SYMBOL) -> Any: return result -def timeout(seconds=10, error_message=os.strerror(errno.ETIME)): +def timeout(seconds: Union[Callable[[], int], int] = 10, error_message=os.strerror(errno.ETIME)): def decorator(func): def _handle_timeout(signum, frame): raise TimeoutError(error_message) def wrapper(*args, **kwargs): signal.signal(signal.SIGALRM, _handle_timeout) - signal.alarm(seconds) + signal.alarm(seconds() if isinstance(seconds, Callable) else seconds) try: result = func(*args, **kwargs) finally: diff --git a/src/libzxbc/zxblex.py b/src/libzxbc/zxblex.py index f7880bb44..3aff9eb26 100755 --- a/src/libzxbc/zxblex.py +++ b/src/libzxbc/zxblex.py @@ -10,10 +10,14 @@ # ---------------------------------------------------------------------- import sys +import re + from src.ply import lex -from .keywords import KEYWORDS as reserved from src import api from src.api.errmsg import error +from src.api import global_ + +from .keywords import KEYWORDS as reserved ASM = '' # Set to asm block when commenting @@ -420,6 +424,16 @@ def t_asm_comment(t): r';.*' +def t_asm_PREPROCLINE(t): + r'\#[ \t]*[Ll][Ii][Nn][Ee][ \t]+([0-9]+)(?:[ \t]+"((?:[^"]|"")*)")?[ \t]*\r?\n' + global ASM + + ASM += t.value + match = re.match('#[ \t]*[Ll][Ii][Nn][Ee][ \t]+([0-9]+)(?:[ \t]+"((?:[^"]|"")*)")?[ \t]*\r?\n', t.value) + t.lexer.lineno = int(match.groups()[0]) + global_.FILENAME = match.groups()[1] or global_.FILENAME + + def t_asm_next(t): r'.' global ASM diff --git a/src/libzxbpp/base_pplex.py b/src/libzxbpp/base_pplex.py new file mode 100755 index 000000000..9c9cdb96b --- /dev/null +++ b/src/libzxbpp/base_pplex.py @@ -0,0 +1,200 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +# ---------------------------------------------------------------------- +# Copyleft (K), Jose M. Rodriguez-Rosa (a.k.a. Boriel) +# +# This program is Free Software and is released under the terms of +# the GNU General License +# +# This is the Lexer for the ZXBppASM (ZXBASM Preprocessor) +# ---------------------------------------------------------------------- + +import sys +from dataclasses import dataclass + +from typing import Iterable +from typing import List +from typing import Optional +from typing import Tuple + +from src.ply import lex +import src.api.utils +from src.libzxbpp.prepro.output import warning, error + +EOL = '\n' + +# Names for std input/output +STDOUT = '' +STDIN = '' +STDERR = '' + + +@dataclass +class LexerState: + filename: str + lineno: int + lex: Optional[lex.Lexer] + input_data: str + + +class BaseLexer: + """ Own class lexer to allow multiple instances. + This lexer is just a wrapper of the current FILESTACK[-1] lexer + It's the base class for the asm and basic preprocessor lexers. + """ + + def __init__(self, tokens: Iterable[str], states: Iterable[Tuple[str, str]]): + """ Creates a new GLOBAL lexer instance + """ + self.lex: Optional[lex.Lexer] = None + self.filestack: List[LexerState] = [] # Current filename, and line number being parsed + self.input_data: str = '' + self.tokens = tuple(tokens) + self.states = tuple(states) + self.next_token = None # if set to something, this will be returned once + + def put_current_line(self, prefix: str = '', suffix: str = '') -> str: + """ Returns line and file for include / end of include sequences. + """ + assert self.lex is not None + return '%s#line %i "%s"%s' % (prefix, self.lex.lineno, self.filestack[-1].filename, suffix) + + def include(self, filename: str) -> str: + """ Changes FILENAME and line count + """ + if filename != STDIN and filename in set(x.filename for x in self.filestack): # Already included? + self.warning('Recursive inclusion') + + self.filestack.append(LexerState(filename, 1, self.lex, self.input_data)) + + if self.lex is None: + self.lex = lex.lex(object=self) + else: + self.lex = self.lex.clone() + self.lex.lineno = 1 # resets line number + + result = self.put_current_line() # First #line start with \n (EOL) + + try: + if filename == STDIN: + self.input_data = sys.stdin.read() + else: + self.input_data = src.api.utils.read_txt_file(filename) + if len(self.input_data) and self.input_data[-1] != EOL: + self.input_data += EOL + except IOError: + self.input_data = EOL + + self.lex.input(self.input_data) + return result + + def include_end(self): + """ Performs and end of include. + """ + old_lineno = self.lex.lineno + old_lexpos = self.lex.lexpos + self.lex = self.filestack[-1].lex + self.input_data = self.filestack[-1].input_data + self.filestack.pop() + + if not self.filestack: # End of input? + return None + + self.filestack[-1].lineno += 1 # Increment line counter of previous file + + result = lex.LexToken() # create token + result.value = self.put_current_line(suffix='\n') + result.type = '_ENDFILE_' + result.lineno = old_lineno + result.lexpos = old_lexpos + + return result + + def input(self, str_: str, filename: str = '', lexpos: int = 0): + """ Defines input string, removing current lexer. + """ + self.filestack.append(LexerState(filename, 1, self.lex, self.input_data)) + self.input_data = str_ + self.set_state(str_, lexpos) + + def set_state(self, new_input: str, new_lexpos: int = 0): + self.lex = lex.lex(object=self) + self.lex.input(new_input) + self.lexpos = new_lexpos + + @property + def lexpos(self) -> int: + if self.lex is None: + return 0 + + return self.lex.lexpos + + @lexpos.setter + def lexpos(self, value: int): + assert self.lex is not None + self.lex.lexpos = value + + @property + def lineno(self) -> int: + if self.lex is None: + return 0 + + return self.lex.lineno + + def token(self) -> Optional[lex.LexToken]: + """ Returns a token from the current input. If tok is None + from the current input, it means we are at end of current input + (e.g. at end of include file). If so, closes the current input + and discards it; then pops the previous input and lexer from + the input stack, and gets another token. + + If new token is again None, repeat the process described above + until the token is either not None, or self.lex is None, wich + means we must effectively return None, because parsing has + ended. + """ + tok = None + if self.next_token is not None: + tok = lex.LexToken() + tok.value = '' + tok.lineno = self.lex.lineno + tok.lexpos = self.lex.lexpos + tok.type = self.next_token + self.next_token = None + + while self.lex is not None and tok is None: + tok = self.lex.token() + if tok is not None: + break + + tok = self.include_end() + + return tok + + def find_column(self, token) -> int: + """ Compute column: + - token is a token instance + """ + i = token.lexpos + while i > 0: + if self.input_data[i - 1] == '\n': + break + i -= 1 + + column = token.lexpos - i + 1 + return column + + def error(self, msg: str, lineno: int = None): + """ Prints an error msg and continues execution. + """ + if lineno is None: + lineno = self.lineno + error(lineno, msg) + + def warning(self, msg: str, lineno: int = None): + """ Emits a warning and continue execution. + """ + if lineno is None: + lineno = self.lineno + warning(lineno, msg) diff --git a/src/libzxbpp/prepro/__init__.py b/src/libzxbpp/prepro/__init__.py index 5846dcb9e..743380c5f 100644 --- a/src/libzxbpp/prepro/__init__.py +++ b/src/libzxbpp/prepro/__init__.py @@ -1,6 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- # vim: ts=4:sw=4:et: + from .id_ import ID from .definestable import DefinesTable from .macrocall import MacroCall diff --git a/src/libzxbpp/prepro/args.py b/src/libzxbpp/prepro/args.py index afc656f52..fdc42045e 100644 --- a/src/libzxbpp/prepro/args.py +++ b/src/libzxbpp/prepro/args.py @@ -48,6 +48,8 @@ class ArgList(object): def __init__(self, table): self.table = table self.value = [] + self.start_lineno = -1 + self.end_lineno = -1 def __len__(self): return len(self.value) diff --git a/src/libzxbpp/prepro/id_.py b/src/libzxbpp/prepro/id_.py index 2f90c02aa..63b6a78a0 100644 --- a/src/libzxbpp/prepro/id_.py +++ b/src/libzxbpp/prepro/id_.py @@ -23,7 +23,7 @@ class ID: """ This class represents an identifier. It stores a string (the ID name and value by default). """ - __slots__ = 'name', 'value', 'lineno', 'fname', 'args' + __slots__ = 'name', 'value', 'lineno', 'fname', 'args', 'evaluating' def __init__(self, id_: str, args=None, value=None, lineno: int = None, fname: str = None): if fname is None: @@ -40,6 +40,7 @@ def __init__(self, id_: str, args=None, value=None, lineno: int = None, fname: s self.lineno: Optional[int] = lineno # line number at which de ID was defined self.fname: str = fname # file name in which the ID was defined self.args = args + self.evaluating = False @property def hasArgs(self) -> bool: @@ -64,10 +65,22 @@ def __call__(self, table) -> str: __DEBUG__("undefined (null) value. BUG?", DEBUG_LEVEL) return '' + if self.evaluating: + result = self.name + if self.hasArgs: + result += '(' + result += ', '.join(table[arg.name](table) if isinstance(arg, ID) else str(arg) for arg in self.args) + result += ')' + return result + + self.evaluating = True + result = '' for token in self.value: __DEBUG__("evaluating token '%s'" % str(token), DEBUG_LEVEL) if isinstance(token, MacroCall): + if isinstance(token.id_, MacroCall): + token.id_ = token.id_(table) __DEBUG__("token '%s'(%s) is a MacroCall" % (token.id_, str(token)), DEBUG_LEVEL) if table.defined(token.id_): tmp = table[token.id_] @@ -90,4 +103,5 @@ def __call__(self, table) -> str: __DEBUG__("token got value '%s'" % tmp, DEBUG_LEVEL) result += tmp + self.evaluating = False return result diff --git a/src/libzxbpp/prepro/macrocall.py b/src/libzxbpp/prepro/macrocall.py index fd8c7c5c9..1cd3f620a 100644 --- a/src/libzxbpp/prepro/macrocall.py +++ b/src/libzxbpp/prepro/macrocall.py @@ -2,7 +2,9 @@ # -*- coding: utf-8 -*- # vim:ts=4:et:sw=4: +import re import copy + from .exceptions import PreprocError from src.api.debug import __DEBUG__ @@ -10,6 +12,7 @@ DEBUG_LEVEL = 3 # Which -d level is required to show debug info +RE_ID = re.compile('(?:.*[^_0-9a-zA-Z]|^)([a-zA-Z_][a-zA-Z_0-9]*)$') class MacroCall: @@ -39,6 +42,9 @@ def eval(arg) -> str: def __call__(self, symbolTable: 'prepro.DefinesTable' = None) -> str: """ Execute the macro call using LAZY evaluation """ + if isinstance(self.id_, MacroCall): + self.id_ = self.id_() + __DEBUG__("evaluating '%s'" % self.id_, DEBUG_LEVEL) if symbolTable is None: symbolTable = self.table diff --git a/src/libzxbpp/prepro/output.py b/src/libzxbpp/prepro/output.py index 204bc4e7c..4ad26b3fe 100644 --- a/src/libzxbpp/prepro/output.py +++ b/src/libzxbpp/prepro/output.py @@ -6,17 +6,18 @@ Need the global OPTION object """ +from typing import List from typing import Optional import src.api.errmsg -CURRENT_FILE = [] # The current file being processed +CURRENT_FILE: List[str] = [] # The current file being processed -def error(lineno, str_, fname: Optional[str] = None): - src.api.errmsg.error(lineno, str_, fname=fname) +def error(lineno: int, msg: str, fname: Optional[str] = None): + src.api.errmsg.error(lineno, msg, fname=fname) -def warning(lineno, str_, fname: Optional[str] = None): - src.api.errmsg.warning(lineno, str_, fname=fname) +def warning(lineno: int, msg: str, fname: Optional[str] = None): + src.api.errmsg.warning(lineno, msg, fname=fname) diff --git a/src/libzxbpp/zxbasmpplex.py b/src/libzxbpp/zxbasmpplex.py index 6a8a746e2..87074fef9 100755 --- a/src/libzxbpp/zxbasmpplex.py +++ b/src/libzxbpp/zxbasmpplex.py @@ -10,12 +10,12 @@ # This is the Lexer for the ZXBppASM (ZXBASM Preprocessor) # ---------------------------------------------------------------------- -import os import sys from src.ply import lex -import src.api.utils -from src.libzxbpp.prepro.output import warning, error + +from .base_pplex import BaseLexer + EOL = '\n' @@ -37,7 +37,7 @@ _tokens = ('STRING', 'TOKEN', 'NEWLINE', '_ENDFILE_', 'FILENAME', 'ID', 'INTEGER', 'EQ', 'PUSH', 'POP', 'LP', 'LLP', 'RRP', 'RP', 'COMMA', - 'CONTINUE', 'NUMBER', 'SEPARATOR' + 'CONTINUE', 'NUMBER', 'SEPARATOR', 'PASTE' ) reserved_directives = { @@ -61,10 +61,15 @@ __COMMENT_LEVEL = 0 -class Lexer(object): +class Lexer(BaseLexer): """ Own class lexer to allow multiple instances. This lexer is just a wrapper of the current FILESTACK[-1] lexer """ + def __init__(self): + super().__init__( + tokens=tokens, + states=states + ) # -------------- TOKEN ACTIONS -------------- def t_INITIAL_asmcomment_CONTINUE(self, t): @@ -296,128 +301,6 @@ def t_defargs_defargsopt_prepro_define_defexpr_pragma_singlecomment_INITIAL_asmc """ pass # The lexer will raise an exception here. This is intended - def put_current_line(self, prefix=''): - """ Returns line and file for include / end of include sequences. - """ - return '%s#line %i "%s"\n' % (prefix, self.lex.lineno, os.path.basename(self.filestack[-1][0])) - - def include(self, filename): - """ Changes FILENAME and line count - """ - if filename != STDIN and filename in [x[0] for x in self.filestack]: # Already included? - self.warning(' Recursive inclusion') - - self.filestack.append([filename, 1, self.lex, self.input_data]) - self.lex = lex.lex(object=self) - result = self.put_current_line() # First #line start with \n (EOL) - - try: - if filename == STDIN: - self.input_data = sys.stdin.read() - else: - self.input_data = src.api.utils.read_txt_file(filename) - - if len(self.input_data) and self.input_data[-1] != EOL: - self.input_data += EOL - except IOError: - self.input_data = EOL - - self.lex.input(self.input_data) - return result - - def include_end(self): - """ Performs and end of include. - """ - self.lex = self.filestack[-1][2] - self.input_data = self.filestack[-1][3] - self.filestack.pop() - - if not self.filestack: # End of input? - return - - self.filestack[-1][1] += 1 # Increment line counter of previous file - - result = lex.LexToken() # Creates the token - result.value = self.put_current_line() - result.type = '_ENDFILE_' - result.lineno = self.lex.lineno - result.lexpos = self.lex.lexpos - - return result - - def input(self, str_, filename=''): - """ Defines input string, removing current lexer. - """ - self.filestack.append([filename, 1, self.lex, self.input_data]) - - self.input_data = str_ - self.lex = lex.lex(object=self) - self.lex.input(self.input_data) - - def token(self): - """ Returns a token from the current input. If tok is None - from the current input, it means we are at end of current input - (e.g. at end of include file). If so, closes the current input - and discards it; then pops the previous input and lexer from - the input stack, and gets another token. - - If new token is again None, repeat the process described above - until the token is either not None, or self.lex is None, wich - means we must effectively return None, because parsing has - ended. - """ - tok = None - if self.next_token is not None: - tok = lex.LexToken() - tok.value = '' - tok.lineno = self.lex.lineno - tok.lexpos = self.lex.lexpos - tok.type = self.next_token - self.next_token = None - - while self.lex is not None and tok is None: - tok = self.lex.token() - if tok is not None: - break - - tok = self.include_end() - - return tok - - def find_column(self, token): - """ Compute column: - - token is a token instance - """ - i = token.lexpos - while i > 0: - if self.input_data[i - 1] == '\n': - break - i -= 1 - - column = token.lexpos - i + 1 - - return column - - def error(self, msg): - """ Prints an error msg and continues execution. - """ - error(self.lex.lineno, msg) - - def warning(self, msg): - """ Emits a warning and continue execution. - """ - warning(self.lex.lineno, msg) - - def __init__(self): - """ Creates a new GLOBAL lexer instance - """ - self.lex = None - self.filestack = [] # Current filename, and line number being parsed - self.input_data = '' - self.tokens = tokens - self.states = states - self.next_token = None # if set to something, this will be returned once - # --------------------- PREPROCESSOR FUNCTIONS ------------------- diff --git a/src/libzxbpp/zxbpp.py b/src/libzxbpp/zxbpp.py index 04e889373..3559db975 100755 --- a/src/libzxbpp/zxbpp.py +++ b/src/libzxbpp/zxbpp.py @@ -13,13 +13,12 @@ import sys import os -import re import argparse from typing import NamedTuple, List from .zxbpplex import tokens # noqa -from . import zxbpplex -from . import zxbasmpplex +from src.libzxbpp import zxbpplex +from src.libzxbpp import zxbasmpplex from src.ply import yacc from src.api.config import OPTIONS @@ -36,7 +35,6 @@ OUTPUT = '' INCLUDED = {} # Already included files (with lines) -SPACES = re.compile(r'[ \t]+') # Set to BASIC or ASM depending on the Lexer context # e.g. for .ASM files should be set to zxbasmpplex.Lexer() @@ -62,12 +60,19 @@ class IfDef(NamedTuple): IFDEFS: List[IfDef] = [] # Push (Line, state here) precedence = ( - ('left', 'DUMMY'), + ('nonassoc', 'DUMMY'), ('left', 'EQ', 'NE', 'LT', 'LE', 'GT', 'GE'), ('right', 'LLP'), ) +def remove_spaces(x: str) -> str: + if not x: + return x + + return x.strip(' \t') or ' ' + + def init(): """ Initializes the preprocessor """ @@ -114,7 +119,7 @@ def setMode(mode): mode = mode.upper() if mode not in ('ASM', 'BASIC'): - raise PreprocError('Invalid mode "%s"' % mode) + raise PreprocError('Invalid mode "%s"' % mode, lineno=LEXER.lineno) if mode == 'ASM': LEXER = zxbasmpplex.Lexer() @@ -220,9 +225,11 @@ def p_program_tokenstring(p): """ program : defs NEWLINE """ try: - tmp = [str(x()) if isinstance(x, MacroCall) else x for x in p[1]] + tmp = [remove_spaces(str(x())) if isinstance(x, MacroCall) else x for x in p[1]] except PreprocError as v: error(v.lineno, v.message) + p[0] = [] + return tmp.append(p[2]) p[0] = tmp @@ -252,7 +259,7 @@ def p_program_newline(p): """ program : program defs NEWLINE """ try: - tmp = [str(x()) if isinstance(x, MacroCall) else x for x in p[2]] + tmp = [remove_spaces(str(x())) if isinstance(x, MacroCall) else x for x in p[2]] except PreprocError as v: error(v.lineno, v.message) p[0] = [] @@ -416,10 +423,10 @@ def p_define(p): """ if ENABLED: if p[4]: - if SPACES.match(p[4][0]): - p[4][0] = p[4][0][1:] + if p[4][0] in ' \t': # remove leading whitespaces + p[4][0] = p[4][0].lstrip(' \t') else: - warning(p.lineno(1), "missing whitespace after the macro name") + warning(p.lineno(1), "missing whitespace after macro name") ID_TABLE.define(p[2], args=p[3], value=p[4], lineno=p.lineno(2), fname=output.CURRENT_FILE[-1]) @@ -646,7 +653,8 @@ def p_defs_list_eps(p): def p_defs_list(p): """ defs : defs def """ - p[0] = p[1] + [p[2]] + p[0] = p[1] + p[0].append(p[2]) def p_def(p): @@ -659,27 +667,29 @@ def p_def(p): def p_def_macrocall(p): - """ def : macrocall + """ def : macrocall %prec DUMMY """ p[0] = p[1] def p_macrocall(p): - """ macrocall : ID args + """ macrocall : ID """ - p[0] = MacroCall(p.lineno(1), ID_TABLE, p[1], p[2]) + p[0] = MacroCall(p.lineno(1), ID_TABLE, p[1], None) -def p_args_eps(p): - """ args : %prec DUMMY +def p_macrocall_args(p): + """ macrocall : macrocall args """ - p[0] = None + p[0] = MacroCall(p[2].end_lineno, ID_TABLE, p[1], p[2]) def p_args(p): """ args : LLP arglist RRP """ p[0] = p[2] + p[0].start_lineno = p.slice[1].lineno + p[0].end_lineno = p.slice[3].lineno def p_arglist(p): @@ -710,7 +720,7 @@ def p_arg_argstring(p): def p_argstring(p): """ argstring : token - | macrocall + | macrocall %prec DUMMY """ p[0] = Arg(p[1]) @@ -723,7 +733,7 @@ def p_argstring_argslist(p): def p_argstring_token(p): """ argstring : argstring token - | argstring macrocall + | argstring macrocall %prec DUMMY """ p[0] = p[1] p[0].addToken(p[2]) @@ -789,7 +799,7 @@ def main(argv): return OUTPUT += include_once(included_file, 0, local_first=False) - if len(OUTPUT) and OUTPUT[-1] != '\n': + if OUTPUT and OUTPUT[-1] != '\n': OUTPUT += '\n' parser.parse(lexer=LEXER, debug=OPTIONS.debug_zxbpp) @@ -799,7 +809,7 @@ def main(argv): prev_file = global_.FILENAME global_.FILENAME = output.CURRENT_FILE[-1] OUTPUT += LEXER.include(output.CURRENT_FILE[-1]) - if len(OUTPUT) and OUTPUT[-1] != '\n': + if OUTPUT and OUTPUT[-1] != '\n': OUTPUT += '\n' parser.parse(lexer=LEXER, debug=OPTIONS.debug_zxbpp) @@ -808,7 +818,8 @@ def main(argv): return global_.has_errors -parser = yacc.yacc() +parser = src.api.utils.get_or_create('zxbpp', lambda: yacc.yacc(debug=True)) + parser.defaulted_states = {} ID_TABLE = DefinesTable() diff --git a/src/libzxbpp/zxbpplex.py b/src/libzxbpp/zxbpplex.py index eda37df0a..277094c9e 100755 --- a/src/libzxbpp/zxbpplex.py +++ b/src/libzxbpp/zxbpplex.py @@ -12,8 +12,8 @@ import sys from src.ply import lex -from src.libzxbpp.prepro.output import warning, error -import src.api.utils +from src.libzxbpp.base_pplex import BaseLexer + EOL = '\n' @@ -64,10 +64,19 @@ tokens = sorted(_tokens + tuple(reserved_directives.values())) -class Lexer(object): +class Lexer(BaseLexer): """ Own class lexer to allow multiple instances. This lexer is just a wrapper of the current FILESTACK[-1] lexer """ + def __init__(self): + """ Creates a new GLOBAL lexer instance + """ + super().__init__( + tokens=tokens, + states=states + ) + self.expectingDirective = False # True if the lexer expects a preprocessor directive + self.__COMMENT_LEVEL = 0 # -------------- TOKEN ACTIONS -------------- def t_INITIAL_COMMENT(self, t): @@ -385,141 +394,12 @@ def t_asm_asmcomment_if_msg_error(self, t): """ pass - def put_current_line(self, prefix='', suffix=''): - """ Returns line and file for include / end of include sequences. - """ - return '%s#line %i "%s"%s' % (prefix, self.lex.lineno, self.filestack[-1][0], suffix) - - def include(self, filename): - """ Changes FILENAME and line count - """ - if filename != STDIN and filename in [x[0] for x in self.filestack]: # Already included? - self.warning(filename + ' Recursive inclusion') - - self.filestack.append([filename, 1, self.lex, self.input_data]) - - if self.lex is None: - self.lex = lex.lex(object=self) - else: - self.lex = self.lex.clone() - self.lex.lineno = 1 # resets line number - - result = self.put_current_line() # First #line start with \n (EOL) - - try: - if filename == STDIN: - self.input_data = sys.stdin.read() - else: - self.input_data = src.api.utils.read_txt_file(filename) - if len(self.input_data) and self.input_data[-1] != EOL: - self.input_data += EOL - except IOError: - self.input_data = EOL - - self.lex.input(self.input_data) - return result - - def include_end(self): - """ Performs and end of include. - """ - old_lineno = self.lex.lineno - old_lexpos = self.lex.lexpos - self.lex = self.filestack[-1][2] - self.input_data = self.filestack[-1][3] - self.filestack.pop() - - if not self.filestack: # End of input? - return - - self.filestack[-1][1] += 1 # Increment line counter of previous file - - result = lex.LexToken() - result.value = self.put_current_line(suffix='\n') - result.type = '_ENDFILE_' - result.lineno = old_lineno - result.lexpos = old_lexpos - - return result - - def input(self, str, filename=''): - """ Defines input string, removing current lexer. - """ - self.filestack.append([filename, 1, self.lex, self.input_data]) - - self.input_data = str - self.lex = lex.lex(object=self) - self.lex.input(self.input_data) - - def token(self): - """ Returns a token from the current input. If tok is None - from the current input, it means we are at end of current input - (e.g. at end of include file). If so, closes the current input - and discards it; then pops the previous input and lexer from - the input stack, and gets another token. - - If new token is again None, repeat the process described above - until the token is either not None, or self.lex is None, wich - means we must effectively return None, because parsing has - ended. - """ - tok = None - if self.next_token is not None: - tok = lex.LexToken() - tok.value = '' - tok.lineno = self.lex.lineno - tok.lexpos = self.lex.lexpos - tok.type = self.next_token - self.next_token = None - - while self.lex is not None and tok is None: - tok = self.lex.token() - if tok is not None: - break - - tok = self.include_end() - - return tok - - def find_column(self, token): - """ Compute column: - - token is a token instance - """ - i = token.lexpos - while i > 0: - if self.input_data[i - 1] == '\n': - break - i -= 1 - - column = token.lexpos - i + 1 - return column - - def error(self, msg): - """ Prints an error msg and continues execution. - """ - error(self.lex.lineno, msg) - - def warning(self, msg): - """ Emits a warning and continue execution. - """ - warning(self.lex.lineno, msg) - - def __init__(self): - """ Creates a new GLOBAL lexer instance - """ - self.lex = None - self.filestack = [] # Current filename, and line number being parsed - self.input_data = '' - self.tokens = tokens - self.states = states - self.next_token = None # if set to something, this will be returned once - self.expectingDirective = False # True if the lexer expects a preprocessor directive - self.__COMMENT_LEVEL = 0 -# --------------------- PREPROCESOR FUNCTIONS ------------------- +# --------------------- PREPROCESSOR FUNCTIONS ------------------- # Needed for states -tmp = lex.lex(object=Lexer()) +lex.lex(object=Lexer()) # ------------------ Test if called from cmd line --------------- if __name__ == '__main__': # For testing purposes diff --git a/src/parsetab/tabs.dbm.bak b/src/parsetab/tabs.dbm.bak index a6d6c432a..284663b80 100644 --- a/src/parsetab/tabs.dbm.bak +++ b/src/parsetab/tabs.dbm.bak @@ -1,3 +1,4 @@ 'asmparse', (0, 254311) 'zxnext_asmparse', (254464, 285299) 'zxbparser', (540160, 712099) +'zxbpp', (1252352, 69831) diff --git a/src/parsetab/tabs.dbm.dat b/src/parsetab/tabs.dbm.dat index 529eb4470..37c0ebc7d 100644 Binary files a/src/parsetab/tabs.dbm.dat and b/src/parsetab/tabs.dbm.dat differ diff --git a/src/parsetab/tabs.dbm.dir b/src/parsetab/tabs.dbm.dir index a6d6c432a..284663b80 100644 --- a/src/parsetab/tabs.dbm.dir +++ b/src/parsetab/tabs.dbm.dir @@ -1,3 +1,4 @@ 'asmparse', (0, 254311) 'zxnext_asmparse', (254464, 285299) 'zxbparser', (540160, 712099) +'zxbpp', (1252352, 69831) diff --git a/tests/functional/arrbase1.asm b/tests/functional/arrbase1.asm index a3f966c01..55d44c6bc 100644 --- a/tests/functional/arrbase1.asm +++ b/tests/functional/arrbase1.asm @@ -86,7 +86,7 @@ __CALL_BACK__: __DATA__0: __DATA__END: DEFB 00h -#line 1 "array.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -102,7 +102,7 @@ __DATA__END: ; O = [a0 + b0 * (a1 + b1 * (a2 + ... bN-2(aN-1)))] ; What I will do here is to calculate the following sequence: ; ((aN-1 * bN-2) + aN-2) * bN-3 + ... -#line 1 "mul16.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/mul16.asm" __MUL16: ; Mutiplies HL with the last value stored into de stack ; Works for both signed and unsigned PROC @@ -126,8 +126,8 @@ __MUL16NOADD: djnz __MUL16LOOP ret ; Result in hl (16 lower bits) ENDP -#line 20 "array.asm" -#line 24 "/zxbasic/arch/zx48k/library-asm/array.asm" +#line 20 "/zxbasic/src/arch/zx48k/library-asm/array.asm" +#line 24 "/zxbasic/src/arch/zx48k/library-asm/array.asm" __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) inc hl @@ -156,9 +156,9 @@ __ARRAY: exx ld hl, 0 ; HL = Offset "accumulator" LOOP: -#line 62 "/zxbasic/arch/zx48k/library-asm/array.asm" +#line 62 "/zxbasic/src/arch/zx48k/library-asm/array.asm" pop bc ; Get next index (Ai) from the stack -#line 72 "/zxbasic/arch/zx48k/library-asm/array.asm" +#line 72 "/zxbasic/src/arch/zx48k/library-asm/array.asm" add hl, bc ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -177,7 +177,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 101 "/zxbasic/arch/zx48k/library-asm/array.asm" +#line 101 "/zxbasic/src/arch/zx48k/library-asm/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -185,7 +185,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 111 "/zxbasic/arch/zx48k/library-asm/array.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -215,7 +215,7 @@ TMP_ARR_PTR: DW 0 ; temporary storage for pointer to tables ENDP #line 48 "arrbase1.bas" -#line 1 "read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code ;; Updates the DATA_ADDR read ptr for the next read @@ -233,7 +233,7 @@ TMP_ARR_PTR: ;; 09: Float ;; bit7 is set for a parameter-less function ;; In that case, the next two bytes are the ptr of the function to jump -#line 1 "error.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" ; Simple error control routines ; vim:ts=4:et: ERR_NR EQU 23610 ; Error code system variable @@ -265,9 +265,9 @@ __ERROR_CODE: __STOP: ld (ERR_NR), a ret -#line 23 "read_restore.asm" -#line 1 "loadstr.asm" -#line 1 "alloc.asm" +#line 23 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -327,7 +327,7 @@ __STOP: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "heapinit.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -432,7 +432,7 @@ __MEM_INIT2: ld (__MEM_INIT), a; "Pokes" with a RET so ensure this routine is not called again ret ENDP -#line 70 "alloc.asm" +#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -462,9 +462,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 111 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ret z ; NULL -#line 113 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -528,7 +528,7 @@ __MEM_SUBTRACT: inc hl ; Return hl ret ENDP -#line 2 "loadstr.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again ; Finally, it returns result pointer in HL @@ -563,8 +563,8 @@ __LOADSTR: ; __FASTCALL__ entry ldir ; Copies string (length number included) pop hl ; Recovers destiny in hl as result ret -#line 24 "read_restore.asm" -#line 1 "iload32.asm" +#line 24 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iload32.asm" ; __FASTCALL__ routine which ; loads a 32 bits integer into DE,HL ; stored at position pointed by POINTER HL @@ -580,8 +580,8 @@ __ILOAD32: ld l, a ex de, hl ret -#line 25 "read_restore.asm" -#line 1 "iloadf.asm" +#line 25 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB ; stored at position pointed by POINTER HL @@ -606,10 +606,10 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL inc hl ld b, (hl) ret -#line 26 "read_restore.asm" -#line 1 "ftof16reg.asm" -#line 1 "ftou32reg.asm" -#line 1 "neg32.asm" +#line 26 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" __ABS32: bit 7, d ret z @@ -632,7 +632,7 @@ __NEG32: ; Negates DEHL (Two's complement) ret nz inc de ret -#line 2 "ftou32reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" __FTOU32REG: ; Converts a Float to (un)signed 32 bit integer (NOTE: It's ALWAYS 32 bit signed) ; Input FP number in A EDCB (A exponent, EDCB mantissa) ; Output: DEHL 32 bit number (signed) @@ -705,7 +705,7 @@ __FTOU8: ; Converts float in C ED LH to Unsigned byte in A call __FTOU32REG ld a, l ret -#line 2 "ftof16reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal ; Input FP number in A EDCB (A exponent, EDCB mantissa) ld l, a ; Saves exponent for later @@ -734,9 +734,9 @@ __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal jp c, __FTOU32REG_END ; It was decimal (0.xxx). We are done (return 0) ld b, a ; Loop counter = exponent - 128 + 16 (we need to shift 16 bit more) jp __FTOU32REG_LOOP ; proceed as an u32 integer -#line 27 "read_restore.asm" -#line 1 "f16tofreg.asm" -#line 1 "u32tofreg.asm" +#line 27 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" __I8TOFREG: ld l, a rlca @@ -804,7 +804,7 @@ __U32TOFREG_END: res 7, e ; Sets the sign bit to 0 (positive) ret ENDP -#line 3 "f16tofreg.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" __F16TOFREG: ; Converts a 16.16 signed fixed point (stored in DEHL) ; to a Floating Point Number returned in (C ED CB) PROC @@ -837,8 +837,8 @@ __F16TOFREG2: ; Converts an unsigned 32 bit integer (DEHL) ld e, c jp __U32TOFREG_LOOP ; Proceed as an integer ENDP -#line 28 "read_restore.asm" -#line 1 "free.asm" +#line 28 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -994,7 +994,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ld (hl), d ; Next saved ret ENDP -#line 29 "read_restore.asm" +#line 29 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; Updates restore point to the given HL mem. address __RESTORE: PROC @@ -1067,7 +1067,7 @@ dynamic_cast3: jr c, dynamic_cast4 ;; here the user expected type is "larger" than the read one ld a, b - sub 2 + sub 2 add a, a ld l, a ld h, 0 @@ -1272,4 +1272,4 @@ __DATA_ADDR: ;; Stores current DATA ptr dw __DATA__0 ENDP #line 49 "arrbase1.bas" - END + END \ No newline at end of file diff --git a/tests/functional/coverage.sh b/tests/functional/coverage.sh deleted file mode 100755 index a24f29c47..000000000 --- a/tests/functional/coverage.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Coverage tests using python coverage - -# TMP FILE used for output -TMPFILE=coverage.tmp.asm -ZXBASIC=~/src/spyder/zxbasic/zxb.py - -# Sets virtualenv por testing -#source virtualenvwrapper.sh -#workon tests - -# removes previous tests data if any -coverage erase - -for f in $*; do - coverage run -a $ZXBASIC --asm -o $TMPFILE $f - rm -f $TMPFILE -done - -# leave virtualenv -# deactivate - diff --git a/tests/functional/data1.asm b/tests/functional/data1.asm index cb35e0703..e6dace71d 100644 --- a/tests/functional/data1.asm +++ b/tests/functional/data1.asm @@ -56,7 +56,7 @@ __DATA__0: __DATA__1: __DATA__END: DEFB 00h -#line 1 "read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code ;; Updates the DATA_ADDR read ptr for the next read @@ -74,7 +74,7 @@ __DATA__END: ;; 09: Float ;; bit7 is set for a parameter-less function ;; In that case, the next two bytes are the ptr of the function to jump -#line 1 "error.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" ; Simple error control routines ; vim:ts=4:et: ERR_NR EQU 23610 ; Error code system variable @@ -106,9 +106,9 @@ __ERROR_CODE: __STOP: ld (ERR_NR), a ret -#line 23 "read_restore.asm" -#line 1 "loadstr.asm" -#line 1 "alloc.asm" +#line 23 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -168,7 +168,7 @@ __STOP: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "heapinit.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -273,7 +273,7 @@ __MEM_INIT2: ld (__MEM_INIT), a; "Pokes" with a RET so ensure this routine is not called again ret ENDP -#line 70 "alloc.asm" +#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -303,9 +303,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 111 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ret z ; NULL -#line 113 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -369,7 +369,7 @@ __MEM_SUBTRACT: inc hl ; Return hl ret ENDP -#line 2 "loadstr.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again ; Finally, it returns result pointer in HL @@ -404,8 +404,8 @@ __LOADSTR: ; __FASTCALL__ entry ldir ; Copies string (length number included) pop hl ; Recovers destiny in hl as result ret -#line 24 "read_restore.asm" -#line 1 "iload32.asm" +#line 24 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iload32.asm" ; __FASTCALL__ routine which ; loads a 32 bits integer into DE,HL ; stored at position pointed by POINTER HL @@ -421,8 +421,8 @@ __ILOAD32: ld l, a ex de, hl ret -#line 25 "read_restore.asm" -#line 1 "iloadf.asm" +#line 25 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB ; stored at position pointed by POINTER HL @@ -447,10 +447,10 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL inc hl ld b, (hl) ret -#line 26 "read_restore.asm" -#line 1 "ftof16reg.asm" -#line 1 "ftou32reg.asm" -#line 1 "neg32.asm" +#line 26 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" __ABS32: bit 7, d ret z @@ -473,7 +473,7 @@ __NEG32: ; Negates DEHL (Two's complement) ret nz inc de ret -#line 2 "ftou32reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" __FTOU32REG: ; Converts a Float to (un)signed 32 bit integer (NOTE: It's ALWAYS 32 bit signed) ; Input FP number in A EDCB (A exponent, EDCB mantissa) ; Output: DEHL 32 bit number (signed) @@ -546,7 +546,7 @@ __FTOU8: ; Converts float in C ED LH to Unsigned byte in A call __FTOU32REG ld a, l ret -#line 2 "ftof16reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal ; Input FP number in A EDCB (A exponent, EDCB mantissa) ld l, a ; Saves exponent for later @@ -575,9 +575,9 @@ __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal jp c, __FTOU32REG_END ; It was decimal (0.xxx). We are done (return 0) ld b, a ; Loop counter = exponent - 128 + 16 (we need to shift 16 bit more) jp __FTOU32REG_LOOP ; proceed as an u32 integer -#line 27 "read_restore.asm" -#line 1 "f16tofreg.asm" -#line 1 "u32tofreg.asm" +#line 27 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" __I8TOFREG: ld l, a rlca @@ -645,7 +645,7 @@ __U32TOFREG_END: res 7, e ; Sets the sign bit to 0 (positive) ret ENDP -#line 3 "f16tofreg.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" __F16TOFREG: ; Converts a 16.16 signed fixed point (stored in DEHL) ; to a Floating Point Number returned in (C ED CB) PROC @@ -678,8 +678,8 @@ __F16TOFREG2: ; Converts an unsigned 32 bit integer (DEHL) ld e, c jp __U32TOFREG_LOOP ; Proceed as an integer ENDP -#line 28 "read_restore.asm" -#line 1 "free.asm" +#line 28 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -835,7 +835,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ld (hl), d ; Next saved ret ENDP -#line 29 "read_restore.asm" +#line 29 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; Updates restore point to the given HL mem. address __RESTORE: PROC @@ -908,7 +908,7 @@ dynamic_cast3: jr c, dynamic_cast4 ;; here the user expected type is "larger" than the read one ld a, b - sub 2 + sub 2 add a, a ld l, a ld h, 0 @@ -1113,7 +1113,7 @@ __DATA_ADDR: ;; Stores current DATA ptr dw __DATA__0 ENDP #line 33 "data1.bas" -#line 1 "storef.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/storef.asm" __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) push de ex de, hl ; DE <- HL @@ -1140,4 +1140,4 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret #line 34 "data1.bas" - END + END \ No newline at end of file diff --git a/tests/functional/emook0.out b/tests/functional/emook0.out index 9fdc31ec5..7fb90e2bb 100644 --- a/tests/functional/emook0.out +++ b/tests/functional/emook0.out @@ -1,6 +1,11 @@ #line 1 "emook0.bi" + + ASM + LD A,A LD BC,254 #line 6 + end Asm + diff --git a/tests/functional/error_array.bas b/tests/functional/error_array.bas new file mode 100644 index 000000000..3f3f09cdd --- /dev/null +++ b/tests/functional/error_array.bas @@ -0,0 +1,4 @@ + +DIM z(30) as Ubyte +LET z$="#" + diff --git a/tests/functional/opt3_data2.asm b/tests/functional/opt3_data2.asm index ec4663fd3..b1427686f 100644 --- a/tests/functional/opt3_data2.asm +++ b/tests/functional/opt3_data2.asm @@ -139,7 +139,7 @@ __DATA__1: DEFW ___DATA__FUNCPTR__5 __DATA__END: DEFB 00h -#line 1 "array.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -155,7 +155,7 @@ __DATA__END: ; O = [a0 + b0 * (a1 + b1 * (a2 + ... bN-2(aN-1)))] ; What I will do here is to calculate the following sequence: ; ((aN-1 * bN-2) + aN-2) * bN-3 + ... -#line 1 "mul16.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/mul16.asm" __MUL16: ; Mutiplies HL with the last value stored into de stack ; Works for both signed and unsigned PROC @@ -179,8 +179,8 @@ __MUL16NOADD: djnz __MUL16LOOP ret ; Result in hl (16 lower bits) ENDP -#line 20 "array.asm" -#line 24 "/zxbasic/arch/zx48k/library-asm/array.asm" +#line 20 "/zxbasic/src/arch/zx48k/library-asm/array.asm" +#line 24 "/zxbasic/src/arch/zx48k/library-asm/array.asm" __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) inc hl @@ -209,9 +209,9 @@ __ARRAY: exx ld hl, 0 ; HL = Offset "accumulator" LOOP: -#line 62 "/zxbasic/arch/zx48k/library-asm/array.asm" +#line 62 "/zxbasic/src/arch/zx48k/library-asm/array.asm" pop bc ; Get next index (Ai) from the stack -#line 72 "/zxbasic/arch/zx48k/library-asm/array.asm" +#line 72 "/zxbasic/src/arch/zx48k/library-asm/array.asm" add hl, bc ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -230,7 +230,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 101 "/zxbasic/arch/zx48k/library-asm/array.asm" +#line 101 "/zxbasic/src/arch/zx48k/library-asm/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -238,7 +238,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 111 "/zxbasic/arch/zx48k/library-asm/array.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -268,7 +268,7 @@ TMP_ARR_PTR: DW 0 ; temporary storage for pointer to tables ENDP #line 97 "opt3_data2.bas" -#line 1 "mul8.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/mul8.asm" __MUL8: ; Performs 8bit x 8bit multiplication PROC ;LOCAL __MUL8A @@ -313,12 +313,12 @@ __MUL8B: ret ; result = HL ENDP #line 98 "opt3_data2.bas" -#line 1 "print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; vim:ts=4:sw=4:et: ; vim:ts=4:sw=4:et: ; PRINT command routine ; Does not print attribute. Use PRINT_STR or PRINT_NUM for that -#line 1 "sposn.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/sposn.asm" ; Printing positioning library. PROC LOCAL ECHO_E @@ -342,8 +342,8 @@ __SAVE_S_POSN: ; Saves ROW, COL from DE into S_POSN mem var. POSX EQU S_POSN ; Current POS X POSY EQU S_POSN + 1 ; Current POS Y ENDP -#line 7 "print.asm" -#line 1 "cls.asm" +#line 7 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/cls.asm" ; JUMPS directly to spectrum CLS ; This routine does not clear lower screen ;CLS EQU 0DAFh @@ -379,9 +379,9 @@ __CLS_SCR: SCREEN_ADDR EQU (__CLS_SCR + 1) ; Address used by print and other screen routines ; to get the start of the screen ENDP -#line 8 "print.asm" -#line 1 "in_screen.asm" -#line 1 "error.asm" +#line 8 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" ; Simple error control routines ; vim:ts=4:et: ERR_NR EQU 23610 ; Error code system variable @@ -413,7 +413,7 @@ __ERROR_CODE: __STOP: ld (ERR_NR), a ret -#line 3 "in_screen.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" __IN_SCREEN: ; Returns NO carry if current coords (D, E) ; are OUT of the screen limits (MAXX, MAXY) @@ -435,8 +435,8 @@ __OUT_OF_SCREEN_ERR: ld a, ERROR_OutOfScreen jp __STOP ; Saves error code and exits ENDP -#line 9 "print.asm" -#line 1 "table_jump.asm" +#line 9 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/table_jump.asm" JUMP_HL_PLUS_2A: ; Does JP (HL + A*2) Modifies DE. Modifies A add a, a JUMP_HL_PLUS_A: ; Does JP (HL + A) Modifies DE @@ -450,11 +450,11 @@ JUMP_HL_PLUS_DE: ; Does JP (HL + DE) ex de, hl CALL_HL: jp (hl) -#line 10 "print.asm" -#line 1 "ink.asm" +#line 10 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" ; Sets ink color in ATTR_P permanently ; Parameter: Paper color in A register -#line 1 "const.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/const.asm" ; Global constants P_FLAG EQU 23697 FLAGS2 EQU 23681 @@ -463,7 +463,7 @@ CALL_HL: CHARS EQU 23606 ; Pointer to ROM/RAM Charset UDG EQU 23675 ; Pointer to UDG Charset MEM0 EQU 5C92h ; Temporary memory buffer used by ROM chars -#line 5 "ink.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" INK: PROC LOCAL __SET_INK @@ -495,8 +495,8 @@ INK_TMP: ld de, ATTR_T jp __SET_INK ENDP -#line 11 "print.asm" -#line 1 "paper.asm" +#line 11 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/paper.asm" ; Sets paper color in ATTR_P permanently ; Parameter: Paper color in A register PAPER: @@ -533,8 +533,8 @@ PAPER_TMP: ld de, ATTR_T jp __SET_PAPER ENDP -#line 12 "print.asm" -#line 1 "flash.asm" +#line 12 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/flash.asm" ; Sets flash flag in ATTR_P permanently ; Parameter: Paper color in A register FLASH: @@ -568,8 +568,8 @@ FLASH_TMP: ld hl, ATTR_T jr __SET_FLASH ENDP -#line 13 "print.asm" -#line 1 "bright.asm" +#line 13 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bright.asm" ; Sets bright flag in ATTR_P permanently ; Parameter: Paper color in A register BRIGHT: @@ -603,12 +603,12 @@ BRIGHT_TMP: ld hl, ATTR_T jr __SET_BRIGHT ENDP -#line 14 "print.asm" -#line 1 "over.asm" +#line 14 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/over.asm" ; Sets OVER flag in P_FLAG permanently ; Parameter: OVER flag in bit 0 of A register -#line 1 "copy_attr.asm" -#line 4 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" COPY_ATTR: ; Just copies current permanent attribs to temporal attribs ; and sets print mode @@ -648,7 +648,7 @@ TABLE: xor (hl) ; OVER 1 MODE and (hl) ; OVER 2 MODE or (hl) ; OVER 3 MODE -#line 65 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 65 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" __REFRESH_TMP: ld a, (hl) and 10101010b @@ -658,7 +658,7 @@ __REFRESH_TMP: ld (hl), a ret ENDP -#line 4 "over.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/over.asm" OVER: PROC ld c, a ; saves it for later @@ -692,8 +692,8 @@ OVER_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 15 "print.asm" -#line 1 "inverse.asm" +#line 15 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/inverse.asm" ; Sets INVERSE flag in P_FLAG permanently ; Parameter: INVERSE flag in bit 0 of A register INVERSE: @@ -718,8 +718,8 @@ INVERSE_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 16 "print.asm" -#line 1 "bold.asm" +#line 16 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bold.asm" ; Sets BOLD flag in P_FLAG permanently ; Parameter: BOLD flag in bit 0 of A register BOLD: @@ -744,8 +744,8 @@ BOLD_TMP: ld (hl), a ret ENDP -#line 17 "print.asm" -#line 1 "italic.asm" +#line 17 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/italic.asm" ; Sets ITALIC flag in P_FLAG permanently ; Parameter: ITALIC flag in bit 0 of A register ITALIC: @@ -772,8 +772,8 @@ ITALIC_TMP: ld (hl), a ret ENDP -#line 18 "print.asm" -#line 1 "attr.asm" +#line 18 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/attr.asm" ; Attribute routines ; vim:ts=4:et:sw: __ATTR_ADDR: @@ -830,7 +830,7 @@ SET_PIXEL_ADDR_ATTR: ld de, (SCREEN_ADDR) add hl, de ;; Final screen addr jp __SET_ATTR2 -#line 20 "print.asm" +#line 20 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; Putting a comment starting with @INIT
; will make the compiler to add a CALL to
; It is useful for initialization routines. @@ -870,14 +870,14 @@ __SCROLL: ; Scroll? ld hl, __TVFLAGS res 1, (hl) ret -#line 76 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 76 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_START: cp ' ' jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones exx ; Switch to alternative registers ex af, af' ; Saves a value (char to print) for later call __SCROLL -#line 87 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 87 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN ; At this point we have the new coord ld hl, (SCREEN_ADDR) @@ -972,7 +972,7 @@ PRINT_EOL: ; Called WHENEVER there is no ";" at end of PRINT sentence exx __PRINT_0Dh: ; Called WHEN printing CHR$(13) call __SCROLL -#line 210 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 210 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN __PRINT_EOL1: ; Another entry called from PRINT when next line required ld e, 0 @@ -986,7 +986,7 @@ __PRINT_AT1_END: ld hl, __TVFLAGS set 1, (hl) ld a, d -#line 230 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 230 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_EOL_END: ld d, a __PRINT_AT2_END: @@ -1199,7 +1199,7 @@ PRINT_AT: ; Changes cursor to ROW, COL ret nc ; Return if out of screen ld hl, __TVFLAGS res 1, (hl) -#line 482 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 482 "/zxbasic/src/arch/zx48k/library-asm/print.asm" jp __SAVE_S_POSN LOCAL __PRINT_COM LOCAL __BOLD @@ -1246,9 +1246,9 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes DW __PRINT_TAB ; 23 TAB ENDP #line 99 "opt3_data2.bas" -#line 1 "printu8.asm" -#line 1 "printi8.asm" -#line 1 "printnum.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printu8.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printi8.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printnum.asm" __PRINTU_START: PROC LOCAL __PRINTU_CONT @@ -1269,8 +1269,8 @@ __PRINT_MINUS: ; PRINT the MINUS (-) sign. CALLER mus preserve registers ld a, '-' jp __PRINT_DIGIT __PRINT_DIGIT EQU __PRINTCHAR ; PRINTS the char in A register, and puts its attrs -#line 2 "printi8.asm" -#line 1 "div8.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/printi8.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/div8.asm" ; -------------------------------- __DIVU8: ; 8 bit unsigned integer division ; Divides (Top of stack, High Byte) / A @@ -1333,7 +1333,7 @@ __MODI8_FAST: ; __FASTCALL__ entry call __DIVI8_FAST ld a, l ; remainder ret ; a = Modulus -#line 3 "printi8.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/printi8.asm" __PRINTI8: ; Prints an 8 bits number in Accumulator (A) ; Converts 8 to 32 bits or a @@ -1360,9 +1360,9 @@ __PRINTU_LOOP: inc b jp __PRINTU_LOOP ; Uses JP in loops ENDP -#line 2 "printu8.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/printu8.asm" #line 100 "opt3_data2.bas" -#line 1 "read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code ;; Updates the DATA_ADDR read ptr for the next read @@ -1380,8 +1380,8 @@ __PRINTU_LOOP: ;; 09: Float ;; bit7 is set for a parameter-less function ;; In that case, the next two bytes are the ptr of the function to jump -#line 1 "loadstr.asm" -#line 1 "alloc.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1441,7 +1441,7 @@ __PRINTU_LOOP: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "heapinit.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1546,7 +1546,7 @@ __MEM_INIT2: ld (__MEM_INIT), a; "Pokes" with a RET so ensure this routine is not called again ret ENDP -#line 70 "alloc.asm" +#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -1576,9 +1576,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 111 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ret z ; NULL -#line 113 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -1642,7 +1642,7 @@ __MEM_SUBTRACT: inc hl ; Return hl ret ENDP -#line 2 "loadstr.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again ; Finally, it returns result pointer in HL @@ -1677,8 +1677,8 @@ __LOADSTR: ; __FASTCALL__ entry ldir ; Copies string (length number included) pop hl ; Recovers destiny in hl as result ret -#line 24 "read_restore.asm" -#line 1 "iload32.asm" +#line 24 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iload32.asm" ; __FASTCALL__ routine which ; loads a 32 bits integer into DE,HL ; stored at position pointed by POINTER HL @@ -1694,8 +1694,8 @@ __ILOAD32: ld l, a ex de, hl ret -#line 25 "read_restore.asm" -#line 1 "iloadf.asm" +#line 25 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB ; stored at position pointed by POINTER HL @@ -1720,10 +1720,10 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL inc hl ld b, (hl) ret -#line 26 "read_restore.asm" -#line 1 "ftof16reg.asm" -#line 1 "ftou32reg.asm" -#line 1 "neg32.asm" +#line 26 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" __ABS32: bit 7, d ret z @@ -1746,7 +1746,7 @@ __NEG32: ; Negates DEHL (Two's complement) ret nz inc de ret -#line 2 "ftou32reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" __FTOU32REG: ; Converts a Float to (un)signed 32 bit integer (NOTE: It's ALWAYS 32 bit signed) ; Input FP number in A EDCB (A exponent, EDCB mantissa) ; Output: DEHL 32 bit number (signed) @@ -1819,7 +1819,7 @@ __FTOU8: ; Converts float in C ED LH to Unsigned byte in A call __FTOU32REG ld a, l ret -#line 2 "ftof16reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal ; Input FP number in A EDCB (A exponent, EDCB mantissa) ld l, a ; Saves exponent for later @@ -1848,9 +1848,9 @@ __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal jp c, __FTOU32REG_END ; It was decimal (0.xxx). We are done (return 0) ld b, a ; Loop counter = exponent - 128 + 16 (we need to shift 16 bit more) jp __FTOU32REG_LOOP ; proceed as an u32 integer -#line 27 "read_restore.asm" -#line 1 "f16tofreg.asm" -#line 1 "u32tofreg.asm" +#line 27 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" __I8TOFREG: ld l, a rlca @@ -1918,7 +1918,7 @@ __U32TOFREG_END: res 7, e ; Sets the sign bit to 0 (positive) ret ENDP -#line 3 "f16tofreg.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" __F16TOFREG: ; Converts a 16.16 signed fixed point (stored in DEHL) ; to a Floating Point Number returned in (C ED CB) PROC @@ -1951,8 +1951,8 @@ __F16TOFREG2: ; Converts an unsigned 32 bit integer (DEHL) ld e, c jp __U32TOFREG_LOOP ; Proceed as an integer ENDP -#line 28 "read_restore.asm" -#line 1 "free.asm" +#line 28 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -2108,7 +2108,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ld (hl), d ; Next saved ret ENDP -#line 29 "read_restore.asm" +#line 29 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; Updates restore point to the given HL mem. address __RESTORE: PROC @@ -2181,7 +2181,7 @@ dynamic_cast3: jr c, dynamic_cast4 ;; here the user expected type is "larger" than the read one ld a, b - sub 2 + sub 2 add a, a ld l, a ld h, 0 @@ -2386,4 +2386,4 @@ __DATA_ADDR: ;; Stores current DATA ptr dw __DATA__0 ENDP #line 101 "opt3_data2.bas" - END + END \ No newline at end of file diff --git a/tests/functional/prepro00.out b/tests/functional/prepro00.out index 81478a10d..15da5d2ae 100644 --- a/tests/functional/prepro00.out +++ b/tests/functional/prepro00.out @@ -1,38 +1,104 @@ #line 1 "prepro00.bi" #line 1 "/zxbasic/src/arch/zx48k/library/attr.bas" + + + + + + + + + + + + + #pragma push(case_insensitive) #pragma case_insensitive = TRUE + + + + + + + + + + + function attr(byval row as ubyte, byval col as ubyte) as ubyte asm + PROC LOCAL __ATTR_END + ld e, (ix+7) ld d, (ix+5) + + call __IN_SCREEN jr nc, __ATTR_END + call __ATTR_ADDR ld a, (hl) + __ATTR_END: ENDP + end asm + end function + + + + + + + + + + + + + + sub setattr(byval row as ubyte, byval col as ubyte, byval value as ubyte) asm + PROC LOCAL __ATTR_END + ld e, (ix+7) ld d, (ix+5) + + call __IN_SCREEN jr nc, __ATTR_END + call __ATTR_ADDR ld a, (ix+9) ld (hl), a + __ATTR_END: ENDP + end asm + end sub + + + + + + + + + + + function fastcall attraddr(byval row as ubyte, byval col as ubyte) as uinteger asm + pop hl ex (sp), hl ld d, a @@ -40,9 +106,19 @@ function fastcall attraddr(byval row as ubyte, byval col as ubyte) as uinteger jp __ATTR_ADDR end asm end function + + + #pragma pop(case_insensitive) + + #require "attr.asm" + + #require "in_screen.asm" + #line 119 "/zxbasic/src/arch/zx48k/library/attr.bas" + #line 2 "prepro00.bi" PRINT "HELLO" + diff --git a/tests/functional/prepro01.out b/tests/functional/prepro01.out index f3f634906..4e4fc9241 100644 --- a/tests/functional/prepro01.out +++ b/tests/functional/prepro01.out @@ -1,38 +1,104 @@ #line 1 "prepro01.bi" #line 1 "/zxbasic/src/arch/zx48k/library/attr.bas" + + + + + + + + + + + + + #pragma push(case_insensitive) #pragma case_insensitive = TRUE + + + + + + + + + + + function attr(byval row as ubyte, byval col as ubyte) as ubyte asm + PROC LOCAL __ATTR_END + ld e, (ix+7) ld d, (ix+5) + + call __IN_SCREEN jr nc, __ATTR_END + call __ATTR_ADDR ld a, (hl) + __ATTR_END: ENDP + end asm + end function + + + + + + + + + + + + + + sub setattr(byval row as ubyte, byval col as ubyte, byval value as ubyte) asm + PROC LOCAL __ATTR_END + ld e, (ix+7) ld d, (ix+5) + + call __IN_SCREEN jr nc, __ATTR_END + call __ATTR_ADDR ld a, (ix+9) ld (hl), a + __ATTR_END: ENDP + end asm + end sub + + + + + + + + + + + function fastcall attraddr(byval row as ubyte, byval col as ubyte) as uinteger asm + pop hl ex (sp), hl ld d, a @@ -40,9 +106,20 @@ function fastcall attraddr(byval row as ubyte, byval col as ubyte) as uinteger jp __ATTR_ADDR end asm end function + + + #pragma pop(case_insensitive) + + #require "attr.asm" + + #require "in_screen.asm" + #line 119 "/zxbasic/src/arch/zx48k/library/attr.bas" + #line 2 "prepro01.bi" + PRINT "HOLA" + diff --git a/tests/functional/prepro02.out b/tests/functional/prepro02.out index 11ef53d61..998c05f24 100644 --- a/tests/functional/prepro02.out +++ b/tests/functional/prepro02.out @@ -1,2 +1,9 @@ #line 1 "prepro02.bi" + + + + #line 6 "prepro02.bi" + + + diff --git a/tests/functional/prepro03.out b/tests/functional/prepro03.out index d9ca7e437..23a24a466 100644 --- a/tests/functional/prepro03.out +++ b/tests/functional/prepro03.out @@ -1,3 +1,11 @@ #line 1 "prepro03.bi" -x -y + + + + +x +y + + + + diff --git a/tests/functional/prepro04.out b/tests/functional/prepro04.out index 24f5f26d5..a9b5f342c 100644 --- a/tests/functional/prepro04.out +++ b/tests/functional/prepro04.out @@ -1,3 +1,7 @@ #line 1 "prepro04.bi" + #line 5 "prepro04.bi" + #line 7 "prepro04.bi" + + diff --git a/tests/functional/prepro05.out b/tests/functional/prepro05.out index 9c2516264..0b2daf94e 100644 --- a/tests/functional/prepro05.out +++ b/tests/functional/prepro05.out @@ -1,3 +1,11 @@ #line 1 "prepro05.bi" -y + + + + +y test2 + + + + diff --git a/tests/functional/prepro06.out b/tests/functional/prepro06.out index 47e97ccba..de861da4f 100644 --- a/tests/functional/prepro06.out +++ b/tests/functional/prepro06.out @@ -1,2 +1,10 @@ #line 1 "prepro06.bi" + + + + func () + + + + diff --git a/tests/functional/prepro09.out b/tests/functional/prepro09.out index 105b451a9..d77b6f49a 100644 --- a/tests/functional/prepro09.out +++ b/tests/functional/prepro09.out @@ -1 +1,5 @@ #line 1 "prepro09.bi" + + + + diff --git a/tests/functional/prepro10.out b/tests/functional/prepro10.out index c46d4df7d..dbca9aa93 100644 --- a/tests/functional/prepro10.out +++ b/tests/functional/prepro10.out @@ -1,4 +1,7 @@ #line 1 "prepro10.bi" + + function test(byval a as byte) let test = 0 end function + diff --git a/tests/functional/prepro11.out b/tests/functional/prepro11.out index cfab134e5..6b285bf5e 100644 --- a/tests/functional/prepro11.out +++ b/tests/functional/prepro11.out @@ -1,2 +1,10 @@ #line 1 "prepro11.bi" + + + + + + PRINT "HELLO WORLD" + + diff --git a/tests/functional/prepro12.out b/tests/functional/prepro12.out index 439c87300..be40bb7e3 100644 --- a/tests/functional/prepro12.out +++ b/tests/functional/prepro12.out @@ -1,2 +1,10 @@ #line 1 "prepro12.bi" + + + + + + )PRINT "HELLO WORLD" + + diff --git a/tests/functional/prepro13.out b/tests/functional/prepro13.out index fc47d6aad..abc3eae6c 100644 --- a/tests/functional/prepro13.out +++ b/tests/functional/prepro13.out @@ -1,2 +1,10 @@ #line 1 "prepro13.bi" + + + + + + PRINT "HELLO WORLD" + + diff --git a/tests/functional/prepro14.out b/tests/functional/prepro14.out index 3da85cf2d..c461971d2 100644 --- a/tests/functional/prepro14.out +++ b/tests/functional/prepro14.out @@ -1,2 +1,11 @@ #line 1 "prepro14.bi" + + + + + + + PRINT "HELLO WORLD" + + diff --git a/tests/functional/prepro15.out b/tests/functional/prepro15.out index cad8432e2..13d6a5a08 100644 --- a/tests/functional/prepro15.out +++ b/tests/functional/prepro15.out @@ -1,4 +1,14 @@ #line 1 "prepro15.bi" + + + + + + + + PRINT 10; PRINT "Hello"; macro + + diff --git a/tests/functional/prepro16.out b/tests/functional/prepro16.out index ccdc18474..185f08a7b 100644 --- a/tests/functional/prepro16.out +++ b/tests/functional/prepro16.out @@ -1,3 +1,13 @@ #line 1 "prepro16.bi" + + + + + + + + PRINT 20; PRINT 10 + 20; + + diff --git a/tests/functional/prepro17.out b/tests/functional/prepro17.out index f4d9c8e99..129f6d3a3 100644 --- a/tests/functional/prepro17.out +++ b/tests/functional/prepro17.out @@ -1,2 +1,10 @@ #line 1 "prepro17.bi" + + + + + + PRINT PRINT PRINT 10;;; + + diff --git a/tests/functional/prepro18.out b/tests/functional/prepro18.out index ce12121d0..403b30cf8 100644 --- a/tests/functional/prepro18.out +++ b/tests/functional/prepro18.out @@ -1,2 +1,9 @@ #line 1 "prepro18.bi" + + + + + PRINT (10, 20); + + diff --git a/tests/functional/prepro19.out b/tests/functional/prepro19.out index 1040df65b..42d912f48 100644 --- a/tests/functional/prepro19.out +++ b/tests/functional/prepro19.out @@ -1,2 +1,9 @@ #line 1 "prepro19.bi" + + + + + PRINT (10 + PRINT 20;); + + diff --git a/tests/functional/prepro20.out b/tests/functional/prepro20.out index 5f297839a..57691fbcf 100644 --- a/tests/functional/prepro20.out +++ b/tests/functional/prepro20.out @@ -1,2 +1,8 @@ #line 1 "prepro20.bi" + + + + + PRINT ;) + diff --git a/tests/functional/prepro21.out b/tests/functional/prepro21.out index 32cc7ca15..cbcf45d3e 100644 --- a/tests/functional/prepro21.out +++ b/tests/functional/prepro21.out @@ -1,2 +1,9 @@ #line 1 "prepro21.bi" -10 + + + + + + +10 + diff --git a/tests/functional/prepro23.out b/tests/functional/prepro23.out index 9cdb75d82..c697ba14b 100644 --- a/tests/functional/prepro23.out +++ b/tests/functional/prepro23.out @@ -1,2 +1,12 @@ #line 1 "prepro23.bi" + + + + + + + PRINT 10; + + + diff --git a/tests/functional/prepro24.out b/tests/functional/prepro24.out index faa571044..13ff4bcc5 100644 --- a/tests/functional/prepro24.out +++ b/tests/functional/prepro24.out @@ -1,6 +1,12 @@ #line 1 "prepro24.bi" + + + + + FOR xxx = 1 TO 10 PRINT xxx NEXT #line 8 + PRINT "Line 9" diff --git a/tests/functional/prepro25.out b/tests/functional/prepro25.out index deb08d882..aa904e121 100644 --- a/tests/functional/prepro25.out +++ b/tests/functional/prepro25.out @@ -1,2 +1,8 @@ #line 1 "prepro25.bi" + + + + + (x + y) * 2 + diff --git a/tests/functional/prepro26.out b/tests/functional/prepro26.out index 078f8ad8d..ff180c860 100644 --- a/tests/functional/prepro26.out +++ b/tests/functional/prepro26.out @@ -1,2 +1,8 @@ #line 1 "prepro26.bi" + + + + + (x + y) + 4 * 2 + diff --git a/tests/functional/prepro27.out b/tests/functional/prepro27.out index 89b8ce1f6..bd5102d7e 100644 --- a/tests/functional/prepro27.out +++ b/tests/functional/prepro27.out @@ -1,9 +1,16 @@ #line 1 "prepro27.bi" Sub x End Sub + + + + #line 1 "prepro27.bi" Sub x End Sub + #line 9 "prepro27.bi" + #line 8 "prepro27.bi" #line 9 "prepro27.bi" + diff --git a/tests/functional/prepro29.out b/tests/functional/prepro29.out index e078f4c9d..37ed1129d 100644 --- a/tests/functional/prepro29.out +++ b/tests/functional/prepro29.out @@ -1,2 +1,5 @@ #line 1 "prepro29.bi" + + ZZ + diff --git a/tests/functional/prepro30.out b/tests/functional/prepro30.out index a703ffea9..a304c9b00 100644 --- a/tests/functional/prepro30.out +++ b/tests/functional/prepro30.out @@ -1,38 +1,104 @@ #line 1 "prepro30.bi" #line 1 "/zxbasic/src/arch/zx48k/library/attr.bas" + + + + + + + + + + + + + #pragma push(case_insensitive) #pragma case_insensitive = TRUE + + + + + + + + + + + function attr(byval row as ubyte, byval col as ubyte) as ubyte asm + PROC LOCAL __ATTR_END + ld e, (ix+7) ld d, (ix+5) + + call __IN_SCREEN jr nc, __ATTR_END + call __ATTR_ADDR ld a, (hl) + __ATTR_END: ENDP + end asm + end function + + + + + + + + + + + + + + sub setattr(byval row as ubyte, byval col as ubyte, byval value as ubyte) asm + PROC LOCAL __ATTR_END + ld e, (ix+7) ld d, (ix+5) + + call __IN_SCREEN jr nc, __ATTR_END + call __ATTR_ADDR ld a, (ix+9) ld (hl), a + __ATTR_END: ENDP + end asm + end sub + + + + + + + + + + + function fastcall attraddr(byval row as ubyte, byval col as ubyte) as uinteger asm + pop hl ex (sp), hl ld d, a @@ -40,8 +106,20 @@ function fastcall attraddr(byval row as ubyte, byval col as ubyte) as uinteger jp __ATTR_ADDR end asm end function + + + #pragma pop(case_insensitive) + + #require "attr.asm" + + #require "in_screen.asm" + #line 119 "/zxbasic/src/arch/zx48k/library/attr.bas" + #line 2 "prepro30.bi" + + + diff --git a/tests/functional/prepro31.out b/tests/functional/prepro31.out index f026d4646..31a875b21 100644 --- a/tests/functional/prepro31.out +++ b/tests/functional/prepro31.out @@ -1,2 +1,5 @@ #line 1 "prepro31.bi" + + t(x, (y - 1)) + diff --git a/tests/functional/prepro32.out b/tests/functional/prepro32.out index 0cbce80d6..7c9409da9 100644 --- a/tests/functional/prepro32.out +++ b/tests/functional/prepro32.out @@ -1,9 +1,14 @@ #line 1 "prepro32.bi" DIM a As Ubyte = 1 + + + PRINT "HELLO WORLD" + PRINT a; " MACRO START" ASM ld hl, _a inc (hl) END ASM PRINT a; " MACRO END" + diff --git a/tests/functional/prepro33.out b/tests/functional/prepro33.out index 6b4d12e37..b25449678 100644 --- a/tests/functional/prepro33.out +++ b/tests/functional/prepro33.out @@ -2,6 +2,7 @@ asm EX DE,HL PUSH DE + LD L,(IX+8) LD H,(IX+9) EX AF,AF' @@ -9,9 +10,12 @@ asm EX AF,AF' BLPutCharLoop: LD B,8 + BLPutCharOneCharLoop: XOR A LD C,A + + LDI LDI LDI @@ -23,8 +27,10 @@ asm LD A,B OR A JP NZ,BLPutCharOneCharLoop + EX AF,AF' DEC A JR Z, BLPutCharsEnd EX AF,AF' end asm + diff --git a/tests/functional/prepro34.out b/tests/functional/prepro34.out index 473497e35..28a371b7a 100644 --- a/tests/functional/prepro34.out +++ b/tests/functional/prepro34.out @@ -1,3 +1,6 @@ #line 1 "prepro34.bi" + + LET a = _ 5 + diff --git a/tests/functional/prepro36.out b/tests/functional/prepro36.out index d2e17a3ee..da1d63b02 100644 --- a/tests/functional/prepro36.out +++ b/tests/functional/prepro36.out @@ -1 +1,5 @@ #line 1 "prepro36.bi" + + + + diff --git a/tests/functional/prepro37.out b/tests/functional/prepro37.out index b570099eb..b962b5c3c 100644 --- a/tests/functional/prepro37.out +++ b/tests/functional/prepro37.out @@ -1,2 +1,7 @@ #line 1 "prepro37.bi" + + + + PRINT + diff --git a/tests/functional/prepro38.out b/tests/functional/prepro38.out index 7c34ce715..b227c34cb 100644 --- a/tests/functional/prepro38.out +++ b/tests/functional/prepro38.out @@ -1,3 +1,10 @@ #line 1 "prepro38.bi" + + + + Test #line 5 + + + diff --git a/tests/functional/prepro39.out b/tests/functional/prepro39.out index 164e5b8c0..e4c287756 100644 --- a/tests/functional/prepro39.out +++ b/tests/functional/prepro39.out @@ -1,3 +1,11 @@ #line 1 "prepro39.bi" + + + + + + PRINT , #line 7 + + diff --git a/tests/functional/prepro40.out b/tests/functional/prepro40.out index 340b5df7c..4b6cc78c4 100644 --- a/tests/functional/prepro40.out +++ b/tests/functional/prepro40.out @@ -1,2 +1,7 @@ #line 1 "prepro40.bi" + + macro + + + diff --git a/tests/functional/prepro41.out b/tests/functional/prepro41.out index 857abad22..74912b1dc 100644 --- a/tests/functional/prepro41.out +++ b/tests/functional/prepro41.out @@ -1,7 +1,11 @@ #line 1 "prepro41.bi" + + 10 PAUSE 0 : asm call 65012 end asm #line 6 : PAUSE 0 + + diff --git a/tests/functional/prepro42.out b/tests/functional/prepro42.out index 29fdf4552..b57f94be1 100644 --- a/tests/functional/prepro42.out +++ b/tests/functional/prepro42.out @@ -1,2 +1,5 @@ #line 1 "prepro42.bi" + + #line 6 "prepro42.bi" + diff --git a/tests/functional/prepro43.out b/tests/functional/prepro43.out index 2033ac32a..d3c43be47 100644 --- a/tests/functional/prepro43.out +++ b/tests/functional/prepro43.out @@ -1,3 +1,7 @@ #line 1 "prepro43.bi" + + + print 1 #line 6 "prepro43.bi" + diff --git a/tests/functional/prepro44.out b/tests/functional/prepro44.out index 30b057889..4153f31d7 100644 --- a/tests/functional/prepro44.out +++ b/tests/functional/prepro44.out @@ -1,2 +1,5 @@ #line 1 "prepro44.bi" + + #line 6 "prepro44.bi" + diff --git a/tests/functional/prepro45.out b/tests/functional/prepro45.out index 313e31fef..91c362dee 100644 --- a/tests/functional/prepro45.out +++ b/tests/functional/prepro45.out @@ -1,2 +1,7 @@ #line 1 "prepro45.bi" + + #line 7 "prepro45.bi" + + + diff --git a/tests/functional/prepro46.out b/tests/functional/prepro46.out index 8693272c7..15b58f4aa 100644 --- a/tests/functional/prepro46.out +++ b/tests/functional/prepro46.out @@ -1,3 +1,9 @@ #line 1 "prepro46.bi" + + + print 1 #line 6 "prepro46.bi" + + + diff --git a/tests/functional/prepro47.out b/tests/functional/prepro47.out index 99fd6d87d..01fea5359 100644 --- a/tests/functional/prepro47.out +++ b/tests/functional/prepro47.out @@ -1,2 +1,8 @@ #line 1 "prepro47.bi" + + + #line 8 "prepro47.bi" + + + diff --git a/tests/functional/prepro48.out b/tests/functional/prepro48.out index 2e89604c4..863c0447c 100644 --- a/tests/functional/prepro48.out +++ b/tests/functional/prepro48.out @@ -1,2 +1,8 @@ #line 1 "prepro48.bi" + + + #line 8 "prepro48.bi" + + + diff --git a/tests/functional/prepro49.out b/tests/functional/prepro49.out index 103298123..eda1b6ad8 100644 --- a/tests/functional/prepro49.out +++ b/tests/functional/prepro49.out @@ -1,2 +1,8 @@ #line 1 "prepro49.bi" + + + #line 8 "prepro49.bi" + + + diff --git a/tests/functional/prepro50.out b/tests/functional/prepro50.out index 28371815e..5c0098549 100644 --- a/tests/functional/prepro50.out +++ b/tests/functional/prepro50.out @@ -1,3 +1,11 @@ #line 1 "prepro50.bi" + + + + print 1 + #line 8 "prepro50.bi" + + + diff --git a/tests/functional/prepro51.out b/tests/functional/prepro51.out index 476a3c30a..92e5aef07 100644 --- a/tests/functional/prepro51.out +++ b/tests/functional/prepro51.out @@ -1,2 +1,7 @@ #line 1 "prepro51.bi" + + A(1) + + + diff --git a/tests/functional/prepro52.out b/tests/functional/prepro52.out index e22b37138..60d64adf6 100644 --- a/tests/functional/prepro52.out +++ b/tests/functional/prepro52.out @@ -1,2 +1,8 @@ #line 1 "prepro52.bi" + + + 1 + + + diff --git a/tests/functional/prepro53.out b/tests/functional/prepro53.out index c054a9abe..52bcd64a4 100644 --- a/tests/functional/prepro53.out +++ b/tests/functional/prepro53.out @@ -1,2 +1,8 @@ #line 1 "prepro53.bi" + + + 1 + + + diff --git a/tests/functional/prepro54.out b/tests/functional/prepro54.out index 382562fdb..699a7ae28 100644 --- a/tests/functional/prepro54.out +++ b/tests/functional/prepro54.out @@ -1,2 +1,6 @@ #line 1 "prepro54.bi" + + + #line 7 "prepro54.bi" + diff --git a/tests/functional/prepro55.out b/tests/functional/prepro55.out index a4e62a750..f7e46dbba 100644 --- a/tests/functional/prepro55.out +++ b/tests/functional/prepro55.out @@ -1,3 +1,8 @@ #line 1 "prepro55.bi" + + + + ok #line 7 "prepro55.bi" + diff --git a/tests/functional/prepro56.out b/tests/functional/prepro56.out index 7c714c6c4..59c43aa68 100644 --- a/tests/functional/prepro56.out +++ b/tests/functional/prepro56.out @@ -1,2 +1,6 @@ #line 1 "prepro56.bi" + + + #line 7 "prepro56.bi" + diff --git a/tests/functional/prepro57.out b/tests/functional/prepro57.out index a5a5a8cd9..0892b25e4 100644 --- a/tests/functional/prepro57.out +++ b/tests/functional/prepro57.out @@ -1,3 +1,7 @@ #line 1 "prepro57.bi" + + PRINT "LANG = es" #line 5 "prepro57.bi" + + diff --git a/tests/functional/prepro58.out b/tests/functional/prepro58.out index 0d224895e..b6af41f9b 100644 --- a/tests/functional/prepro58.out +++ b/tests/functional/prepro58.out @@ -4,3 +4,4 @@ sub test() ex af,af' end asm end sub + diff --git a/tests/functional/prepro59.out b/tests/functional/prepro59.out index 2ef4180fc..c5c52799b 100644 --- a/tests/functional/prepro59.out +++ b/tests/functional/prepro59.out @@ -1,2 +1,6 @@ #line 1 "prepro59.bi" -LET a$ = (a$ + CHR$(0)) + + + +LET a$ = (a$ + CHR$(0)) + diff --git a/tests/functional/prepro60.out b/tests/functional/prepro60.out index 61330109f..ac7a8c690 100644 --- a/tests/functional/prepro60.out +++ b/tests/functional/prepro60.out @@ -3,3 +3,4 @@ Function FASTCALL ESXDOSWrite(ByVal handle as Byte, _ ByVal buffer as UInteger, _ ByVal nbytes as UInteger) as Uinteger End Function + diff --git a/tests/functional/prepro61.bi b/tests/functional/prepro61.bi new file mode 100644 index 000000000..a814f6c0a --- /dev/null +++ b/tests/functional/prepro61.bi @@ -0,0 +1,6 @@ +#define x(b) xx b a(b) + +#define a(b) aa b x(b) + +x(1) + diff --git a/tests/functional/prepro61.out b/tests/functional/prepro61.out new file mode 100644 index 000000000..326a2d807 --- /dev/null +++ b/tests/functional/prepro61.out @@ -0,0 +1,7 @@ +#line 1 "prepro61.bi" + + + + +xx 1 aa 1 x(1) + diff --git a/tests/functional/prepro62.bi b/tests/functional/prepro62.bi new file mode 100644 index 000000000..5706b5dbe --- /dev/null +++ b/tests/functional/prepro62.bi @@ -0,0 +1,8 @@ + +#define q z +#define z(a, b) (a + 1, b + 2) + +z(1, 2) +q(3, 4) + + diff --git a/tests/functional/prepro62.out b/tests/functional/prepro62.out new file mode 100644 index 000000000..bbbef229a --- /dev/null +++ b/tests/functional/prepro62.out @@ -0,0 +1,9 @@ +#line 1 "prepro62.bi" + + + + +(1 + 1, 2 + 2) +(3 + 1, 4 + 2) + + diff --git a/tests/functional/prepro70.out b/tests/functional/prepro70.out index 7fdc95ef2..599230c43 100644 --- a/tests/functional/prepro70.out +++ b/tests/functional/prepro70.out @@ -1,8 +1,13 @@ #line 1 "prepro70.bi" DIM b + + + #line 1 "./prepro70.bi" DIM b #line 10 "./prepro70.bi" #line 6 "prepro70.bi" + DIM a + #line 10 "prepro70.bi" diff --git a/tests/functional/prepro71.out b/tests/functional/prepro71.out index c75680044..f4feaab75 100644 --- a/tests/functional/prepro71.out +++ b/tests/functional/prepro71.out @@ -1,27 +1,112 @@ #line 1 "prepro71.bi" #line 1 "/zxbasic/src/arch/zx48k/library/alloc.bas" + + + + + + + + + + + + + #pragma push(case_insensitive) #pragma case_insensitive = True + + + + + + + + + + + + + + + function FASTCALL allocate(byval n as uinteger) as uinteger + + + + asm ld b, h ld c, l jp __MEM_ALLOC end asm end function + + + + + + + + + + + + + + + + + function FASTCALL callocate(byval n as uinteger) as uinteger + + + + asm ld b, h ld c, l jp __MEM_CALLOC end asm end function + + + + + + + + sub FASTCALL deallocate(byval addr as integer) + + + asm jp __MEM_FREE end asm end sub + + + + + + + + + + + + + + + + function FASTCALL reallocate(byval addr as uinteger, byval n as uinteger) as uinteger + + + + + asm ex de, hl pop hl @@ -32,67 +117,117 @@ function FASTCALL reallocate(byval addr as uinteger, byval n as uinteger) as uin jp __REALLOC end asm end function + + + + + + + + function FASTCALL memavail as uInteger asm PROC + LOCAL LOOP + ld hl, ZXBASIC_MEM_HEAP ld de, 0 + LOOP: + ld c, (hl) inc hl ld b, (hl) inc hl + + ld a, (hl) inc hl ld h, (hl) ld l, a + + ex de, hl add hl, bc ex de, hl + + ld a, h or l jr nz, LOOP + ex de, hl + ENDP end asm end function + + + + + + + function FASTCALL maxavail as uInteger asm PROC + LOCAL LOOP, CONT + ld hl, ZXBASIC_MEM_HEAP ld de, 0 + LOOP: + ld c, (hl) inc hl ld b, (hl) inc hl + + ld a, (hl) inc hl ld h, (hl) ld l, a + + + ex de, hl or a sbc hl, bc add hl, bc ex de, hl + + jr nc, CONT + ld d, b ld e, c + CONT: + ld a, h or l jr nz, LOOP + ex de, hl + ENDP end asm end function + + #pragma pop(case_insensitive) + #require "alloc.asm" #require "free.asm" #require "realloc.asm" #require "calloc.asm" + #line 227 "/zxbasic/src/arch/zx48k/library/alloc.bas" + #line 2 "prepro71.bi" + PRINT "HOLA" + diff --git a/tests/functional/prepro72.out b/tests/functional/prepro72.out index 22c26abd7..3ba0b5f2a 100644 --- a/tests/functional/prepro72.out +++ b/tests/functional/prepro72.out @@ -1,8 +1,13 @@ #line 1 "prepro72.bi" DIM b + + + #line 1 "./prepro70.bi" DIM b #line 10 "./prepro70.bi" #line 6 "prepro72.bi" + DIM a + #line 10 "prepro72.bi" diff --git a/tests/functional/prepro73.out b/tests/functional/prepro73.out index b720c6987..8a9481bb0 100644 --- a/tests/functional/prepro73.out +++ b/tests/functional/prepro73.out @@ -1,23 +1,69 @@ #line 1 "prepro73.bi" #line 1 "/zxbasic/src/arch/zx48k/library/pos.bas" + + + + + + + + + + + + + + + #pragma push(case_insensitive) #pragma case_insensitive = true + + + + + + + + + function FASTCALL pos as ubyte asm PROC + call __LOAD_S_POSN ld a, e + ENDP end asm end function + #pragma pop(case_insensitive) #require "sposn.asm" + + #line 43 "/zxbasic/src/arch/zx48k/library/pos.bas" + #line 2 "prepro73.bi" + + + #line 1 "prepro73.bi" #line 1 "/zxbasic/src/arch/zx48k/library/pos.bas" + + + + + + + + + #line 43 "/zxbasic/src/arch/zx48k/library/pos.bas" + #line 2 "prepro73.bi" + #line 7 "prepro73.bi" + #line 6 "prepro73.bi" #line 7 "prepro73.bi" + diff --git a/tests/functional/prepro74.out b/tests/functional/prepro74.out index f950c359a..810fb37f4 100644 --- a/tests/functional/prepro74.out +++ b/tests/functional/prepro74.out @@ -1,22 +1,61 @@ #line 1 "prepro74.bi" #line 1 "/zxbasic/src/arch/zx48k/library/pos.bas" + + + + + + + + + + + + + + + #pragma push(case_insensitive) #pragma case_insensitive = true + + + + + + + + + function FASTCALL pos as ubyte asm PROC + call __LOAD_S_POSN ld a, e + ENDP end asm end function + #pragma pop(case_insensitive) #require "sposn.asm" + + #line 43 "/zxbasic/src/arch/zx48k/library/pos.bas" + #line 2 "prepro74.bi" + + + #line 1 "prepro74.bi" + + #line 7 "prepro74.bi" + glibberish + #line 6 "prepro74.bi" #line 7 "prepro74.bi" + glibberish + diff --git a/tests/functional/prepro75.out b/tests/functional/prepro75.out index 111fd0258..cb2ba7e75 100644 --- a/tests/functional/prepro75.out +++ b/tests/functional/prepro75.out @@ -1,7 +1,11 @@ #line 1 "prepro75.bi" A = 0 + + #line 1 "prepro75.bi" A = 0 #line 6 "prepro75.bi" + #line 5 "prepro75.bi" #line 6 "prepro75.bi" + diff --git a/tests/functional/prepro77.out b/tests/functional/prepro77.out index ad999c91a..252ff806c 100644 --- a/tests/functional/prepro77.out +++ b/tests/functional/prepro77.out @@ -1 +1,3 @@ #line 1 "prepro77.bi" + + diff --git a/tests/functional/prepro80.out b/tests/functional/prepro80.out index 5d24a8f32..c2855c979 100644 --- a/tests/functional/prepro80.out +++ b/tests/functional/prepro80.out @@ -1,6 +1,12 @@ #line 1 "prepro80.bi" + + + + asm halt halt end asm + #line 11 "prepro80.bi" + diff --git a/tests/functional/prepro90.out b/tests/functional/prepro90.out index 2e11bb63e..e11a883ff 100644 --- a/tests/functional/prepro90.out +++ b/tests/functional/prepro90.out @@ -1,4 +1,8 @@ #line 1 "prepro90.bi" + + + #line 7 "prepro90.bi" OK #line 9 "prepro90.bi" + diff --git a/tests/functional/prepro91.out b/tests/functional/prepro91.out index 6ff850821..d10e03ec4 100644 --- a/tests/functional/prepro91.out +++ b/tests/functional/prepro91.out @@ -1,4 +1,6 @@ #line 1 "prepro91.bi" + #line 7 "prepro91.bi" OK #line 9 "prepro91.bi" + diff --git a/tests/functional/prepro92.out b/tests/functional/prepro92.out index f4b03ae04..9045992a9 100644 --- a/tests/functional/prepro92.out +++ b/tests/functional/prepro92.out @@ -1,4 +1,8 @@ #line 1 "prepro92.bi" + + + #line 7 "prepro92.bi" OK #line 9 "prepro92.bi" + diff --git a/tests/functional/prepro93.out b/tests/functional/prepro93.out index 1ee67768e..ef4839d9f 100644 --- a/tests/functional/prepro93.out +++ b/tests/functional/prepro93.out @@ -1,4 +1,8 @@ #line 1 "prepro93.bi" + + + #line 9 "prepro93.bi" OK #line 11 "prepro93.bi" + diff --git a/tests/functional/prepro94.out b/tests/functional/prepro94.out index 342db343f..f712fd64e 100644 --- a/tests/functional/prepro94.out +++ b/tests/functional/prepro94.out @@ -1,4 +1,6 @@ #line 1 "prepro94.bi" + + #line 8 "prepro94.bi" OK #line 10 "prepro94.bi" diff --git a/tests/functional/prepro95.out b/tests/functional/prepro95.out index 3fdd51eab..09eaacd3f 100644 --- a/tests/functional/prepro95.out +++ b/tests/functional/prepro95.out @@ -1,4 +1,6 @@ #line 1 "prepro95.bi" + #line 11 "prepro95.bi" OK #line 13 "prepro95.bi" + diff --git a/tests/functional/read.asm b/tests/functional/read.asm index b32386104..970bb8de0 100644 --- a/tests/functional/read.asm +++ b/tests/functional/read.asm @@ -72,8 +72,8 @@ __LABEL0: DEFB 75h DEFB 61h DEFB 6Eh -#line 1 "loadstr.asm" -#line 1 "alloc.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -133,7 +133,7 @@ __LABEL0: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "error.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" ; Simple error control routines ; vim:ts=4:et: ERR_NR EQU 23610 ; Error code system variable @@ -165,8 +165,8 @@ __ERROR_CODE: __STOP: ld (ERR_NR), a ret -#line 69 "alloc.asm" -#line 1 "heapinit.asm" +#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -271,7 +271,7 @@ __MEM_INIT2: ld (__MEM_INIT), a; "Pokes" with a RET so ensure this routine is not called again ret ENDP -#line 70 "alloc.asm" +#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -301,9 +301,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 111 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ret z ; NULL -#line 113 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -367,7 +367,7 @@ __MEM_SUBTRACT: inc hl ; Return hl ret ENDP -#line 2 "loadstr.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again ; Finally, it returns result pointer in HL @@ -403,7 +403,7 @@ __LOADSTR: ; __FASTCALL__ entry pop hl ; Recovers destiny in hl as result ret #line 49 "read.bas" -#line 1 "read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code ;; Updates the DATA_ADDR read ptr for the next read @@ -421,7 +421,7 @@ __LOADSTR: ; __FASTCALL__ entry ;; 09: Float ;; bit7 is set for a parameter-less function ;; In that case, the next two bytes are the ptr of the function to jump -#line 1 "iload32.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iload32.asm" ; __FASTCALL__ routine which ; loads a 32 bits integer into DE,HL ; stored at position pointed by POINTER HL @@ -437,8 +437,8 @@ __ILOAD32: ld l, a ex de, hl ret -#line 25 "read_restore.asm" -#line 1 "iloadf.asm" +#line 25 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB ; stored at position pointed by POINTER HL @@ -463,10 +463,10 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL inc hl ld b, (hl) ret -#line 26 "read_restore.asm" -#line 1 "ftof16reg.asm" -#line 1 "ftou32reg.asm" -#line 1 "neg32.asm" +#line 26 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" __ABS32: bit 7, d ret z @@ -489,7 +489,7 @@ __NEG32: ; Negates DEHL (Two's complement) ret nz inc de ret -#line 2 "ftou32reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" __FTOU32REG: ; Converts a Float to (un)signed 32 bit integer (NOTE: It's ALWAYS 32 bit signed) ; Input FP number in A EDCB (A exponent, EDCB mantissa) ; Output: DEHL 32 bit number (signed) @@ -562,7 +562,7 @@ __FTOU8: ; Converts float in C ED LH to Unsigned byte in A call __FTOU32REG ld a, l ret -#line 2 "ftof16reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal ; Input FP number in A EDCB (A exponent, EDCB mantissa) ld l, a ; Saves exponent for later @@ -591,9 +591,9 @@ __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal jp c, __FTOU32REG_END ; It was decimal (0.xxx). We are done (return 0) ld b, a ; Loop counter = exponent - 128 + 16 (we need to shift 16 bit more) jp __FTOU32REG_LOOP ; proceed as an u32 integer -#line 27 "read_restore.asm" -#line 1 "f16tofreg.asm" -#line 1 "u32tofreg.asm" +#line 27 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" __I8TOFREG: ld l, a rlca @@ -661,7 +661,7 @@ __U32TOFREG_END: res 7, e ; Sets the sign bit to 0 (positive) ret ENDP -#line 3 "f16tofreg.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" __F16TOFREG: ; Converts a 16.16 signed fixed point (stored in DEHL) ; to a Floating Point Number returned in (C ED CB) PROC @@ -694,8 +694,8 @@ __F16TOFREG2: ; Converts an unsigned 32 bit integer (DEHL) ld e, c jp __U32TOFREG_LOOP ; Proceed as an integer ENDP -#line 28 "read_restore.asm" -#line 1 "free.asm" +#line 28 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -851,7 +851,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ld (hl), d ; Next saved ret ENDP -#line 29 "read_restore.asm" +#line 29 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; Updates restore point to the given HL mem. address __RESTORE: PROC @@ -924,7 +924,7 @@ dynamic_cast3: jr c, dynamic_cast4 ;; here the user expected type is "larger" than the read one ld a, b - sub 2 + sub 2 add a, a ld l, a ld h, 0 @@ -1129,7 +1129,7 @@ __DATA_ADDR: ;; Stores current DATA ptr dw __DATA__0 ENDP #line 50 "read.bas" -#line 1 "storef.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/storef.asm" __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) push de ex de, hl ; DE <- HL @@ -1156,4 +1156,4 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret #line 51 "read.bas" - END + END \ No newline at end of file diff --git a/tests/functional/read10.asm b/tests/functional/read10.asm index e837f89f1..e5c0b1832 100644 --- a/tests/functional/read10.asm +++ b/tests/functional/read10.asm @@ -144,8 +144,8 @@ __DATA__0: DEFW ___DATA__FUNCPTR__2 __DATA__END: DEFB 00h -#line 1 "mulf.asm" -#line 1 "stackf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/mulf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/stackf.asm" ; ------------------------------------------------------------- ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC ; ------------------------------------------------------------- @@ -182,7 +182,7 @@ __FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK xor a ld b, a jp __FPSTACK_PUSH -#line 2 "mulf.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/mulf.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -199,12 +199,12 @@ __MULF: ; Multiplication defb 38h; ; END CALC jp __FPSTACK_POP #line 116 "read10.bas" -#line 1 "ploadf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ploadf.asm" ; Parameter / Local var load ; A => Offset ; IX = Stack Frame ; RESULT: HL => IX + DE -#line 1 "iloadf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB ; stored at position pointed by POINTER HL @@ -229,14 +229,14 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL inc hl ld b, (hl) ret -#line 7 "ploadf.asm" +#line 7 "/zxbasic/src/arch/zx48k/library-asm/ploadf.asm" __PLOADF: push ix pop hl add hl, de jp __LOADF #line 117 "read10.bas" -#line 1 "pow.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/pow.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -260,12 +260,12 @@ __POW: ; Exponentiation jp __FPSTACK_POP ENDP #line 118 "read10.bas" -#line 1 "print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; vim:ts=4:sw=4:et: ; vim:ts=4:sw=4:et: ; PRINT command routine ; Does not print attribute. Use PRINT_STR or PRINT_NUM for that -#line 1 "sposn.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/sposn.asm" ; Printing positioning library. PROC LOCAL ECHO_E @@ -289,8 +289,8 @@ __SAVE_S_POSN: ; Saves ROW, COL from DE into S_POSN mem var. POSX EQU S_POSN ; Current POS X POSY EQU S_POSN + 1 ; Current POS Y ENDP -#line 7 "print.asm" -#line 1 "cls.asm" +#line 7 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/cls.asm" ; JUMPS directly to spectrum CLS ; This routine does not clear lower screen ;CLS EQU 0DAFh @@ -326,9 +326,9 @@ __CLS_SCR: SCREEN_ADDR EQU (__CLS_SCR + 1) ; Address used by print and other screen routines ; to get the start of the screen ENDP -#line 8 "print.asm" -#line 1 "in_screen.asm" -#line 1 "error.asm" +#line 8 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" ; Simple error control routines ; vim:ts=4:et: ERR_NR EQU 23610 ; Error code system variable @@ -360,7 +360,7 @@ __ERROR_CODE: __STOP: ld (ERR_NR), a ret -#line 3 "in_screen.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" __IN_SCREEN: ; Returns NO carry if current coords (D, E) ; are OUT of the screen limits (MAXX, MAXY) @@ -382,8 +382,8 @@ __OUT_OF_SCREEN_ERR: ld a, ERROR_OutOfScreen jp __STOP ; Saves error code and exits ENDP -#line 9 "print.asm" -#line 1 "table_jump.asm" +#line 9 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/table_jump.asm" JUMP_HL_PLUS_2A: ; Does JP (HL + A*2) Modifies DE. Modifies A add a, a JUMP_HL_PLUS_A: ; Does JP (HL + A) Modifies DE @@ -397,11 +397,11 @@ JUMP_HL_PLUS_DE: ; Does JP (HL + DE) ex de, hl CALL_HL: jp (hl) -#line 10 "print.asm" -#line 1 "ink.asm" +#line 10 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" ; Sets ink color in ATTR_P permanently ; Parameter: Paper color in A register -#line 1 "const.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/const.asm" ; Global constants P_FLAG EQU 23697 FLAGS2 EQU 23681 @@ -410,7 +410,7 @@ CALL_HL: CHARS EQU 23606 ; Pointer to ROM/RAM Charset UDG EQU 23675 ; Pointer to UDG Charset MEM0 EQU 5C92h ; Temporary memory buffer used by ROM chars -#line 5 "ink.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" INK: PROC LOCAL __SET_INK @@ -442,8 +442,8 @@ INK_TMP: ld de, ATTR_T jp __SET_INK ENDP -#line 11 "print.asm" -#line 1 "paper.asm" +#line 11 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/paper.asm" ; Sets paper color in ATTR_P permanently ; Parameter: Paper color in A register PAPER: @@ -480,8 +480,8 @@ PAPER_TMP: ld de, ATTR_T jp __SET_PAPER ENDP -#line 12 "print.asm" -#line 1 "flash.asm" +#line 12 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/flash.asm" ; Sets flash flag in ATTR_P permanently ; Parameter: Paper color in A register FLASH: @@ -515,8 +515,8 @@ FLASH_TMP: ld hl, ATTR_T jr __SET_FLASH ENDP -#line 13 "print.asm" -#line 1 "bright.asm" +#line 13 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bright.asm" ; Sets bright flag in ATTR_P permanently ; Parameter: Paper color in A register BRIGHT: @@ -550,12 +550,12 @@ BRIGHT_TMP: ld hl, ATTR_T jr __SET_BRIGHT ENDP -#line 14 "print.asm" -#line 1 "over.asm" +#line 14 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/over.asm" ; Sets OVER flag in P_FLAG permanently ; Parameter: OVER flag in bit 0 of A register -#line 1 "copy_attr.asm" -#line 4 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" COPY_ATTR: ; Just copies current permanent attribs to temporal attribs ; and sets print mode @@ -595,7 +595,7 @@ TABLE: xor (hl) ; OVER 1 MODE and (hl) ; OVER 2 MODE or (hl) ; OVER 3 MODE -#line 65 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 65 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" __REFRESH_TMP: ld a, (hl) and 10101010b @@ -605,7 +605,7 @@ __REFRESH_TMP: ld (hl), a ret ENDP -#line 4 "over.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/over.asm" OVER: PROC ld c, a ; saves it for later @@ -639,8 +639,8 @@ OVER_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 15 "print.asm" -#line 1 "inverse.asm" +#line 15 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/inverse.asm" ; Sets INVERSE flag in P_FLAG permanently ; Parameter: INVERSE flag in bit 0 of A register INVERSE: @@ -665,8 +665,8 @@ INVERSE_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 16 "print.asm" -#line 1 "bold.asm" +#line 16 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bold.asm" ; Sets BOLD flag in P_FLAG permanently ; Parameter: BOLD flag in bit 0 of A register BOLD: @@ -691,8 +691,8 @@ BOLD_TMP: ld (hl), a ret ENDP -#line 17 "print.asm" -#line 1 "italic.asm" +#line 17 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/italic.asm" ; Sets ITALIC flag in P_FLAG permanently ; Parameter: ITALIC flag in bit 0 of A register ITALIC: @@ -719,8 +719,8 @@ ITALIC_TMP: ld (hl), a ret ENDP -#line 18 "print.asm" -#line 1 "attr.asm" +#line 18 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/attr.asm" ; Attribute routines ; vim:ts=4:et:sw: __ATTR_ADDR: @@ -777,7 +777,7 @@ SET_PIXEL_ADDR_ATTR: ld de, (SCREEN_ADDR) add hl, de ;; Final screen addr jp __SET_ATTR2 -#line 20 "print.asm" +#line 20 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; Putting a comment starting with @INIT
; will make the compiler to add a CALL to
; It is useful for initialization routines. @@ -817,14 +817,14 @@ __SCROLL: ; Scroll? ld hl, __TVFLAGS res 1, (hl) ret -#line 76 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 76 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_START: cp ' ' jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones exx ; Switch to alternative registers ex af, af' ; Saves a value (char to print) for later call __SCROLL -#line 87 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 87 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN ; At this point we have the new coord ld hl, (SCREEN_ADDR) @@ -919,7 +919,7 @@ PRINT_EOL: ; Called WHENEVER there is no ";" at end of PRINT sentence exx __PRINT_0Dh: ; Called WHEN printing CHR$(13) call __SCROLL -#line 210 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 210 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN __PRINT_EOL1: ; Another entry called from PRINT when next line required ld e, 0 @@ -933,7 +933,7 @@ __PRINT_AT1_END: ld hl, __TVFLAGS set 1, (hl) ld a, d -#line 230 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 230 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_EOL_END: ld d, a __PRINT_AT2_END: @@ -1146,7 +1146,7 @@ PRINT_AT: ; Changes cursor to ROW, COL ret nc ; Return if out of screen ld hl, __TVFLAGS res 1, (hl) -#line 482 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 482 "/zxbasic/src/arch/zx48k/library-asm/print.asm" jp __SAVE_S_POSN LOCAL __PRINT_COM LOCAL __BOLD @@ -1193,9 +1193,9 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes DW __PRINT_TAB ; 23 TAB ENDP #line 119 "read10.bas" -#line 1 "printf.asm" -#line 1 "printstr.asm" -#line 1 "free.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1255,7 +1255,7 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "heapinit.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1360,7 +1360,7 @@ __MEM_INIT2: ld (__MEM_INIT), a; "Pokes" with a RET so ensure this routine is not called again ret ENDP -#line 69 "free.asm" +#line 69 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; --------------------------------------------------------------------- ; MEM_FREE ; Frees a block of memory @@ -1457,7 +1457,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ld (hl), d ; Next saved ret ENDP -#line 5 "printstr.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/printstr.asm" ; PRINT command routine ; Prints string pointed by HL PRINT_STR: @@ -1498,7 +1498,7 @@ __PRINT_STR: ld d, a ; Saves a FLAG jp __PRINT_STR_LOOP ENDP -#line 2 "printf.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/printf.asm" __PRINTF: ; Prints a Fixed point Number stored in C ED LH PROC LOCAL RECLAIM2 @@ -1527,12 +1527,12 @@ __PRINTF: ; Prints a Fixed point Number stored in C ED LH RECLAIM2 EQU 19E8h ENDP #line 120 "read10.bas" -#line 1 "pstoref.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/pstoref.asm" ; Stores FP number in A ED CB at location HL+IX ; HL = Offset ; IX = Stack Frame ; A ED CB = FP Number -#line 1 "storef.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/storef.asm" __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) push de ex de, hl ; DE <- HL @@ -1558,7 +1558,7 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL inc hl ld (hl), b ret -#line 7 "pstoref.asm" +#line 7 "/zxbasic/src/arch/zx48k/library-asm/pstoref.asm" ; Stored a float number in A ED CB into the address pointed by IX + HL __PSTOREF: push de @@ -1569,7 +1569,7 @@ __PSTOREF: pop de jp __STOREF #line 121 "read10.bas" -#line 1 "read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code ;; Updates the DATA_ADDR read ptr for the next read @@ -1587,8 +1587,8 @@ __PSTOREF: ;; 09: Float ;; bit7 is set for a parameter-less function ;; In that case, the next two bytes are the ptr of the function to jump -#line 1 "loadstr.asm" -#line 1 "alloc.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1677,9 +1677,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 111 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ret z ; NULL -#line 113 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -1743,7 +1743,7 @@ __MEM_SUBTRACT: inc hl ; Return hl ret ENDP -#line 2 "loadstr.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again ; Finally, it returns result pointer in HL @@ -1778,8 +1778,8 @@ __LOADSTR: ; __FASTCALL__ entry ldir ; Copies string (length number included) pop hl ; Recovers destiny in hl as result ret -#line 24 "read_restore.asm" -#line 1 "iload32.asm" +#line 24 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iload32.asm" ; __FASTCALL__ routine which ; loads a 32 bits integer into DE,HL ; stored at position pointed by POINTER HL @@ -1795,10 +1795,10 @@ __ILOAD32: ld l, a ex de, hl ret -#line 25 "read_restore.asm" -#line 1 "ftof16reg.asm" -#line 1 "ftou32reg.asm" -#line 1 "neg32.asm" +#line 25 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" __ABS32: bit 7, d ret z @@ -1821,7 +1821,7 @@ __NEG32: ; Negates DEHL (Two's complement) ret nz inc de ret -#line 2 "ftou32reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" __FTOU32REG: ; Converts a Float to (un)signed 32 bit integer (NOTE: It's ALWAYS 32 bit signed) ; Input FP number in A EDCB (A exponent, EDCB mantissa) ; Output: DEHL 32 bit number (signed) @@ -1894,7 +1894,7 @@ __FTOU8: ; Converts float in C ED LH to Unsigned byte in A call __FTOU32REG ld a, l ret -#line 2 "ftof16reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal ; Input FP number in A EDCB (A exponent, EDCB mantissa) ld l, a ; Saves exponent for later @@ -1923,9 +1923,9 @@ __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal jp c, __FTOU32REG_END ; It was decimal (0.xxx). We are done (return 0) ld b, a ; Loop counter = exponent - 128 + 16 (we need to shift 16 bit more) jp __FTOU32REG_LOOP ; proceed as an u32 integer -#line 27 "read_restore.asm" -#line 1 "f16tofreg.asm" -#line 1 "u32tofreg.asm" +#line 27 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" __I8TOFREG: ld l, a rlca @@ -1993,7 +1993,7 @@ __U32TOFREG_END: res 7, e ; Sets the sign bit to 0 (positive) ret ENDP -#line 3 "f16tofreg.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" __F16TOFREG: ; Converts a 16.16 signed fixed point (stored in DEHL) ; to a Floating Point Number returned in (C ED CB) PROC @@ -2026,7 +2026,7 @@ __F16TOFREG2: ; Converts an unsigned 32 bit integer (DEHL) ld e, c jp __U32TOFREG_LOOP ; Proceed as an integer ENDP -#line 28 "read_restore.asm" +#line 28 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; Updates restore point to the given HL mem. address __RESTORE: PROC @@ -2099,7 +2099,7 @@ dynamic_cast3: jr c, dynamic_cast4 ;; here the user expected type is "larger" than the read one ld a, b - sub 2 + sub 2 add a, a ld l, a ld h, 0 @@ -2304,7 +2304,7 @@ __DATA_ADDR: ;; Stores current DATA ptr dw __DATA__0 ENDP #line 122 "read10.bas" -#line 1 "sin.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/sin.asm" SIN: ; Computes SIN using ROM FP-CALC call __FPSTACK_PUSH rst 28h ; ROM CALC @@ -2312,7 +2312,7 @@ SIN: ; Computes SIN using ROM FP-CALC defb 38h ; END CALC jp __FPSTACK_POP #line 123 "read10.bas" -#line 1 "tan.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/tan.asm" TAN: ; Computes TAN using ROM FP-CALC call __FPSTACK_PUSH rst 28h ; ROM CALC @@ -2320,4 +2320,4 @@ TAN: ; Computes TAN using ROM FP-CALC defb 38h ; END CALC jp __FPSTACK_POP #line 124 "read10.bas" - END + END \ No newline at end of file diff --git a/tests/functional/read12.asm b/tests/functional/read12.asm index 828a5c052..aaf883bed 100644 --- a/tests/functional/read12.asm +++ b/tests/functional/read12.asm @@ -76,8 +76,8 @@ __LABEL0: DEFB 6Fh DEFB 6Ch DEFB 61h -#line 1 "loadstr.asm" -#line 1 "alloc.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -137,7 +137,7 @@ __LABEL0: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "error.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" ; Simple error control routines ; vim:ts=4:et: ERR_NR EQU 23610 ; Error code system variable @@ -169,8 +169,8 @@ __ERROR_CODE: __STOP: ld (ERR_NR), a ret -#line 69 "alloc.asm" -#line 1 "heapinit.asm" +#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -275,7 +275,7 @@ __MEM_INIT2: ld (__MEM_INIT), a; "Pokes" with a RET so ensure this routine is not called again ret ENDP -#line 70 "alloc.asm" +#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -305,9 +305,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 111 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ret z ; NULL -#line 113 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -371,7 +371,7 @@ __MEM_SUBTRACT: inc hl ; Return hl ret ENDP -#line 2 "loadstr.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again ; Finally, it returns result pointer in HL @@ -407,12 +407,12 @@ __LOADSTR: ; __FASTCALL__ entry pop hl ; Recovers destiny in hl as result ret #line 52 "read12.bas" -#line 1 "print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; vim:ts=4:sw=4:et: ; vim:ts=4:sw=4:et: ; PRINT command routine ; Does not print attribute. Use PRINT_STR or PRINT_NUM for that -#line 1 "sposn.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/sposn.asm" ; Printing positioning library. PROC LOCAL ECHO_E @@ -436,8 +436,8 @@ __SAVE_S_POSN: ; Saves ROW, COL from DE into S_POSN mem var. POSX EQU S_POSN ; Current POS X POSY EQU S_POSN + 1 ; Current POS Y ENDP -#line 7 "print.asm" -#line 1 "cls.asm" +#line 7 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/cls.asm" ; JUMPS directly to spectrum CLS ; This routine does not clear lower screen ;CLS EQU 0DAFh @@ -473,8 +473,8 @@ __CLS_SCR: SCREEN_ADDR EQU (__CLS_SCR + 1) ; Address used by print and other screen routines ; to get the start of the screen ENDP -#line 8 "print.asm" -#line 1 "in_screen.asm" +#line 8 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" __IN_SCREEN: ; Returns NO carry if current coords (D, E) ; are OUT of the screen limits (MAXX, MAXY) @@ -496,8 +496,8 @@ __OUT_OF_SCREEN_ERR: ld a, ERROR_OutOfScreen jp __STOP ; Saves error code and exits ENDP -#line 9 "print.asm" -#line 1 "table_jump.asm" +#line 9 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/table_jump.asm" JUMP_HL_PLUS_2A: ; Does JP (HL + A*2) Modifies DE. Modifies A add a, a JUMP_HL_PLUS_A: ; Does JP (HL + A) Modifies DE @@ -511,11 +511,11 @@ JUMP_HL_PLUS_DE: ; Does JP (HL + DE) ex de, hl CALL_HL: jp (hl) -#line 10 "print.asm" -#line 1 "ink.asm" +#line 10 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" ; Sets ink color in ATTR_P permanently ; Parameter: Paper color in A register -#line 1 "const.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/const.asm" ; Global constants P_FLAG EQU 23697 FLAGS2 EQU 23681 @@ -524,7 +524,7 @@ CALL_HL: CHARS EQU 23606 ; Pointer to ROM/RAM Charset UDG EQU 23675 ; Pointer to UDG Charset MEM0 EQU 5C92h ; Temporary memory buffer used by ROM chars -#line 5 "ink.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" INK: PROC LOCAL __SET_INK @@ -556,8 +556,8 @@ INK_TMP: ld de, ATTR_T jp __SET_INK ENDP -#line 11 "print.asm" -#line 1 "paper.asm" +#line 11 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/paper.asm" ; Sets paper color in ATTR_P permanently ; Parameter: Paper color in A register PAPER: @@ -594,8 +594,8 @@ PAPER_TMP: ld de, ATTR_T jp __SET_PAPER ENDP -#line 12 "print.asm" -#line 1 "flash.asm" +#line 12 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/flash.asm" ; Sets flash flag in ATTR_P permanently ; Parameter: Paper color in A register FLASH: @@ -629,8 +629,8 @@ FLASH_TMP: ld hl, ATTR_T jr __SET_FLASH ENDP -#line 13 "print.asm" -#line 1 "bright.asm" +#line 13 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bright.asm" ; Sets bright flag in ATTR_P permanently ; Parameter: Paper color in A register BRIGHT: @@ -664,12 +664,12 @@ BRIGHT_TMP: ld hl, ATTR_T jr __SET_BRIGHT ENDP -#line 14 "print.asm" -#line 1 "over.asm" +#line 14 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/over.asm" ; Sets OVER flag in P_FLAG permanently ; Parameter: OVER flag in bit 0 of A register -#line 1 "copy_attr.asm" -#line 4 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" COPY_ATTR: ; Just copies current permanent attribs to temporal attribs ; and sets print mode @@ -709,7 +709,7 @@ TABLE: xor (hl) ; OVER 1 MODE and (hl) ; OVER 2 MODE or (hl) ; OVER 3 MODE -#line 65 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 65 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" __REFRESH_TMP: ld a, (hl) and 10101010b @@ -719,7 +719,7 @@ __REFRESH_TMP: ld (hl), a ret ENDP -#line 4 "over.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/over.asm" OVER: PROC ld c, a ; saves it for later @@ -753,8 +753,8 @@ OVER_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 15 "print.asm" -#line 1 "inverse.asm" +#line 15 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/inverse.asm" ; Sets INVERSE flag in P_FLAG permanently ; Parameter: INVERSE flag in bit 0 of A register INVERSE: @@ -779,8 +779,8 @@ INVERSE_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 16 "print.asm" -#line 1 "bold.asm" +#line 16 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bold.asm" ; Sets BOLD flag in P_FLAG permanently ; Parameter: BOLD flag in bit 0 of A register BOLD: @@ -805,8 +805,8 @@ BOLD_TMP: ld (hl), a ret ENDP -#line 17 "print.asm" -#line 1 "italic.asm" +#line 17 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/italic.asm" ; Sets ITALIC flag in P_FLAG permanently ; Parameter: ITALIC flag in bit 0 of A register ITALIC: @@ -833,8 +833,8 @@ ITALIC_TMP: ld (hl), a ret ENDP -#line 18 "print.asm" -#line 1 "attr.asm" +#line 18 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/attr.asm" ; Attribute routines ; vim:ts=4:et:sw: __ATTR_ADDR: @@ -891,7 +891,7 @@ SET_PIXEL_ADDR_ATTR: ld de, (SCREEN_ADDR) add hl, de ;; Final screen addr jp __SET_ATTR2 -#line 20 "print.asm" +#line 20 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; Putting a comment starting with @INIT
; will make the compiler to add a CALL to
; It is useful for initialization routines. @@ -931,14 +931,14 @@ __SCROLL: ; Scroll? ld hl, __TVFLAGS res 1, (hl) ret -#line 76 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 76 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_START: cp ' ' jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones exx ; Switch to alternative registers ex af, af' ; Saves a value (char to print) for later call __SCROLL -#line 87 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 87 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN ; At this point we have the new coord ld hl, (SCREEN_ADDR) @@ -1033,7 +1033,7 @@ PRINT_EOL: ; Called WHENEVER there is no ";" at end of PRINT sentence exx __PRINT_0Dh: ; Called WHEN printing CHR$(13) call __SCROLL -#line 210 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 210 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN __PRINT_EOL1: ; Another entry called from PRINT when next line required ld e, 0 @@ -1047,7 +1047,7 @@ __PRINT_AT1_END: ld hl, __TVFLAGS set 1, (hl) ld a, d -#line 230 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 230 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_EOL_END: ld d, a __PRINT_AT2_END: @@ -1260,7 +1260,7 @@ PRINT_AT: ; Changes cursor to ROW, COL ret nc ; Return if out of screen ld hl, __TVFLAGS res 1, (hl) -#line 482 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 482 "/zxbasic/src/arch/zx48k/library-asm/print.asm" jp __SAVE_S_POSN LOCAL __PRINT_COM LOCAL __BOLD @@ -1307,8 +1307,8 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes DW __PRINT_TAB ; 23 TAB ENDP #line 53 "read12.bas" -#line 1 "printi8.asm" -#line 1 "printnum.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printi8.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printnum.asm" __PRINTU_START: PROC LOCAL __PRINTU_CONT @@ -1329,8 +1329,8 @@ __PRINT_MINUS: ; PRINT the MINUS (-) sign. CALLER mus preserve registers ld a, '-' jp __PRINT_DIGIT __PRINT_DIGIT EQU __PRINTCHAR ; PRINTS the char in A register, and puts its attrs -#line 2 "printi8.asm" -#line 1 "div8.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/printi8.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/div8.asm" ; -------------------------------- __DIVU8: ; 8 bit unsigned integer division ; Divides (Top of stack, High Byte) / A @@ -1393,7 +1393,7 @@ __MODI8_FAST: ; __FASTCALL__ entry call __DIVI8_FAST ld a, l ; remainder ret ; a = Modulus -#line 3 "printi8.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/printi8.asm" __PRINTI8: ; Prints an 8 bits number in Accumulator (A) ; Converts 8 to 32 bits or a @@ -1421,7 +1421,7 @@ __PRINTU_LOOP: jp __PRINTU_LOOP ; Uses JP in loops ENDP #line 54 "read12.bas" -#line 1 "read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code ;; Updates the DATA_ADDR read ptr for the next read @@ -1439,7 +1439,7 @@ __PRINTU_LOOP: ;; 09: Float ;; bit7 is set for a parameter-less function ;; In that case, the next two bytes are the ptr of the function to jump -#line 1 "iload32.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iload32.asm" ; __FASTCALL__ routine which ; loads a 32 bits integer into DE,HL ; stored at position pointed by POINTER HL @@ -1455,8 +1455,8 @@ __ILOAD32: ld l, a ex de, hl ret -#line 25 "read_restore.asm" -#line 1 "iloadf.asm" +#line 25 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB ; stored at position pointed by POINTER HL @@ -1481,10 +1481,10 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL inc hl ld b, (hl) ret -#line 26 "read_restore.asm" -#line 1 "ftof16reg.asm" -#line 1 "ftou32reg.asm" -#line 1 "neg32.asm" +#line 26 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" __ABS32: bit 7, d ret z @@ -1507,7 +1507,7 @@ __NEG32: ; Negates DEHL (Two's complement) ret nz inc de ret -#line 2 "ftou32reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" __FTOU32REG: ; Converts a Float to (un)signed 32 bit integer (NOTE: It's ALWAYS 32 bit signed) ; Input FP number in A EDCB (A exponent, EDCB mantissa) ; Output: DEHL 32 bit number (signed) @@ -1580,7 +1580,7 @@ __FTOU8: ; Converts float in C ED LH to Unsigned byte in A call __FTOU32REG ld a, l ret -#line 2 "ftof16reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal ; Input FP number in A EDCB (A exponent, EDCB mantissa) ld l, a ; Saves exponent for later @@ -1609,9 +1609,9 @@ __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal jp c, __FTOU32REG_END ; It was decimal (0.xxx). We are done (return 0) ld b, a ; Loop counter = exponent - 128 + 16 (we need to shift 16 bit more) jp __FTOU32REG_LOOP ; proceed as an u32 integer -#line 27 "read_restore.asm" -#line 1 "f16tofreg.asm" -#line 1 "u32tofreg.asm" +#line 27 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" __I8TOFREG: ld l, a rlca @@ -1679,7 +1679,7 @@ __U32TOFREG_END: res 7, e ; Sets the sign bit to 0 (positive) ret ENDP -#line 3 "f16tofreg.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" __F16TOFREG: ; Converts a 16.16 signed fixed point (stored in DEHL) ; to a Floating Point Number returned in (C ED CB) PROC @@ -1712,8 +1712,8 @@ __F16TOFREG2: ; Converts an unsigned 32 bit integer (DEHL) ld e, c jp __U32TOFREG_LOOP ; Proceed as an integer ENDP -#line 28 "read_restore.asm" -#line 1 "free.asm" +#line 28 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1869,7 +1869,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ld (hl), d ; Next saved ret ENDP -#line 29 "read_restore.asm" +#line 29 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; Updates restore point to the given HL mem. address __RESTORE: PROC @@ -1942,7 +1942,7 @@ dynamic_cast3: jr c, dynamic_cast4 ;; here the user expected type is "larger" than the read one ld a, b - sub 2 + sub 2 add a, a ld l, a ld h, 0 @@ -2147,4 +2147,4 @@ __DATA_ADDR: ;; Stores current DATA ptr dw __DATA__0 ENDP #line 55 "read12.bas" - END + END \ No newline at end of file diff --git a/tests/functional/read4.asm b/tests/functional/read4.asm index ad7eb86db..6e3c3ef7c 100644 --- a/tests/functional/read4.asm +++ b/tests/functional/read4.asm @@ -150,8 +150,8 @@ __LABEL0: DEFB 6Ch DEFB 6Ch DEFB 6Fh -#line 1 "loadstr.asm" -#line 1 "alloc.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -211,7 +211,7 @@ __LABEL0: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "error.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" ; Simple error control routines ; vim:ts=4:et: ERR_NR EQU 23610 ; Error code system variable @@ -243,8 +243,8 @@ __ERROR_CODE: __STOP: ld (ERR_NR), a ret -#line 69 "alloc.asm" -#line 1 "heapinit.asm" +#line 69 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -349,7 +349,7 @@ __MEM_INIT2: ld (__MEM_INIT), a; "Pokes" with a RET so ensure this routine is not called again ret ENDP -#line 70 "alloc.asm" +#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -379,9 +379,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 111 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ret z ; NULL -#line 113 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -445,7 +445,7 @@ __MEM_SUBTRACT: inc hl ; Return hl ret ENDP -#line 2 "loadstr.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again ; Finally, it returns result pointer in HL @@ -481,8 +481,8 @@ __LOADSTR: ; __FASTCALL__ entry pop hl ; Recovers destiny in hl as result ret #line 90 "read4.bas" -#line 1 "mulf.asm" -#line 1 "stackf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/mulf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/stackf.asm" ; ------------------------------------------------------------- ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC ; ------------------------------------------------------------- @@ -519,7 +519,7 @@ __FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK xor a ld b, a jp __FPSTACK_PUSH -#line 2 "mulf.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/mulf.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -536,7 +536,7 @@ __MULF: ; Multiplication defb 38h; ; END CALC jp __FPSTACK_POP #line 91 "read4.bas" -#line 1 "pow.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/pow.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -560,7 +560,7 @@ __POW: ; Exponentiation jp __FPSTACK_POP ENDP #line 92 "read4.bas" -#line 1 "pushf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/pushf.asm" ; Routine to push Float pointed by HL ; Into the stack. Notice that the hl points to the last ; byte of the FP number. @@ -586,7 +586,7 @@ __FP_PUSH_REV: exx ret #line 93 "read4.bas" -#line 1 "read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code ;; Updates the DATA_ADDR read ptr for the next read @@ -604,7 +604,7 @@ __FP_PUSH_REV: ;; 09: Float ;; bit7 is set for a parameter-less function ;; In that case, the next two bytes are the ptr of the function to jump -#line 1 "iload32.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iload32.asm" ; __FASTCALL__ routine which ; loads a 32 bits integer into DE,HL ; stored at position pointed by POINTER HL @@ -620,8 +620,8 @@ __ILOAD32: ld l, a ex de, hl ret -#line 25 "read_restore.asm" -#line 1 "iloadf.asm" +#line 25 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB ; stored at position pointed by POINTER HL @@ -646,10 +646,10 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL inc hl ld b, (hl) ret -#line 26 "read_restore.asm" -#line 1 "ftof16reg.asm" -#line 1 "ftou32reg.asm" -#line 1 "neg32.asm" +#line 26 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" __ABS32: bit 7, d ret z @@ -672,7 +672,7 @@ __NEG32: ; Negates DEHL (Two's complement) ret nz inc de ret -#line 2 "ftou32reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" __FTOU32REG: ; Converts a Float to (un)signed 32 bit integer (NOTE: It's ALWAYS 32 bit signed) ; Input FP number in A EDCB (A exponent, EDCB mantissa) ; Output: DEHL 32 bit number (signed) @@ -745,7 +745,7 @@ __FTOU8: ; Converts float in C ED LH to Unsigned byte in A call __FTOU32REG ld a, l ret -#line 2 "ftof16reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal ; Input FP number in A EDCB (A exponent, EDCB mantissa) ld l, a ; Saves exponent for later @@ -774,9 +774,9 @@ __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal jp c, __FTOU32REG_END ; It was decimal (0.xxx). We are done (return 0) ld b, a ; Loop counter = exponent - 128 + 16 (we need to shift 16 bit more) jp __FTOU32REG_LOOP ; proceed as an u32 integer -#line 27 "read_restore.asm" -#line 1 "f16tofreg.asm" -#line 1 "u32tofreg.asm" +#line 27 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" __I8TOFREG: ld l, a rlca @@ -844,7 +844,7 @@ __U32TOFREG_END: res 7, e ; Sets the sign bit to 0 (positive) ret ENDP -#line 3 "f16tofreg.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" __F16TOFREG: ; Converts a 16.16 signed fixed point (stored in DEHL) ; to a Floating Point Number returned in (C ED CB) PROC @@ -877,8 +877,8 @@ __F16TOFREG2: ; Converts an unsigned 32 bit integer (DEHL) ld e, c jp __U32TOFREG_LOOP ; Proceed as an integer ENDP -#line 28 "read_restore.asm" -#line 1 "free.asm" +#line 28 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1034,7 +1034,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ld (hl), d ; Next saved ret ENDP -#line 29 "read_restore.asm" +#line 29 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; Updates restore point to the given HL mem. address __RESTORE: PROC @@ -1107,7 +1107,7 @@ dynamic_cast3: jr c, dynamic_cast4 ;; here the user expected type is "larger" than the read one ld a, b - sub 2 + sub 2 add a, a ld l, a ld h, 0 @@ -1312,7 +1312,7 @@ __DATA_ADDR: ;; Stores current DATA ptr dw __DATA__0 ENDP #line 94 "read4.bas" -#line 1 "sin.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/sin.asm" SIN: ; Computes SIN using ROM FP-CALC call __FPSTACK_PUSH rst 28h ; ROM CALC @@ -1320,7 +1320,7 @@ SIN: ; Computes SIN using ROM FP-CALC defb 38h ; END CALC jp __FPSTACK_POP #line 95 "read4.bas" -#line 1 "storef.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/storef.asm" __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) push de ex de, hl ; DE <- HL @@ -1347,7 +1347,7 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret #line 96 "read4.bas" -#line 1 "tan.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/tan.asm" TAN: ; Computes TAN using ROM FP-CALC call __FPSTACK_PUSH rst 28h ; ROM CALC @@ -1355,4 +1355,4 @@ TAN: ; Computes TAN using ROM FP-CALC defb 38h ; END CALC jp __FPSTACK_POP #line 97 "read4.bas" - END + END \ No newline at end of file diff --git a/tests/functional/read5.asm b/tests/functional/read5.asm index 45a26fa4a..9eba69543 100644 --- a/tests/functional/read5.asm +++ b/tests/functional/read5.asm @@ -144,8 +144,8 @@ __DATA__0: DEFW ___DATA__FUNCPTR__2 __DATA__END: DEFB 00h -#line 1 "mulf.asm" -#line 1 "stackf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/mulf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/stackf.asm" ; ------------------------------------------------------------- ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC ; ------------------------------------------------------------- @@ -182,7 +182,7 @@ __FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK xor a ld b, a jp __FPSTACK_PUSH -#line 2 "mulf.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/mulf.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -199,7 +199,7 @@ __MULF: ; Multiplication defb 38h; ; END CALC jp __FPSTACK_POP #line 110 "read5.bas" -#line 1 "pow.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/pow.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -223,12 +223,12 @@ __POW: ; Exponentiation jp __FPSTACK_POP ENDP #line 111 "read5.bas" -#line 1 "print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; vim:ts=4:sw=4:et: ; vim:ts=4:sw=4:et: ; PRINT command routine ; Does not print attribute. Use PRINT_STR or PRINT_NUM for that -#line 1 "sposn.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/sposn.asm" ; Printing positioning library. PROC LOCAL ECHO_E @@ -252,8 +252,8 @@ __SAVE_S_POSN: ; Saves ROW, COL from DE into S_POSN mem var. POSX EQU S_POSN ; Current POS X POSY EQU S_POSN + 1 ; Current POS Y ENDP -#line 7 "print.asm" -#line 1 "cls.asm" +#line 7 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/cls.asm" ; JUMPS directly to spectrum CLS ; This routine does not clear lower screen ;CLS EQU 0DAFh @@ -289,9 +289,9 @@ __CLS_SCR: SCREEN_ADDR EQU (__CLS_SCR + 1) ; Address used by print and other screen routines ; to get the start of the screen ENDP -#line 8 "print.asm" -#line 1 "in_screen.asm" -#line 1 "error.asm" +#line 8 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" ; Simple error control routines ; vim:ts=4:et: ERR_NR EQU 23610 ; Error code system variable @@ -323,7 +323,7 @@ __ERROR_CODE: __STOP: ld (ERR_NR), a ret -#line 3 "in_screen.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" __IN_SCREEN: ; Returns NO carry if current coords (D, E) ; are OUT of the screen limits (MAXX, MAXY) @@ -345,8 +345,8 @@ __OUT_OF_SCREEN_ERR: ld a, ERROR_OutOfScreen jp __STOP ; Saves error code and exits ENDP -#line 9 "print.asm" -#line 1 "table_jump.asm" +#line 9 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/table_jump.asm" JUMP_HL_PLUS_2A: ; Does JP (HL + A*2) Modifies DE. Modifies A add a, a JUMP_HL_PLUS_A: ; Does JP (HL + A) Modifies DE @@ -360,11 +360,11 @@ JUMP_HL_PLUS_DE: ; Does JP (HL + DE) ex de, hl CALL_HL: jp (hl) -#line 10 "print.asm" -#line 1 "ink.asm" +#line 10 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" ; Sets ink color in ATTR_P permanently ; Parameter: Paper color in A register -#line 1 "const.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/const.asm" ; Global constants P_FLAG EQU 23697 FLAGS2 EQU 23681 @@ -373,7 +373,7 @@ CALL_HL: CHARS EQU 23606 ; Pointer to ROM/RAM Charset UDG EQU 23675 ; Pointer to UDG Charset MEM0 EQU 5C92h ; Temporary memory buffer used by ROM chars -#line 5 "ink.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" INK: PROC LOCAL __SET_INK @@ -405,8 +405,8 @@ INK_TMP: ld de, ATTR_T jp __SET_INK ENDP -#line 11 "print.asm" -#line 1 "paper.asm" +#line 11 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/paper.asm" ; Sets paper color in ATTR_P permanently ; Parameter: Paper color in A register PAPER: @@ -443,8 +443,8 @@ PAPER_TMP: ld de, ATTR_T jp __SET_PAPER ENDP -#line 12 "print.asm" -#line 1 "flash.asm" +#line 12 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/flash.asm" ; Sets flash flag in ATTR_P permanently ; Parameter: Paper color in A register FLASH: @@ -478,8 +478,8 @@ FLASH_TMP: ld hl, ATTR_T jr __SET_FLASH ENDP -#line 13 "print.asm" -#line 1 "bright.asm" +#line 13 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bright.asm" ; Sets bright flag in ATTR_P permanently ; Parameter: Paper color in A register BRIGHT: @@ -513,12 +513,12 @@ BRIGHT_TMP: ld hl, ATTR_T jr __SET_BRIGHT ENDP -#line 14 "print.asm" -#line 1 "over.asm" +#line 14 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/over.asm" ; Sets OVER flag in P_FLAG permanently ; Parameter: OVER flag in bit 0 of A register -#line 1 "copy_attr.asm" -#line 4 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" COPY_ATTR: ; Just copies current permanent attribs to temporal attribs ; and sets print mode @@ -558,7 +558,7 @@ TABLE: xor (hl) ; OVER 1 MODE and (hl) ; OVER 2 MODE or (hl) ; OVER 3 MODE -#line 65 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 65 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" __REFRESH_TMP: ld a, (hl) and 10101010b @@ -568,7 +568,7 @@ __REFRESH_TMP: ld (hl), a ret ENDP -#line 4 "over.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/over.asm" OVER: PROC ld c, a ; saves it for later @@ -602,8 +602,8 @@ OVER_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 15 "print.asm" -#line 1 "inverse.asm" +#line 15 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/inverse.asm" ; Sets INVERSE flag in P_FLAG permanently ; Parameter: INVERSE flag in bit 0 of A register INVERSE: @@ -628,8 +628,8 @@ INVERSE_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 16 "print.asm" -#line 1 "bold.asm" +#line 16 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bold.asm" ; Sets BOLD flag in P_FLAG permanently ; Parameter: BOLD flag in bit 0 of A register BOLD: @@ -654,8 +654,8 @@ BOLD_TMP: ld (hl), a ret ENDP -#line 17 "print.asm" -#line 1 "italic.asm" +#line 17 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/italic.asm" ; Sets ITALIC flag in P_FLAG permanently ; Parameter: ITALIC flag in bit 0 of A register ITALIC: @@ -682,8 +682,8 @@ ITALIC_TMP: ld (hl), a ret ENDP -#line 18 "print.asm" -#line 1 "attr.asm" +#line 18 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/attr.asm" ; Attribute routines ; vim:ts=4:et:sw: __ATTR_ADDR: @@ -740,7 +740,7 @@ SET_PIXEL_ADDR_ATTR: ld de, (SCREEN_ADDR) add hl, de ;; Final screen addr jp __SET_ATTR2 -#line 20 "print.asm" +#line 20 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; Putting a comment starting with @INIT
; will make the compiler to add a CALL to
; It is useful for initialization routines. @@ -780,14 +780,14 @@ __SCROLL: ; Scroll? ld hl, __TVFLAGS res 1, (hl) ret -#line 76 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 76 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_START: cp ' ' jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones exx ; Switch to alternative registers ex af, af' ; Saves a value (char to print) for later call __SCROLL -#line 87 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 87 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN ; At this point we have the new coord ld hl, (SCREEN_ADDR) @@ -882,7 +882,7 @@ PRINT_EOL: ; Called WHENEVER there is no ";" at end of PRINT sentence exx __PRINT_0Dh: ; Called WHEN printing CHR$(13) call __SCROLL -#line 210 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 210 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN __PRINT_EOL1: ; Another entry called from PRINT when next line required ld e, 0 @@ -896,7 +896,7 @@ __PRINT_AT1_END: ld hl, __TVFLAGS set 1, (hl) ld a, d -#line 230 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 230 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_EOL_END: ld d, a __PRINT_AT2_END: @@ -1109,7 +1109,7 @@ PRINT_AT: ; Changes cursor to ROW, COL ret nc ; Return if out of screen ld hl, __TVFLAGS res 1, (hl) -#line 482 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 482 "/zxbasic/src/arch/zx48k/library-asm/print.asm" jp __SAVE_S_POSN LOCAL __PRINT_COM LOCAL __BOLD @@ -1156,9 +1156,9 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes DW __PRINT_TAB ; 23 TAB ENDP #line 112 "read5.bas" -#line 1 "printf.asm" -#line 1 "printstr.asm" -#line 1 "free.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1218,7 +1218,7 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "heapinit.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1323,7 +1323,7 @@ __MEM_INIT2: ld (__MEM_INIT), a; "Pokes" with a RET so ensure this routine is not called again ret ENDP -#line 69 "free.asm" +#line 69 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; --------------------------------------------------------------------- ; MEM_FREE ; Frees a block of memory @@ -1420,7 +1420,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ld (hl), d ; Next saved ret ENDP -#line 5 "printstr.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/printstr.asm" ; PRINT command routine ; Prints string pointed by HL PRINT_STR: @@ -1461,7 +1461,7 @@ __PRINT_STR: ld d, a ; Saves a FLAG jp __PRINT_STR_LOOP ENDP -#line 2 "printf.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/printf.asm" __PRINTF: ; Prints a Fixed point Number stored in C ED LH PROC LOCAL RECLAIM2 @@ -1490,7 +1490,7 @@ __PRINTF: ; Prints a Fixed point Number stored in C ED LH RECLAIM2 EQU 19E8h ENDP #line 113 "read5.bas" -#line 1 "read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code ;; Updates the DATA_ADDR read ptr for the next read @@ -1508,8 +1508,8 @@ __PRINTF: ; Prints a Fixed point Number stored in C ED LH ;; 09: Float ;; bit7 is set for a parameter-less function ;; In that case, the next two bytes are the ptr of the function to jump -#line 1 "loadstr.asm" -#line 1 "alloc.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1598,9 +1598,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 111 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ret z ; NULL -#line 113 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -1664,7 +1664,7 @@ __MEM_SUBTRACT: inc hl ; Return hl ret ENDP -#line 2 "loadstr.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again ; Finally, it returns result pointer in HL @@ -1699,8 +1699,8 @@ __LOADSTR: ; __FASTCALL__ entry ldir ; Copies string (length number included) pop hl ; Recovers destiny in hl as result ret -#line 24 "read_restore.asm" -#line 1 "iload32.asm" +#line 24 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iload32.asm" ; __FASTCALL__ routine which ; loads a 32 bits integer into DE,HL ; stored at position pointed by POINTER HL @@ -1716,8 +1716,8 @@ __ILOAD32: ld l, a ex de, hl ret -#line 25 "read_restore.asm" -#line 1 "iloadf.asm" +#line 25 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB ; stored at position pointed by POINTER HL @@ -1742,10 +1742,10 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL inc hl ld b, (hl) ret -#line 26 "read_restore.asm" -#line 1 "ftof16reg.asm" -#line 1 "ftou32reg.asm" -#line 1 "neg32.asm" +#line 26 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" __ABS32: bit 7, d ret z @@ -1768,7 +1768,7 @@ __NEG32: ; Negates DEHL (Two's complement) ret nz inc de ret -#line 2 "ftou32reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" __FTOU32REG: ; Converts a Float to (un)signed 32 bit integer (NOTE: It's ALWAYS 32 bit signed) ; Input FP number in A EDCB (A exponent, EDCB mantissa) ; Output: DEHL 32 bit number (signed) @@ -1841,7 +1841,7 @@ __FTOU8: ; Converts float in C ED LH to Unsigned byte in A call __FTOU32REG ld a, l ret -#line 2 "ftof16reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal ; Input FP number in A EDCB (A exponent, EDCB mantissa) ld l, a ; Saves exponent for later @@ -1870,9 +1870,9 @@ __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal jp c, __FTOU32REG_END ; It was decimal (0.xxx). We are done (return 0) ld b, a ; Loop counter = exponent - 128 + 16 (we need to shift 16 bit more) jp __FTOU32REG_LOOP ; proceed as an u32 integer -#line 27 "read_restore.asm" -#line 1 "f16tofreg.asm" -#line 1 "u32tofreg.asm" +#line 27 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" __I8TOFREG: ld l, a rlca @@ -1940,7 +1940,7 @@ __U32TOFREG_END: res 7, e ; Sets the sign bit to 0 (positive) ret ENDP -#line 3 "f16tofreg.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" __F16TOFREG: ; Converts a 16.16 signed fixed point (stored in DEHL) ; to a Floating Point Number returned in (C ED CB) PROC @@ -1973,7 +1973,7 @@ __F16TOFREG2: ; Converts an unsigned 32 bit integer (DEHL) ld e, c jp __U32TOFREG_LOOP ; Proceed as an integer ENDP -#line 28 "read_restore.asm" +#line 28 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; Updates restore point to the given HL mem. address __RESTORE: PROC @@ -2046,7 +2046,7 @@ dynamic_cast3: jr c, dynamic_cast4 ;; here the user expected type is "larger" than the read one ld a, b - sub 2 + sub 2 add a, a ld l, a ld h, 0 @@ -2251,7 +2251,7 @@ __DATA_ADDR: ;; Stores current DATA ptr dw __DATA__0 ENDP #line 114 "read5.bas" -#line 1 "sin.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/sin.asm" SIN: ; Computes SIN using ROM FP-CALC call __FPSTACK_PUSH rst 28h ; ROM CALC @@ -2259,7 +2259,7 @@ SIN: ; Computes SIN using ROM FP-CALC defb 38h ; END CALC jp __FPSTACK_POP #line 115 "read5.bas" -#line 1 "storef.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/storef.asm" __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) push de ex de, hl ; DE <- HL @@ -2286,7 +2286,7 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret #line 116 "read5.bas" -#line 1 "tan.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/tan.asm" TAN: ; Computes TAN using ROM FP-CALC call __FPSTACK_PUSH rst 28h ; ROM CALC @@ -2294,4 +2294,4 @@ TAN: ; Computes TAN using ROM FP-CALC defb 38h ; END CALC jp __FPSTACK_POP #line 117 "read5.bas" - END + END \ No newline at end of file diff --git a/tests/functional/read8.asm b/tests/functional/read8.asm index 11f5f9b40..91fb4122a 100644 --- a/tests/functional/read8.asm +++ b/tests/functional/read8.asm @@ -159,8 +159,8 @@ __DATA__0: DEFW ___DATA__FUNCPTR__2 __DATA__END: DEFB 00h -#line 1 "mulf.asm" -#line 1 "stackf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/mulf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/stackf.asm" ; ------------------------------------------------------------- ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC ; ------------------------------------------------------------- @@ -197,7 +197,7 @@ __FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK xor a ld b, a jp __FPSTACK_PUSH -#line 2 "mulf.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/mulf.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -214,7 +214,7 @@ __MULF: ; Multiplication defb 38h; ; END CALC jp __FPSTACK_POP #line 101 "read8.bas" -#line 1 "pow.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/pow.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -238,12 +238,12 @@ __POW: ; Exponentiation jp __FPSTACK_POP ENDP #line 102 "read8.bas" -#line 1 "print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; vim:ts=4:sw=4:et: ; vim:ts=4:sw=4:et: ; PRINT command routine ; Does not print attribute. Use PRINT_STR or PRINT_NUM for that -#line 1 "sposn.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/sposn.asm" ; Printing positioning library. PROC LOCAL ECHO_E @@ -267,8 +267,8 @@ __SAVE_S_POSN: ; Saves ROW, COL from DE into S_POSN mem var. POSX EQU S_POSN ; Current POS X POSY EQU S_POSN + 1 ; Current POS Y ENDP -#line 7 "print.asm" -#line 1 "cls.asm" +#line 7 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/cls.asm" ; JUMPS directly to spectrum CLS ; This routine does not clear lower screen ;CLS EQU 0DAFh @@ -304,9 +304,9 @@ __CLS_SCR: SCREEN_ADDR EQU (__CLS_SCR + 1) ; Address used by print and other screen routines ; to get the start of the screen ENDP -#line 8 "print.asm" -#line 1 "in_screen.asm" -#line 1 "error.asm" +#line 8 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" ; Simple error control routines ; vim:ts=4:et: ERR_NR EQU 23610 ; Error code system variable @@ -338,7 +338,7 @@ __ERROR_CODE: __STOP: ld (ERR_NR), a ret -#line 3 "in_screen.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" __IN_SCREEN: ; Returns NO carry if current coords (D, E) ; are OUT of the screen limits (MAXX, MAXY) @@ -360,8 +360,8 @@ __OUT_OF_SCREEN_ERR: ld a, ERROR_OutOfScreen jp __STOP ; Saves error code and exits ENDP -#line 9 "print.asm" -#line 1 "table_jump.asm" +#line 9 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/table_jump.asm" JUMP_HL_PLUS_2A: ; Does JP (HL + A*2) Modifies DE. Modifies A add a, a JUMP_HL_PLUS_A: ; Does JP (HL + A) Modifies DE @@ -375,11 +375,11 @@ JUMP_HL_PLUS_DE: ; Does JP (HL + DE) ex de, hl CALL_HL: jp (hl) -#line 10 "print.asm" -#line 1 "ink.asm" +#line 10 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" ; Sets ink color in ATTR_P permanently ; Parameter: Paper color in A register -#line 1 "const.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/const.asm" ; Global constants P_FLAG EQU 23697 FLAGS2 EQU 23681 @@ -388,7 +388,7 @@ CALL_HL: CHARS EQU 23606 ; Pointer to ROM/RAM Charset UDG EQU 23675 ; Pointer to UDG Charset MEM0 EQU 5C92h ; Temporary memory buffer used by ROM chars -#line 5 "ink.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" INK: PROC LOCAL __SET_INK @@ -420,8 +420,8 @@ INK_TMP: ld de, ATTR_T jp __SET_INK ENDP -#line 11 "print.asm" -#line 1 "paper.asm" +#line 11 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/paper.asm" ; Sets paper color in ATTR_P permanently ; Parameter: Paper color in A register PAPER: @@ -458,8 +458,8 @@ PAPER_TMP: ld de, ATTR_T jp __SET_PAPER ENDP -#line 12 "print.asm" -#line 1 "flash.asm" +#line 12 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/flash.asm" ; Sets flash flag in ATTR_P permanently ; Parameter: Paper color in A register FLASH: @@ -493,8 +493,8 @@ FLASH_TMP: ld hl, ATTR_T jr __SET_FLASH ENDP -#line 13 "print.asm" -#line 1 "bright.asm" +#line 13 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bright.asm" ; Sets bright flag in ATTR_P permanently ; Parameter: Paper color in A register BRIGHT: @@ -528,12 +528,12 @@ BRIGHT_TMP: ld hl, ATTR_T jr __SET_BRIGHT ENDP -#line 14 "print.asm" -#line 1 "over.asm" +#line 14 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/over.asm" ; Sets OVER flag in P_FLAG permanently ; Parameter: OVER flag in bit 0 of A register -#line 1 "copy_attr.asm" -#line 4 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" COPY_ATTR: ; Just copies current permanent attribs to temporal attribs ; and sets print mode @@ -573,7 +573,7 @@ TABLE: xor (hl) ; OVER 1 MODE and (hl) ; OVER 2 MODE or (hl) ; OVER 3 MODE -#line 65 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 65 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" __REFRESH_TMP: ld a, (hl) and 10101010b @@ -583,7 +583,7 @@ __REFRESH_TMP: ld (hl), a ret ENDP -#line 4 "over.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/over.asm" OVER: PROC ld c, a ; saves it for later @@ -617,8 +617,8 @@ OVER_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 15 "print.asm" -#line 1 "inverse.asm" +#line 15 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/inverse.asm" ; Sets INVERSE flag in P_FLAG permanently ; Parameter: INVERSE flag in bit 0 of A register INVERSE: @@ -643,8 +643,8 @@ INVERSE_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 16 "print.asm" -#line 1 "bold.asm" +#line 16 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bold.asm" ; Sets BOLD flag in P_FLAG permanently ; Parameter: BOLD flag in bit 0 of A register BOLD: @@ -669,8 +669,8 @@ BOLD_TMP: ld (hl), a ret ENDP -#line 17 "print.asm" -#line 1 "italic.asm" +#line 17 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/italic.asm" ; Sets ITALIC flag in P_FLAG permanently ; Parameter: ITALIC flag in bit 0 of A register ITALIC: @@ -697,8 +697,8 @@ ITALIC_TMP: ld (hl), a ret ENDP -#line 18 "print.asm" -#line 1 "attr.asm" +#line 18 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/attr.asm" ; Attribute routines ; vim:ts=4:et:sw: __ATTR_ADDR: @@ -755,7 +755,7 @@ SET_PIXEL_ADDR_ATTR: ld de, (SCREEN_ADDR) add hl, de ;; Final screen addr jp __SET_ATTR2 -#line 20 "print.asm" +#line 20 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; Putting a comment starting with @INIT
; will make the compiler to add a CALL to
; It is useful for initialization routines. @@ -795,14 +795,14 @@ __SCROLL: ; Scroll? ld hl, __TVFLAGS res 1, (hl) ret -#line 76 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 76 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_START: cp ' ' jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones exx ; Switch to alternative registers ex af, af' ; Saves a value (char to print) for later call __SCROLL -#line 87 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 87 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN ; At this point we have the new coord ld hl, (SCREEN_ADDR) @@ -897,7 +897,7 @@ PRINT_EOL: ; Called WHENEVER there is no ";" at end of PRINT sentence exx __PRINT_0Dh: ; Called WHEN printing CHR$(13) call __SCROLL -#line 210 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 210 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN __PRINT_EOL1: ; Another entry called from PRINT when next line required ld e, 0 @@ -911,7 +911,7 @@ __PRINT_AT1_END: ld hl, __TVFLAGS set 1, (hl) ld a, d -#line 230 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 230 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_EOL_END: ld d, a __PRINT_AT2_END: @@ -1124,7 +1124,7 @@ PRINT_AT: ; Changes cursor to ROW, COL ret nc ; Return if out of screen ld hl, __TVFLAGS res 1, (hl) -#line 482 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 482 "/zxbasic/src/arch/zx48k/library-asm/print.asm" jp __SAVE_S_POSN LOCAL __PRINT_COM LOCAL __BOLD @@ -1171,9 +1171,9 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes DW __PRINT_TAB ; 23 TAB ENDP #line 103 "read8.bas" -#line 1 "printf.asm" -#line 1 "printstr.asm" -#line 1 "free.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1233,7 +1233,7 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "heapinit.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1338,7 +1338,7 @@ __MEM_INIT2: ld (__MEM_INIT), a; "Pokes" with a RET so ensure this routine is not called again ret ENDP -#line 69 "free.asm" +#line 69 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; --------------------------------------------------------------------- ; MEM_FREE ; Frees a block of memory @@ -1435,7 +1435,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ld (hl), d ; Next saved ret ENDP -#line 5 "printstr.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/printstr.asm" ; PRINT command routine ; Prints string pointed by HL PRINT_STR: @@ -1476,7 +1476,7 @@ __PRINT_STR: ld d, a ; Saves a FLAG jp __PRINT_STR_LOOP ENDP -#line 2 "printf.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/printf.asm" __PRINTF: ; Prints a Fixed point Number stored in C ED LH PROC LOCAL RECLAIM2 @@ -1505,7 +1505,7 @@ __PRINTF: ; Prints a Fixed point Number stored in C ED LH RECLAIM2 EQU 19E8h ENDP #line 104 "read8.bas" -#line 1 "read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code ;; Updates the DATA_ADDR read ptr for the next read @@ -1523,8 +1523,8 @@ __PRINTF: ; Prints a Fixed point Number stored in C ED LH ;; 09: Float ;; bit7 is set for a parameter-less function ;; In that case, the next two bytes are the ptr of the function to jump -#line 1 "loadstr.asm" -#line 1 "alloc.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1613,9 +1613,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 111 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ret z ; NULL -#line 113 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -1679,7 +1679,7 @@ __MEM_SUBTRACT: inc hl ; Return hl ret ENDP -#line 2 "loadstr.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again ; Finally, it returns result pointer in HL @@ -1714,8 +1714,8 @@ __LOADSTR: ; __FASTCALL__ entry ldir ; Copies string (length number included) pop hl ; Recovers destiny in hl as result ret -#line 24 "read_restore.asm" -#line 1 "iload32.asm" +#line 24 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iload32.asm" ; __FASTCALL__ routine which ; loads a 32 bits integer into DE,HL ; stored at position pointed by POINTER HL @@ -1731,8 +1731,8 @@ __ILOAD32: ld l, a ex de, hl ret -#line 25 "read_restore.asm" -#line 1 "iloadf.asm" +#line 25 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB ; stored at position pointed by POINTER HL @@ -1757,10 +1757,10 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL inc hl ld b, (hl) ret -#line 26 "read_restore.asm" -#line 1 "ftof16reg.asm" -#line 1 "ftou32reg.asm" -#line 1 "neg32.asm" +#line 26 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" __ABS32: bit 7, d ret z @@ -1783,7 +1783,7 @@ __NEG32: ; Negates DEHL (Two's complement) ret nz inc de ret -#line 2 "ftou32reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" __FTOU32REG: ; Converts a Float to (un)signed 32 bit integer (NOTE: It's ALWAYS 32 bit signed) ; Input FP number in A EDCB (A exponent, EDCB mantissa) ; Output: DEHL 32 bit number (signed) @@ -1856,7 +1856,7 @@ __FTOU8: ; Converts float in C ED LH to Unsigned byte in A call __FTOU32REG ld a, l ret -#line 2 "ftof16reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal ; Input FP number in A EDCB (A exponent, EDCB mantissa) ld l, a ; Saves exponent for later @@ -1885,9 +1885,9 @@ __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal jp c, __FTOU32REG_END ; It was decimal (0.xxx). We are done (return 0) ld b, a ; Loop counter = exponent - 128 + 16 (we need to shift 16 bit more) jp __FTOU32REG_LOOP ; proceed as an u32 integer -#line 27 "read_restore.asm" -#line 1 "f16tofreg.asm" -#line 1 "u32tofreg.asm" +#line 27 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" __I8TOFREG: ld l, a rlca @@ -1955,7 +1955,7 @@ __U32TOFREG_END: res 7, e ; Sets the sign bit to 0 (positive) ret ENDP -#line 3 "f16tofreg.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" __F16TOFREG: ; Converts a 16.16 signed fixed point (stored in DEHL) ; to a Floating Point Number returned in (C ED CB) PROC @@ -1988,7 +1988,7 @@ __F16TOFREG2: ; Converts an unsigned 32 bit integer (DEHL) ld e, c jp __U32TOFREG_LOOP ; Proceed as an integer ENDP -#line 28 "read_restore.asm" +#line 28 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; Updates restore point to the given HL mem. address __RESTORE: PROC @@ -2061,7 +2061,7 @@ dynamic_cast3: jr c, dynamic_cast4 ;; here the user expected type is "larger" than the read one ld a, b - sub 2 + sub 2 add a, a ld l, a ld h, 0 @@ -2266,7 +2266,7 @@ __DATA_ADDR: ;; Stores current DATA ptr dw __DATA__0 ENDP #line 105 "read8.bas" -#line 1 "sin.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/sin.asm" SIN: ; Computes SIN using ROM FP-CALC call __FPSTACK_PUSH rst 28h ; ROM CALC @@ -2274,7 +2274,7 @@ SIN: ; Computes SIN using ROM FP-CALC defb 38h ; END CALC jp __FPSTACK_POP #line 106 "read8.bas" -#line 1 "storef.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/storef.asm" __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) push de ex de, hl ; DE <- HL @@ -2301,7 +2301,7 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret #line 107 "read8.bas" -#line 1 "tan.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/tan.asm" TAN: ; Computes TAN using ROM FP-CALC call __FPSTACK_PUSH rst 28h ; ROM CALC @@ -2309,4 +2309,4 @@ TAN: ; Computes TAN using ROM FP-CALC defb 38h ; END CALC jp __FPSTACK_POP #line 108 "read8.bas" - END + END \ No newline at end of file diff --git a/tests/functional/read9.asm b/tests/functional/read9.asm index c0cedf44b..a7b3dc425 100644 --- a/tests/functional/read9.asm +++ b/tests/functional/read9.asm @@ -174,7 +174,7 @@ __DATA__0: DEFW ___DATA__FUNCPTR__2 __DATA__END: DEFB 00h -#line 1 "array.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/array.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -190,7 +190,7 @@ __DATA__END: ; O = [a0 + b0 * (a1 + b1 * (a2 + ... bN-2(aN-1)))] ; What I will do here is to calculate the following sequence: ; ((aN-1 * bN-2) + aN-2) * bN-3 + ... -#line 1 "mul16.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/mul16.asm" __MUL16: ; Mutiplies HL with the last value stored into de stack ; Works for both signed and unsigned PROC @@ -214,8 +214,8 @@ __MUL16NOADD: djnz __MUL16LOOP ret ; Result in hl (16 lower bits) ENDP -#line 20 "array.asm" -#line 24 "/zxbasic/arch/zx48k/library-asm/array.asm" +#line 20 "/zxbasic/src/arch/zx48k/library-asm/array.asm" +#line 24 "/zxbasic/src/arch/zx48k/library-asm/array.asm" __ARRAY_PTR: ;; computes an array offset from a pointer ld c, (hl) inc hl @@ -244,9 +244,9 @@ __ARRAY: exx ld hl, 0 ; HL = Offset "accumulator" LOOP: -#line 62 "/zxbasic/arch/zx48k/library-asm/array.asm" +#line 62 "/zxbasic/src/arch/zx48k/library-asm/array.asm" pop bc ; Get next index (Ai) from the stack -#line 72 "/zxbasic/arch/zx48k/library-asm/array.asm" +#line 72 "/zxbasic/src/arch/zx48k/library-asm/array.asm" add hl, bc ; Adds current index exx ; Checks if B'C' = 0 ld a, b ; Which means we must exit (last element is not multiplied by anything) @@ -265,7 +265,7 @@ LOOP: ARRAY_END: ld a, (hl) exx -#line 101 "/zxbasic/arch/zx48k/library-asm/array.asm" +#line 101 "/zxbasic/src/arch/zx48k/library-asm/array.asm" LOCAL ARRAY_SIZE_LOOP ex de, hl ld hl, 0 @@ -273,7 +273,7 @@ ARRAY_END: ARRAY_SIZE_LOOP: add hl, de djnz ARRAY_SIZE_LOOP -#line 111 "/zxbasic/arch/zx48k/library-asm/array.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/array.asm" ex de, hl ld hl, (TMP_ARR_PTR) ld a, (hl) @@ -303,7 +303,7 @@ TMP_ARR_PTR: DW 0 ; temporary storage for pointer to tables ENDP #line 116 "read9.bas" -#line 1 "iloadf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB ; stored at position pointed by POINTER HL @@ -329,8 +329,8 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL ld b, (hl) ret #line 117 "read9.bas" -#line 1 "mulf.asm" -#line 1 "stackf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/mulf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/stackf.asm" ; ------------------------------------------------------------- ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC ; ------------------------------------------------------------- @@ -367,7 +367,7 @@ __FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK xor a ld b, a jp __FPSTACK_PUSH -#line 2 "mulf.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/mulf.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -384,7 +384,7 @@ __MULF: ; Multiplication defb 38h; ; END CALC jp __FPSTACK_POP #line 118 "read9.bas" -#line 1 "pow.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/pow.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -408,12 +408,12 @@ __POW: ; Exponentiation jp __FPSTACK_POP ENDP #line 119 "read9.bas" -#line 1 "print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; vim:ts=4:sw=4:et: ; vim:ts=4:sw=4:et: ; PRINT command routine ; Does not print attribute. Use PRINT_STR or PRINT_NUM for that -#line 1 "sposn.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/sposn.asm" ; Printing positioning library. PROC LOCAL ECHO_E @@ -437,8 +437,8 @@ __SAVE_S_POSN: ; Saves ROW, COL from DE into S_POSN mem var. POSX EQU S_POSN ; Current POS X POSY EQU S_POSN + 1 ; Current POS Y ENDP -#line 7 "print.asm" -#line 1 "cls.asm" +#line 7 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/cls.asm" ; JUMPS directly to spectrum CLS ; This routine does not clear lower screen ;CLS EQU 0DAFh @@ -474,9 +474,9 @@ __CLS_SCR: SCREEN_ADDR EQU (__CLS_SCR + 1) ; Address used by print and other screen routines ; to get the start of the screen ENDP -#line 8 "print.asm" -#line 1 "in_screen.asm" -#line 1 "error.asm" +#line 8 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" ; Simple error control routines ; vim:ts=4:et: ERR_NR EQU 23610 ; Error code system variable @@ -508,7 +508,7 @@ __ERROR_CODE: __STOP: ld (ERR_NR), a ret -#line 3 "in_screen.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" __IN_SCREEN: ; Returns NO carry if current coords (D, E) ; are OUT of the screen limits (MAXX, MAXY) @@ -530,8 +530,8 @@ __OUT_OF_SCREEN_ERR: ld a, ERROR_OutOfScreen jp __STOP ; Saves error code and exits ENDP -#line 9 "print.asm" -#line 1 "table_jump.asm" +#line 9 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/table_jump.asm" JUMP_HL_PLUS_2A: ; Does JP (HL + A*2) Modifies DE. Modifies A add a, a JUMP_HL_PLUS_A: ; Does JP (HL + A) Modifies DE @@ -545,11 +545,11 @@ JUMP_HL_PLUS_DE: ; Does JP (HL + DE) ex de, hl CALL_HL: jp (hl) -#line 10 "print.asm" -#line 1 "ink.asm" +#line 10 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" ; Sets ink color in ATTR_P permanently ; Parameter: Paper color in A register -#line 1 "const.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/const.asm" ; Global constants P_FLAG EQU 23697 FLAGS2 EQU 23681 @@ -558,7 +558,7 @@ CALL_HL: CHARS EQU 23606 ; Pointer to ROM/RAM Charset UDG EQU 23675 ; Pointer to UDG Charset MEM0 EQU 5C92h ; Temporary memory buffer used by ROM chars -#line 5 "ink.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" INK: PROC LOCAL __SET_INK @@ -590,8 +590,8 @@ INK_TMP: ld de, ATTR_T jp __SET_INK ENDP -#line 11 "print.asm" -#line 1 "paper.asm" +#line 11 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/paper.asm" ; Sets paper color in ATTR_P permanently ; Parameter: Paper color in A register PAPER: @@ -628,8 +628,8 @@ PAPER_TMP: ld de, ATTR_T jp __SET_PAPER ENDP -#line 12 "print.asm" -#line 1 "flash.asm" +#line 12 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/flash.asm" ; Sets flash flag in ATTR_P permanently ; Parameter: Paper color in A register FLASH: @@ -663,8 +663,8 @@ FLASH_TMP: ld hl, ATTR_T jr __SET_FLASH ENDP -#line 13 "print.asm" -#line 1 "bright.asm" +#line 13 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bright.asm" ; Sets bright flag in ATTR_P permanently ; Parameter: Paper color in A register BRIGHT: @@ -698,12 +698,12 @@ BRIGHT_TMP: ld hl, ATTR_T jr __SET_BRIGHT ENDP -#line 14 "print.asm" -#line 1 "over.asm" +#line 14 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/over.asm" ; Sets OVER flag in P_FLAG permanently ; Parameter: OVER flag in bit 0 of A register -#line 1 "copy_attr.asm" -#line 4 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" COPY_ATTR: ; Just copies current permanent attribs to temporal attribs ; and sets print mode @@ -743,7 +743,7 @@ TABLE: xor (hl) ; OVER 1 MODE and (hl) ; OVER 2 MODE or (hl) ; OVER 3 MODE -#line 65 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 65 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" __REFRESH_TMP: ld a, (hl) and 10101010b @@ -753,7 +753,7 @@ __REFRESH_TMP: ld (hl), a ret ENDP -#line 4 "over.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/over.asm" OVER: PROC ld c, a ; saves it for later @@ -787,8 +787,8 @@ OVER_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 15 "print.asm" -#line 1 "inverse.asm" +#line 15 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/inverse.asm" ; Sets INVERSE flag in P_FLAG permanently ; Parameter: INVERSE flag in bit 0 of A register INVERSE: @@ -813,8 +813,8 @@ INVERSE_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 16 "print.asm" -#line 1 "bold.asm" +#line 16 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bold.asm" ; Sets BOLD flag in P_FLAG permanently ; Parameter: BOLD flag in bit 0 of A register BOLD: @@ -839,8 +839,8 @@ BOLD_TMP: ld (hl), a ret ENDP -#line 17 "print.asm" -#line 1 "italic.asm" +#line 17 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/italic.asm" ; Sets ITALIC flag in P_FLAG permanently ; Parameter: ITALIC flag in bit 0 of A register ITALIC: @@ -867,8 +867,8 @@ ITALIC_TMP: ld (hl), a ret ENDP -#line 18 "print.asm" -#line 1 "attr.asm" +#line 18 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/attr.asm" ; Attribute routines ; vim:ts=4:et:sw: __ATTR_ADDR: @@ -925,7 +925,7 @@ SET_PIXEL_ADDR_ATTR: ld de, (SCREEN_ADDR) add hl, de ;; Final screen addr jp __SET_ATTR2 -#line 20 "print.asm" +#line 20 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; Putting a comment starting with @INIT
; will make the compiler to add a CALL to
; It is useful for initialization routines. @@ -965,14 +965,14 @@ __SCROLL: ; Scroll? ld hl, __TVFLAGS res 1, (hl) ret -#line 76 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 76 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_START: cp ' ' jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones exx ; Switch to alternative registers ex af, af' ; Saves a value (char to print) for later call __SCROLL -#line 87 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 87 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN ; At this point we have the new coord ld hl, (SCREEN_ADDR) @@ -1067,7 +1067,7 @@ PRINT_EOL: ; Called WHENEVER there is no ";" at end of PRINT sentence exx __PRINT_0Dh: ; Called WHEN printing CHR$(13) call __SCROLL -#line 210 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 210 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN __PRINT_EOL1: ; Another entry called from PRINT when next line required ld e, 0 @@ -1081,7 +1081,7 @@ __PRINT_AT1_END: ld hl, __TVFLAGS set 1, (hl) ld a, d -#line 230 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 230 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_EOL_END: ld d, a __PRINT_AT2_END: @@ -1294,7 +1294,7 @@ PRINT_AT: ; Changes cursor to ROW, COL ret nc ; Return if out of screen ld hl, __TVFLAGS res 1, (hl) -#line 482 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 482 "/zxbasic/src/arch/zx48k/library-asm/print.asm" jp __SAVE_S_POSN LOCAL __PRINT_COM LOCAL __BOLD @@ -1341,9 +1341,9 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes DW __PRINT_TAB ; 23 TAB ENDP #line 120 "read9.bas" -#line 1 "printf.asm" -#line 1 "printstr.asm" -#line 1 "free.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1403,7 +1403,7 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "heapinit.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1508,7 +1508,7 @@ __MEM_INIT2: ld (__MEM_INIT), a; "Pokes" with a RET so ensure this routine is not called again ret ENDP -#line 69 "free.asm" +#line 69 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; --------------------------------------------------------------------- ; MEM_FREE ; Frees a block of memory @@ -1605,7 +1605,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ld (hl), d ; Next saved ret ENDP -#line 5 "printstr.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/printstr.asm" ; PRINT command routine ; Prints string pointed by HL PRINT_STR: @@ -1646,7 +1646,7 @@ __PRINT_STR: ld d, a ; Saves a FLAG jp __PRINT_STR_LOOP ENDP -#line 2 "printf.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/printf.asm" __PRINTF: ; Prints a Fixed point Number stored in C ED LH PROC LOCAL RECLAIM2 @@ -1675,7 +1675,7 @@ __PRINTF: ; Prints a Fixed point Number stored in C ED LH RECLAIM2 EQU 19E8h ENDP #line 121 "read9.bas" -#line 1 "read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code ;; Updates the DATA_ADDR read ptr for the next read @@ -1693,8 +1693,8 @@ __PRINTF: ; Prints a Fixed point Number stored in C ED LH ;; 09: Float ;; bit7 is set for a parameter-less function ;; In that case, the next two bytes are the ptr of the function to jump -#line 1 "loadstr.asm" -#line 1 "alloc.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1783,9 +1783,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 111 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ret z ; NULL -#line 113 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -1849,7 +1849,7 @@ __MEM_SUBTRACT: inc hl ; Return hl ret ENDP -#line 2 "loadstr.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again ; Finally, it returns result pointer in HL @@ -1884,8 +1884,8 @@ __LOADSTR: ; __FASTCALL__ entry ldir ; Copies string (length number included) pop hl ; Recovers destiny in hl as result ret -#line 24 "read_restore.asm" -#line 1 "iload32.asm" +#line 24 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iload32.asm" ; __FASTCALL__ routine which ; loads a 32 bits integer into DE,HL ; stored at position pointed by POINTER HL @@ -1901,10 +1901,10 @@ __ILOAD32: ld l, a ex de, hl ret -#line 25 "read_restore.asm" -#line 1 "ftof16reg.asm" -#line 1 "ftou32reg.asm" -#line 1 "neg32.asm" +#line 25 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" __ABS32: bit 7, d ret z @@ -1927,7 +1927,7 @@ __NEG32: ; Negates DEHL (Two's complement) ret nz inc de ret -#line 2 "ftou32reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" __FTOU32REG: ; Converts a Float to (un)signed 32 bit integer (NOTE: It's ALWAYS 32 bit signed) ; Input FP number in A EDCB (A exponent, EDCB mantissa) ; Output: DEHL 32 bit number (signed) @@ -2000,7 +2000,7 @@ __FTOU8: ; Converts float in C ED LH to Unsigned byte in A call __FTOU32REG ld a, l ret -#line 2 "ftof16reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal ; Input FP number in A EDCB (A exponent, EDCB mantissa) ld l, a ; Saves exponent for later @@ -2029,9 +2029,9 @@ __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal jp c, __FTOU32REG_END ; It was decimal (0.xxx). We are done (return 0) ld b, a ; Loop counter = exponent - 128 + 16 (we need to shift 16 bit more) jp __FTOU32REG_LOOP ; proceed as an u32 integer -#line 27 "read_restore.asm" -#line 1 "f16tofreg.asm" -#line 1 "u32tofreg.asm" +#line 27 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" __I8TOFREG: ld l, a rlca @@ -2099,7 +2099,7 @@ __U32TOFREG_END: res 7, e ; Sets the sign bit to 0 (positive) ret ENDP -#line 3 "f16tofreg.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" __F16TOFREG: ; Converts a 16.16 signed fixed point (stored in DEHL) ; to a Floating Point Number returned in (C ED CB) PROC @@ -2132,7 +2132,7 @@ __F16TOFREG2: ; Converts an unsigned 32 bit integer (DEHL) ld e, c jp __U32TOFREG_LOOP ; Proceed as an integer ENDP -#line 28 "read_restore.asm" +#line 28 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; Updates restore point to the given HL mem. address __RESTORE: PROC @@ -2205,7 +2205,7 @@ dynamic_cast3: jr c, dynamic_cast4 ;; here the user expected type is "larger" than the read one ld a, b - sub 2 + sub 2 add a, a ld l, a ld h, 0 @@ -2410,7 +2410,7 @@ __DATA_ADDR: ;; Stores current DATA ptr dw __DATA__0 ENDP #line 122 "read9.bas" -#line 1 "sin.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/sin.asm" SIN: ; Computes SIN using ROM FP-CALC call __FPSTACK_PUSH rst 28h ; ROM CALC @@ -2418,7 +2418,7 @@ SIN: ; Computes SIN using ROM FP-CALC defb 38h ; END CALC jp __FPSTACK_POP #line 123 "read9.bas" -#line 1 "storef.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/storef.asm" __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) push de ex de, hl ; DE <- HL @@ -2445,7 +2445,7 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret #line 124 "read9.bas" -#line 1 "tan.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/tan.asm" TAN: ; Computes TAN using ROM FP-CALC call __FPSTACK_PUSH rst 28h ; ROM CALC @@ -2453,4 +2453,4 @@ TAN: ; Computes TAN using ROM FP-CALC defb 38h ; END CALC jp __FPSTACK_POP #line 125 "read9.bas" - END + END \ No newline at end of file diff --git a/tests/functional/readbug.asm b/tests/functional/readbug.asm index 1eb903b90..f382d2b01 100644 --- a/tests/functional/readbug.asm +++ b/tests/functional/readbug.asm @@ -47,7 +47,7 @@ __CALL_BACK__: __DATA__0: __DATA__END: DEFB 00h -#line 1 "read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code ;; Updates the DATA_ADDR read ptr for the next read @@ -65,7 +65,7 @@ __DATA__END: ;; 09: Float ;; bit7 is set for a parameter-less function ;; In that case, the next two bytes are the ptr of the function to jump -#line 1 "error.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" ; Simple error control routines ; vim:ts=4:et: ERR_NR EQU 23610 ; Error code system variable @@ -97,9 +97,9 @@ __ERROR_CODE: __STOP: ld (ERR_NR), a ret -#line 23 "read_restore.asm" -#line 1 "loadstr.asm" -#line 1 "alloc.asm" +#line 23 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -159,7 +159,7 @@ __STOP: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "heapinit.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -264,7 +264,7 @@ __MEM_INIT2: ld (__MEM_INIT), a; "Pokes" with a RET so ensure this routine is not called again ret ENDP -#line 70 "alloc.asm" +#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -294,9 +294,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 111 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ret z ; NULL -#line 113 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -360,7 +360,7 @@ __MEM_SUBTRACT: inc hl ; Return hl ret ENDP -#line 2 "loadstr.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again ; Finally, it returns result pointer in HL @@ -395,8 +395,8 @@ __LOADSTR: ; __FASTCALL__ entry ldir ; Copies string (length number included) pop hl ; Recovers destiny in hl as result ret -#line 24 "read_restore.asm" -#line 1 "iload32.asm" +#line 24 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iload32.asm" ; __FASTCALL__ routine which ; loads a 32 bits integer into DE,HL ; stored at position pointed by POINTER HL @@ -412,8 +412,8 @@ __ILOAD32: ld l, a ex de, hl ret -#line 25 "read_restore.asm" -#line 1 "iloadf.asm" +#line 25 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB ; stored at position pointed by POINTER HL @@ -438,10 +438,10 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL inc hl ld b, (hl) ret -#line 26 "read_restore.asm" -#line 1 "ftof16reg.asm" -#line 1 "ftou32reg.asm" -#line 1 "neg32.asm" +#line 26 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" __ABS32: bit 7, d ret z @@ -464,7 +464,7 @@ __NEG32: ; Negates DEHL (Two's complement) ret nz inc de ret -#line 2 "ftou32reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" __FTOU32REG: ; Converts a Float to (un)signed 32 bit integer (NOTE: It's ALWAYS 32 bit signed) ; Input FP number in A EDCB (A exponent, EDCB mantissa) ; Output: DEHL 32 bit number (signed) @@ -537,7 +537,7 @@ __FTOU8: ; Converts float in C ED LH to Unsigned byte in A call __FTOU32REG ld a, l ret -#line 2 "ftof16reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal ; Input FP number in A EDCB (A exponent, EDCB mantissa) ld l, a ; Saves exponent for later @@ -566,9 +566,9 @@ __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal jp c, __FTOU32REG_END ; It was decimal (0.xxx). We are done (return 0) ld b, a ; Loop counter = exponent - 128 + 16 (we need to shift 16 bit more) jp __FTOU32REG_LOOP ; proceed as an u32 integer -#line 27 "read_restore.asm" -#line 1 "f16tofreg.asm" -#line 1 "u32tofreg.asm" +#line 27 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" __I8TOFREG: ld l, a rlca @@ -636,7 +636,7 @@ __U32TOFREG_END: res 7, e ; Sets the sign bit to 0 (positive) ret ENDP -#line 3 "f16tofreg.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" __F16TOFREG: ; Converts a 16.16 signed fixed point (stored in DEHL) ; to a Floating Point Number returned in (C ED CB) PROC @@ -669,8 +669,8 @@ __F16TOFREG2: ; Converts an unsigned 32 bit integer (DEHL) ld e, c jp __U32TOFREG_LOOP ; Proceed as an integer ENDP -#line 28 "read_restore.asm" -#line 1 "free.asm" +#line 28 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -826,7 +826,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ld (hl), d ; Next saved ret ENDP -#line 29 "read_restore.asm" +#line 29 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; Updates restore point to the given HL mem. address __RESTORE: PROC @@ -899,7 +899,7 @@ dynamic_cast3: jr c, dynamic_cast4 ;; here the user expected type is "larger" than the read one ld a, b - sub 2 + sub 2 add a, a ld l, a ld h, 0 @@ -1104,4 +1104,4 @@ __DATA_ADDR: ;; Stores current DATA ptr dw __DATA__0 ENDP #line 24 "readbug.bas" - END + END \ No newline at end of file diff --git a/tests/functional/readokdown.asm b/tests/functional/readokdown.asm index fed559871..18e76a8ac 100644 --- a/tests/functional/readokdown.asm +++ b/tests/functional/readokdown.asm @@ -131,12 +131,12 @@ __DATA__0: DEFW 0E880h, 04627h __DATA__END: DEFB 00h -#line 1 "print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; vim:ts=4:sw=4:et: ; vim:ts=4:sw=4:et: ; PRINT command routine ; Does not print attribute. Use PRINT_STR or PRINT_NUM for that -#line 1 "sposn.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/sposn.asm" ; Printing positioning library. PROC LOCAL ECHO_E @@ -160,8 +160,8 @@ __SAVE_S_POSN: ; Saves ROW, COL from DE into S_POSN mem var. POSX EQU S_POSN ; Current POS X POSY EQU S_POSN + 1 ; Current POS Y ENDP -#line 7 "print.asm" -#line 1 "cls.asm" +#line 7 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/cls.asm" ; JUMPS directly to spectrum CLS ; This routine does not clear lower screen ;CLS EQU 0DAFh @@ -197,9 +197,9 @@ __CLS_SCR: SCREEN_ADDR EQU (__CLS_SCR + 1) ; Address used by print and other screen routines ; to get the start of the screen ENDP -#line 8 "print.asm" -#line 1 "in_screen.asm" -#line 1 "error.asm" +#line 8 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" ; Simple error control routines ; vim:ts=4:et: ERR_NR EQU 23610 ; Error code system variable @@ -231,7 +231,7 @@ __ERROR_CODE: __STOP: ld (ERR_NR), a ret -#line 3 "in_screen.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" __IN_SCREEN: ; Returns NO carry if current coords (D, E) ; are OUT of the screen limits (MAXX, MAXY) @@ -253,8 +253,8 @@ __OUT_OF_SCREEN_ERR: ld a, ERROR_OutOfScreen jp __STOP ; Saves error code and exits ENDP -#line 9 "print.asm" -#line 1 "table_jump.asm" +#line 9 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/table_jump.asm" JUMP_HL_PLUS_2A: ; Does JP (HL + A*2) Modifies DE. Modifies A add a, a JUMP_HL_PLUS_A: ; Does JP (HL + A) Modifies DE @@ -268,11 +268,11 @@ JUMP_HL_PLUS_DE: ; Does JP (HL + DE) ex de, hl CALL_HL: jp (hl) -#line 10 "print.asm" -#line 1 "ink.asm" +#line 10 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" ; Sets ink color in ATTR_P permanently ; Parameter: Paper color in A register -#line 1 "const.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/const.asm" ; Global constants P_FLAG EQU 23697 FLAGS2 EQU 23681 @@ -281,7 +281,7 @@ CALL_HL: CHARS EQU 23606 ; Pointer to ROM/RAM Charset UDG EQU 23675 ; Pointer to UDG Charset MEM0 EQU 5C92h ; Temporary memory buffer used by ROM chars -#line 5 "ink.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" INK: PROC LOCAL __SET_INK @@ -313,8 +313,8 @@ INK_TMP: ld de, ATTR_T jp __SET_INK ENDP -#line 11 "print.asm" -#line 1 "paper.asm" +#line 11 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/paper.asm" ; Sets paper color in ATTR_P permanently ; Parameter: Paper color in A register PAPER: @@ -351,8 +351,8 @@ PAPER_TMP: ld de, ATTR_T jp __SET_PAPER ENDP -#line 12 "print.asm" -#line 1 "flash.asm" +#line 12 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/flash.asm" ; Sets flash flag in ATTR_P permanently ; Parameter: Paper color in A register FLASH: @@ -386,8 +386,8 @@ FLASH_TMP: ld hl, ATTR_T jr __SET_FLASH ENDP -#line 13 "print.asm" -#line 1 "bright.asm" +#line 13 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bright.asm" ; Sets bright flag in ATTR_P permanently ; Parameter: Paper color in A register BRIGHT: @@ -421,12 +421,12 @@ BRIGHT_TMP: ld hl, ATTR_T jr __SET_BRIGHT ENDP -#line 14 "print.asm" -#line 1 "over.asm" +#line 14 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/over.asm" ; Sets OVER flag in P_FLAG permanently ; Parameter: OVER flag in bit 0 of A register -#line 1 "copy_attr.asm" -#line 4 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" COPY_ATTR: ; Just copies current permanent attribs to temporal attribs ; and sets print mode @@ -466,7 +466,7 @@ TABLE: xor (hl) ; OVER 1 MODE and (hl) ; OVER 2 MODE or (hl) ; OVER 3 MODE -#line 65 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 65 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" __REFRESH_TMP: ld a, (hl) and 10101010b @@ -476,7 +476,7 @@ __REFRESH_TMP: ld (hl), a ret ENDP -#line 4 "over.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/over.asm" OVER: PROC ld c, a ; saves it for later @@ -510,8 +510,8 @@ OVER_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 15 "print.asm" -#line 1 "inverse.asm" +#line 15 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/inverse.asm" ; Sets INVERSE flag in P_FLAG permanently ; Parameter: INVERSE flag in bit 0 of A register INVERSE: @@ -536,8 +536,8 @@ INVERSE_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 16 "print.asm" -#line 1 "bold.asm" +#line 16 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bold.asm" ; Sets BOLD flag in P_FLAG permanently ; Parameter: BOLD flag in bit 0 of A register BOLD: @@ -562,8 +562,8 @@ BOLD_TMP: ld (hl), a ret ENDP -#line 17 "print.asm" -#line 1 "italic.asm" +#line 17 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/italic.asm" ; Sets ITALIC flag in P_FLAG permanently ; Parameter: ITALIC flag in bit 0 of A register ITALIC: @@ -590,8 +590,8 @@ ITALIC_TMP: ld (hl), a ret ENDP -#line 18 "print.asm" -#line 1 "attr.asm" +#line 18 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/attr.asm" ; Attribute routines ; vim:ts=4:et:sw: __ATTR_ADDR: @@ -648,7 +648,7 @@ SET_PIXEL_ADDR_ATTR: ld de, (SCREEN_ADDR) add hl, de ;; Final screen addr jp __SET_ATTR2 -#line 20 "print.asm" +#line 20 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; Putting a comment starting with @INIT
; will make the compiler to add a CALL to
; It is useful for initialization routines. @@ -688,14 +688,14 @@ __SCROLL: ; Scroll? ld hl, __TVFLAGS res 1, (hl) ret -#line 76 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 76 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_START: cp ' ' jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones exx ; Switch to alternative registers ex af, af' ; Saves a value (char to print) for later call __SCROLL -#line 87 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 87 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN ; At this point we have the new coord ld hl, (SCREEN_ADDR) @@ -790,7 +790,7 @@ PRINT_EOL: ; Called WHENEVER there is no ";" at end of PRINT sentence exx __PRINT_0Dh: ; Called WHEN printing CHR$(13) call __SCROLL -#line 210 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 210 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN __PRINT_EOL1: ; Another entry called from PRINT when next line required ld e, 0 @@ -804,7 +804,7 @@ __PRINT_AT1_END: ld hl, __TVFLAGS set 1, (hl) ld a, d -#line 230 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 230 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_EOL_END: ld d, a __PRINT_AT2_END: @@ -1017,7 +1017,7 @@ PRINT_AT: ; Changes cursor to ROW, COL ret nc ; Return if out of screen ld hl, __TVFLAGS res 1, (hl) -#line 482 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 482 "/zxbasic/src/arch/zx48k/library-asm/print.asm" jp __SAVE_S_POSN LOCAL __PRINT_COM LOCAL __BOLD @@ -1064,9 +1064,9 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes DW __PRINT_TAB ; 23 TAB ENDP #line 93 "readokdown.bas" -#line 1 "printf.asm" -#line 1 "printstr.asm" -#line 1 "free.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1126,7 +1126,7 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "heapinit.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1231,7 +1231,7 @@ __MEM_INIT2: ld (__MEM_INIT), a; "Pokes" with a RET so ensure this routine is not called again ret ENDP -#line 69 "free.asm" +#line 69 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; --------------------------------------------------------------------- ; MEM_FREE ; Frees a block of memory @@ -1328,7 +1328,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ld (hl), d ; Next saved ret ENDP -#line 5 "printstr.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/printstr.asm" ; PRINT command routine ; Prints string pointed by HL PRINT_STR: @@ -1369,8 +1369,8 @@ __PRINT_STR: ld d, a ; Saves a FLAG jp __PRINT_STR_LOOP ENDP -#line 2 "printf.asm" -#line 1 "stackf.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/printf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/stackf.asm" ; ------------------------------------------------------------- ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC ; ------------------------------------------------------------- @@ -1407,7 +1407,7 @@ __FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK xor a ld b, a jp __FPSTACK_PUSH -#line 3 "printf.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/printf.asm" __PRINTF: ; Prints a Fixed point Number stored in C ED LH PROC LOCAL RECLAIM2 @@ -1436,8 +1436,8 @@ __PRINTF: ; Prints a Fixed point Number stored in C ED LH RECLAIM2 EQU 19E8h ENDP #line 94 "readokdown.bas" -#line 1 "printf16.asm" -#line 1 "printnum.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printf16.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printnum.asm" __PRINTU_START: PROC LOCAL __PRINTU_CONT @@ -1458,12 +1458,12 @@ __PRINT_MINUS: ; PRINT the MINUS (-) sign. CALLER mus preserve registers ld a, '-' jp __PRINT_DIGIT __PRINT_DIGIT EQU __PRINTCHAR ; PRINTS the char in A register, and puts its attrs -#line 2 "printf16.asm" -#line 1 "printi16.asm" -#line 1 "div16.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/printf16.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printi16.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/div16.asm" ; 16 bit division and modulo functions ; for both signed and unsigned values -#line 1 "neg16.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg16.asm" ; Negates HL value (16 bit) __ABS16: bit 7, h @@ -1477,7 +1477,7 @@ __NEGHL: ld h, a inc hl ret -#line 5 "div16.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/div16.asm" __DIVU16: ; 16 bit unsigned division ; HL = Dividend, Stack Top = Divisor ; -- OBSOLETE ; Now uses FASTCALL convention @@ -1548,7 +1548,7 @@ __MODI16: ; 16 bit modulus ex de, hl ; hl = reminder (modulus) ; de = quotient ret -#line 3 "printi16.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/printi16.asm" __PRINTI16: ; Prints a 16bits signed in HL ; Converts 16 to 32 bits PROC @@ -1574,8 +1574,8 @@ __PRINTU_LOOP: inc b jp __PRINTU_LOOP ; Uses JP in loops ENDP -#line 3 "printf16.asm" -#line 1 "neg32.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/printf16.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" __ABS32: bit 7, d ret z @@ -1598,7 +1598,7 @@ __NEG32: ; Negates DEHL (Two's complement) ret nz inc de ret -#line 4 "printf16.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/printf16.asm" __PRINTF16: ; Prints a 32bit 16.16 fixed point number PROC LOCAL __PRINT_FIX_LOOP @@ -1642,8 +1642,8 @@ __PRINT_FIX_LOOP: jp __PRINT_FIX_LOOP ENDP #line 95 "readokdown.bas" -#line 1 "printi32.asm" -#line 1 "div32.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printi32.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/div32.asm" ; --------------------------------------------------------- __DIVU32: ; 32 bit unsigned division ; DEHL = Dividend, Stack Top = Divisor @@ -1754,7 +1754,7 @@ __MODI32: ; 32bits signed division modulus ex (sp), hl ; CALLEE Convention ; H'L'D'E' => Dividend call __DIVI32START jp __MODU32START -#line 4 "printi32.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/printi32.asm" __PRINTI32: ld a, d or a @@ -1787,8 +1787,8 @@ __PRINTU_LOOP: jp __PRINTU_LOOP ; Uses JP in loops ENDP #line 97 "readokdown.bas" -#line 1 "printi8.asm" -#line 1 "div8.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printi8.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/div8.asm" ; -------------------------------- __DIVU8: ; 8 bit unsigned integer division ; Divides (Top of stack, High Byte) / A @@ -1851,7 +1851,7 @@ __MODI8_FAST: ; __FASTCALL__ entry call __DIVI8_FAST ld a, l ; remainder ret ; a = Modulus -#line 3 "printi8.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/printi8.asm" __PRINTI8: ; Prints an 8 bits number in Accumulator (A) ; Converts 8 to 32 bits or a @@ -1879,13 +1879,13 @@ __PRINTU_LOOP: jp __PRINTU_LOOP ; Uses JP in loops ENDP #line 98 "readokdown.bas" -#line 1 "printu16.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printu16.asm" #line 99 "readokdown.bas" -#line 1 "printu32.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printu32.asm" #line 100 "readokdown.bas" -#line 1 "printu8.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printu8.asm" #line 101 "readokdown.bas" -#line 1 "read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code ;; Updates the DATA_ADDR read ptr for the next read @@ -1903,8 +1903,8 @@ __PRINTU_LOOP: ;; 09: Float ;; bit7 is set for a parameter-less function ;; In that case, the next two bytes are the ptr of the function to jump -#line 1 "loadstr.asm" -#line 1 "alloc.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1993,9 +1993,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 111 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ret z ; NULL -#line 113 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -2059,7 +2059,7 @@ __MEM_SUBTRACT: inc hl ; Return hl ret ENDP -#line 2 "loadstr.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again ; Finally, it returns result pointer in HL @@ -2094,8 +2094,8 @@ __LOADSTR: ; __FASTCALL__ entry ldir ; Copies string (length number included) pop hl ; Recovers destiny in hl as result ret -#line 24 "read_restore.asm" -#line 1 "iload32.asm" +#line 24 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iload32.asm" ; __FASTCALL__ routine which ; loads a 32 bits integer into DE,HL ; stored at position pointed by POINTER HL @@ -2111,8 +2111,8 @@ __ILOAD32: ld l, a ex de, hl ret -#line 25 "read_restore.asm" -#line 1 "iloadf.asm" +#line 25 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB ; stored at position pointed by POINTER HL @@ -2137,9 +2137,9 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL inc hl ld b, (hl) ret -#line 26 "read_restore.asm" -#line 1 "ftof16reg.asm" -#line 1 "ftou32reg.asm" +#line 26 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" __FTOU32REG: ; Converts a Float to (un)signed 32 bit integer (NOTE: It's ALWAYS 32 bit signed) ; Input FP number in A EDCB (A exponent, EDCB mantissa) ; Output: DEHL 32 bit number (signed) @@ -2212,7 +2212,7 @@ __FTOU8: ; Converts float in C ED LH to Unsigned byte in A call __FTOU32REG ld a, l ret -#line 2 "ftof16reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal ; Input FP number in A EDCB (A exponent, EDCB mantissa) ld l, a ; Saves exponent for later @@ -2241,9 +2241,9 @@ __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal jp c, __FTOU32REG_END ; It was decimal (0.xxx). We are done (return 0) ld b, a ; Loop counter = exponent - 128 + 16 (we need to shift 16 bit more) jp __FTOU32REG_LOOP ; proceed as an u32 integer -#line 27 "read_restore.asm" -#line 1 "f16tofreg.asm" -#line 1 "u32tofreg.asm" +#line 27 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" __I8TOFREG: ld l, a rlca @@ -2311,7 +2311,7 @@ __U32TOFREG_END: res 7, e ; Sets the sign bit to 0 (positive) ret ENDP -#line 3 "f16tofreg.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" __F16TOFREG: ; Converts a 16.16 signed fixed point (stored in DEHL) ; to a Floating Point Number returned in (C ED CB) PROC @@ -2344,7 +2344,7 @@ __F16TOFREG2: ; Converts an unsigned 32 bit integer (DEHL) ld e, c jp __U32TOFREG_LOOP ; Proceed as an integer ENDP -#line 28 "read_restore.asm" +#line 28 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; Updates restore point to the given HL mem. address __RESTORE: PROC @@ -2417,7 +2417,7 @@ dynamic_cast3: jr c, dynamic_cast4 ;; here the user expected type is "larger" than the read one ld a, b - sub 2 + sub 2 add a, a ld l, a ld h, 0 @@ -2622,7 +2622,7 @@ __DATA_ADDR: ;; Stores current DATA ptr dw __DATA__0 ENDP #line 102 "readokdown.bas" -#line 1 "storef.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/storef.asm" __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) push de ex de, hl ; DE <- HL @@ -2649,4 +2649,4 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret #line 103 "readokdown.bas" - END + END \ No newline at end of file diff --git a/tests/functional/readokup.asm b/tests/functional/readokup.asm index c18835a62..d4304ca3a 100644 --- a/tests/functional/readokup.asm +++ b/tests/functional/readokup.asm @@ -130,12 +130,12 @@ __DATA__0: DEFB -1 __DATA__END: DEFB 00h -#line 1 "print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; vim:ts=4:sw=4:et: ; vim:ts=4:sw=4:et: ; PRINT command routine ; Does not print attribute. Use PRINT_STR or PRINT_NUM for that -#line 1 "sposn.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/sposn.asm" ; Printing positioning library. PROC LOCAL ECHO_E @@ -159,8 +159,8 @@ __SAVE_S_POSN: ; Saves ROW, COL from DE into S_POSN mem var. POSX EQU S_POSN ; Current POS X POSY EQU S_POSN + 1 ; Current POS Y ENDP -#line 7 "print.asm" -#line 1 "cls.asm" +#line 7 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/cls.asm" ; JUMPS directly to spectrum CLS ; This routine does not clear lower screen ;CLS EQU 0DAFh @@ -196,9 +196,9 @@ __CLS_SCR: SCREEN_ADDR EQU (__CLS_SCR + 1) ; Address used by print and other screen routines ; to get the start of the screen ENDP -#line 8 "print.asm" -#line 1 "in_screen.asm" -#line 1 "error.asm" +#line 8 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" ; Simple error control routines ; vim:ts=4:et: ERR_NR EQU 23610 ; Error code system variable @@ -230,7 +230,7 @@ __ERROR_CODE: __STOP: ld (ERR_NR), a ret -#line 3 "in_screen.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/in_screen.asm" __IN_SCREEN: ; Returns NO carry if current coords (D, E) ; are OUT of the screen limits (MAXX, MAXY) @@ -252,8 +252,8 @@ __OUT_OF_SCREEN_ERR: ld a, ERROR_OutOfScreen jp __STOP ; Saves error code and exits ENDP -#line 9 "print.asm" -#line 1 "table_jump.asm" +#line 9 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/table_jump.asm" JUMP_HL_PLUS_2A: ; Does JP (HL + A*2) Modifies DE. Modifies A add a, a JUMP_HL_PLUS_A: ; Does JP (HL + A) Modifies DE @@ -267,11 +267,11 @@ JUMP_HL_PLUS_DE: ; Does JP (HL + DE) ex de, hl CALL_HL: jp (hl) -#line 10 "print.asm" -#line 1 "ink.asm" +#line 10 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" ; Sets ink color in ATTR_P permanently ; Parameter: Paper color in A register -#line 1 "const.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/const.asm" ; Global constants P_FLAG EQU 23697 FLAGS2 EQU 23681 @@ -280,7 +280,7 @@ CALL_HL: CHARS EQU 23606 ; Pointer to ROM/RAM Charset UDG EQU 23675 ; Pointer to UDG Charset MEM0 EQU 5C92h ; Temporary memory buffer used by ROM chars -#line 5 "ink.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/ink.asm" INK: PROC LOCAL __SET_INK @@ -312,8 +312,8 @@ INK_TMP: ld de, ATTR_T jp __SET_INK ENDP -#line 11 "print.asm" -#line 1 "paper.asm" +#line 11 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/paper.asm" ; Sets paper color in ATTR_P permanently ; Parameter: Paper color in A register PAPER: @@ -350,8 +350,8 @@ PAPER_TMP: ld de, ATTR_T jp __SET_PAPER ENDP -#line 12 "print.asm" -#line 1 "flash.asm" +#line 12 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/flash.asm" ; Sets flash flag in ATTR_P permanently ; Parameter: Paper color in A register FLASH: @@ -385,8 +385,8 @@ FLASH_TMP: ld hl, ATTR_T jr __SET_FLASH ENDP -#line 13 "print.asm" -#line 1 "bright.asm" +#line 13 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bright.asm" ; Sets bright flag in ATTR_P permanently ; Parameter: Paper color in A register BRIGHT: @@ -420,12 +420,12 @@ BRIGHT_TMP: ld hl, ATTR_T jr __SET_BRIGHT ENDP -#line 14 "print.asm" -#line 1 "over.asm" +#line 14 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/over.asm" ; Sets OVER flag in P_FLAG permanently ; Parameter: OVER flag in bit 0 of A register -#line 1 "copy_attr.asm" -#line 4 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" COPY_ATTR: ; Just copies current permanent attribs to temporal attribs ; and sets print mode @@ -465,7 +465,7 @@ TABLE: xor (hl) ; OVER 1 MODE and (hl) ; OVER 2 MODE or (hl) ; OVER 3 MODE -#line 65 "/zxbasic/arch/zx48k/library-asm/copy_attr.asm" +#line 65 "/zxbasic/src/arch/zx48k/library-asm/copy_attr.asm" __REFRESH_TMP: ld a, (hl) and 10101010b @@ -475,7 +475,7 @@ __REFRESH_TMP: ld (hl), a ret ENDP -#line 4 "over.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/over.asm" OVER: PROC ld c, a ; saves it for later @@ -509,8 +509,8 @@ OVER_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 15 "print.asm" -#line 1 "inverse.asm" +#line 15 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/inverse.asm" ; Sets INVERSE flag in P_FLAG permanently ; Parameter: INVERSE flag in bit 0 of A register INVERSE: @@ -535,8 +535,8 @@ INVERSE_TMP: ld (hl), a jp __SET_ATTR_MODE ENDP -#line 16 "print.asm" -#line 1 "bold.asm" +#line 16 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/bold.asm" ; Sets BOLD flag in P_FLAG permanently ; Parameter: BOLD flag in bit 0 of A register BOLD: @@ -561,8 +561,8 @@ BOLD_TMP: ld (hl), a ret ENDP -#line 17 "print.asm" -#line 1 "italic.asm" +#line 17 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/italic.asm" ; Sets ITALIC flag in P_FLAG permanently ; Parameter: ITALIC flag in bit 0 of A register ITALIC: @@ -589,8 +589,8 @@ ITALIC_TMP: ld (hl), a ret ENDP -#line 18 "print.asm" -#line 1 "attr.asm" +#line 18 "/zxbasic/src/arch/zx48k/library-asm/print.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/attr.asm" ; Attribute routines ; vim:ts=4:et:sw: __ATTR_ADDR: @@ -647,7 +647,7 @@ SET_PIXEL_ADDR_ATTR: ld de, (SCREEN_ADDR) add hl, de ;; Final screen addr jp __SET_ATTR2 -#line 20 "print.asm" +#line 20 "/zxbasic/src/arch/zx48k/library-asm/print.asm" ; Putting a comment starting with @INIT
; will make the compiler to add a CALL to
; It is useful for initialization routines. @@ -687,14 +687,14 @@ __SCROLL: ; Scroll? ld hl, __TVFLAGS res 1, (hl) ret -#line 76 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 76 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_START: cp ' ' jp c, __PRINT_SPECIAL ; Characters below ' ' are special ones exx ; Switch to alternative registers ex af, af' ; Saves a value (char to print) for later call __SCROLL -#line 87 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 87 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN ; At this point we have the new coord ld hl, (SCREEN_ADDR) @@ -789,7 +789,7 @@ PRINT_EOL: ; Called WHENEVER there is no ";" at end of PRINT sentence exx __PRINT_0Dh: ; Called WHEN printing CHR$(13) call __SCROLL -#line 210 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 210 "/zxbasic/src/arch/zx48k/library-asm/print.asm" call __LOAD_S_POSN __PRINT_EOL1: ; Another entry called from PRINT when next line required ld e, 0 @@ -803,7 +803,7 @@ __PRINT_AT1_END: ld hl, __TVFLAGS set 1, (hl) ld a, d -#line 230 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 230 "/zxbasic/src/arch/zx48k/library-asm/print.asm" __PRINT_EOL_END: ld d, a __PRINT_AT2_END: @@ -1016,7 +1016,7 @@ PRINT_AT: ; Changes cursor to ROW, COL ret nc ; Return if out of screen ld hl, __TVFLAGS res 1, (hl) -#line 482 "/zxbasic/arch/zx48k/library-asm/print.asm" +#line 482 "/zxbasic/src/arch/zx48k/library-asm/print.asm" jp __SAVE_S_POSN LOCAL __PRINT_COM LOCAL __BOLD @@ -1063,9 +1063,9 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes DW __PRINT_TAB ; 23 TAB ENDP #line 92 "readokup.bas" -#line 1 "printf.asm" -#line 1 "printstr.asm" -#line 1 "free.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1125,7 +1125,7 @@ __PRINT_TABLE: ; Jump table for 0 .. 22 codes ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "heapinit.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1230,7 +1230,7 @@ __MEM_INIT2: ld (__MEM_INIT), a; "Pokes" with a RET so ensure this routine is not called again ret ENDP -#line 69 "free.asm" +#line 69 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; --------------------------------------------------------------------- ; MEM_FREE ; Frees a block of memory @@ -1327,7 +1327,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ld (hl), d ; Next saved ret ENDP -#line 5 "printstr.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/printstr.asm" ; PRINT command routine ; Prints string pointed by HL PRINT_STR: @@ -1368,8 +1368,8 @@ __PRINT_STR: ld d, a ; Saves a FLAG jp __PRINT_STR_LOOP ENDP -#line 2 "printf.asm" -#line 1 "stackf.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/printf.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/stackf.asm" ; ------------------------------------------------------------- ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC ; ------------------------------------------------------------- @@ -1406,7 +1406,7 @@ __FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK xor a ld b, a jp __FPSTACK_PUSH -#line 3 "printf.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/printf.asm" __PRINTF: ; Prints a Fixed point Number stored in C ED LH PROC LOCAL RECLAIM2 @@ -1435,8 +1435,8 @@ __PRINTF: ; Prints a Fixed point Number stored in C ED LH RECLAIM2 EQU 19E8h ENDP #line 93 "readokup.bas" -#line 1 "printf16.asm" -#line 1 "printnum.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printf16.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printnum.asm" __PRINTU_START: PROC LOCAL __PRINTU_CONT @@ -1457,12 +1457,12 @@ __PRINT_MINUS: ; PRINT the MINUS (-) sign. CALLER mus preserve registers ld a, '-' jp __PRINT_DIGIT __PRINT_DIGIT EQU __PRINTCHAR ; PRINTS the char in A register, and puts its attrs -#line 2 "printf16.asm" -#line 1 "printi16.asm" -#line 1 "div16.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/printf16.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printi16.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/div16.asm" ; 16 bit division and modulo functions ; for both signed and unsigned values -#line 1 "neg16.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg16.asm" ; Negates HL value (16 bit) __ABS16: bit 7, h @@ -1476,7 +1476,7 @@ __NEGHL: ld h, a inc hl ret -#line 5 "div16.asm" +#line 5 "/zxbasic/src/arch/zx48k/library-asm/div16.asm" __DIVU16: ; 16 bit unsigned division ; HL = Dividend, Stack Top = Divisor ; -- OBSOLETE ; Now uses FASTCALL convention @@ -1547,7 +1547,7 @@ __MODI16: ; 16 bit modulus ex de, hl ; hl = reminder (modulus) ; de = quotient ret -#line 3 "printi16.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/printi16.asm" __PRINTI16: ; Prints a 16bits signed in HL ; Converts 16 to 32 bits PROC @@ -1573,8 +1573,8 @@ __PRINTU_LOOP: inc b jp __PRINTU_LOOP ; Uses JP in loops ENDP -#line 3 "printf16.asm" -#line 1 "neg32.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/printf16.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" __ABS32: bit 7, d ret z @@ -1597,7 +1597,7 @@ __NEG32: ; Negates DEHL (Two's complement) ret nz inc de ret -#line 4 "printf16.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/printf16.asm" __PRINTF16: ; Prints a 32bit 16.16 fixed point number PROC LOCAL __PRINT_FIX_LOOP @@ -1641,8 +1641,8 @@ __PRINT_FIX_LOOP: jp __PRINT_FIX_LOOP ENDP #line 94 "readokup.bas" -#line 1 "printi32.asm" -#line 1 "div32.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printi32.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/div32.asm" ; --------------------------------------------------------- __DIVU32: ; 32 bit unsigned division ; DEHL = Dividend, Stack Top = Divisor @@ -1753,7 +1753,7 @@ __MODI32: ; 32bits signed division modulus ex (sp), hl ; CALLEE Convention ; H'L'D'E' => Dividend call __DIVI32START jp __MODU32START -#line 4 "printi32.asm" +#line 4 "/zxbasic/src/arch/zx48k/library-asm/printi32.asm" __PRINTI32: ld a, d or a @@ -1786,8 +1786,8 @@ __PRINTU_LOOP: jp __PRINTU_LOOP ; Uses JP in loops ENDP #line 96 "readokup.bas" -#line 1 "printi8.asm" -#line 1 "div8.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printi8.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/div8.asm" ; -------------------------------- __DIVU8: ; 8 bit unsigned integer division ; Divides (Top of stack, High Byte) / A @@ -1850,7 +1850,7 @@ __MODI8_FAST: ; __FASTCALL__ entry call __DIVI8_FAST ld a, l ; remainder ret ; a = Modulus -#line 3 "printi8.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/printi8.asm" __PRINTI8: ; Prints an 8 bits number in Accumulator (A) ; Converts 8 to 32 bits or a @@ -1878,13 +1878,13 @@ __PRINTU_LOOP: jp __PRINTU_LOOP ; Uses JP in loops ENDP #line 97 "readokup.bas" -#line 1 "printu16.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printu16.asm" #line 98 "readokup.bas" -#line 1 "printu32.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printu32.asm" #line 99 "readokup.bas" -#line 1 "printu8.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/printu8.asm" #line 100 "readokup.bas" -#line 1 "read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code ;; Updates the DATA_ADDR read ptr for the next read @@ -1902,8 +1902,8 @@ __PRINTU_LOOP: ;; 09: Float ;; bit7 is set for a parameter-less function ;; In that case, the next two bytes are the ptr of the function to jump -#line 1 "loadstr.asm" -#line 1 "alloc.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -1992,9 +1992,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 111 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ret z ; NULL -#line 113 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -2058,7 +2058,7 @@ __MEM_SUBTRACT: inc hl ; Return hl ret ENDP -#line 2 "loadstr.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again ; Finally, it returns result pointer in HL @@ -2093,8 +2093,8 @@ __LOADSTR: ; __FASTCALL__ entry ldir ; Copies string (length number included) pop hl ; Recovers destiny in hl as result ret -#line 24 "read_restore.asm" -#line 1 "iload32.asm" +#line 24 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iload32.asm" ; __FASTCALL__ routine which ; loads a 32 bits integer into DE,HL ; stored at position pointed by POINTER HL @@ -2110,8 +2110,8 @@ __ILOAD32: ld l, a ex de, hl ret -#line 25 "read_restore.asm" -#line 1 "iloadf.asm" +#line 25 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB ; stored at position pointed by POINTER HL @@ -2136,9 +2136,9 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL inc hl ld b, (hl) ret -#line 26 "read_restore.asm" -#line 1 "ftof16reg.asm" -#line 1 "ftou32reg.asm" +#line 26 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" __FTOU32REG: ; Converts a Float to (un)signed 32 bit integer (NOTE: It's ALWAYS 32 bit signed) ; Input FP number in A EDCB (A exponent, EDCB mantissa) ; Output: DEHL 32 bit number (signed) @@ -2211,7 +2211,7 @@ __FTOU8: ; Converts float in C ED LH to Unsigned byte in A call __FTOU32REG ld a, l ret -#line 2 "ftof16reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal ; Input FP number in A EDCB (A exponent, EDCB mantissa) ld l, a ; Saves exponent for later @@ -2240,9 +2240,9 @@ __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal jp c, __FTOU32REG_END ; It was decimal (0.xxx). We are done (return 0) ld b, a ; Loop counter = exponent - 128 + 16 (we need to shift 16 bit more) jp __FTOU32REG_LOOP ; proceed as an u32 integer -#line 27 "read_restore.asm" -#line 1 "f16tofreg.asm" -#line 1 "u32tofreg.asm" +#line 27 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" __I8TOFREG: ld l, a rlca @@ -2310,7 +2310,7 @@ __U32TOFREG_END: res 7, e ; Sets the sign bit to 0 (positive) ret ENDP -#line 3 "f16tofreg.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" __F16TOFREG: ; Converts a 16.16 signed fixed point (stored in DEHL) ; to a Floating Point Number returned in (C ED CB) PROC @@ -2343,7 +2343,7 @@ __F16TOFREG2: ; Converts an unsigned 32 bit integer (DEHL) ld e, c jp __U32TOFREG_LOOP ; Proceed as an integer ENDP -#line 28 "read_restore.asm" +#line 28 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; Updates restore point to the given HL mem. address __RESTORE: PROC @@ -2416,7 +2416,7 @@ dynamic_cast3: jr c, dynamic_cast4 ;; here the user expected type is "larger" than the read one ld a, b - sub 2 + sub 2 add a, a ld l, a ld h, 0 @@ -2621,7 +2621,7 @@ __DATA_ADDR: ;; Stores current DATA ptr dw __DATA__0 ENDP #line 101 "readokup.bas" -#line 1 "storef.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/storef.asm" __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) push de ex de, hl ; DE <- HL @@ -2648,4 +2648,4 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret #line 102 "readokup.bas" - END + END \ No newline at end of file diff --git a/tests/functional/restore1.asm b/tests/functional/restore1.asm index 39c89ba79..3cc4eb679 100644 --- a/tests/functional/restore1.asm +++ b/tests/functional/restore1.asm @@ -54,7 +54,7 @@ __DATA__0: DEFB 85 __DATA__END: DEFB 00h -#line 1 "read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code ;; Updates the DATA_ADDR read ptr for the next read @@ -72,7 +72,7 @@ __DATA__END: ;; 09: Float ;; bit7 is set for a parameter-less function ;; In that case, the next two bytes are the ptr of the function to jump -#line 1 "error.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/error.asm" ; Simple error control routines ; vim:ts=4:et: ERR_NR EQU 23610 ; Error code system variable @@ -104,9 +104,9 @@ __ERROR_CODE: __STOP: ld (ERR_NR), a ret -#line 23 "read_restore.asm" -#line 1 "loadstr.asm" -#line 1 "alloc.asm" +#line 23 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -166,7 +166,7 @@ __STOP: ; HL = BLOCK Start & DE = Length. ; An init directive is useful for initialization routines. ; They will be added automatically if needed. -#line 1 "heapinit.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/heapinit.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -271,7 +271,7 @@ __MEM_INIT2: ld (__MEM_INIT), a; "Pokes" with a RET so ensure this routine is not called again ret ENDP -#line 70 "alloc.asm" +#line 70 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; --------------------------------------------------------------------- ; MEM_ALLOC ; Allocates a block of memory in the heap. @@ -301,9 +301,9 @@ __MEM_START: __MEM_LOOP: ; Loads lengh at (HL, HL+). If Lenght >= BC, jump to __MEM_DONE ld a, h ; HL = NULL (No memory available?) or l -#line 111 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 111 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ret z ; NULL -#line 113 "/zxbasic/arch/zx48k/library-asm/alloc.asm" +#line 113 "/zxbasic/src/arch/zx48k/library-asm/alloc.asm" ; HL = Pointer to Free block ld e, (hl) inc hl @@ -367,7 +367,7 @@ __MEM_SUBTRACT: inc hl ; Return hl ret ENDP -#line 2 "loadstr.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/loadstr.asm" ; Loads a string (ptr) from HL ; and duplicates it on dynamic memory again ; Finally, it returns result pointer in HL @@ -402,8 +402,8 @@ __LOADSTR: ; __FASTCALL__ entry ldir ; Copies string (length number included) pop hl ; Recovers destiny in hl as result ret -#line 24 "read_restore.asm" -#line 1 "iload32.asm" +#line 24 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iload32.asm" ; __FASTCALL__ routine which ; loads a 32 bits integer into DE,HL ; stored at position pointed by POINTER HL @@ -419,8 +419,8 @@ __ILOAD32: ld l, a ex de, hl ret -#line 25 "read_restore.asm" -#line 1 "iloadf.asm" +#line 25 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/iloadf.asm" ; __FASTCALL__ routine which ; loads a 40 bits floating point into A ED CB ; stored at position pointed by POINTER HL @@ -445,10 +445,10 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL inc hl ld b, (hl) ret -#line 26 "read_restore.asm" -#line 1 "ftof16reg.asm" -#line 1 "ftou32reg.asm" -#line 1 "neg32.asm" +#line 26 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/neg32.asm" __ABS32: bit 7, d ret z @@ -471,7 +471,7 @@ __NEG32: ; Negates DEHL (Two's complement) ret nz inc de ret -#line 2 "ftou32reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftou32reg.asm" __FTOU32REG: ; Converts a Float to (un)signed 32 bit integer (NOTE: It's ALWAYS 32 bit signed) ; Input FP number in A EDCB (A exponent, EDCB mantissa) ; Output: DEHL 32 bit number (signed) @@ -544,7 +544,7 @@ __FTOU8: ; Converts float in C ED LH to Unsigned byte in A call __FTOU32REG ld a, l ret -#line 2 "ftof16reg.asm" +#line 2 "/zxbasic/src/arch/zx48k/library-asm/ftof16reg.asm" __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal ; Input FP number in A EDCB (A exponent, EDCB mantissa) ld l, a ; Saves exponent for later @@ -573,9 +573,9 @@ __FTOF16REG: ; Converts a Float to 16.16 (32 bit) fixed point decimal jp c, __FTOU32REG_END ; It was decimal (0.xxx). We are done (return 0) ld b, a ; Loop counter = exponent - 128 + 16 (we need to shift 16 bit more) jp __FTOU32REG_LOOP ; proceed as an u32 integer -#line 27 "read_restore.asm" -#line 1 "f16tofreg.asm" -#line 1 "u32tofreg.asm" +#line 27 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/u32tofreg.asm" __I8TOFREG: ld l, a rlca @@ -643,7 +643,7 @@ __U32TOFREG_END: res 7, e ; Sets the sign bit to 0 (positive) ret ENDP -#line 3 "f16tofreg.asm" +#line 3 "/zxbasic/src/arch/zx48k/library-asm/f16tofreg.asm" __F16TOFREG: ; Converts a 16.16 signed fixed point (stored in DEHL) ; to a Floating Point Number returned in (C ED CB) PROC @@ -676,8 +676,8 @@ __F16TOFREG2: ; Converts an unsigned 32 bit integer (DEHL) ld e, c jp __U32TOFREG_LOOP ; Proceed as an integer ENDP -#line 28 "read_restore.asm" -#line 1 "free.asm" +#line 28 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/free.asm" ; vim: ts=4:et:sw=4: ; Copyleft (K) by Jose M. Rodriguez de la Rosa ; (a.k.a. Boriel) @@ -833,7 +833,7 @@ __MEM_BLOCK_JOIN: ; Joins current block (pointed by HL) with next one (pointed ld (hl), d ; Next saved ret ENDP -#line 29 "read_restore.asm" +#line 29 "/zxbasic/src/arch/zx48k/library-asm/read_restore.asm" ;; Updates restore point to the given HL mem. address __RESTORE: PROC @@ -906,7 +906,7 @@ dynamic_cast3: jr c, dynamic_cast4 ;; here the user expected type is "larger" than the read one ld a, b - sub 2 + sub 2 add a, a ld l, a ld h, 0 @@ -1111,7 +1111,7 @@ __DATA_ADDR: ;; Stores current DATA ptr dw __DATA__0 ENDP #line 31 "restore1.bas" -#line 1 "storef.asm" +#line 1 "/zxbasic/src/arch/zx48k/library-asm/storef.asm" __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) push de ex de, hl ; DE <- HL @@ -1138,4 +1138,4 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret #line 32 "restore1.bas" - END + END \ No newline at end of file diff --git a/tests/functional/spectrum.out b/tests/functional/spectrum.out index f777aac37..cb29e0f0f 100644 --- a/tests/functional/spectrum.out +++ b/tests/functional/spectrum.out @@ -1,2 +1,6 @@ #line 1 "spectrum.bi" + + + PRINT "HELLO WORLD!" + diff --git a/tests/functional/test.py b/tests/functional/test.py index 0001394ee..6751e0899 100755 --- a/tests/functional/test.py +++ b/tests/functional/test.py @@ -10,6 +10,9 @@ import difflib import tempfile +from typing import List + + reOPT = re.compile(r'^opt([0-9]+)_') # To detect -On tests reBIN = re.compile(r'^(?:.*/)?(tzx|tap)_.*') # To detect tzx / tap test @@ -47,13 +50,14 @@ RAISE_EXCEPTIONS = False # True if we want the testing to abort on compiler crashes TIMEOUT = 3 # Max number of seconds a test should last +_timeout = lambda: TIMEOUT + class TempTestFile(object): """ Uses a python guard context to ensure file deletion. Executes a system command which creates a temporary file and ensures file deletion upon return. """ - def __init__(self, func, fname, keep_file=False): """ Initializes the context. The flag dont_remove will only be taken into account if the System command execution was successful (returns 0) @@ -82,7 +86,7 @@ def __exit__(self, type_, value, traceback): if self.error_level or not self.keep_file: # command failure or remove file? try: os.unlink(self.fname) - except OSError: + except (OSError, FileNotFoundError): pass # Ok. It might be that the wasn't created @@ -102,14 +106,14 @@ def _msg(msg, force=False): FOUT.write(msg) -def get_file_lines(filename, ignore_regexp=None, replace_regexp=None, - replace_what='.', replace_with='.', strip_blanks=True): +def get_file_lines(filename: str, ignore_regexp=None, replace_regexp=None, + replace_what: str = '.', replace_with: str = '.', strip_blanks: bool = True) -> List[str]: """ Opens source file and load its lines, discarding those not important for comparison. """ from src.api.utils import open_file with open_file(filename, 'rt', 'utf-8') as f: - lines = [x for x in f] + lines = [x.rstrip('\r\n') for x in f] if ignore_regexp is not None: r = re.compile(ignore_regexp) @@ -120,7 +124,7 @@ def get_file_lines(filename, ignore_regexp=None, replace_regexp=None, lines = [x.replace(replace_what, replace_with, 1) if r.search(x) else x for x in lines] if strip_blanks: - lines = [x.rstrip(' \t') for x in lines if x.rstrip()] + lines = [x.rstrip(' \t') for x in lines if x.rstrip(' \t')] return lines @@ -173,7 +177,7 @@ def systemExec(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT): return exit_code -def getExtension(fname): +def getExtension(fname: str): """ Returns filename extension. Returns None if no extension. """ @@ -181,7 +185,7 @@ def getExtension(fname): return split[-1] if len(split) > 1 else None -def getName(fname): +def getName(fname: str) -> str: """ Returns filename (without extension) """ basename = os.path.basename(fname) @@ -191,7 +195,7 @@ def getName(fname): return basename.split(os.extsep)[0] -def _get_testbas_options(fname): +def _get_testbas_options(fname: str): """ Generates a command line string to be executed to get the .asm test file from a .bas one. :param str fname: .bas filename source file @@ -226,7 +230,7 @@ def _get_testbas_options(fname): return options, tfname, ext -def updateTest(tfname, pattern_): +def updateTest(tfname: str, pattern_, strip_blanks: bool = True): if not os.path.exists(tfname): return # was deleted -> The test is an error test and no compile filed should exist @@ -234,12 +238,12 @@ def updateTest(tfname, pattern_): return lines = get_file_lines(tfname, replace_regexp=pattern_, replace_what=ZXBASIC_ROOT, - replace_with=_original_root) + replace_with=_original_root, strip_blanks=strip_blanks) with src.api.utils.open_file(tfname, 'wt', encoding='utf-8') as f: - f.write(''.join(lines)) + f.write('\n'.join(lines)) -@src.api.utils.timeout(TIMEOUT) +@src.api.utils.timeout(_timeout) def testPREPRO(fname, pattern_=None, inline=None, cmdline_args=None): """ Test preprocessing file. Test is done by preprocessing the file and then comparing the output against an expected one. The output file can optionally be filtered @@ -289,16 +293,16 @@ def testPREPRO(fname, pattern_=None, inline=None, cmdline_args=None): with TempTestFile(func, tfname, UPDATE): if not UPDATE: result = is_same_file(okfile, tfname, replace_regexp=pattern_, replace_what=ZXBASIC_ROOT, - replace_with=_original_root, strip_blanks=True) + replace_with=_original_root, strip_blanks=False) else: - updateTest(tfname, pattern_) + updateTest(tfname, pattern_, strip_blanks=False) finally: os.chdir(current_path) return result -@src.api.utils.timeout(TIMEOUT) +@src.api.utils.timeout(_timeout) def testASM(fname, inline=None, cmdline_args=None): """ Test assembling an ASM (.asm) file. Test is done by assembling the source code into a binary and then comparing the output file against an expected binary output. @@ -341,7 +345,7 @@ def testASM(fname, inline=None, cmdline_args=None): return result -@src.api.utils.timeout(TIMEOUT) +@src.api.utils.timeout(_timeout) def testBAS(fname, filter_=None, inline=None, cmdline_args=None): """ Test compiling a BASIC (.bas) file. Test is done by compiling the source code into asm and then comparing the output asm against an expected asm output. The output asm file can optionally be filtered @@ -425,21 +429,24 @@ def testFiles(file_list, cmdline_args=None): _msg('FAIL\n') -def upgradeTest(fileList, f3diff): +def upgradeTest(fileList: List[str], f3diff: str): """ Run against the list of files, and a 3rd file containing the diff. If the diff between file1 and file2 are the same as file3, then the .asm file is patched. """ + global COUNTER - def normalizeDiff(diff): + def normalizeDiff(diff: List[str]) -> List[str]: diff = [x.strip(' \t') for x in diff] reHEADER = re.compile(r'[-+]{3}') while diff and reHEADER.match(diff[0]): diff = diff[1:] + O1 = O2 = 0 first = True reHUNK = re.compile(r'@@ [-+](\d+)(,\d+)? [-+](\d+)(,\d+)? @@') + for i in range(len(diff)): line = diff[i] if line[:7] in ('-#line ', '+#line '): @@ -460,7 +467,9 @@ def normalizeDiff(diff): return diff - fdiff = open(f3diff).readlines() + with open(f3diff, 'rt', encoding='utf-8') as patch_file: + fdiff = [line.rstrip('\n') for line in patch_file] + fdiff = normalizeDiff(fdiff) for fname in fileList: @@ -481,7 +490,7 @@ def normalizeDiff(diff): pass continue - lines = [] + lines: List[str] = [] is_same_file(fname1, tfname, ignore_regexp=FILTER, diff=lines) lines = normalizeDiff(lines) @@ -490,13 +499,18 @@ def normalizeDiff(diff): x = x.strip() y = y.strip() c = '=' if x == y else '!' - _msg('"%s"%s"%s"\n' % (x.strip(), c, y.strip())) + _msg('"%s" %s "%s"\n' % (x.strip(), c, y.strip())) os.unlink(tfname) continue # Not the same diff - os.unlink(fname1) - os.rename(tfname, fname1) + lines = get_file_lines(tfname, replace_regexp=FILTER, replace_what=ZXBASIC_ROOT, + replace_with=_original_root) + with src.api.utils.open_file(fname1, 'wt', encoding='utf-8') as f: + f.write('\n'.join(lines)) + + os.unlink(tfname) _msg("\rTest: %s (%s) updated\n" % (fname, fname1)) + COUNTER += 1 def set_temp_dir(tmp_dir=None): @@ -534,6 +548,7 @@ def main(argv=None): global FAILED global EXIT_CODE global RAISE_EXCEPTIONS + global TIMEOUT COUNTER = FAILED = EXIT_CODE = 0 @@ -571,6 +586,9 @@ def main(argv=None): VIM_DIFF = args.show_visual_diff UPDATE = args.force_update + if VIM_DIFF: + TIMEOUT = 0 # disable timeout for Vim-dif + temp_dir_created = set_temp_dir(args.tmp_dir) if args.update: diff --git a/tests/functional/test_errmsg.txt b/tests/functional/test_errmsg.txt index 0afe4bbcd..740c9a4b8 100644 --- a/tests/functional/test_errmsg.txt +++ b/tests/functional/test_errmsg.txt @@ -74,8 +74,8 @@ orgbad.asm:2: error: Memory ORG out of range [0 .. 65535]. Current value: -1 >>> process_file('defsbad.asm') defsbad.asm:2: error: too many arguments for DEFS >>> process_file('asmprepro.asm') -asmprepro.asm:8: warning: Recursive inclusion -asmprepro.asm:12: warning: Recursive inclusion +asmprepro.asm:8: warning: Recursive inclusion +asmprepro.asm:12: warning: Recursive inclusion >>> process_file('strict.bas') strict.bas:2: warning: Using default implicit type 'float' for 'b' strict.bas:4: error: strict mode: missing type declaration for 'a' @@ -170,4 +170,6 @@ due_par.bas:2: error: Syntax error. Unexpected end of line due_par.bas:5: error: Syntax error. Unexpected end of file >>> process_file('error_array.bas') error_array.bas:3: error: Invalid assignment. Variable z$() is an array +>>> process_file('prepro76.bi') +prepro76.bi:2: error: this is an intended error