This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

bits location and order, how?

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
Then it is possible to access such variable both:
- by bit-access, for example:
	SETB	CTRL1_UP	; motor 1 goes up
	SETB	CTRL2_LEFT	; motor 2 goes left
- by byte-access:
	ORL	MOTORS_CONTROL,#00010001b ; both motors go up
It works good but requires absolute locations defined.

What is the way to have the same possibilities but with relative segments?
If we do:
?BI?MOTORS_CTRL	SEGMENT	BIT
		RSEG	?BI?MOTORS_CTRL
CTRL1_UP:	DBIT	1
CTRL1_DOWN:	DBIT	1
; etc
...then it does not guaranty that the bits will be located inside the one and same byte and it does not define their order as well.

For C it is possible to play with BDATA type. In assembler, BDATA segment type is not used. Indeed, "standard" way works good but absolute locations there and there look ugly.
Any idea?

Thanks,
Oleg

0