Jump to content
IGNORED

Constants place in assembler code?


Recommended Posts

Hi, this is a humble post to know where is the correct place to put in code our constants, i found this code (below) time ago...

 

and i think that constant data should go after ORG $F000

 

Please can somebody correct me if i'm not right?

 

cheers!! ty in advance.

 

 

 

processor 6502
include "vcs.h"
include "macro.h"
SPRITE_HEIGHT0 equ 37
Joy0Right equ 128
Joy0Left equ 64
Joy0Down equ 32
Joy0Up equ 16
SEG.U RAM
ORG $80
Player0X ds 1
Player0Y ds 1
Player0PTR ds 2
time_of_jump ds 1
SEG ROM
ORG $F000
Reset
CLEAN_START
lda #%00001000
sta REFP0
;SHALA LALALALALALA....... FOO FOO FOO.... TONS OF CODE FROM HERE.... YEH!
Edited by zilog_z80a
Link to comment
Share on other sites

Functionally, it doesn't really matter where they go, since the generated code will be the same. Ideally you'll place them prior to being referenced, to save the assembler a pass.

 

Aesthetically, I tend to gather them all at the top, just before or after the RAM definitions. It works better for me to have most symbol definitions in one place, so I know immediately where to go to change them. (the exception being labels, of coure.) If some symbols are very local in scope, I might consider placing their definition close to where they're used, though truthfully I can't recall having done so.

 

In a similar vein, just above any semi-complex routine that uses temp memory locations, I'll redefine a symbol for temp locations to give them more meaningful names. e.g. "deltax = temp3"

  • Like 3
Link to comment
Share on other sites

Functionally, it doesn't really matter where they go, since the generated code will be the same. Ideally you'll place them prior to being referenced, to save the assembler a pass.

 

Aesthetically, I tend to gather them all at the top, just before or after the RAM definitions. It works better for me to have most symbol definitions in one place, so I know immediately where to go to change them. (the exception being labels, of coure.) If some symbols are very local in scope, I might consider placing their definition close to where they're used, though truthfully I can't recall having done so.

 

In a similar vein, just above any semi-complex routine that uses temp memory locations, I'll redefine a symbol for temp locations to give them more meaningful names. e.g. "deltax = temp3"

 

tnx RevEng, this text now is a reference and a guide for me, and tnx for your time to write and explain.
cheers!!
  • Like 1
Link to comment
Share on other sites

A good idea is also to separate game specific constants (e.g. SPRITE_HEIGHT) which may change and general Atari 2600 constants (e.g. Joy0Right), which have a fixed value.

 

Also it is a best practice to use all UPPER_CASE for constants (BTW: GRP0, HMOVE etc. are all just general Atari 2600 constants too).

  • Like 3
Link to comment
Share on other sites

A good idea is also to separate game specific constants (e.g. SPRITE_HEIGHT) which may change and general Atari 2600 constants (e.g. Joy0Right), which have a fixed value.

 

Also it is a best practice to use all UPPER_CASE for constants (BTW: GRP0, HMOVE etc. are all just general Atari 2600 constants too).

 

ty Thomas, great, always wanted to know about constants spots and all related, will take note about this too.

 

if somebody else wants to add something about constants is really really welcome.

 

cheers!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...