To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.pbforthOpen lugnet.robotics.rcx.pbforth in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / pbFORTH / 361
360  |  362
Subject: 
RE: Finally able to add asm forth words (long)
Newsgroups: 
lugnet.robotics.rcx.pbforth
Date: 
Mon, 22 May 2000 14:39:32 GMT
Viewed: 
1612 times
  
Steve Morris wrote:

By the way my primary tool for creating the assembler is write the
first pass in C and use gcc -S. My primary source of inspiration is
lnp-logical.c although I have to take care to extract rx from tx. For
example I follow lnp-logical.c's lead on figuring out about where the
interrupt vectors are redirected by the ROM.

Steve,

You ARE using Kekoa's Internals document, right? Here's the part
that describes the interrupt vector redirection. In fact, that's
what I do for grabbing the OC1B interrupt for the servo control words...
remember intercepting the keyboard interrupt for TSRs under DOS?

Here is some information that might be useful...study it carefully
grasshopper :-) I think I can get away with this since you are about
the same age I am and remember the series "Kung Fu", right?

Here is the prototype interrupt service routine...

;------------------------------------------------------------------------------
; OCIBisr is a routine that will handle expiries on the OC1B comparator. Its
; job is to set the motor currently being processed to the correct state.

OCIBisr:
       MOV.W  rA,@-rDSP         ; Save any registers we'll use

       BCLR   #2,@H8_TIER:8     ; Disallow OCRB interrupts
       BCLR   #2,@H8_TCSR:8     ; Clear pending OCRB interrupts

       MOV.W  @SERVOidx,rA      ; Figure out which motor we're on
       XOR.B  rAh,rAh
       ADD.W  rA,rA             ; Set up pointer to servo data
       MOV.W  @(SERVO_IDX,rA),rA

OCIB1: MOV.B  @(9,rA),rAh       ; Grab the default setting for the motor
       MOV.B  @0xEFCA,rAl       ; Force motor to proper FWD/REV state
       OR.B   rAh,rAl           ; OR since OFF was zeros!
       MOV.B  rAl,@0xEFCA       ; Save unmodulated motor state
       MOV.B  rAl,@0xEFCE       ; Save modulated motor state for the real OC1A
       MOV.B  rAl,@0xF000       ; Write result to motor drivers

       MOV.W  @rDSP+,rA
       RTS

;------------------------------------------------------------------------------
; SERVO_INIT ( -- )
;
; This uses the exact same dispatch code as the RCX has in the ROM...it
; assumes that the handler saves all of the resisters it uses, but comes
; back to the caller via an RTS. The ROM routine we vectored through does
; the RTE for us!!!
;
; Knowing this, we can just load R6 (because that's the one the dispatch
; routine saved) and JSR into the old vector...

OCIAsave: .word 0x0000

;------------------------------------------------------------------------------

M_CODE(10,``"SERVO_INIT"'',SERVO_INIT,_SLINK)

       MOV.W  @OCIA_VECTOR,rA   ; Grab the current OCIA vector
       MOV.W  #0x36BA,rB        ; Check if it's been "wedged" already
       CMP.W  rA,rB
       BNE    WDG1              ; And exit if it has

       MOV.W  rA,@OCIAsave      ; And save it
       MOV.W  #OCIAwedge,rA     ; Now set our routine to run first
       MOV.W  rA,@OCIA_VECTOR

       MOV.W  #OCIBisr,rA       ; Now set our routine to run first
       MOV.W  rA,@OCIB_VECTOR
WDG1:
       M_NEXT()

;------------------------------------------------------------------------------

And here are the redirect vectors in RAM:

fd90 - word, like a reset vectorfd92 - word, NMI interrupt vector
fd94 - word, IRQ0 interrupt vectorfd96 - word, IRQ1 interrupt vector
fd98 - word, IRQ2 interrupt vectorfd9a - word, ICIA interrupt vector
fd9c - word, ICIB interrupt vectorfd9e - word, ICIC interrupt vector
fda0 - word, ICID interrupt vector
fda2 - word, OCIA interrupt vector, set to 36ba by 3b9a
fda4 - word, OCIB interrupt vectorfda6 - word, FOVI interrupt vector
fda8 - word, CMI0A interrupt vectorfdaa - word, CMI0B interrupt vector
fdac - word, OVI0 interrupt vectorfdae - word, CMI1A interrupt vector
fdb0 - word, CMI1B interrupt vectorfdb2 - word, OVI1 interrupt vector
fdb4 - word, ERI interrupt vector, set to 30a3 at 31ec
fdb6 - word, RXI interrupt vector, set to 2c10 at 31e4
fdb8 - word, TXI interrupt vector, set to 2aac at 31dc
fdba - word, TEI interrupt vector, set to 2a84 at 31d4
fdbc - word, A/D interrupt vector, set to 3b74 by 3b9a
fdbe - word, WOVF interrupt vector

;------------------------------------------------------------------------------



Message has 1 Reply:
  Re: Finally able to add asm forth words (long)
 
(...) Yep. But if I have two choices I will always steal from working code over documentation. I will always write code in C first and see what assembler the compiler creates, especialy on a new machine. Trust what already works. -- (...) (25 years ago, 22-May-00, to lugnet.robotics.rcx.pbforth)

Message is in Reply To:
  Re: Finally able to add asm forth words.
 
(...) It puzzled me for quite a while until I realized that the output was in pbforth.s. Once I saw the results it was much easier. (...) I agree. I have no interest in supporting a varient. I'll hack until it seems to work and then pass it to you (...) (25 years ago, 22-May-00, to lugnet.robotics.rcx.pbforth)

5 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR