~ubuntu-branches/ubuntu/dapper/fpc/dapper

« back to all changes in this revision

Viewing changes to docs/go32ex/rmpmint.pp

  • Committer: Bazaar Package Importer
  • Author(s): Carlos Laviola
  • Date: 2001-08-29 23:15:17 UTC
  • Revision ID: james.westby@ubuntu.com-20010829231517-thxsp7ctuab584ia
Tags: upstream-1.0.4
ImportĀ upstreamĀ versionĀ 1.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
uses
 
2
        crt,
 
3
        go32;
 
4
 
 
5
var
 
6
        r : trealregs;
 
7
        axreg : Word;
 
8
 
 
9
        oldint21h : tseginfo;
 
10
        newint21h : tseginfo;
 
11
procedure int21h_handler; assembler;
 
12
asm
 
13
        cmpw $0x3001, %ax
 
14
        jne .LCallOld
 
15
        movw $0x3112, %ax
 
16
        iret
 
17
 
 
18
.LCallOld:
 
19
        ljmp %cs:oldint21h
 
20
end;
 
21
 
 
22
procedure resume;
 
23
begin
 
24
        Writeln;
 
25
        Write('-- press any key to resume --'); readkey;
 
26
        gotoxy(1, wherey); clreol;
 
27
end;
 
28
 
 
29
begin
 
30
        clrscr;
 
31
        Writeln('Executing real mode interrupt');
 
32
        resume;
 
33
        r.ah := $30; r.al := $01;  realintr($21, r);
 
34
        Writeln('DOS v', r.al,'.',r.ah, ' detected');
 
35
        resume;
 
36
        Writeln('Executing protected mode interrupt without our own',
 
37
                ' handler');
 
38
        Writeln;
 
39
        asm
 
40
                movb $0x30, %ah
 
41
                movb $0x01, %al
 
42
                int $0x21
 
43
                movw %ax, axreg
 
44
        end;
 
45
        Writeln('DOS v', r.al,'.',r.ah, ' detected');
 
46
        resume;
 
47
        Writeln('As you can see the DPMI hosts default protected mode',
 
48
                'handler');
 
49
        Writeln('simply redirects it to the real mode handler');
 
50
        resume;
 
51
        Writeln('Now exchanging the protected mode interrupt with our ',
 
52
                'own handler');
 
53
        resume;
 
54
 
 
55
        newint21h.offset := @int21h_handler;
 
56
        newint21h.segment := get_cs;
 
57
        get_pm_interrupt($21, oldint21h);
 
58
        set_pm_interrupt($21, newint21h);
 
59
 
 
60
        Writeln('Executing real mode interrupt again');
 
61
        resume;
 
62
        r.ah := $30; r.al := $01; realintr($21, r);
 
63
        Writeln('DOS v', r.al,'.',r.ah, ' detected');
 
64
        Writeln;
 
65
        Writeln('See, it didn''t change in any way.');
 
66
        resume;
 
67
        Writeln('Now calling protected mode interrupt');
 
68
        resume;
 
69
        asm
 
70
                movb $0x30, %ah
 
71
                movb $0x01, %al
 
72
                int $0x21
 
73
                movw %ax, axreg
 
74
        end;
 
75
        Writeln('DOS v', lo(axreg),'.',hi(axreg), ' detected');
 
76
        Writeln;
 
77
        Writeln('Now you can see that there''s a distinction between ',
 
78
                'the two ways of calling interrupts...');
 
79
        set_pm_interrupt($21, oldint21h);
 
80
end.
 
 
b'\\ No newline at end of file'