nesdev.com
http://forums.nesdev.com/

RGBDS "data" segment
http://forums.nesdev.com/viewtopic.php?f=20&t=17953
Page 1 of 1

Author:  slembcke [ Sun Oct 21, 2018 9:48 am ]
Post subject:  RGBDS "data" segment

Is there any way to implement something like a "data" segment using RGBDS? Specificall, it would be really nice to define and declare data once and end up with a block in the ROM I can just memcpy into place. Not really a big deal, I'm just coming to a realization how handy that is in more sophisticated assemblers.

Author:  tepples [ Sun Oct 21, 2018 10:06 am ]
Post subject:  Re: RGBDS "data" segment

Upvote issue #274.

Author:  slembcke [ Sun Oct 21, 2018 4:58 pm ]
Post subject:  Re: RGBDS "data" segment

Hmm. Ok. Good to know I'm not the only one.

Author:  nitro2k01 [ Sun Nov 18, 2018 2:17 pm ]
Post subject:  Re: RGBDS "data" segment

I've solved this by having a bunch of macros that cover all relevant instructions.

Code:
;; Relocated code macros
JPR:   MACRO      ; Relocated jump absolute
   jp   \1+(RCODE-RCODE_S)
   ENDM

JPRC:   MACRO      ; Relocated jump absolute conditional
   jp   \1,\2+(RCODE-RCODE_S)
   ENDM

CALLR:   MACRO      ; Relocated call
   call   \1+(RCODE-RCODE_S)
   ENDM

CALLRC:   MACRO      ; Relocated call conditional
   call   \1,\2+(RCODE-RCODE_S)
   ENDM

LDHLR:   MACRO      ; Relocated ld   HL,addr
   ld   HL,\1+(RCODE-RCODE_S)
   ENDM

LDBCR:   MACRO      ; Relocated ld   BC,addr
   ld   BC,\1+(RCODE-RCODE_S)
   ENDM

LDDER:   MACRO      ; Relocated ld   DE,addr
   ld   DE,\1+(RCODE-RCODE_S)
   ENDM

LDAR:   MACRO      ; Relocated ld   A,[addr]
   ld   A,[\1+(RCODE-RCODE_S)]
   ENDM

DWR:   MACRO      ; Relocated dw   addr
   DW   \1+(RCODE-RCODE_S)
   ENDM


STAR:   MACRO      ; Relocated ld   [addr],A
   ld   [\1+(RCODE-RCODE_S)],A
   ENDM

PREPRELOCATE:   MACRO
        ld      HL,RCODE_S    ; Src
        ld      BC,(RCODE_S_END-RCODE_S)    ; Size
        ld      DE,RCODE        ; Dest
       
        call    COPYPROC


   ENDM

RCODE_AREA_START:   MACRO
RCODE_S::
   ENDM
   
RCODE_AREA_FINISH:   MACRO
RCODE_S_END::
   ENDM

RCODE_RAM_ALLOC:   MACRO
SECTION   "RAMCODE",BSS;;[\1-(RCODE_S_END-RCODE_S)]
RCODE::
   ds   RCODE_S_END-RCODE_S
RCODE_END::
   ENDM

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/