INTERRUPT--- QuickBasic vs. PB 
Author Message
 INTERRUPT--- QuickBasic vs. PB

In a program that I was working on, I was using the Interrupt function (from
the qbx library) in QuickBasic 7.1 to call a software interrupt, relating to
a TSR I have on my machine. When I ported the code over to powerbasic 3.5
and started using PB's native Interrupt routine, I started having problems.
Can anyone tell me if there is any difference between the Interrupt
subroutine in QuickBasic and the one in PowerBasic?

CB



Mon, 12 Aug 2002 03:00:00 GMT  
 INTERRUPT--- QuickBasic vs. PB
Other than filling the REG() array versus filling in the RegType UDT, I've
never noticed any differences.

Can you describe you problems? Do they occur only when using a certain
interrupt? Can you post the code which is causing you The problems?

--
Michael Mattias
Racine WI USA

Quote:

>In a program that I was working on, I was using the Interrupt function
(from
>the qbx library) in QuickBasic 7.1 to call a software interrupt, relating
to
>a TSR I have on my machine. When I ported the code over to PowerBasic 3.5
>and started using PB's native Interrupt routine, I started having problems.
>Can anyone tell me if there is any difference between the Interrupt
>subroutine in QuickBasic and the one in PowerBasic?



Tue, 13 Aug 2002 03:00:00 GMT  
 INTERRUPT--- QuickBasic vs. PB
the problem manifests itself in another function, but is a result of an
incorrect (but not invalid) value of CDSegDiv (used in a Def Seg statement
later) retrieved in the following subroutine.
my register constants are correct:
'Register Constants
%AX = 1
%BX = 2
%CX = 3
the only other thought i had is that the other registers in the buffer need
to be set to zero before i call the interrupt. quickbasic should have done
that in the declaration of the RegTypes, but i don't know if powerbasic does
that. I also don't know if that is important to the tsr; i'm in the process
of meeting with the author of the TSR (a program to change the speed of the
system clock).
the code is listed below.

cb

'*****************************************************************
'       GetClkDivPtr  ---
'
'               10/19/89                DD
'
'               12/23/99
'               -ported to PowerBasic 3.5   CB
'*****************************************************************
SUB GetClkDivPtr (CDSeg as dword, OS as dword)

    reg %AX, &HE105              'set reg AX
    CALL Interrupt &H2F
    OSDiv = REG(%BX)           'retrieve BX
    CDSegDiv = REG(%CX)   'retrieve CX

    'QuickBasic Code
    '   ' DIM InRegs AS RegType, OutRegs AS RegType
    '
    '   InRegs.ax = &HE105
    '   CALL Interrupt(&H2F, InRegs, OutRegs)                   'GET Clk Div
    '   OS = OutRegs.bx
    '   CDSeg = OutRegs.cx

END SUB 'GetClkDivPtr

Quote:

>Other than filling the REG() array versus filling in the RegType UDT, I've
>never noticed any differences.

>Can you describe you problems? Do they occur only when using a certain
>interrupt? Can you post the code which is causing you The problems?

>--
>Michael Mattias
>Racine WI USA


>>In a program that I was working on, I was using the Interrupt function
>(from
>>the qbx library) in QuickBasic 7.1 to call a software interrupt, relating
>to
>>a TSR I have on my machine. When I ported the code over to PowerBasic 3.5
>>and started using PB's native Interrupt routine, I started having
problems.
>>Can anyone tell me if there is any difference between the Interrupt
>>subroutine in QuickBasic and the one in PowerBasic?



Tue, 13 Aug 2002 03:00:00 GMT  
 INTERRUPT--- QuickBasic vs. PB
Hi Chris,

There is a certain amount of danger in assuming that any block of memory
will contain any particular value unless you set it yourself. Also you
should set all of the registers passed to any interrupt routine.

Back in the bad old days of the IBM 360/370 mainframes, the shortest
computer program was one called IEFBR14. That program contained ONE
instruction: Branch to the address contained in register 14 (hence the
name). That casued the operating system to believe that the program had
terminated normally.

The operating system would execute a whole bunch of stuff upon normal
completion and another set of on a bad execution (abend).

A new release of the operating system used register 15 to pass back a
result code but did not always set it to zero at the start of a program.
Result = random operation.

So good old IEFBR14 needed a mod and now contains 2 instructions.

Charles Kincaid



Tue, 13 Aug 2002 03:00:00 GMT  
 INTERRUPT--- QuickBasic vs. PB
Oh, if you have an active DEF SEG, I'd suggest you do this if using PB:

SaveDefSeg = pbvDefSeg
(Set up REG() array and call the interrupt)

DEF SEG = SaveDefSeg

--
Michael Mattias
Racine WI USA

Quote:

>the problem manifests itself in another function, but is a result of an
>incorrect (but not invalid) value of CDSegDiv (used in a Def Seg statement
>later) retrieved in the following subroutine.



Wed, 14 Aug 2002 03:00:00 GMT  
 INTERRUPT--- QuickBasic vs. PB
My feed seems to have not received some of the messages in this
thread, so I'll try to offer some general advice:

Unless you load the REG() buffers before the call, PowerBASIC will not
alter them for you... if you did not tell it to set a particular value
for, say, DX, then the exxisting value will be used...  The compiler
does not try to "guess" that you want the register cleared - you must
explicitly tell it to do so.

If you intend to use inline assembly (rather than CALL INTERRUPT),
then it is important that you preserve the DS register before the
call, and restore it after the call... if DS is alterered, you may
experience problems as the PB runtime library expects it to be
preserved - as you intend to call another application, you cannot
guarantee that this does not alter DS.
' How to preserve DS
! PUSH DS
! MOV AX, value%
...more code to set registers
! INT &H2F
! POP DS

