Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/06/12 20:05
Read: times


 
#185356 - yes
Responding to: ???'s previous message
its simple, will be fast, its easy to read - what more ?
(There is error on last line MOV MESS_1,A is true, MOV A,MESS_1 is wrong

When one is learning language it is very good to learn on real task,
in this case fast results are main aim( consciously or not).
But...
take a moment to learn something additional (its free :-).

One disadvantage in Your code is RAM usage - 8 bytes instead 16 bits.
Below is my proposal- probably it is with more lines(compared to Your code),
probably will be slower, but uses 2 bytes instead 8 bytes.
In Your code some program's segment will load 8 muxer bytes with 2 bits values.
Then other fragment will call Your code to form MESS_1,MESS_2 . My code uses only MEAS_1 ,MEAS_2. Any change in muxer settings is stored in ready to use MEAS_1,MEAS_2 bytes. Code can be extended to allow muxer settings reading.

I wrote , but not tested,
can be wrong, search for errors.


;Inputs: MUX_1, MUX_2, MUX_3, MUX_4, MUX_5, MUX_6, MUX_7, MUX_8
;Outputs: MESS_1, MESS_2

;;;MESS_1 DATA 0x10   ???? this is in bank2 ???
;;;MESS_2 DATA 0x11    ???? this is in bank2 ???
; MUX_1 through 8 will all each contain a value from RES_1 through RES_4
;;;;MUX_1 DATA 0x20;
;;;;.....
;;;;MUX_8 DATA 0x27
;8 bytes instead 16 bits ????


MUX_1byte DATA 100 ;or 0x20 , but manipulating as single bits is not needed ;in this  task (as i assume)
MUX_2byte DATA 101

RES_1 EQU 0x00
;...
RES_4 EQU 0x03



SETMUX1_8byR2R3:  ;R2 is mux numberr 1..8  ,r3 is value res_1..res_4 (0..3)
        
               mov a,r2
               jz SETMUX1_8byR2R3fail
               clr c
               subb a,#9
               jnc SETMUX1_8byR2R3fail
               ;here we are sure mux number is in allowed margins 1..8

              mov a,r3
              anl a,#3 ;2 bits for muxer , see RES_1,RES4
              mov r3,a

              mov a,r2 ;mux number 1..8
              dec a
              ;divide by 4 , ;four muxers in one byte 
              rr a 
              rr a 
              anl a,#1 

              add a,#MUX_1byte
              mov r0,a
              mov a,r2

              mov r4,#3 ;help byte

setmux1_8_r3prepare:
              dec a 
              anl a,#3 
              jz setmux1_8_r3ready
              xch a,r3
              rl a
              rl a
              xch a,r3             
              push a
              mov a,r4
              rl a
              rl a
              mov r4,a       
              pop a
              jmp setmux1_8_r3prepare   
setmux1_8_r3ready:
              mov a,r4
              xrl a,#0ffh
              anl a,@r0
              orl a,r3
              mov @r0,a
              mov a,#0ffh ; ok result
              ret

 SETMUX1_8byR2R3fail:
             clr a ;error result
             ret

 



List of 40 messages in thread
TopicAuthorDate
Assembly coding micro-converters            01/01/70 00:00      
   Code indented            01/01/70 00:00      
      Assemblers often have different syntax            01/01/70 00:00      
         Assembler            01/01/70 00:00      
            Why not use Keil A51 ?            01/01/70 00:00      
               why assembler?            01/01/70 00:00      
                  Libraries?!?!?            01/01/70 00:00      
                     Libraries good, but not always best            01/01/70 00:00      
                        Ok back to Data and Bit            01/01/70 00:00      
                           Manual            01/01/70 00:00      
                           ok back            01/01/70 00:00      
                              I C            01/01/70 00:00      
               Keil A51            01/01/70 00:00      
                  junk downloaders            01/01/70 00:00      
                  take a look at ASEM51            01/01/70 00:00      
                     asem-51 macros            01/01/70 00:00      
                        You don't have to use 'em            01/01/70 00:00      
                  re-think about tools            01/01/70 00:00      
                     ADuC842            01/01/70 00:00      
                        learn            01/01/70 00:00      
                           There are PLENTY of debuggers ...            01/01/70 00:00      
                              Documentation            01/01/70 00:00      
                                 interrupt vectors            01/01/70 00:00      
                                 Memo to Reinhard Keil            01/01/70 00:00      
                                 Keil docs are not bad.            01/01/70 00:00      
                                 Well ... Last time I had questions about ASEM51 ...            01/01/70 00:00      
                                    the good and the bad            01/01/70 00:00      
                                       Well, I must have mistyped            01/01/70 00:00      
                                          asem/asm            01/01/70 00:00      
                                          linker support?            01/01/70 00:00      
                                             it's provided by ASEM-51, I suppose            01/01/70 00:00      
   Ok back to the task at hand            01/01/70 00:00      
      make it easy for yourself            01/01/70 00:00      
         I’m afraid the hard ware is non negotiable            01/01/70 00:00      
            well, ....            01/01/70 00:00      
               Dinosours, I2Cs, Gang-bang???            01/01/70 00:00      
                  1st            01/01/70 00:00      
                     Simple approach            01/01/70 00:00      
                        yes            01/01/70 00:00      
                           For Free :-)            01/01/70 00:00      

Back to Subject List