[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MCL & THINK C Code Resources



Does anyone have any example code for running Think C multi-segment code
resources from MCL?

 I have successfully built a multisegment code resource that uses A4 addressing
and called it from MCL 2.0 using FF-CALL, but seem to get random bus errors.  I
need to see some example code since very simple examples seem to run without
error.

Here is what I'm doing, any suggestions would be appreciated.

1) Open the resource with #_OpenResFile
2) Read in the resource to the main routine with #_GetNamedResource.
2) Lock the resource handle and dereference it.
3) FF-CALL the dereferenced handle and fill the A4 register with it.

The code resource main routine uses the standard header.
It calls a stub function from each segment to force them to be loaded
prior to running its body.

Thanks in advance,
-Jonathan Pierce


  
(defmethod load-code-resource ((pathname t) (module-name symbol))
    (open-resource-file pathname) 
    (let (resource)
        (setf resource (get-named-resource :TCCD (symbol-name module-name)))   
                 
        (cond ((null resource)
                    (error "Can't find the ThinkC module ~a ." module-name))
                  (t (#_DetachResource :ptr resource)
                       resource))))

(defmethod run-code-resource ((resource t))      ;;; This assumes the resource
file is currently open.
    (cond ((null resource) (ed-beep))
              (t  (with-dereferenced-handles ((r resource)) 
                        (ff-call r :a4 r)))))

I am using the standard header and I call a stub function in each code resource
segment which loads them all