OldGuru Posted October 4, 2001 Share Posted October 4, 2001 How do you guys use variables in your code? Do you define a variable and assign an address to it? or, do you use DS? I'd like to set up my variables to start at $300 and would like to use DS to allocate the memory for them... How can that be done in DASM? Thanks. Quote Link to comment Share on other sites More sharing options...
DanBoris Posted October 4, 2001 Share Posted October 4, 2001 This is the easiest way to do it is like this: org 0 VAR1 DS.B 1 VAR2 DS.B 1 lda VAR1 sta VAR2 DS.B 1 allocates 1 byte of memory at he current position. VAR1 will point to this memory. So in this example VAR1 will point to memory address $0000 and VAR2 will point to $0001. You can allocate word (2 bytes) the same way by using DS.W 1 You can set ORG to whatever location in memory you want your variables, just remeber to do another ORG before you code starts so it starts at the right address. You can also allocate block of space this way. If you need a table of 16 bytes you would do: TABLE DS.B 16 Dan Quote Link to comment Share on other sites More sharing options...
OldGuru Posted October 13, 2001 Author Share Posted October 13, 2001 Well, I tried it and the code compiles just fine. It seems that the .lst file is fine as well... However, the .bin file is 48K in size! That would not be loaded by VSS... Apparently, the .bin file seems to start at $300 (the place I want my variables) and therefore the whole code is shifted in the memory... The code looks like that: ORG $300 v_Variable1 DS.B 1 v_Variable2 DS.B 1 ... ORG $4000 l_StartCode: SEI ... I was wondering whether I miss a directive to the compiler that indicates that location $300 is DATA and $4000 is code... I know that there are special directives to do that for the 6809... Any idea? Thanks, OldGuru. Quote Link to comment Share on other sites More sharing options...
Eckhard Stolberg Posted October 13, 2001 Share Posted October 13, 2001 In DASM you need to set up your code like this to reach your goal: SEG.U variables ORG $300 v_variable1 DS.B 1 v_variable2 DS.B 1 ... SEG code ORG $4000 l_StartCode: SEI ... The SEG command defines a segment for your code or data. For the 6502 this is usually unnessessary, since this processor doesn't use segments like the 8086 for example. But by defining a segment as undeclared (SEG.U) you can define variable or code space that doesn't get included into the binary, which is usefull for defining variables in the internal RAM. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.