Jump to content
IGNORED

help with mads macro


 Share

Recommended Posts

Hi *,

 

I could need some help with a MADS macro.

 

Similar to macros like "mva" and "mwa" I would like to have a macro for "double words" (32bit). For instance

 $org 2000

.macro mdwa src,dst
 lda <:src
 sta :dst
 lda >:src
 sta :dst+1
 lda <(:src/65355)
 sta :dst+2
 lda >(:src/65535)
 sta :dst+3
.endm

.struct values
 longvalue .dword
.ends

m values

 mdwa #$12345678,m.longvalue

Unfortunately my attempt does not "compile" . MADS tells me something like "Extra character on line".

It's probably pretty obvious but I'm giving up for now :)

 

 

Link to comment
Share on other sites

MADS doesn't seem to like comma delimited macro arguments in some instances, but even changing that didn't help here. If it's useful, this is an adaptation of the "mda" macro I use:

	org 2000

mdwa 	.macro " "
	.if .not [:0 = 4]
		.error 'Wrong Number of Arguments!'
	.else
		.if :1 = '#' ; immediate mode
			lda #[:2 & $FF]
			sta :4
			lda #[[:2 >> 8 ] & $FF]
			sta :4+1
			sbc #[[:2 >> 16] & $FF]
			sta :4+2
			lda #[:2 >> 24]
			sta :4+3
		.else
			ldy #3
?1
			lda :2,y
			sta :4,y
			dey
			bpl ?1
		.endif
	.endif
	.endm

.struct values
 longvalue .dword
.ends

m values
n values

 mdwa #$12345678 m.longvalue
 mdwa n.longvalue m.longvalue
It's versatile, since it uses a defined delimiter to allow detection of an immediate mode first argument (see example calls). Use of the index registers is just a personal preference in order to reduce bloat. Edited by flashjazzcat
  • Like 2
Link to comment
Share on other sites

  • 1 year later...

Hi *,

 

I could need some help with a MADS macro.

 

Similar to macros like "mva" and "mwa" I would like to have a macro for "double words" (32bit). For instance

 $org 2000

.macro mdwa src,dst
 lda <:src
 sta :dst
 lda >:src
 sta :dst+1
 lda <(:src/65355)
 sta :dst+2
 lda >(:src/65535)
 sta :dst+3
.endm

.struct values
 longvalue .dword
.ends

m values

 mdwa #$12345678,m.longvalue

Unfortunately my attempt does not "compile" . MADS tells me something like "Extra character on line".

It's probably pretty obvious but I'm giving up for now :)

 

 

I figured out the cause of the "Extra character on line" error and thought I would post it here for future reference. I was getting the same error, even when I used the example macros from the MADS documentation. The problem was that I was using an older version of MADS, before support was added for argument labels. Older versions only supported numeric arguments.

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...