ok, this might be a silly question. But, how do we declare a "variable" or something that has a name, and we can store values into it later on?

Recently at the beginning of the sample code, I've seen:

1. test 0x70
2. udata_shr
test res 1
3. test equ 0x20
4. ‪#‎define‬ RS PORTD, 2
5. cblock 0x70
lcd_tmp 
lcd_d1 
lcd_d2 
endc

So these are super confusing... can someone briefly describe what they mean? And which one is for declaring a variable (with or without initial value)?

Thx a lot!

Views: 43

Reply to This

Replies to This Discussion

 you can't really declare a variable, or at least if you can I'm not sure how but you can declare a register and you but it in the clock section. also you can make your own name for the I/0 ports which is what the # define is for. In your example about you're calling the 2nd I/O pin of PORTD "RS" aka you're making the two labels interchangeable.

the "equ" directive does pretty much the same thing as define except its a little more finicky. so ur basically saying "goto test" means goto address 0x70. finally I dunno about data_shr although I think Ryan posted about it below so maybe take a look at that?

of note is that all the things you listed are compiler commands, not assembly code. I'll try and explain all the ones I'm familiar with. udata_shr is meant for multiple file codes (I THINK), but the way it works is it reserves (res) n bytes of memory from the shared general purpose registers (at the bottom at every bank). That specific line section you listed there would have reserved 1 byte of memory for test at 0x70. had there been another line, given that you only reserved one byte of memory, it would have started at 0x71

cblock 0x70 works in a similar way - putting the 0x70 beside it means you start at the registers common to the bank. It will associate one byte of memory for lcd_tmp at 0x70, one by for lcd_d1 at 0x71, etc.. its use is for when you have a large block of registers that you want to keep for yourself, essentially.

RSS

© 2024   Created by PML.   Powered by

Badges  |  Report an Issue  |  Terms of Service