| ??? 04/07/02 20:36 Read: times |
#21527 - RE: quick question on ASM variables, Rob |
Philip T wrote:
------------------------------- if I do a var1 DS 4, how do I go about assigning values to those four bytes? The byte "var1" will be the first of four. The second, third and fourth can be accessed by using the construction "var1+1", "var1+2" and "var1+3", respectively. This applies to both reading and writing. Example: MOV var1,#0A5h MOV var1+1,#03Eh MOV var1+2,#0D9h MOV var1+3,#017h will leave your var1 as: A53ED917h Then, if you do: MOV A,var1+2 the ACC will hold the value D9h It is important to note that if you declare a multi-byte variable, you have to decide which of those bytes will be the MSB. This is especially important if you want to mix assembly with a HLL. Some C compilers are "big endian", meaning that the first byte is the MSB. Others are "little endian", meaning the last byte is the MSB. As a further explanation: there is nothing inherently wrong with using equates, like Hal explained, when you only use ASM. However, having your variables relocatable is crucial when mixing ASM and C. Therefore, it is best, I think, to always use the method I described; so you can never get confused. Regards (not to mention good night), Rob |
| Topic | Author | Date |
| quick question on ASM variables | 01/01/70 00:00 | |
| RE: quick question on ASM variables | 01/01/70 00:00 | |
| RE: quick question on ASM variables | 01/01/70 00:00 | |
| RE: quick question on ASM variables | 01/01/70 00:00 | |
| RE: quick question on ASM variables | 01/01/70 00:00 | |
| RE: ASM variables, moving thru it | 01/01/70 00:00 | |
| RE: ASM variables, moving thru it | 01/01/70 00:00 | |
| RE: quick question on ASM variables | 01/01/70 00:00 | |
| RE: quick question on ASM variables, Rob | 01/01/70 00:00 | |
| RE: quick question on ASM variables, Rob | 01/01/70 00:00 | |
| RE: quick question on ASM variables | 01/01/70 00:00 | |
| RE: data segment variables wont work? | 01/01/70 00:00 | |
| RE: quick question on ASM variables | 01/01/70 00:00 | |
| RE: data segment variables wont work? | 01/01/70 00:00 | |
| RE: Thanks!! | 01/01/70 00:00 | |
RE: Thanks!! | 01/01/70 00:00 |



