This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Setting a segment at specific address

Hello

I am trying to define a segment of 259 bytes at a specific address in my XRAM. I am using assembly and I am doing the following:

PROG    SEGMENT CODE
STACK   SEGMENT IDATA
DOWNLOAD_BUFFER SEGMENT XDATA

        RSEG    DOWNLOAD_BUFFER
        DS      259
        XSEG    AT 0100h

        RSEG  STACK
        DS    10H  ; 16 Bytes Stack

        CSEG  AT   0
        USING   0  ; Register-Bank 0
; Execution starts at address 0 on power-up.
        JMP   START

        RSEG  PROG
; first set Stack Pointer
START:
        CLR             P2.5
        CLR             P2.6
        ;Config I2C
        ;Set I2C interface
        CLR             SPE
        MOV             I2CADD, #44h
        MOV             I2CCON, #80hinterrupt.
        MOV             DPCON, #04h
        MOV             CFG841, #01h
        CALL    INIT_RAM
?ProcessI2C:
        CALL    GET_NEW_I2C_DATA
        JMP             ?ProcessI2C

The segment "DOWNLAOD BUFFER" is properly created and the length of it 259 bytes like I want to. However, I cannot set it at address 100h like I'd like to.

When I look at the map file, I see the following:


            TYPE    BASE      LENGTH    RELOCATION   SEGMENT NAME
            -----------------------------------------------------

            * * * * * * *   D A T A   M E M O R Y   * * * * * * *
            REG     0000H     0008H     ABSOLUTE     "REG BANK 0"
            IDATA   0008H     0010H     UNIT         STACK

            * * * * * * *  X D A T A   M E M O R Y  * * * * * * *
            XDATA   0000H     0103H     UNIT         DOWNLOAD_BUFFER

            * * * * * * *   C O D E   M E M O R Y   * * * * * * *
            CODE    0000H     0003H     ABSOLUTE
            CODE    0003H     0135H     UNIT         PROG



SYMBOL TABLE OF MODULE:  I2C Slave Polling ASM only (MAIN)

  VALUE           TYPE          NAME
  ----------------------------------

  -------         MODULE        MAIN
  C:0003H         SEGMENT       PROG
  I:0008H         SEGMENT       STACK
  X:0000H         SEGMENT       DOWNLOAD_BUFFER

DOWNLOAD_BUFFER is set at address 0000h and not at 100h like I would expect it. Why? Could someone tell me what I am doing wrong or what I should do?

Thanks a lot
Laurent

Parents
  • DOWNLOAD_BUFFER is set at address 0000h and not at 100h like I would expect it. Why?

    I would guess it's because the segment "DOWNLOAD_BUFFER" is a generic segment with 259 bytes, which the linker can place anywhere it sees fit.

    After that, the XSEG directive switches to an absolute segment, which has nothing to do with "DOWNLOAD_BUFFER".

    You can either tell the linker to place the segment "DOWNLOAD_BUFFER" at X:0x0100, or re-check how you define and switch segments in your assembly file.

Reply
  • DOWNLOAD_BUFFER is set at address 0000h and not at 100h like I would expect it. Why?

    I would guess it's because the segment "DOWNLOAD_BUFFER" is a generic segment with 259 bytes, which the linker can place anywhere it sees fit.

    After that, the XSEG directive switches to an absolute segment, which has nothing to do with "DOWNLOAD_BUFFER".

    You can either tell the linker to place the segment "DOWNLOAD_BUFFER" at X:0x0100, or re-check how you define and switch segments in your assembly file.

Children