home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pcmagazi / 1992 / 11 / labnotes / getabs.asm < prev    next >
Assembly Source File  |  1992-02-24  |  3KB  |  94 lines

  1. ;GetAbs.ASM
  2. ;Copyright (c) 1992 Jay Munro
  3. ;First Published in PC Magazine June 16, 1992
  4. ;Syntax
  5. ;  Declare Function GetAbs%(Byval Segment%)
  6. ;  GoodSelector% = GetAbs%(&hB000)
  7. ;---------------------------------------------------------------------------
  8. ; GetAbs.ASM takes an incoming segment value and replaces it with
  9. ; a Windows compatible selector if it matches one of the 9 possible exported
  10. ; values.  If the value doesn't match it is checked to see if it is a valid
  11. ; selector, first a writeable one, then a readable one.  In the event it
  12. ; fails all the tests, a -1 is returned otherwise the original value or the
  13. ; substituted selector is returned.
  14. ;----------------------------------------------------------------------------
  15.  
  16. .286P                           ;protected instructions below
  17.  
  18. .Model Medium
  19.  
  20.     Public   GetAbs
  21.     Include  Labnotes.inc
  22.     
  23.     Extrn   __0000H :ABS
  24.     Extrn   __0040H :ABS
  25.     Extrn   __A000H :ABS
  26.     Extrn   __B000H :ABS
  27.     Extrn   __B800H :ABS
  28.     Extrn   __C000H :ABS
  29.     Extrn   __D000H :ABS
  30.     Extrn   __E000H :ABS
  31.     Extrn   __F000H :ABS
  32.  
  33. .Code
  34.  
  35. GetAbs Proc Far
  36.     WinProlog                   ;standard export setup
  37.     Mov  AX,[BP+6]              ;get incoming value
  38.     Or   AX,AX                  ;asking for segment 0?
  39.     Jnz  @F
  40.     Mov  AX,__0000h             ;get selector
  41.     Jmp  Exit                   ;get out
  42. @@:
  43.     Cmp  AX,0040h               ;Segment 0040h ?
  44.     Jnz  @F
  45.     Mov  AX,__0040h             ;get selector
  46.     Jmp  Exit                   ;get out
  47. @@:
  48.     Cmp  AX,0A000h              ;Segment A000h ?
  49.     Jnz  @F
  50.     Mov  AX,__A000h             ;get selector
  51.     Jmp  Exit                   ;get out
  52. @@:
  53.     Cmp  AX,0B000h              ;Segment B000h ?
  54.     Jnz  @F
  55.     Mov  AX,__B000h             ;get selector
  56.     Jmp  Exit                   ;get out
  57. @@:
  58.     Cmp  AX,0B800h              ;Segment 0040h ?
  59.     Jnz  @F
  60.     Mov  AX,__B800h             ;get selector
  61.     Jmp  Exit                   ;get out
  62. @@:
  63.     Cmp  AX,0C000h              ;Segment C000h ?
  64.     Jnz  @F
  65.     Mov  AX,__C000h             ;get selector
  66.     Jmp  Exit                   ;get out
  67. @@:
  68.     Cmp  AX,0D000h              ;Segment D000h ?
  69.     Jnz  @F
  70.     Mov  AX,__D000h             ;get selector
  71.     Jmp  Exit                   ;get out
  72. @@:
  73.     Cmp  AX,0E000h              ;Segment E000h ?
  74.     Jnz  @F
  75.     Mov  AX,__E000h             ;get selector
  76.     Jmp  Exit                   ;get out
  77. @@:
  78.     Cmp  AX,0F000h              ;Segment F000h ?
  79.     Jnz  @F
  80.     Mov  AX,__F000h             ;get selector
  81.     Jmp  Exit                   ;get out
  82. @@:
  83.     VERW AX                     ;is it writeable?
  84.     Jz   Exit
  85.     VERR AX                     ;not writeable, then is it readable
  86.     Jz   Exit                   ;
  87.     
  88.     Mov  AX,-1                  ;none of the above
  89. Exit:
  90.     WinEpilog
  91.     Ret 2
  92. GetAbs EndP
  93. End
  94.