Searching \ for 'Current assembler adress' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/power.htm?key=current
Search entire site for: 'Current assembler adress'.

Truncated match.
PICList Thread
'Current assembler adress'
1998\01\26@174128 by Morgan Olsson

picon face
How to get it?

I want to make macros thet themselves decide if it is necessary so set page
bits and PCLATH when calling and jumping.

So, in assemly time the macro have to know the adress of where it is compiled.
Another assembler i«ve used used a * to represent current adress.
It could be used like this:

current_ROMadress=*

Where current_ROMadress is a macro variable which will be processed and
compared with the adress we want to call, and only if needed the PCLATH
setting code need to be compiled. (saves space and execution time, without
I have to mind about it)

(I«m using MPLAB 3.30)

Thanks in advance
/Morgan

Morgan Olsson, MORGANS REGLERTEKNIK, Sweden, ph: +46 (0)414 70741; fax 70331
============================================================================

1998\01\26@181658 by Andrew Warren

face
flavicon
face
Morgan Olsson <spam_OUTPICLISTTakeThisOuTspamMITVMA.MIT.EDU> wrote:

> I want to make macros thet themselves decide if it is necessary so
> set page bits and PCLATH when calling and jumping.
>
> So, in assemly time the macro have to know the adress of where it is
> compiled. Another assembler i've used used a * to represent current
> adress.

Morgan:

MPASM uses the "$" character.  Be careful, when you write your
macros, to avoid forward-reference problems.

-Andy

=== Andrew Warren - .....fastfwdKILLspamspam@spam@ix.netcom.com
=== Fast Forward Engineering - Vista, California
=== http://www.geocities.com/SiliconValley/2499

1998\01\26@184151 by Morgan Olsson

picon face
Thanks, this make me happy again!
Anyone know here we can find other undocumented (?) features?

At 15:14 1998-01-26 -0800, you wrote:
{Quote hidden}

Morgan Olsson, MORGANS REGLERTEKNIK, Sweden, ph: +46 (0)414 70741; fax 70331
-

1998\01\27@091927 by ruben

flavicon
face
Hello Morgan.

I use these macros for automaticaly setting and resetting PA0 and PA1
to the right values for a 16C57.

#define lcd_bank 3
org 0 ;bank0
...
xcall lcd_bank,sendchar ;A call to bank 3 from bank 0.

would expand to:

#define lcd_bank 3
org 0  ;bank0
...
bsf f_pa0
bsf f_pa1
call sendchar ;A call to bank 3 from bank 0.
bcf f_pa1
bcf f_pa0

The xgoto only sets the bankselsect bits before the goto instruction.

I use the bset and breset macros to set the bankswitches for
several calls.

#define lcd_bank 3
org 0
...
bset lcd_bank  ;set bank to lcd_bank
call lcd_init
call lcd_send_start_msg
breset lcd_bank ;switch back from lcd_bank to current bank.

would expand to

#define lcd_bank 3
org 0
...
bsf f_pa0 ;set bank to lcd_bank
bsf f_pa1
call lcd_init
call lcd_send_start_msg
bcf f_pa1 ;switch back from lcd_bank to current bank.
bcf f_pa0

The point is that only the bits that needs to be modified are
modified. If a xcall is used to a location within the same bank
no bankselect bits are thus modified. As you can see the '$' is used
to find out the current adress. I have to supply the bank argument to
the macro because if the preprocessor use a forward reference it
doesn't know how many instructions the macro will expand to which
will give me an error of something like 'label doesn't have the same
adress in pass 1 and pass 2.'. In labels after the macro invocation
and before the next ORG statement.

;---- Long call macro
---------------------------------------------------------

xcall       macro   bank,label
           local   this_bank
           this_bank   set ($>>9) & 0x03

           if ((this_bank & 0x01) != (bank & 0x01))
               if (bank & 0x01)
                   bsf     f_pa0
               else
                   bcf     f_pa0
               endif
           endif
           if ((this_bank & 0x02) != (bank & 0x02))
               if (bank & 0x02)
                   bsf     f_pa1
               else
                   bcf     f_pa1
               endif
           endif
           call    label
           if ((this_bank & 0x02) != (bank & 0x02))
               if (bank & 0x02)
                   bcf     f_pa1
               else
                   bsf     f_pa1
               endif
           endif
           if ((this_bank & 0x01) != (bank & 0x01))
               if (bank & 0x01)
                   bcf     f_pa0
               else
                   bsf     f_pa0
               endif
           endif
           endm


;---- Long goto macro ----------------------------------------------------------

xgoto       macro   bank,label
           local   this_bank
           this_bank   set ($>>9) & 0x03
           if ((this_bank & 0x01) != (bank & 0x01))
               if (bank & 0x01)
                   bsf     f_pa0
               else
                   bcf     f_pa0
               endif
           endif
           if ((this_bank & 0x02) != (bank & 0x02))
               if (bank & 0x02)
                   bsf     f_pa1
               else
                   bcf     f_pa1
               endif
           endif
           goto    label
           endm

;---- bank set macro -----------------------------------------------------------

bset        macro   bank
           local   this_bank
           this_bank   set ($>>9) & 0x03
           if ((this_bank & 0x01) != (bank & 0x01))
               if (bank & 0x01)
                   bsf     f_pa0
               else
                   bcf     f_pa0
               endif
           endif
           if ((this_bank & 0x02) != (bank & 0x02))
               if (bank & 0x02)
                   bsf     f_pa1
               else
                   bcf     f_pa1
               endif
           endif
           endm

