TSR, proc near, proc far 
Author Message
 TSR, proc near, proc far

Hi,

Would you please explain to me things about the difference
between "proc near" and "proc far" that I need to understand on
writing a .com-TSR hooking at 08, 09, 2F, 4A on plain-DOS?
I don't think I've ever exactly understood anything about
the syntaxes "proc" and "near/far". How are they important
and what mistakes could I make about them on writing a TSR.

I'm currently using A86 and writing in 8086 instructions.

I picked up an old TSR of mine which has been serving
me everyday as an INT4A-server (my morning-call) and
tried to add more and more things to it.

I saw that the codes were not well-structured and have
created new procedures to collect codes together,
so that I could easily maintain them and avoid repeated
codes. But after adding two new procedures that do nothing
new but just modulize some functions, the TSR hangs when
activated. They are currently NOT called. The TSR works
again if the two new procedures are commented out. Why?

I hope I could post the codes, but they are sort of too
long (ca. 80 KB) for a usenet-post (but would love to
mail to anyone would help). So, I think the best strategy
now is to try to really understand what I'm doing. Therefore,
the above quesiton.

I thank you very much in advance.
(PS. I'm no ASM-oprogrammer)

Rudi



Sat, 18 Oct 2003 03:00:10 GMT  
 TSR, proc near, proc far

Quote:
>Would you please explain to me things about the difference
>between "proc near" and "proc far" that I need to understand on
>writing a .com-TSR hooking at 08, 09, 2F, 4A on plain-DOS?
>I don't think I've ever exactly understood anything about
>the syntaxes "proc" and "near/far". How are they important
>and what mistakes could I make about them on writing a TSR.

The only difference is how other programs issue CALL's or JMP's to
access them and whether the "RET" in that procedure is encoded as RETN
(return near, only pops IP off the stack) or RETF (return far, pops
both CS and IP off the stack).

- Rick C. Hodgin



Sat, 18 Oct 2003 04:27:58 GMT  
 TSR, proc near, proc far

Quote:
>>Would you please explain to me things about the difference
>>between "proc near" and "proc far" that I need to understand on
>>writing a .com-TSR hooking at 08, 09, 2F, 4A on plain-DOS?
>>I don't think I've ever exactly understood anything about
>>the syntaxes "proc" and "near/far". How are they important
>>and what mistakes could I make about them on writing a TSR.
>The only difference is how other programs issue CALL's or JMP's to
>access them and whether the "RET" in that procedure is encoded as RETN
>(return near, only pops IP off the stack) or RETF (return far, pops
>both CS and IP off the stack).

Thanks. What do you mean by "other programs"? Do you mean the,
in my case, the other part of my resident codes? I used "far"
because I've seen them being spelled "far". And do not know
why? The "program" calling this "ISR09" should be ...? BIOS?
Actually triggered by hardware ... What if I write it "near"?

; ------------------
ISR09           proc    far             ; my INT 09H hanlder
                ...
                call    UTIL
OurHotKey:
                ...
AbsorbKey:
                ...
ChainISR09:
                ...
                iret
ISR09           endp
; ------------------

Now, if I need some utility-functions for these interrupt servicing
codes, I've always done it chaotically; that is to say, I just put
them ad libitum "somewhere" after the RET's or JMP's using a simple
label and 'RET'. I'm not feeling well here too. Should I have created
a 'proc' ('near' or 'far'? I guess 'near' because it is then call
inside these small resident codes.)? That is, what's the difference
between

;--------------------------
UTIL:
                ....
                ret
;--------------------------

and

;--------------------------
UTIL            proc    near
                ...
                ret
UTIL            endp
;--------------------------

I mean what different results would typical assembler do on the
above two cases?

BTW. Should I write 'retn' for all "proc near" and "ret" for 'proc far'?

Ah ... I guess I know what you mean. You meant I just write "CALL" and
"RET" and if the codes are encapsulated in the "proc near/far - endp"
syntax, the assembler will know how to put suitable instructions for
"CALL", "RET", "RETN", .... right? So, what happen if I just blindly
created a label "UTIL", use "RET" at the end and put them somewhere
I like? Would this cause some problem?  The style is currently awful.
That's what I mean that my codes are not well-structured and during
adding some additional codes, I frequently got the error message:

        jump > 128 bytes

So, I'll move the codes back and forth in order to be able to avoid
that and make my codes even more ugly ...

And could I suppose that using "far" would be safer. This would require
just one more pushing and popping the code segment. But what happen
if I use a 'near' when it should have been 'far'. Would the assemblers
(like A86) warn about this?

Rudi



Sat, 18 Oct 2003 05:16:02 GMT  
 TSR, proc near, proc far

Quote:
>>The only difference is how other programs issue CALL's or JMP's to
>>access them
>Thanks. What do you mean by "other programs"?

I meant "other procedures". :)  Sorry. hehehe :)

- Rick C. Hodgin



Sat, 18 Oct 2003 06:18:49 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. PROC within a PROC DD override

2. i need my proc-1 to be the same as an existing proc-2

3. Ho do I invoke proc from within proc

4. proc without stack frame OR macro instead of proc

5. proc in proc

6. calling a proc from proc

7. Calling a proc within a proc in tcl/tk8.0

8. Help! Variables in FAR Proc in TASM

9. TSR probs/ proc set by int 21h, fcn 25h won't work

10. Need help with Near and Far explanation

11. NEAR and FAR

12. NEAR - FAR

 

 
Powered by phpBB® Forum Software