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.

349 lines
8.3 KiB

  1. ;++
  2. ;
  3. ; WOW v1.0
  4. ;
  5. ; Copyright (c) 1991, Microsoft Corporation
  6. ;
  7. ; WINSTR.ASM
  8. ; Win16 string services
  9. ;
  10. ; History:
  11. ;
  12. ; Created 18-Jun-1991 by Jeff Parsons (jeffpar)
  13. ; Copied from WIN31 and edited (as little as possible) for WOW16
  14. ;--
  15. ;****************************************************************************
  16. ;* *
  17. ;* WinStr.ASM - *
  18. ;* *
  19. ;* String related API calls to support different lanuages *
  20. ;* *
  21. ;****************************************************************************
  22. TITLE WinStr.ASM
  23. ifdef WOW
  24. NOEXTERNS equ 1
  25. endif
  26. NOTEXT = 1
  27. .xlist
  28. include user.inc
  29. .list
  30. sBegin DATA
  31. sEnd
  32. createSeg _TEXT, CODE, WORD, PUBLIC, CODE
  33. sBegin CODE
  34. assumes CS,CODE
  35. assumes DS,DATA
  36. ExternNP Loc_IsConvertibleToUpperCase
  37. ExternNP Loc_Upper
  38. ExternFP IAnsiUpper
  39. ExternFP IAnsiLower
  40. ExternFP Ilstrcmpi
  41. ifdef FE_SB
  42. ExternFP IsDBCSLeadByte
  43. endif
  44. ; Function codes for all the string functions in USER
  45. ;
  46. ANSINEXT_ID equ 1
  47. ANSIPREV_ID equ 2
  48. ANSIUPPER_ID equ 3
  49. ANSILOWER_ID equ 4
  50. ;--------------------------------------------------------------------------
  51. ; The order of entries in the following table can not be changed
  52. ; unless the *_ID codes are also changed in KERNEL also.
  53. ; ((FunctionCode - 1) << 1) is used as the index into this table
  54. ;
  55. ; Function Codes:
  56. ;
  57. ; NOTE: If you change the entries in this table, kindly update the
  58. ; *_ID statements above and also lString.asm of KERNEL.
  59. ;
  60. ;--------------------------------------------------------------------------
  61. LabelW StringFuncTable
  62. dw codeOFFSET IAnsiNext
  63. dw codeOFFSET IAnsiPrev
  64. dw codeOFFSET IAnsiUpper
  65. dw codeOFFSET IAnsiLower
  66. ;*----------------------------------------------------------------------*
  67. ;* StringFunc() *
  68. ;* The string manipulation functions in kernel have been moved *
  69. ;* into USER. *
  70. ;* This is the common entry point in USER for all the string *
  71. ;* manipulation functions Kernel wants to call. Kernel jumps to *
  72. ;* this function with the function code in CX *
  73. ;* *
  74. ;* Input Parameters: *
  75. ;* [CX] contains the Function code. *
  76. ;* [sp] contains the FAR return address of the original caller of *
  77. ;* the string manipulation functions in Kernel *
  78. ;*----------------------------------------------------------------------*
  79. cProc StringFunc, <FAR, PUBLIC>
  80. cBegin nogen
  81. xchg bx,cx ; move function code to BX
  82. dec bx
  83. shl bx, 1
  84. jmp StringFuncTable[bx]
  85. ; Control does not comeback here. It returns directly
  86. ; to the caller
  87. cEnd nogen
  88. ;*----------------------------------------------------------------------*
  89. ;* *
  90. ;* AnsiPrev() *
  91. ;* *
  92. ;*----------------------------------------------------------------------*
  93. ifdef FE_SB
  94. cProc IAnsiPrev,<PUBLIC,FAR>
  95. ; parmD pFirst ; [bx+10] es:di
  96. ; parmD pStr ; [bx+6] ds:si
  97. cBegin nogen
  98. push bp
  99. mov bp,sp
  100. push ds
  101. push si
  102. push di
  103. lds si,[bp+6]
  104. les di,[bp+10]
  105. regptr dssi,ds,si
  106. regptr esdi,es,di
  107. cld
  108. cmp si,di ; pointer to first char?
  109. jz ap5 ; yes, just quit
  110. dec si ; backup once
  111. cmp si,di ; pointer to first char?
  112. jz ap5 ; yse, just quit
  113. ap1:
  114. dec si ; backup once
  115. mov al, [si] ; fetch a character
  116. cCall IsDBCSLeadByte,<ax> ; DBCS lead byte candidate?
  117. test ax,ax ;
  118. jz ap2 ; jump if not.
  119. cmp si,di ; backword exhausted?
  120. jz ap3 ; jump if so
  121. jmp ap1 ; repeat if not
  122. ap2:
  123. inc si ; adjust pointer correctly
  124. ap3:
  125. mov bx, [bp+6] ;
  126. mov di, bx ; result in DI
  127. dec di ;
  128. sub bx, si ; how many characters backworded
  129. test bx, 1 ; see even or odd...
  130. jnz ap4 ; odd - previous char is SBCS
  131. dec di ; make DI for DBCS
  132. ap4:
  133. mov si, di ; final result in SI
  134. ap5:
  135. mov ax,si
  136. mov dx,ds
  137. pop di
  138. pop si
  139. pop ds
  140. pop bp
  141. ret 8
  142. cEnd nogen
  143. else
  144. cProc IAnsiPrev,<PUBLIC,FAR>
  145. ; parmD pFirst ; [bx+8] es:di
  146. ; parmD pStr ; [bx+4] ds:si
  147. cBegin nogen
  148. mov bx,sp
  149. push ds
  150. push si
  151. push di
  152. lds si,ss:[bx+4]
  153. les di,ss:[bx+8]
  154. regptr dssi,ds,si
  155. regptr esdi,es,di
  156. cld
  157. cmp si,di ; pointer to first char?
  158. jz ap3 ; yes, just quit
  159. ;;ifdef FE_SB
  160. ;; xchg si,di
  161. ;;ap1: mov dx,si
  162. ;; lodsb ; get a char
  163. ;; cCall IsDBCSLeadByte,<ax> ; is it kanji?
  164. ;; cmp al,0
  165. ;; je ap2 ; no, get next char
  166. ;; inc si ; yes, inc past second part
  167. ;;ap2: cmp si,di ; have we at or past end?
  168. ;; jb ap1 ; no, keep going
  169. ;; mov si,dx ; return previous pointer
  170. ;;else
  171. dec si ; assume easy case...
  172. ;;endif ; FE_SB
  173. ap3: mov ax,si
  174. mov dx,ds
  175. pop di
  176. pop si
  177. pop ds
  178. ret 8
  179. cEnd nogen
  180. endif
  181. ;*----------------------------------------------------------------------*
  182. ;* *
  183. ;* AnsiNext() *
  184. ;* *
  185. ;*----------------------------------------------------------------------*
  186. cProc IAnsiNext,<PUBLIC,FAR>
  187. ; parmD pStr
  188. cBegin nogen
  189. mov bx,sp
  190. push di
  191. les di,ss:[bx+4]
  192. mov al,es:[di]
  193. or al,al
  194. jz an1
  195. inc di
  196. ifdef FE_SB
  197. cCall IsDBCSLeadByte,<ax>
  198. cmp al,0
  199. je an1
  200. inc di
  201. endif ; FE_SB
  202. an1: mov ax,di
  203. mov dx,es
  204. pop di
  205. ret 4
  206. cEnd nogen
  207. ;-----------------------------------------------------------------------
  208. ; MyAnsiUpper()
  209. ; convert string at es:di to upper case
  210. ;-----------------------------------------------------------------------
  211. public MyAnsiUpper
  212. MyAnsiUpper:
  213. cld
  214. mov si,di
  215. mau1: lods byte ptr es:[si]
  216. ifdef FE_SB
  217. push ax
  218. cCall IsDBCSLeadByte,<ax>
  219. cmp ax,0
  220. pop ax
  221. je mau2
  222. inc si
  223. inc di
  224. inc di
  225. jmp short mau1
  226. endif
  227. mau2: call MyUpper
  228. stosb
  229. or al,al
  230. jnz mau1
  231. ret
  232. ;-----------------------------------------------------------------------
  233. ; MyAnsiLower()
  234. ; convert string at es:di to lower case
  235. ;-----------------------------------------------------------------------
  236. public MyAnsiLower
  237. MyAnsiLower:
  238. cld
  239. mov si,di
  240. mal1: lods byte ptr es:[si]
  241. ifdef FE_SB
  242. push ax
  243. cCall IsDBCSLeadByte,<ax> ; first byte of double byte?
  244. cmp ax,0
  245. pop ax
  246. je mal2 ; no just do normal stuff
  247. inc si ; skip the two bytes
  248. inc di
  249. inc di
  250. jmp short mal1
  251. endif
  252. mal2: call MyLower
  253. stosb
  254. or al,al
  255. jnz mal1
  256. ret
  257. ;-------------------------------------------------------------------------
  258. ; MyUpper()
  259. ; convert lower case to upper, must preserve es,di,cx
  260. ;-------------------------------------------------------------------------
  261. public MyUpper
  262. MyUpper:
  263. call Loc_IsConvertibleToUpperCase ; Check if it is a lower case char
  264. ; that has an uppercase equivalent
  265. jnc myu1 ;
  266. sub al,'a'-'A'
  267. myu1: ret
  268. ifdef KANJI
  269. #################### KANJI ###############################################
  270. ; convert upper case to lower, must preserve es,di,cx
  271. public MyLower
  272. MyLower:
  273. cmp al,'A'
  274. jb myl2
  275. cmp al,'Z'
  276. jbe myl1
  277. push ds
  278. SetKernelDS
  279. cmp [fFarEast],1 ; this is a far east kbd 1/12/87 linsh
  280. pop ds
  281. UnSetKernelDS
  282. jge myl2 ; yes do nothing to the 0C0H - 0DEH range
  283. cmp al,0C0H ; this is lower case a with a back slash
  284. jb myl2
  285. cmp al,0DEH
  286. ja myl2
  287. myl1: add al,'a'-'A'
  288. myl2: ret
  289. #################### KANJI ###############################################
  290. endif
  291. ;--------------------------------------------------------------------------
  292. ; MyLower()
  293. ; convert upper case to lower, must preserve es,di,cx
  294. ;--------------------------------------------------------------------------
  295. public MyLower
  296. MyLower:
  297. call Loc_Upper
  298. jnc myl1
  299. add al, 'a'-'A'
  300. myl1:
  301. ret
  302. sEnd CODE
  303. end