We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I've tried a variety of methods for storing a bit address in ASM so I can subsequently SET/CLR that bit but have had no luck. Here's the pseudo-code for what I want to do: 1 - Initialize an 8-bit variable (Addr) in my ASM module with the bit address (say 0x97), then 2 - SETB Addr or CLR Addr If I hard-code an address, say for P1.7, it works fine: SETB 0x97 Also if I pass in an offset to a base address it works fine: MOV ACC,R5 SETB 0x90+ACC Any suggestions for how I can optimize my code so I just have to use #2 above?
"Keil assembler does not help you here; there is no indirect-via-address bit access commands" Just to clarify: the 8051 processor itself has no indirect-via-address bit access instruction; therefore no assembler can help you here!
Also if I pass in an offset to a base address it works fine: MOV ACC,R5 SETB 0x90+ACC Does this code work correctly, or does it just assemble correctly? The way I read my instruction set manual, there are only two SETB opcodes. One sets the carry flag. The other is a two-byte instruction that takes a bit address. There is no mode for this instruction that allows an accumulator offset to a base address. I suspect this code will in fact set bit 70H (90H + ACC == 90H + E0H == 170H, which wraps mod 256 to 70H) regardless of the value of R5 when it is executed. The simulator shows the results of assembling the code to be D2 70, which is SETB 2E.0 (in the bit-addressable memory), as expected. I could have hoped for an "out of range" warning on the arithmetic. If you really want to make that one instruction indirect, you'd have to write self-modifying code to modify the direct bit address in the second byte of the instruction. There's lots of reasons why this usually isn't a good idea. If you're passing the address of the bit to a function, then there's already enough overhead that the AND/OR method shouldn't add too much more.
hi, do you not read my above answer? (=
Oleg, I received it, thank you. I had in fact only checked to see if my idea would compile, had not actually checked to see if it really worked... : ( Best regards, Chip Burns