wok annotate linld/stuff/memcpy32.u @ rev 19940

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