PDA

View Full Version : Help with macro



DaveC3
- 30th January 2014, 16:37
I an trying to write a macro to replace several PBP statements.
I want to replace this:



gl_x1 = 30
gl_y1 = 45
gl_x2 = 60
gl_y2 = 45
gosub gl_line


with this:

@ glcdline(30,45,60,45)
using this macro:



ASM ; glcdLine '@ GLCD_line x1,y1,x2,y2
#glcdline macro x1,y1,x2,y2
MOVE?WW x1, _gl_x1
MOVE?WW y1, _gl_y1
MOVE?WW x2, _gl_x2
MOVE?WW y2, _gl_y2
L?CALL _gl_line
endm
#define glcdline(x1,y1,x2,y2) #glcdline x1, y1, x2, y2 ; allows paretheses in macro
ENDASM

all vars are words.

The PBP code works giving me a cross centered at x=45 y=45

the macro gives me horizontal and vertical line of full screen size crossing about x=10, y = 10

Thanks

Dave

Darrel Taylor
- 30th January 2014, 17:35
Dave,

You are providing Constants to the macro, but are trying to move WORDs in the macro.

Use MOVE?CW instead of MOVE?WW

Are you using PBP3?
Usercommands will allow it to use Constants, Bytes, Words, Longs ... whichever you pass to the command.

DaveC3
- 30th January 2014, 18:11
Thanks Darrel

That worked. In this case I am using PBP 2.6, I am helping with a project that is written in 2.6

Ideally I would like to pass variable like


glcdline(_xpos - 15, _ypos, _xpos + 15, _ypos)



Dave