How would you create a conditional %define in asm

I'm tring to create a conditional address statement in my start167.a66. The goal is to be able to use the same start up file with different uv2 targets. one target would be stand-alone and the other target needs to coexist with a bootloader ROM.
(The programming tools I have available can only program CS0 )

I tried to create a block using the if/else statement but found out the hard way that the last/latest %Define statement will over ride any previous ones.

; BUSCON2/ADDRSEL2
; --- Set BUSCON2 = 1 to initialize the BUSCON2/ADDRSEL2 registers
$SET (BUSCON2 = 1) ; Uv2/Dave

;$IF (I_USE_CS0 = 1)     ; pick you chip

%DEFINE(ADDRESS2) (80000H) ;  0x80000 clears the 1'st ROM by 2 times (8*64K)->2x256
%DEFINE(RANGE2) (256K)      ; (this setsup a mask for start address as well as size

$ELSE  ;][ App Programs are to run out of the second ROM and expect intr table @0
%DEFINE(ADDRESS2) (00000H) ; MUST BE SET TO 0! or no intrupts will work
%DEFINE(RANGE2) (256K)     ; only limited by
$ENDIF ; ] of changed chip config
the only other approach I can think of his two break these lines out into other files and then let the IF/else pick one of them. Does anyone have a cleaner approach?

Parents
  • I'm using similar.

    One UV2 target for embedded ROM compilation, and another one for Monitor debug using the same startup.a66.

    Don't apply conditonal compilation at the
    %define but at the init of the ADDSEL (the last %define always win !)(bug sent to KEIL few months ago)

    Here is my code :

    ; --- Set BUSCON1 = 1 to initialize the BUSCON1/ADDRSEL1 registers
    $SET (BUSCON1 = 1)
    
    ; Define the start address and the address range of Chip Select 1 (CS1#)
    ; This values are used to set the ADDRSEL1 register
    %DEFINE (ADDRESS1_NORMAL) (0100000H)    ; normal
    %DEFINE (ADDRESS1_MONITEUR) (0000000H)  ; moniteur
    %DEFINE (RANGE1) (1024K)
    
    ../..
    
    $IF (BUSCON1 = 1)
    BCON1	SET     (_MTTC1 << 5) OR (_RWDC1 << 4)
    BCON1	SET	BCON1 OR ((NOT _MCTC1) AND 0FH)
    BCON1	SET	BCON1 AND (NOT (_RDYEN1 << 3))
    BCON1	SET	BCON1 OR (_RDY_AS1 << 3)  OR (_BTYP1 << 6)
    BCON1	SET	BCON1 OR (_ALECTL1 << 9) OR (_BUSACT1 << 10)
    BCON1	SET	BCON1 OR (_RDYEN1 << 12) OR (_CSREN1 << 14)
    BCON1	SET     BCON1 OR (_CSWEN1 << 15)
    
    $IF NOT MONITOR
    %ADDR (ADDR1,%ADDRESS1_NORMAL,%RANGE1)
    $ELSE
    %ADDR (ADDR1,%ADDRESS1_MONITEUR,%RANGE1)
    $ENDIF
    		MOV	ADDRSEL1,#ADDR1
    		MOV	BUSCON1,#BCON1
    $ENDIF
    

    So create 2 targets
    - one with nothing
    - one with directive MONITOR in Options for target, folder A66, Conditionnal controls, Set

    Glad if this help you
    Bye

Reply
  • I'm using similar.

    One UV2 target for embedded ROM compilation, and another one for Monitor debug using the same startup.a66.

    Don't apply conditonal compilation at the
    %define but at the init of the ADDSEL (the last %define always win !)(bug sent to KEIL few months ago)

    Here is my code :

    ; --- Set BUSCON1 = 1 to initialize the BUSCON1/ADDRSEL1 registers
    $SET (BUSCON1 = 1)
    
    ; Define the start address and the address range of Chip Select 1 (CS1#)
    ; This values are used to set the ADDRSEL1 register
    %DEFINE (ADDRESS1_NORMAL) (0100000H)    ; normal
    %DEFINE (ADDRESS1_MONITEUR) (0000000H)  ; moniteur
    %DEFINE (RANGE1) (1024K)
    
    ../..
    
    $IF (BUSCON1 = 1)
    BCON1	SET     (_MTTC1 << 5) OR (_RWDC1 << 4)
    BCON1	SET	BCON1 OR ((NOT _MCTC1) AND 0FH)
    BCON1	SET	BCON1 AND (NOT (_RDYEN1 << 3))
    BCON1	SET	BCON1 OR (_RDY_AS1 << 3)  OR (_BTYP1 << 6)
    BCON1	SET	BCON1 OR (_ALECTL1 << 9) OR (_BUSACT1 << 10)
    BCON1	SET	BCON1 OR (_RDYEN1 << 12) OR (_CSREN1 << 14)
    BCON1	SET     BCON1 OR (_CSWEN1 << 15)
    
    $IF NOT MONITOR
    %ADDR (ADDR1,%ADDRESS1_NORMAL,%RANGE1)
    $ELSE
    %ADDR (ADDR1,%ADDRESS1_MONITEUR,%RANGE1)
    $ENDIF
    		MOV	ADDRSEL1,#ADDR1
    		MOV	BUSCON1,#BCON1
    $ENDIF
    

    So create 2 targets
    - one with nothing
    - one with directive MONITOR in Options for target, folder A66, Conditionnal controls, Set

    Glad if this help you
    Bye

Children
More questions in this forum