Shop OBEX P1 Docs P2 Docs Learn Events
Defining variables — Parallax Forums

Defining variables

MikeSMikeS Posts: 131
edited 2005-04-01 23:56 in General Discussion
I am working my way through Exploring the SX Microcontroller with Assembly and BASIC Programming manual. In Unit 4:Variables and Math (pg45) there is a section on defining variables by reserving space for·them using the ds directive.

············ org······· 8
Myvar···· ds·········1

The text reads:
"The confusing part about this is that the org directive can refer to the data space or the program space, depending on the contnet of the context. In this case, the 8 refers to data memory"

My question is this. Is the 8 a memory location (address #8) in data memory? Is there anything special about the number 8? I see alot of examples· in the manual with org 8.

thanks,

Mike S

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-04-01 21:01
    Yes there is something special about location 8, it is the start of the unused global variables for the SX28. locations $00 - $07 are special registers as defined in Table 2.1 on page 24 of http://www.parallax.com/dl/docs/prod/sx/SxUsersManualV31.pdf·locations $08 -$0F are globally accessable user variables (regardless what your current bank is, you can access them). In the SX48/52, the global variables are $0A-$0F.

    To keep myself straight when writing code I'll write "org $08" for data, and "org $008" for program origin. The result is the same, but if makes it easier for you to see 2 digits = data, 3 digits = program. I picked this up from Gunther's book and it serves as a handy mental notation.

    Post Edited (Paul Baker) : 4/1/2005 9:10:30 PM GMT
  • MikeSMikeS Posts: 131
    edited 2005-04-01 23:56
    Paul,

    I appreciate the reply and the link. It answered other questions that I had.

    Haven't programmed with assembly since 1985 with the Moto 6800, but its slowly comming back.



    Thanks

    Mike S.
Sign In or Register to comment.