![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
hold macro ;delay macro for I2C
nop nop nop endm disp_str macro string ;Macro for sending string to LCD irpc char, <string> if nul 'char' exitm endif mov a,#'char' lcall data_in endm endm interfacing ds1307 with 8051 cant understand this macro i got from net...can anyone help?? |
|
|
|
|
|
|
(permalink) |
|
what is your compiler?
|
|
|
|
|
|
|
(permalink) | |
|
Quote:
IMHO this is a really silly and stupid way to do things for strings which are longer than 3 or 4 characters. Example: disp_string "Hello World" would expand as: Code:
mov a,#'H'
lcall disp_in
mov a,#'e'
lcall disp_in
mov a,#'l'
lcall disp_in
mov a,#'l'
lcall disp_in
mov a,#'o'
lcall disp_in
mov a,#' '
lcall disp_in
mov a,#'W'
lcall disp_in
mov a,#'o'
lcall disp_in
mov a,#'r'
lcall disp_in
mov a,#'l'
lcall disp_in
mov a,#'d'
lcall disp_in
Last edited by Papabravo; 23rd June 2007 at 03:01 AM. |
||
|
|
|
|
|
(permalink) |
|
PB,
How does that macro loop? Does it automatically produce the code for each character in the string? Mike. |
|
|
|
|
|
|
(permalink) |
|
The irpc is a macro within a macro. It stands for "indefinite repeat character". It is common to many assemblers going back to at least the 1960's. Here is a snippet from the top google hit
http://www.physic.ut.ee/rprojekt/PicBasic/PM.TXT 5.2. IRPC IRPC Param , String Body ENDM The body of the macro is repeated once for each character in the specified string. The specified parameter is substituted on each expansion with the scanned character. The IRPC macro is executed immediately. That is also why there are two "endm" statements. The inner one is for the irpc and the outer one is for the disp_str macro Last edited by Papabravo; 23rd June 2007 at 07:09 PM. |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Timer0 Prescale | lord loh. | Micro Controllers | 10 | 8th October 2008 05:13 PM |
| Macro in MPLAB_IDE | KANADE D.G. | Micro Controllers | 2 | 6th September 2006 04:01 AM |
| size of arguments in macro | subot.robot | Micro Controllers | 3 | 11th May 2006 06:01 AM |
| Difference between Macro and Subroutine? | NewGeek | Micro Controllers | 4 | 31st August 2004 07:13 PM |
| pic assembly - macro or subroutine??? | spyghost | Micro Controllers | 3 | 18th May 2004 04:28 AM |