It is currently Tue Nov 20, 2018 5:16 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: RGBDS "data" segment
PostPosted: Sun Oct 21, 2018 9:48 am 
Offline
User avatar

Joined: Fri Nov 24, 2017 2:40 pm
Posts: 86
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.


Top
 Profile  
 
 Post subject: Re: RGBDS "data" segment
PostPosted: Sun Oct 21, 2018 10:06 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20789
Location: NE Indiana, USA (NTSC)
Upvote issue #274.


Top
 Profile  
 
 Post subject: Re: RGBDS "data" segment
PostPosted: Sun Oct 21, 2018 4:58 pm 
Offline
User avatar

Joined: Fri Nov 24, 2017 2:40 pm
Posts: 86
Hmm. Ok. Good to know I'm not the only one.


Top
 Profile  
 
 Post subject: Re: RGBDS "data" segment
PostPosted: Sun Nov 18, 2018 2:17 pm 
Offline

Joined: Sat Aug 28, 2010 9:01 am
Posts: 221
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

_________________
Gameboy Genius (Blog) - Gameboy development forum (+wiki and file area)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group