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

How to use LJMP with variable address?

I have a 16-bit address in the A register. I need to make a long jump
to this address, however it seems there is no way to do this with
assembly code. By looking at some assembly produced by Keil, when
they want to do this type of jump then end up doing:

LJMP    ?C?ICALL
Which registers do I load up with my address so that the jump to ?C?ICALL succeeds?

Parents
  • Hey Dan, I ended up doing it this way:

            UART_0_INT      EQU     23h 
    
    ; . . .
    
            CSEG    AT      UART_0_INT
            LJMP            UART_0_ISR
    
    ; . . .
    
    UART_0_ISR:
    ;       if (!missionCodeIsRunning()) {
    ;               bootloader_uart0_isr();
    ;       else
    ;               mission_uart0_isr();
    ;       }
            LCALL   _?missionCodeIsRunning
            MOV     A,R7
            JZ      bootloader_uart0
            JMP     mission_uart0
    
            bootloader_uart0:
            LJMP    uart0_isr
    
            mission_uart0:
            LCALL   _?goAddr
            MOV     DPH,R6
            MOV     DPL,R7
            CLR     A
            ADD     A, #UART_0_INT
            JMP     @A+DPTR
    I had to ensure that my bootloader code specified NOINTVECTOR as you suggested in an earlier post. Thanks for your help. I still have one more problem, which I posted in another thread.

    -Ted

Reply
  • Hey Dan, I ended up doing it this way:

            UART_0_INT      EQU     23h 
    
    ; . . .
    
            CSEG    AT      UART_0_INT
            LJMP            UART_0_ISR
    
    ; . . .
    
    UART_0_ISR:
    ;       if (!missionCodeIsRunning()) {
    ;               bootloader_uart0_isr();
    ;       else
    ;               mission_uart0_isr();
    ;       }
            LCALL   _?missionCodeIsRunning
            MOV     A,R7
            JZ      bootloader_uart0
            JMP     mission_uart0
    
            bootloader_uart0:
            LJMP    uart0_isr
    
            mission_uart0:
            LCALL   _?goAddr
            MOV     DPH,R6
            MOV     DPL,R7
            CLR     A
            ADD     A, #UART_0_INT
            JMP     @A+DPTR
    I had to ensure that my bootloader code specified NOINTVECTOR as you suggested in an earlier post. Thanks for your help. I still have one more problem, which I posted in another thread.

    -Ted

Children