;---- bank reset macro --------------------------------------------------------

breset      macro   bank
           local   this_bank
           this_bank   set ($>>9) & 0x03
           if ((this_bank & 0x02) != (bank & 0x02))
               if (bank & 0x02)
                   bcf     f_pa1
               else
                   bsf     f_pa1
               endif
           endif
           if ((this_bank & 0x01) != (bank & 0x01))
               if (bank & 0x01)
                   bcf     f_pa0
               else
                   bsf     f_pa0
               endif
           endif
           endm

;------------------------------------------------------------------------------

{Quote hidden}

-----------------------------------
Ruben Jšnsson
AB Liros Elektronik, Sweden
EraseMEmaxrubenspam_OUTspamTakeThisOuTmail.bip.net
-----------------------------------

1998\01\28@014242 by ruben

flavicon
face
From:          Self <Single-user mode>
To:            PICLISTspamspam_OUTMITVMA.MIT.EDU
Subject:       Re: Current assembler adress
Reply-to:      @spam@rubenKILLspamspammail.bip.net
Date:          Tue, 27 Jan 1998 13:07:02


Hello Morgan.

I use these macros for automaticaly setting and resetting PA0 and PA1
to the right values for a 16C57.

#define lcd_bank 3
org 0 ;bank0
...
xcall lcd_bank,sendchar ;A call to bank 3 from bank 0.

would expand to:

#define lcd_bank 3
org 0  ;bank0
...
bsf f_pa0
bsf f_pa1
call sendchar ;A call to bank 3 from bank 0.
bcf f_pa1
bcf f_pa0

The xgoto only sets the bankselsect bits before the goto instruction.

I use the bset and breset macros to set the bankswitches for
several calls.

#define lcd_bank 3
org 0
...
bset lcd_bank  ;set bank to lcd_bank
call lcd_init
call lcd_send_start_msg
breset lcd_bank ;switch back from lcd_bank to current bank.

would expand to

#define lcd_bank 3
org 0
...
bsf f_pa0 ;set bank to lcd_bank
bsf f_pa1
call lcd_init
call lcd_send_start_msg
bcf f_pa1 ;switch back from lcd_bank to current bank.
bcf f_pa0

The point is that only the bits that needs to be modified are
modified. If a xcall is used to a location within the same bank
no bankselect bits are thus modified. As you can see the '$' is used
to find out the current adress. I have to supply the bank argument to
the macro because if the preprocessor use a forward reference it
doesn't know how many instructions the macro will expand to which
will give me an error of something like 'label doesn't have the same
adress in pass 1 and pass 2.'. In labels after the macro invocation
and before the next ORG statement.

;---- Long call macro
---------------------------------------------------------

xcall       macro   bank,label
           local   this_bank
           this_bank   set ($>>9) & 0x03

           if ((this_bank & 0x01) != (bank & 0x01))
               if (bank & 0x01)
                   bsf     f_pa0
               else
                   bcf     f_pa0
               endif
           endif
           if ((this_bank & 0x02) != (bank & 0x02))
               if (bank & 0x02)
                   bsf     f_pa1
               else
                   bcf     f_pa1
               endif
           endif
           call    label
           if ((this_bank & 0x02) != (bank & 0x02))
               if (bank & 0x02)
                   bcf     f_pa1
               else
                   bsf     f_pa1
               endif
           endif
           if ((this_bank & 0x01) != (bank & 0x01))
               if (bank & 0x01)
                   bcf     f_pa0
               else
                   bsf     f_pa0
               endif
           endif
           endm


;---- Long goto macro ----------------------------------------------------------

xgoto       macro   bank,label
           local   this_bank
           this_bank   set ($>>9) & 0x03
           if ((this_bank & 0x01) != (bank & 0x01))
               if (bank & 0x01)
                   bsf     f_pa0
               else
                   bcf     f_pa0
               endif
           endif
           if ((this_bank & 0x02) != (bank & 0x02))
               if (bank & 0x02)
                   bsf     f_pa1
               else
                   bcf     f_pa1
               endif
           endif
           goto    label
           endm

;---- bank set macro -----------------------------------------------------------

bset        macro   bank
           local   this_bank
           this_bank   set ($>>9) & 0x03
           if ((this_bank & 0x01) != (bank & 0x01))
               if (bank & 0x01)
                   bsf     f_pa0
               else
                   bcf     f_pa0
               endif
           endif
           if ((this_bank & 0x02) != (bank & 0x02))
               if (bank & 0x02)
                   bsf     f_pa1
               else
                   bcf     f_pa1
               endif
           endif
           endm

;---- bank reset macro --------------------------------------------------------

breset      macro   bank
           local   this_bank
           this_bank   set ($>>9) & 0x03
           if ((this_bank & 0x02) != (bank & 0x02))
               if (bank & 0x02)
                   bcf     f_pa1
               else
                   bsf     f_pa1
               endif
           endif
           if ((this_bank & 0x01) != (bank & 0x01))
               if (bank & 0x01)
                   bcf     f_pa0
               else
                   bsf     f_pa0
               endif
           endif
           endm

;------------------------------------------------------------------------------

{Quote hidden}

-----------------------------------
Ruben Jšnsson
AB Liros Elektronik, Sweden
KILLspammaxrubenKILLspamspammail.bip.net
-----------------------------------

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...