Another possible cause of problems is overwriting memory
"accidentially".  

Always add $ERROR ALL ON to your code to ensure that a bad array
subscript does not cause grief somewhere else in the code.  This can
also happen when using pointers or inline-assembly incorrectly... the
problem does not show up until the affected memory block is referenced
and because the cause of the corruption is not obvious, it can be
difficult to trace the real cause.

Finally, from your code, I assume CDSEGDIV and OSDIV are SHARED
variables?  As it stands, your sub does not alter the two DWORD values
passed to the code by reference.

Quote:

>the problem manifests itself in another function, but is a result of an
>incorrect (but not invalid) value of CDSegDiv (used in a Def Seg statement
>later) retrieved in the following subroutine.
>my register constants are correct:
>'Register Constants
>%AX = 1
>%BX = 2
>%CX = 3
>the only other thought i had is that the other registers in the buffer need
>to be set to zero before i call the interrupt. quickbasic should have done
>that in the declaration of the RegTypes, but i don't know if powerbasic does
>that. I also don't know if that is important to the tsr; i'm in the process
>of meeting with the author of the TSR (a program to change the speed of the
>system clock).
>the code is listed below.

>cb

>'*****************************************************************
>'       GetClkDivPtr  ---
>'
>'               10/19/89                DD
>'
>'               12/23/99
>'               -ported to PowerBasic 3.5   CB
>'*****************************************************************
>SUB GetClkDivPtr (CDSeg as dword, OS as dword)

>    reg %AX, &HE105              'set reg AX
>    CALL Interrupt &H2F
>    OSDiv = REG(%BX)           'retrieve BX
>    CDSegDiv = REG(%CX)   'retrieve CX

>    'QuickBasic Code
>    '   ' DIM InRegs AS RegType, OutRegs AS RegType
>    '
>    '   InRegs.ax = &HE105
>    '   CALL Interrupt(&H2F, InRegs, OutRegs)                   'GET Clk Div
>    '   OS = OutRegs.bx
>    '   CDSeg = OutRegs.cx

>END SUB 'GetClkDivPtr


>>Other than filling the REG() array versus filling in the RegType UDT, I've
>>never noticed any differences.

>>Can you describe you problems? Do they occur only when using a certain
>>interrupt? Can you post the code which is causing you The problems?

>>--
>>Michael Mattias
>>Racine WI USA


>>>In a program that I was working on, I was using the Interrupt function
>>(from
>>>the qbx library) in QuickBasic 7.1 to call a software interrupt, relating
>>to
>>>a TSR I have on my machine. When I ported the code over to PowerBasic 3.5
>>>and started using PB's native Interrupt routine, I started having
>problems.
>>>Can anyone tell me if there is any difference between the Interrupt
>>>subroutine in QuickBasic and the one in PowerBasic?

Lance
PowerBASIC Support

-------------------------------------------------------------------------
PowerBASIC, Inc.      | 800-780-7707 Sales | "We put the Power in Basic!"
316 Mid Valley Center | 831-659-8000 Voice | http://www.powerbasic.com



Wed, 14 Aug 2002 03:00:00 GMT  
 INTERRUPT--- QuickBasic vs. PB
CDSegDiv and OSDiv are shared variables... I sent an older version of the
subroutine definition by accident.
I will try clearing the other registers before the interrupt call. Also, I
will save the old Def Seg; whether or not that is my problem, I see how it
could cause other problems.

Thanks,
Chris

Quote:

>My feed seems to have not received some of the messages in this
>thread, so I'll try to offer some general advice:

>Unless you load the REG() buffers before the call, PowerBASIC will not
>alter them for you... if you did not tell it to set a particular value
>for, say, DX, then the exxisting value will be used...  The compiler
>does not try to "guess" that you want the register cleared - you must
>explicitly tell it to do so.

>If you intend to use inline assembly (rather than CALL INTERRUPT),
>then it is important that you preserve the DS register before the
>call, and restore it after the call... if DS is alterered, you may
>experience problems as the PB runtime library expects it to be
>preserved - as you intend to call another application, you cannot
>guarantee that this does not alter DS.
>' How to preserve DS
>! PUSH DS
>! MOV AX, value%
>...more code to set registers
>! INT &H2F
>! POP DS

>Another possible cause of problems is overwriting memory
>"accidentially".

>Always add $ERROR ALL ON to your code to ensure that a bad array
>subscript does not cause grief somewhere else in the code.  This can
>also happen when using pointers or inline-assembly incorrectly... the
>problem does not show up until the affected memory block is referenced
>and because the cause of the corruption is not obvious, it can be
>difficult to trace the real cause.

>Finally, from your code, I assume CDSEGDIV and OSDIV are SHARED
>variables?  As it stands, your sub does not alter the two DWORD values
>passed to the code by reference.



Fri, 16 Aug 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. qbasic vs QuickBasic

2. Calling Real Mode Interrupts from PB/DLL

3. Subs vs Functions PB 3.2

4. QB vs PB

5. QB vs PB????

6. QB vs PB

7. PB 3.2.PB/Vision 2.0 Timerinstallcode.Shared Arrays

8. MX Lookup with PB/CC or PB/DLL

9. TCPADDR for PB/DLL & PB/CC

10. Info on new PB/CC and PB/DLL

11. Announcing the JazzAge COM Wizard for PB/DLL and PB/CC

12. animated characters, speech input/output in PB/DLL and PB/CC

 

 
Powered by phpBB® Forum Software