hi, in "standard" way it is possible to locate a variable next way:
; motors control register MOTORS_CONTROL DATA 0x20 ; motor 1 CTRL1_UP BIT CONTROL_BITS.0 CTRL1_DOWN BIT CONTROL_BITS.1 CTRL1_LEFT BIT CONTROL_BITS.2 CTRL1_RIGHT BIT CONTROL_BITS.3 ; motor 2 CTRL2_UP BIT CONTROL_BITS.4 CTRL2_DOWN BIT CONTROL_BITS.5 CTRL2_LEFT BIT CONTROL_BITS.6 CTRL2_RIGHT BIT CONTROL_BITS.7
SETB CTRL1_UP ; motor 1 goes up SETB CTRL2_LEFT ; motor 2 goes left
ORL MOTORS_CONTROL,#00010001b ; both motors go up
?BI?MOTORS_CTRL SEGMENT BIT RSEG ?BI?MOTORS_CTRL CTRL1_UP: DBIT 1 CTRL1_DOWN: DBIT 1 ; etc
Sounds like everything can be done on C level using bdata and sbit. See: http://www.keil.com/support/man/docs/c51/c51_le_bitaddrobj.htm Reinhard
hi, Thanks for the ideas! Indeed I know how it may be done with C51, the question was about the same task be done in assembler. This limitation is due a customer asks me for some add-on routines for SiLabs F120 demoboard which is equiped only with full Keil A51. Anyway, thanks again for clean answer. Oleg
"Indeed I know how it may be done with C51, the question was about the same task be done in assembler." Get C51 to show you - use the SRC Directive! C51:
bdata unsigned char fred; sbit fred0 = fred^0; sbit fred1 = fred^1; sbit fred2 = fred^2; sbit fred3 = fred^3; sbit fred4 = fred^4; sbit fred5 = fred^5; sbit fred6 = fred^6; sbit fred7 = fred^7;
?BA?MAIN SEGMENT DATA BITADDRESSABLE RSEG ?BA?MAIN fred: DS 1 fred0 EQU (fred+0).0 fred1 EQU (fred+0).1 fred2 EQU (fred+0).2 fred3 EQU (fred+0).3 fred4 EQU (fred+0).4 fred5 EQU (fred+0).5 fred6 EQU (fred+0).6 fred7 EQU (fred+0).7
?BA?MAIN SEGMENT DATA BITADDRESSABLE RSEG ?BA?MAIN fred: DS 1 fred0 BIT fred.0 etc
hi, after all, it seems I have found the solution:
?BA?MOTORS_CTRL SEGMENT DATA BITADDRESSABLE RSEG ?BA?MOTORS_CTRL MOTORS_CONTROL: DS 1 ; motors control register ; bits declarations CTRL1_UP BIT MOTORS_CONTROL.0 CTRL1_DOWN BIT MOTORS_CONTROL.1 CTRL1_LEFT BIT MOTORS_CONTROL.2 CTRL1_RIGHT BIT MOTORS_CONTROL.3 ; motor 2 CTRL2_UP BIT MOTORS_CONTROL.4 CTRL2_DOWN BIT MOTORS_CONTROL.5 CTRL2_LEFT BIT MOTORS_CONTROL.6 CTRL2_RIGHT BIT MOTORS_CONTROL.7
A.W. Neil, Yes, I have found this way some time ago myself, thanks! Regards, Oleg
"Is it valid to use BITADDRESSABLE keyword?" I'm sure the assembler would soon tell you if it wasn't...! ;-) But if it wasn't, where would that leave C51?!
It seems that much of what I do to handle things like this (NOT a problem, just observing) is things that were needed with older software, but is not with current Keil. I'll probably continue trodding along in my well worn and proven path, but for the freshmen the features comming out of the woodwork in this thread seems the way to go. Erik