wok-current view linld/stuff/memcpy32.u @ rev 22472
updated adwaita-icon-theme (3.20 -> 3.34.3)
author | Hans-G?nter Theisgen |
---|---|
date | Fri Dec 27 17:29:42 2019 +0100 (2019-12-27) |
parents | |
children |
line source
1 --- LINLD097/MEMCPY32.ASM
2 +++ LINLD097/MEMCPY32.ASM
3 @@ -22,70 +22,34 @@
4 global _is_rm32:near
5 proc _is_rm32 near
7 - pushf
8 - cli
9 + pushf
10 + push dx
11 ; Check for oldies
12 - push sp
13 - pop ax
14 - cmp ax,sp
15 - jne @@bad ;it is a 86/186, not a 286+
16 + mov ax, 0F000h
17 + push ax ; < 286 : flags[12..15] are forced 1
18 + popf ; = 286 : flags[12..15] are forced 0
19 + pushf ; > 286 : only flags[15] is forced 0
20 + pop dx
21 + add dh,ah ; NS=386+, NC=286
22 + stc
23 + js @@bad ;it is a 86/186/286, not a 386+
24 ; Check for vm
25 smsw ax ;SMSW cannot be trapped! :-)
26 test al,1 ;MSW_PE
27 -
28 -; We're in vm, this is 386+ (there is no vm in 286)
29 +; We're in vm
30 jnz check_vcpi
32 -; We're in rm, chk for 386+
33 - push ds dx
34 - push 0
35 - pop ds
36 - mov ax,offset excp6
37 - mov dx,cs
38 - xchg [06h*4 ],ax
39 - xchg [06h*4+2],dx
40 - ;cmp sp,sp ;sets ZF - already done
41 - xchg eax,eax ;triggers excp6 on 286 - clears ZF
42 - mov [06h*4 ],ax
43 - mov [06h*4+2],dx
44 - pop dx ds
45 - jnz @@bad ;it's a 286
46 -
47 ; It's a 386 in real mode, chk for paging (crazy but possible)
48 - push eax
49 mov eax,cr0
50 shl eax,1 ;CR0_PG to CF
51 - pop eax
52 - jc @@bad ;CR0_PG was set - real mode paging
53 -@@386rm:
54 - mov ax,1
55 - popf
56 - ret
57 -@@bad: xor ax,ax
58 - popf
59 - ret
60 +@@bad: sbb ax,ax ; ax=0h+!CF
61 + inc ax
62 + jmp @@end
64 ;***************************************************************
65 -;****** Helper int 6 handler: clears ZF, moves IP by 2 bytes
66 -;***************************************************************
67 -label excp6 near
68 -@@oldFlags = (word bp+6)
69 -@@oldCS = (word bp+4)
70 -@@oldIP = (word bp+2)
71 -@@oldBP = (word bp+0)
72 -@@Flags_ZF = 0040h
73 - push bp
74 - mov bp,sp
75 - add [@@oldIP],2
76 - and [byte low @@oldFlags],not @@Flags_ZF
77 - pop bp
78 - iret
79 -
80 -;***************************************************************
81 ;****** Helper: checks for vcpi
82 ;***************************************************************
83 label check_vcpi near
84 - push dx
85 push ds
86 ; Check whether it is safe to call 67h (we trust only known EMM managers)
87 push 0
88 @@ -119,6 +83,7 @@
89 ;;push dx ;$ save handle
90 mov ax,0DE00h ; check for vcpi present
91 int 67h
92 + mov al,2
93 test ah,ah
94 jz @@386vcpi
95 ;;pop dx ;$ handle
96 @@ -126,11 +91,10 @@
97 ;;int 67h
98 @@no_vcpi:
99 xor ax,ax
100 - jmp @@ret
101 @@386vcpi:
102 - mov ax,2
103 @@ret:
104 pop ds
105 +@@end:
106 pop dx
107 popf
108 ret
109 @@ -214,7 +178,7 @@
110 jmp short $+2
112 ;****** Return *************************************************
113 -@@ret: lgdt [oldGDTR]
114 + lgdt [oldGDTR]
115 pop edi esi ecx eax ds es
116 popf
117 leave