| ??? 06/21/02 07:19 Read: times |
#24721 - RE: declaring arrays in assembly? |
You could write a few functions that would manipulate a bunch of bytes as an array. You can use the indirect addressing mode to access the elements of the array.
I would do it something like this.... ;use R0 to hold starting address of array(pointer) ;use R1 to hold offset of element from pointer (index) ;specify addresses for array1 and array2 and do not use the memory allocated for anything else. . . . mov a, value mov R0, array1 mov R1, #03h ;write 3rd element of array1 lcall write_array ;equivalent to array1[3] = value . . mov R0, array2 mov R1, #04h ;access 4th element of array2 call read_array ;element returned in acc ; equivalent to a = array2[4] . . . write_array: mov a,R0 add a,R1 mov R2,a mov @R2,a ret read_array: mov a,R0 add a,R1 mov R2,a mov a,@R2 ;return value in acc ret Of course, writing a function to do these operations only makes sense if they are repeated a number of times in the program. If they are repeated only a couple of times, you could spend some code memory and save some execution cycles by writing them inline. Similarly you can declare your own structure for float and long int and implement funcions to operate on them.This is the structure I used once: ;float=2 bytes ;byte1=integer part, byte2 = decimal part ;you can then have functions like: add_floats sub_floats etc. etc. kundi |
| Topic | Author | Date |
| declaring arrays in assembly? | 01/01/70 00:00 | |
| RE: declaring arrays in assembly? | 01/01/70 00:00 | |
| RE: declaring arrays in assembly? | 01/01/70 00:00 | |
| RE: declaring arrays in assembly? | 01/01/70 00:00 | |
RE: declaring arrays in assembly? | 01/01/70 00:00 |



