• Use of temporary in a do{}while(--i)

    From bill rowe@21:1/5 to All on Sat Mar 11 04:14:50 2017
    I'm working on a version of LCC42 targeted on the RCA 1802 processor.

    If I have the statement --i; in open code (and i is in a register) i emit a decrement for the register but if the --i is in a do/while test it copies the reg to a temp, decrements the temp, and copies it back. It also uses the temp for the loop test so
    my peephole optimizer doesn't cut out the double copy. I would ideally like to emit a single "decrement and jump if not 0" but i would settle for getting rid of the temp. Any suggestions?

    In the code below I hope the mnemonics are obvious. R7 is the variable i and R11 is a temp. The assembly macros are decorated with the LCC table entries that emit them except for the first cpy2 which I am tracking down. Any suggestions?

    ; i--;
    decm R7,1 ;SUBU2(reg,consm)
    L2:
    ; do{
    ; }
    L3:
    ; while(--i);
    cpy2 R11,R7
    decm R11,1 ;SUBU2(reg,consm)
    cpy2 R7,R11 ;LOADU2(reg)
    jnzU2 R11,L2; NE 0
    ;}

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)