shared variable slots

The feature of shared variables in C is a wonderful saver of DATA space. Can the same be implemented in assembler ?

Erik

Parents
  • Hi Erik!

    Well, I think, you just have to use your memoryspace carefully.

    What I do is being restrictive with reserving space for global or static variables. I store all the local stuff in registers and the first thing I do in a subroutine is to save all used registers on stack.

    This requires commenting the souce code, though, because the variables are just named R0..R7 and don't have names that describe their purpose.

    I also use temporary storage like a place to store the result of 32bit or floating point calculation, but that has to be used very carefully. That means, I cannot be sure that the content of that location in memory will survive a subroutine call.

    Sure, a linker will be able to generate a more compact memory usage from C code, but I have done some pretty big projects in just assembler before I had the C compiler and it all worked out well. Programming assembler requires lotsa discipline and commenting. I think, I am faster with C, but will still do a couple of things in assembler.

    Take care
    Sven.

Reply
  • Hi Erik!

    Well, I think, you just have to use your memoryspace carefully.

    What I do is being restrictive with reserving space for global or static variables. I store all the local stuff in registers and the first thing I do in a subroutine is to save all used registers on stack.

    This requires commenting the souce code, though, because the variables are just named R0..R7 and don't have names that describe their purpose.

    I also use temporary storage like a place to store the result of 32bit or floating point calculation, but that has to be used very carefully. That means, I cannot be sure that the content of that location in memory will survive a subroutine call.

    Sure, a linker will be able to generate a more compact memory usage from C code, but I have done some pretty big projects in just assembler before I had the C compiler and it all worked out well. Programming assembler requires lotsa discipline and commenting. I think, I am faster with C, but will still do a couple of things in assembler.

    Take care
    Sven.

Children
More questions in this forum