Jump to content
Sign in to follow this  
jbs30000

Macro problem cheat or work-around

Recommended Posts

First, this is post is kind of long probably complicated.

I was playing around with macros, and decided to see what could be done with if-then statements. This macro seems to produce perfectly valid asm code, but gives a fatal assembly error. I'm just curious as to what the error is, seeing as how the asm looks fine, and if there's another way to write this code to avoid the error. If not then no biggie.

bB Code

dim Mario=a
const T1=3
const V1=1

macro Value_If
temp1={1}&{3}
if temp1={3} then goto {4}
end

callmacro Value_If Mario T1 V1 JLoop

JLoop

Here's the asm code, which seems fine:

     0  f48f					      Value_If	Mario, #T1, #V1, JLoop,
     1  f48f
     2  f48f				   .L05
     3  f48f
     4  f48f		       a5 d6		      LDA	Mario
     5  f491		       29 01		      AND	#V1
     6  f493		       85 9c		      STA	temp1
     7  f495				   .L06
     8  f495
     9  f495		       a5 9c		      LDA	temp1
    10  f497		       c9 01		      CMP	#V1
    11  f499		       d0 03		      BNE	.skipL06
    12  f49b				   .condpart0
    13  f49b		       4c 00 00 	      jmp	.JLoop
    14  f49e
    15  f49e				   .skipL06
  1568  f49e				   .
  1569  f49e							;
  1570  f49e
  1571  f49e				   .JLoop

But I get this error:

DASM V2.20.07, Macro Assembler (C)1988-2003
  bytes of ROM space left
  2814 bytes of ROM space left
  2814 bytes of ROM space left
--- Unresolved Symbol List
pfcenter                 0000 ????         (R )
22.JLoop                 0000 ????         (R )
kernelmacrodef           0000 ????         (R )
pfhalfwidth              0000 ????         (R )

Fatal assembly error: Source is not resolvable.
Errors were encountered during assembly.

I've even tried using asm within the macro, but still get the same error.

macro Value_If
asm
lda {1}
and {3}
cmp {3}
beq {4}
end
end

Share this post


Link to post
Share on other sites

Where is the label 22.JLoop defined in the final assembly language listing? Are you using the macro more than once?

Share this post


Link to post
Share on other sites

That double post is kind of funny. Anyway, I don't know why it says 22.JLoop. The 9 lines of code I posted is all there is.

Share this post


Link to post
Share on other sites

The problem is definitely with JLoop. The hex for the opcode has zero for address bytes.

 

The 22.JLoop is happening because bB actually uses a . in front of the basic label names when it generates the assembly. But when dasm see's the .JLoop in a macro, it thinks the label needs to be renamed to be unique.

 

It you restructure your code to use inline assembly and to use "jmp JLoop" instead of "jmp .JLoop", and define the JLoop label within an inline assembly block, I think it will work.

Edited by RevEng

Share this post


Link to post
Share on other sites

If you look though, JLoop is named .JLoop in the asm output. But you're right that the machine code seems to be saying jump to address 0, which isn't right.

 

Anyway, what I was trying for was to be able to jump to any label, not just labels inside of the macro. But that's OK, after trying a few different tricks it looks like it's not possible. It's not that big of a deal, there are other ways to accomplish what I want. Thank you for the help. I appreciate it.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...