|
Last change
on this file since 21786 was 21783, checked in by dmik, 14 years ago |
|
Use underscores for symbols defined in .asm as they are cdecl.
IBM VAC seemed to detect they are ASM and not use underscores
when referencing them from C.
|
|
File size:
4.7 KB
|
| Line | |
|---|
| 1 | ; $Id: asmutil.asm,v 1.3 2003-03-27 14:13:10 sandervl Exp $
|
|---|
| 2 |
|
|---|
| 3 | ;/*
|
|---|
| 4 | ; * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 5 | ; * Win32 Exception handling + misc functions for OS/2
|
|---|
| 6 | ; *
|
|---|
| 7 | ; * Copyright 1998 Sander van Leeuwen
|
|---|
| 8 | ; *
|
|---|
| 9 | ; */
|
|---|
| 10 | .386p
|
|---|
| 11 | NAME except
|
|---|
| 12 |
|
|---|
| 13 | DATA32 segment dword use32 public 'DATA'
|
|---|
| 14 | DATA32 ends
|
|---|
| 15 | CONST32_RO segment dword use32 public 'CONST'
|
|---|
| 16 | CONST32_RO ends
|
|---|
| 17 | BSS32 segment dword use32 public 'BSS'
|
|---|
| 18 | BSS32 ends
|
|---|
| 19 | DGROUP group BSS32, DATA32
|
|---|
| 20 | assume cs:FLAT, ds:FLAT, ss:FLAT, es:FLAT
|
|---|
| 21 |
|
|---|
| 22 | extrn Dos32TIB:abs
|
|---|
| 23 |
|
|---|
| 24 | CODE32 SEGMENT DWORD PUBLIC USE32 'CODE'
|
|---|
| 25 |
|
|---|
| 26 | PUBLIC _getEAX
|
|---|
| 27 | _getEAX proc near
|
|---|
| 28 | ret
|
|---|
| 29 | _getEAX endp
|
|---|
| 30 |
|
|---|
| 31 | PUBLIC _getEDX
|
|---|
| 32 | _getEDX proc near
|
|---|
| 33 | mov EAX, EDX
|
|---|
| 34 | ret
|
|---|
| 35 | _getEDX endp
|
|---|
| 36 |
|
|---|
| 37 | PUBLIC _getEBX
|
|---|
| 38 | _getEBX proc near
|
|---|
| 39 | mov eax, ebx
|
|---|
| 40 | ret
|
|---|
| 41 | _getEBX endp
|
|---|
| 42 |
|
|---|
| 43 | IFNDEF __GNUC__
|
|---|
| 44 |
|
|---|
| 45 | PUBLIC GetFS
|
|---|
| 46 | GetFS proc near
|
|---|
| 47 | mov eax, fs
|
|---|
| 48 | ret
|
|---|
| 49 | GetFS endp
|
|---|
| 50 |
|
|---|
| 51 | PUBLIC SetFS
|
|---|
| 52 | SetFS proc near
|
|---|
| 53 | mov eax, [esp+4]
|
|---|
| 54 | mov fs, eax
|
|---|
| 55 | ret
|
|---|
| 56 | SetFS endp
|
|---|
| 57 |
|
|---|
| 58 | ENDIF ; __GNUC__
|
|---|
| 59 |
|
|---|
| 60 | PUBLIC _getCS
|
|---|
| 61 | _getCS proc near
|
|---|
| 62 | mov eax, cs
|
|---|
| 63 | ret
|
|---|
| 64 | _getCS endp
|
|---|
| 65 |
|
|---|
| 66 | PUBLIC _getDS
|
|---|
| 67 | _getDS proc near
|
|---|
| 68 | mov eax, ds
|
|---|
| 69 | ret
|
|---|
| 70 | _getDS endp
|
|---|
| 71 |
|
|---|
| 72 | IFNDEF __GNUC__
|
|---|
| 73 |
|
|---|
| 74 | PUBLIC SetReturnFS
|
|---|
| 75 | SetReturnFS proc near
|
|---|
| 76 | push fs
|
|---|
| 77 | mov eax, [esp+8]
|
|---|
| 78 | mov fs, eax
|
|---|
| 79 | pop eax
|
|---|
| 80 | ret
|
|---|
| 81 | SetReturnFS endp
|
|---|
| 82 |
|
|---|
| 83 | ENDIF ; __GNUC__
|
|---|
| 84 |
|
|---|
| 85 | PUBLIC _getSS
|
|---|
| 86 | _getSS proc near
|
|---|
| 87 | mov ax, ss
|
|---|
| 88 | ret
|
|---|
| 89 | _getSS endp
|
|---|
| 90 |
|
|---|
| 91 | PUBLIC _getES
|
|---|
| 92 | _getES proc near
|
|---|
| 93 | mov eax, es
|
|---|
| 94 | ret
|
|---|
| 95 | _getES endp
|
|---|
| 96 |
|
|---|
| 97 | PUBLIC _getGS
|
|---|
| 98 | _getGS proc near
|
|---|
| 99 | mov eax, gs
|
|---|
| 100 | ret
|
|---|
| 101 | _getGS endp
|
|---|
| 102 |
|
|---|
| 103 | PUBLIC _getESP
|
|---|
| 104 | _getESP proc near
|
|---|
| 105 | mov eax, esp
|
|---|
| 106 | ret
|
|---|
| 107 | _getESP endp
|
|---|
| 108 |
|
|---|
| 109 | IFNDEF __GNUC__
|
|---|
| 110 |
|
|---|
| 111 | PUBLIC RestoreOS2FS
|
|---|
| 112 | RestoreOS2FS proc near
|
|---|
| 113 | push Dos32TIB
|
|---|
| 114 | mov ax, fs
|
|---|
| 115 | pop fs
|
|---|
| 116 | ret
|
|---|
| 117 | RestoreOS2FS endp
|
|---|
| 118 |
|
|---|
| 119 | ENDIF ; __GNUC__
|
|---|
| 120 |
|
|---|
| 121 | PUBLIC _Mul32x32to64
|
|---|
| 122 | _Mul32x32to64 proc near
|
|---|
| 123 | push ebp
|
|---|
| 124 | mov ebp, esp
|
|---|
| 125 | push eax
|
|---|
| 126 | push edx
|
|---|
| 127 | push edi
|
|---|
| 128 |
|
|---|
| 129 | mov edi, [ebp+8] ;64 bits result
|
|---|
| 130 | mov eax, [ebp+12] ;op1
|
|---|
| 131 | mov edx, [ebp+16] ;op2
|
|---|
| 132 | mul edx
|
|---|
| 133 | mov [edi], eax
|
|---|
| 134 | mov [edi+4], edx
|
|---|
| 135 |
|
|---|
| 136 | pop edi
|
|---|
| 137 | pop edx
|
|---|
| 138 | pop eax
|
|---|
| 139 | pop ebp
|
|---|
| 140 | ret
|
|---|
| 141 | _Mul32x32to64 endp
|
|---|
| 142 |
|
|---|
| 143 | align 4h
|
|---|
| 144 |
|
|---|
| 145 | public _Sub64
|
|---|
| 146 | _Sub64 proc
|
|---|
| 147 |
|
|---|
| 148 | ; 34 c = a - b;
|
|---|
| 149 | push ebp
|
|---|
| 150 | mov ebp, esp
|
|---|
| 151 | push esi
|
|---|
| 152 | push edi
|
|---|
| 153 | push edx
|
|---|
| 154 |
|
|---|
| 155 | mov edi, [ebp+10h] ;&c
|
|---|
| 156 | mov esi, [ebp+08h] ;&a
|
|---|
| 157 | mov eax,[esi] ;a.low
|
|---|
| 158 | mov edx,[esi+04h] ;a.high
|
|---|
| 159 | mov esi, [ebp+0ch] ;&b
|
|---|
| 160 | sub eax,[esi] ;b.low
|
|---|
| 161 | sbb edx,[esi+04h] ;b.high
|
|---|
| 162 |
|
|---|
| 163 | mov [edi], eax ;c.low
|
|---|
| 164 | mov [edi+4], edx ;c.high
|
|---|
| 165 |
|
|---|
| 166 | pop edx
|
|---|
| 167 | pop edi
|
|---|
| 168 | pop esi
|
|---|
| 169 | leave
|
|---|
| 170 | ret
|
|---|
| 171 | _Sub64 endp
|
|---|
| 172 |
|
|---|
| 173 | align 4h
|
|---|
| 174 |
|
|---|
| 175 | public _Add64
|
|---|
| 176 | _Add64 proc
|
|---|
| 177 |
|
|---|
| 178 | ; 25 c = a + b;
|
|---|
| 179 | push ebp
|
|---|
| 180 | mov ebp, esp
|
|---|
| 181 | push esi
|
|---|
| 182 | push edi
|
|---|
| 183 | push edx
|
|---|
| 184 |
|
|---|
| 185 | mov edi, [ebp+10h] ;&c
|
|---|
| 186 | mov esi, [ebp+08h] ;&a
|
|---|
| 187 | mov eax,[esi] ;a.low
|
|---|
| 188 | mov edx,[esi+04h] ;a.high
|
|---|
| 189 | mov esi, [ebp+0ch] ;&b
|
|---|
| 190 | add eax,[esi] ;b.low
|
|---|
| 191 | adc edx,[esi+04h] ;b.high
|
|---|
| 192 |
|
|---|
| 193 | mov [edi], eax ;c.low
|
|---|
| 194 | mov [edi+4], edx ;c.high
|
|---|
| 195 |
|
|---|
| 196 | pop edx
|
|---|
| 197 | pop edi
|
|---|
| 198 | pop esi
|
|---|
| 199 | leave
|
|---|
| 200 | ret
|
|---|
| 201 |
|
|---|
| 202 | _Add64 endp
|
|---|
| 203 |
|
|---|
| 204 |
|
|---|
| 205 | align 4h
|
|---|
| 206 |
|
|---|
| 207 | public _set_bit
|
|---|
| 208 | ;void CDECL set_bit(int bitnr, void *addr);
|
|---|
| 209 | _set_bit proc near
|
|---|
| 210 | push esi
|
|---|
| 211 |
|
|---|
| 212 | mov esi, [esp+12]
|
|---|
| 213 | mov eax, [esp+8]
|
|---|
| 214 |
|
|---|
| 215 | bts dword ptr [esi], eax
|
|---|
| 216 |
|
|---|
| 217 | pop esi
|
|---|
| 218 | ret
|
|---|
| 219 | _set_bit endp
|
|---|
| 220 |
|
|---|
| 221 | align 4h
|
|---|
| 222 |
|
|---|
| 223 | public _test_bit
|
|---|
| 224 | ;int CDECL test_bit(int bitnr, void *addr);
|
|---|
| 225 | _test_bit proc near
|
|---|
| 226 | push esi
|
|---|
| 227 |
|
|---|
| 228 | mov esi, [esp+12]
|
|---|
| 229 | mov eax, [esp+8]
|
|---|
| 230 |
|
|---|
| 231 | bt dword ptr [esi], eax
|
|---|
| 232 | setc al
|
|---|
| 233 | movzx eax, al
|
|---|
| 234 |
|
|---|
| 235 | pop esi
|
|---|
| 236 | ret
|
|---|
| 237 | _test_bit endp
|
|---|
| 238 |
|
|---|
| 239 | public _clear_bit
|
|---|
| 240 | ;void CDECL clear_bit(int bitnr, void *addr);
|
|---|
| 241 | _clear_bit proc near
|
|---|
| 242 | push esi
|
|---|
| 243 |
|
|---|
| 244 | mov esi, [esp+12]
|
|---|
| 245 | mov eax, [esp+8]
|
|---|
| 246 |
|
|---|
| 247 | btr dword ptr [esi], eax
|
|---|
| 248 |
|
|---|
| 249 | pop esi
|
|---|
| 250 | ret
|
|---|
| 251 | _clear_bit endp
|
|---|
| 252 |
|
|---|
| 253 | rdtsc macro
|
|---|
| 254 | db 0Fh, 31h
|
|---|
| 255 | endm
|
|---|
| 256 |
|
|---|
| 257 | public GetPentiumTSC
|
|---|
| 258 | GetPentiumTSC proc near
|
|---|
| 259 | mov ecx , [esp + 4]
|
|---|
| 260 | rdtsc
|
|---|
| 261 | mov [ecx] , eax
|
|---|
| 262 | mov [ecx + 4] , edx
|
|---|
| 263 | xor eax , eax
|
|---|
| 264 | ret
|
|---|
| 265 | GetPentiumTSC endp
|
|---|
| 266 |
|
|---|
| 267 | CODE32 ENDS
|
|---|
| 268 |
|
|---|
| 269 | END
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.