Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
2.8 KiB

  1. ;++
  2. ;
  3. ; WOW v1.0
  4. ;
  5. ; Copyright (c) 1991, Microsoft Corporation
  6. ;
  7. ; WSPHELP.ASM
  8. ; Win16 wsprintf/wvsprintf helper services
  9. ;
  10. ; History:
  11. ;
  12. ; Created 28-May-1991 by Jeff Parsons (jeffpar)
  13. ; Copied from WIN31 and edited (as little as possible) for WOW16
  14. ;--
  15. ;
  16. ; WSPHELP.ASM
  17. ;
  18. ; Assembly language helper functions for wvsprintf(), primarily for
  19. ; space optimization.
  20. ;
  21. ; History:
  22. ; 2/15/89 craigc Initial
  23. ;
  24. memS=1
  25. ?PLM=1
  26. ?WIN=1
  27. ifdef WOW
  28. SEGNAME equ <TEXT>
  29. endif
  30. .xlist
  31. include cmacros.inc
  32. .list
  33. createSeg _%SEGNAME,%SEGNAME,WORD,public,CODE
  34. sBegin %SEGNAME
  35. assumes cs,%SEGNAME
  36. ;
  37. ; SP_PutNumber
  38. ;
  39. ; Takes an unsigned long integer and places it into a buffer, respecting
  40. ; a buffer limit, a radix, and a case select (upper or lower, for hex).
  41. ;
  42. cProc SP_PutNumber, <NEAR,PUBLIC>, <si,di>
  43. parmD lpb
  44. parmD n
  45. parmW limit
  46. parmW radix
  47. parmW case
  48. cBegin
  49. mov al,'a'-'0'-10 ; figure out conversion offset
  50. cmp case,0
  51. jz pn_lower
  52. mov al,'A'-'0'-10
  53. pn_lower:
  54. mov byte ptr case,al
  55. mov bx,word ptr n[0] ; bx:dx=number
  56. mov dx,word ptr n[2]
  57. mov cx,radix ; cx=radix
  58. les di,lpb ; es:di->string
  59. mov si,limit ; cchLimit
  60. ;
  61. ; following adapted from fultoa.asm
  62. ;
  63. ; dx:bx = unsigned number, cx = radix, es:di->output
  64. ;
  65. divdown:
  66. xchg ax,dx ; divide hi
  67. xor dx,dx
  68. or ax,ax
  69. jz nohigh ; save a divide
  70. div cx ; dx = rem, ax = hi div
  71. nohigh:
  72. xchg ax,bx ; ax = lo, bx = hi div
  73. div cx ; dx = rem, bx:ax = div
  74. xchg ax,dx ; ax = rem, bx:dx = div
  75. xchg dx,bx ; ax = rem, dx:bx = div (tight!!!!)
  76. add al,'0'
  77. cmp al,'9'
  78. jbe isadig ; is a digit already
  79. add al,byte ptr case ; convert to letter
  80. isadig:
  81. dec si ; decrement cchLimit
  82. jz pn_exit ; go away if end of string
  83. stosb ; stick it in
  84. mov ax,dx
  85. or ax,bx
  86. jnz divdown ; crack out next digit
  87. pn_exit:
  88. mov ax,di
  89. sub ax,word ptr lpb[0] ; find number of chars output
  90. cEnd
  91. ;
  92. ; SP_Reverse
  93. ;
  94. ; Reverses a string in place
  95. ;
  96. cProc SP_Reverse,<NEAR,PUBLIC>,<si,di>
  97. parmD lpFirst
  98. parmD lpLast
  99. cBegin
  100. push ds
  101. lds si,lpFirst
  102. les di,lpLast
  103. mov cx,di ; number of character difference
  104. sub cx,si
  105. inc cx
  106. shr cx,1 ; number of swaps required
  107. jcxz spr_boring ; nuthin' to do
  108. spr100:
  109. mov ah,es:[di]
  110. mov al,[si] ; load the two characters
  111. mov [si],ah
  112. mov es:[di],al ; swap them
  113. inc si
  114. dec di ; adjust the pointers
  115. loop spr100 ; ...until we've done 'em all
  116. spr_boring:
  117. pop ds
  118. cEnd
  119. sEnd %SEGNAME
  120. end