79688582

Date: 2025-07-03 09:15:10
Score: 0.5
Natty:
Report link

Solved. The problem was the incomplete naming of the the segments. With more imagination for the solution on my side, it would have been quicker and easier: So, I wrote the same function in an external C file and compiled with the SRC option, that makes assembler code from C - et voilĂ .

Here is the complete ASM file for a function that rotates an uint32, n (uint8) times, that can be called from RC51 with the C-declaration shown above:

$include (reg51.inc)

NAME    bitops

?PR?_rotr?bitops    SEGMENT     CODE 
?DT?_rotr?bitops    SEGMENT     DATA    OVERLAYABLE

PUBLIC ?_rotr?BYTE  
PUBLIC  _rotr

RSEG        ?DT?_rotr?bitops
    ?_rotr?BYTE:
    n:      DS 1


RSEG ?PR?_rotr?bitops
    USING 0

_rotr PROC

    PUSH    ACC

    mov R3, n

rotr_loop:

    CLR C

    MOV A,R4
    RRC A   
    MOV R4,A    

    MOV A,R5    
    RRC A
    MOV R5,A    

    MOV A,R6    
    RRC A
    MOV R6,A    

    MOV A,R7
    RRC A
    MOV R7,A    

    MOV A,R4
    MOV ACC.7,C
    MOV R4,A    

    djnz R3, rotr_loop


    POP ACC

    RET

ENDP

END


Thanks to all, who supported.

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Walt