bugZ80 assembler - Bugs: bug #44033, macro with multiple arguments

 
 

bug #44033: macro with multiple arguments

Submitter:  None
Submitted:  Sat 17 Jan 2015 11:44:28 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Ready For Test
Privacy:  Public Assigned to:  asgalon
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 03 May 2017 03:34:12 AM UTC, comment #4: 

Version 1.8 under the Fedora 25 updates still has an issue
You must omit the comma separators in both the macro and the usage of the macro.

sherman owen <shermanowen>
Thu 05 May 2016 11:49:55 PM UTC, comment #3: 

will be fixed in next release.

Peter Kollner <asgalon>
Group Member
Sun 18 Jan 2015 12:08:22 AM UTC, comment #2: 

Unfortunatly debian didn't compile it with debugging info.

(gdb) b get_macro_args
Function "get_macro_args" not defined.


(gdb) run macro.asm
Starting program: /usr/bin/z80asm macro.asm
macro.asm:1: error: empty macro argument
^C
Program received signal SIGINT, Interrupt.
_int_malloc (av=0x7ffff7dd6620 <main_arena>, bytes=1) at malloc.c:3775
(gdb) bt
#0  _int_malloc (av=0x7ffff7dd6620 <main_arena>, bytes=1) at malloc.c:3775
#1  0x00007ffff7aaeeb0 in __GI___libc_malloc (bytes=1) at malloc.c:2891
#2  0x0000000000404caf in ?? ()
[snip]

Anonymous
Sat 17 Jan 2015 11:58:52 PM UTC, comment #1: 

very verbose log is this:

Verbosity increased to level 5
Verbosity increased to level 6
Verbosity increased to level 7
Verbosity increased to level 8
Verbosity increased to level 9
Verbosity increased to level 10
queued inputfile macro.asm
Assembling....
    1 (0x0000): Starting to read label (string=locate: macro xpos, ypos ).
rd_label returns invalid value
    1 (0x0000): Label found: locate
    1 (0x0000): Piece of code found:macro
    1 (0x0000): Remainder of line= xpos, ypos .
macro.asm:1: error: empty macro argument
    2 (0x0000): Piece of code found:push
    2 (0x0000): Remainder of line= hl .
added line to macro (cmd = 13):         push hl
    3 (0x0000): Piece of code found:ld
    3 (0x0000): Remainder of line= hl,(xpos+1)*256+ypos+1 .
added line to macro (cmd = 71):         ld hl,(s+1)*256+ypos+1
    4 (0x0000): Piece of code found:ld
    4 (0x0000): Remainder of line= (0f3dch),hl .
added line to macro (cmd = 71):         ld (0f3dch),hl
    5 (0x0000): Piece of code found:pop
    5 (0x0000): Remainder of line= hl .
added line to macro (cmd = 42):         pop hl
    6 (0x0000): Piece of code found:endm
    6 (0x0000): Remainder of line= .
added line to macro (cmd = 86): endm
    8 (0x0000): Piece of code found:org
    8 (0x0000): Remainder of line= 0c000h .
    8 (0x0000): Starting to read expression (string= 0c000h , delimiter= ).
    8 (0x0000): Starting to read or expression (string=0c000h ).
    8 (0x0000): Starting to read xor expression (string=0c000h ).
    8 (0x0000): Starting to read and expression (string=0c000h ).
    8 (0x0000): Starting to read equality epression (string=0c000h ).
    8 (0x0000): Starting to read unequality expression (string=0c000h ).
    8 (0x0000): Starting to read shift expression (string=0c000h ).
    8 (0x0000): Starting to read term (string=0c000h ).
    8 (0x0000): Starting to read factor (string=0c000h ).
    8 (0x0000): Starting to read value (string=0c000h ).
    8 (0x0000): Starting to read number of base 36(string=0c000h ).
    8 (0x0000): Digit found:0.
    8 (0x0000): Digit found:c.
    8 (0x0000): Digit found:0.
    8 (0x0000): Digit found:0.
    8 (0x0000): Digit found:0.
    8 (0x0000): Digit found:11.
    8 (0x0000): rd_number returned 20155409 (1338c11).
    8 (0x0000): Starting to read number of base 16(string=0c000h ).
    8 (0x0000): Digit found:0.
    8 (0x0000): Digit found:c.
    8 (0x0000): Digit found:0.
    8 (0x0000): Digit found:0.
    8 (0x0000): Digit found:0.
    8 (0x0000): rd_number returned 49152 (c000).
    8 (0x0000): rd_factor returned 49152 (c000).
    8 (0x0000): rd_term returned 49152 (c000).
    8 (0x0000): rd_shift returned 49152 (c000).
    8 (0x0000): rd_shift returned 49152 (c000).
    8 (0x0000): rd_equal returned 49152 (c000).
    8 (0x0000): rd_expr_and returned 49152 (c000).
    8 (0x0000): rd_expr_xor: rd_expr_and returned 49152 (c000).
    8 (0x0000): rd_expr_xor returned 49152 (c000).
    8 (0x0000): rd_expr_or: rd_expr_xor returned 49152 (c000).
    8 (0x0000): rd_expr_or returned 49152 (c000).
    8 (0x0000): rd_expr returned 49152 (c000).
[here it allocates memory until exhausted]

this line is also of interest since it's the error i get when i don't use comma's to seperate arguments:
added line to macro (cmd = 71):         ld hl,(s+1)*256+ypos+1
The 's' seems like unitialized memory, when i trie this for example:
%cat test.asm                                                   
testm: macro one two three
        db one, two, three
endm

% z80asm test.asm                                                
test.asm:6: error: unable to resolve reference:  three
test.asm:6: error: unable to resolve reference:  o, three
test.asm:6: error: unable to resolve reference: e, o, three
* 3 errors found *

wit comma's it hangs again like the original.

Anonymous
Sat 17 Jan 2015 11:44:28 PM UTC, original submission:  

I'm trying to use a macro with multiple arguments but can't get it to work. I'm using Z80 assembler version 1.8 on Debian Jessie for amd64 (the version from the repositories).
The example macro.asm with 1 argument works but when i try 2 or more I get this:

% z80asm macro.asm                                               
macro.asm:1: error: empty macro argument

and the program hangs until memory is exhausted. The source code for macro.asm is this:

locate: macro xpos, ypos
        push hl
        ld hl,(xpos+1)*256+ypos+1
        ld (0f3dch),hl
        pop hl
endm

org 0c000h
        locate 10, 10
        ret

I'm not sure if macro arguments should have comma's (they should according the documentation) but when i leave them out the error message goes away, detection of multiple arguments works but only 1 is recognized. This is the ouput when i don't use comma's to seperate arguments anywhere.

% z80asm macro.asm                                               
macro.asm:11: error: unable to resolve reference: (s+1)*256+10+1
* 1 error found *

Maybe the macro example could have more arguments as an example of how to use them with more macro's?
I've tried another example which i saw online but that also didn't work:
% cat m2.asm                                                     
callf: macro slot, address rst 030h db slot dw address endm

org 0c000h
        callf 08bh, 04000h

% z80asm m2.asm                                                  
m2.asm:1: error: empty macro argument
* 1 error found *

although this doesn't take up all memory but exits cleanly after the error.


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by shermanowen (Posted a comment)
  • -email is unavailable- added by asgalon (Updated the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-05-05 asgalon StatusIn Progress Ready For Test
    2016-05-05 asgalon StatusNone In Progress
        Assigned toNone asgalon

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code