home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v2.zip / DDKX86 / DBCSDD / SRC_DBCS / VDHWNDW / XGASUBAX.INC < prev    next >
Text File  |  1995-04-14  |  32KB  |  746 lines

  1. ;*DDK*************************************************************************/
  2. ;
  3. ; COPYRIGHT (C) Microsoft Corporation, 1989
  4. ; COPYRIGHT    Copyright (C) 1995 IBM Corporation
  5. ;
  6. ;    The following IBM OS/2 WARP source code is provided to you solely for
  7. ;    the purpose of assisting you in your development of OS/2 WARP device
  8. ;    drivers. You may use this code in accordance with the IBM License
  9. ;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
  10. ;    Copyright statement may not be removed.;
  11. ;*****************************************************************************/
  12. ;       SCCSID = @(#)xgasubax.inc        6.1 91/04/26
  13.  
  14. ; ****************************************************************************
  15. ; *                                                                          *
  16. ; *                                                                          *
  17. ; *                                                                          *
  18. ; ****************************************************************************
  19.  
  20. ;********************** START OF SPECIFICATIONS ****************************
  21. ;*                                                                         *
  22. ;* SOURCE FILE NAME:    XGASUBAX.INC                                       *
  23. ;*                                                                         *
  24. ;* DESCRIPTIVE NAME:    BUFFERUPDATE subroutine for DBCS Codepage          *
  25. ;*                                                                         *
  26. ;* COPYRIGHT:   na                                                         *
  27. ;*                                                                         *
  28. ;* STATUS:      OS/2 version 2.0                                           *
  29. ;*                                                                         *
  30. ;* CHANGE HISTORY:                                                         *
  31. ;*                                                                         *
  32. ;* NOTES:       Ring 2 conforming code segment                             *
  33. ;*                                                                         *
  34. ;*    DEPENDENCIES:     None                                               *
  35. ;*                                                                         *
  36. ;*    RESTRICTIONS:     None                                               *
  37. ;*                                                                         *
  38. ;*    PATH LABEL:       na                                                 *
  39. ;*                                                                         *
  40. ;* ENTRY POINTS:
  41. ;*                                                                         *
  42. ;*                                                                         *
  43. ;* EXTERNAL REFERENCES: included XGASUBAX.ASM                              *
  44. ;*                                                                         *
  45. ;********************** END OF SPECIFICATIONS ******************************
  46.  
  47.  
  48.  
  49.  
  50. ;Entry
  51. ;  ds:si - user cells pointer
  52. ;  es:di - LVB pointer
  53. ;  cx    - cell length (in byte)
  54.  
  55.  
  56. UBCellToLVB1    PROC
  57.         public  UBCellToLVB1
  58.  
  59. ; check to see whether we are about to overwrite to a trailing byte
  60. ; and if so, erase preceding lead byte.
  61.         Erase1x
  62.  
  63.         shr     cx,1                    ; convert bytes to number of cell
  64.         xor     dx,dx                   ; clear DH for use as flag in loop
  65.  
  66. ; write cells.
  67.         .repeat
  68.             mov     bx,word ptr es:[di] ; Save for restoring the previous ;@A00
  69.                                         ; cp & attr#1 for tail exception  ;@A00
  70.             lodsw                       ; AL = char, AH = 1st attribute
  71.             stosw                       ; write char and 1st attribute
  72.             push    ds                  ; save source selector
  73.             mov     ds,[bp].j_dbcslvbsel; use DBCS flag LVB
  74.             xor     ah,ah               ; ignore attr#2(including lcid),  ;@A01
  75.                                         ; which means using a default     ;@A01
  76.                                         ; dbcs env. vector.               ;@A01
  77.             SetSystemByte               ; AH = system byte
  78.             mov     byte ptr ds:[di-1],ah       ; store system byte
  79.             pop     ds                  ; restore source selector
  80.         .loop
  81.  
  82. ; Check to see if the last char written was a lead byte, if so, erase
  83.         .if     <bit dh and 1>          ; last char copied was lead byte
  84.             push    ds                  ; save source selector
  85.             mov     ds,[bp].j_dbcslvbsel; use DBCS flag LVB
  86. ;@A00       mov     byte ptr es:[di-2],CharBlank
  87. ;@A00                                   ; write a blank into the last character
  88. ;@A00       mov     byte ptr ds:[di-1],SBCS_BYTE
  89. ;@A00                                   ; clear system byte
  90.             mov     word ptr es:[di-2],bx ; Undo                          ;@A00
  91.             shl     dh,1                                                  ;@A00
  92.             pop     ds                  ; restore source selector
  93.         .endif
  94.  
  95. ; Check if next cell contains a trail byte, if so, erase
  96.         .if     <dh ne 2>               ; When dbcs 1st has been ignored, ;@A00
  97.                                         ; forget the exception handling.  ;@A00
  98.             Erase2x
  99.         .endif                                                            ;@A00
  100.  
  101.         ret
  102. UBCellToLVB1    ENDP
  103.  
  104.  
  105. ;Entry
  106. ;  ds:si - user chars pointer
  107. ;  es:di - LVB pointer
  108. ;  cx    - char length (in byte)
  109.  
  110. UBCharToLVB1    PROC
  111.         public  UBCharToLVB1
  112.  
  113. ; check to see whether we are about to overwrite to a trailing byte
  114. ; and if so, erase preceding lead byte.
  115.         Erase1x
  116.  
  117.         xor     dx,dx                   ; clear DH for use as flag in loop
  118.  
  119. ; write characters
  120.         .repeat
  121.             mov     bl,byte ptr es:[di] ; Save for restoring the previous ;@A01
  122.             lodsb                       ; copy char
  123.             stosb
  124.             push    ds                  ; save source selector
  125.             mov     ds,[bp].j_dbcslvbsel; use DBCS flag LVB
  126.             xor     ah,ah               ; ignore attr#2(including lcid),  ;@A01
  127.                                         ; which means using a default     ;@A01
  128.                                         ; dbcs env. vector.               ;@A01
  129.             SetSystemByte               ; AH = system byte
  130.             mov     byte ptr ds:[di],ah ; store system byte
  131.             pop     ds                  ; restore source selector
  132.             inc     di                  ; skip 1st attribute
  133.         .loop
  134.  
  135. ; Check to see if the last char written was a lead byte, if so, erase
  136.         .if     <bit dh and 1>          ; last char copied was lead byte
  137.             push    ds                  ; save source selector
  138.             mov     ds,[bp].j_dbcslvbsel; use DBCS flag LVB
  139. ;@A01       mov     byte ptr es:[di-2],CharBlank
  140. ;@A01                                   ; write a blank into the last character
  141. ;@A01       mov     byte ptr ds:[di-1],SBCS_BYTE
  142. ;@A01                                   ; clear system byte
  143.             mov     byte ptr es:[di-2],bl ; undo ; restore the prev. cp.  ;@A01
  144.             shl     dh,1                                                  ;@A01
  145.             pop     ds                  ; restore source selector
  146.         .endif
  147.  
  148. ; Check if next cell contains a trail byte, if so, erase
  149.         .if     <dh ne 2>               ; When dbcs 1st has been ignored, ;@A00
  150.                                         ; forget the exception handling.  ;@A00
  151.             Erase2x
  152.         .endif                                                            ;@A00
  153.  
  154.         ret
  155. UBCharToLVB1    ENDP
  156.  
  157.  
  158. ;Entry
  159. ;  ah    - 1st attribute
  160. ;  dl    - 2nd attribute (if WorldFormat)
  161. ;  dh    - system byte   (if WorldFormat)
  162. ;  ds:si - user chars pointer
  163. ;  es:di - LVB pointer
  164. ;  cx    - char length (in byte)
  165.  
  166. UBCharAttToLVB1 PROC
  167.         public  UBCharAttToLVB1
  168.  
  169. ; check to see whether we are about to overwrite to a trailing byte
  170. ; and if so, erase preceding lead byte.
  171.         Erase1x
  172.  
  173.         mov     bl,ah                   ; BL = 1st attribute
  174.         xor     dx,dx                   ; clear DH for use as flag in loop
  175.  
  176. ; write characters and attributes
  177.         .repeat
  178.             mov     ax,word ptr es:[di]              ; save for retrieve ;@A01
  179.             mov     word ptr [bp].wSaveCpAttr1,ax                        ;@A01
  180.             lodsb                       ; char = AL
  181.             mov     ah,bl               ; AH = first attribute
  182.             stosw                       ; write char and 1st attribute
  183.             push    ds                  ; save source selector
  184.             mov     ds,[bp].j_dbcslvbsel; use DBCS flag LVB
  185.             xor     ah,ah               ; ignore attr#2(including lcid),  ;@A01
  186.                                         ; which means using a default     ;@A01
  187.                                         ; dbcs env. vector.               ;@A01
  188.             SetSystemByte               ; AH = system byte
  189.             mov     byte ptr ds:[di-1],ah       ; store system byte
  190.             pop     ds                  ; restore source selector
  191.         .loop
  192.  
  193. ; Check to see if the last char written was a lead byte, if so, erase
  194.         .if     <bit dh and 1>          ; last char copied was lead byte
  195.             push    ds                  ; save source selector
  196.             mov     ds,[bp].j_dbcslvbsel; use DBCS flag LVB
  197. ;@A01       mov     byte ptr es:[di-2],CharBlank
  198. ;@A01                                   ; write a blank into the last character
  199. ;@A01       mov     byte ptr ds:[di-1],SBCS_BYTE
  200. ;@A01                                   ; clear system byte
  201.  
  202.             .if     <bit <word ptr [bp].shadow_Flags> and CGAAttr>       ;@A03
  203.                 mov     byte ptr es:[di-2],CharBlank                     ;@A03
  204.                                             ; write a blank at           ;@A03
  205.                                             ; the last character         ;@A03
  206.                                                                          ;@A03
  207. ;@A04           mov     byte ptr es:[di-1],SBCS_BYTE                     ;@A03
  208.                 and     byte ptr es:[di-1],NOT DBCSFlag+TrailByteFlag    ;@A04
  209.                                             ; clear system byte          ;@A03
  210.             .else                                                        ;@A03
  211.                 mov     ax,word ptr [bp].wSaveCpAttr1    ; retrieve      ;@A01
  212.                 mov     word ptr es:[di-2],ax                            ;@A01
  213.                 shl     dh,1                                             ;@A01
  214.             .endif                                                       ;@A03
  215.             pop     ds                  ; restore source selector
  216.         .endif
  217.  
  218. ; Check if next cell contains a trail byte, if so, erase
  219.         .if     <dh ne 2>               ; When dbcs 1st has been ignored, ;@A00
  220.                                         ; forget the exception handling.  ;@A00
  221.             Erase2x
  222.         .endif                                                            ;@A00
  223.  
  224.         ret
  225. UBCharAttToLVB1 ENDP
  226.  
  227.  
  228.  
  229. ;Entry
  230. ;  al    - leading character or SBCS character
  231. ;  ah    - trailing character
  232. ;  es:di - LVB pointer
  233. ;  cx    - char count
  234.  
  235. UBNCharToLVB1   PROC
  236.         public  UBNCharToLVB1
  237.  
  238. ; check to see whether we are about to overwrite to a trailing byte
  239. ; and if so, erase preceding lead byte.
  240.         Erase1x
  241.  
  242.         xor     dx,dx                   ; clear DX (system byte)
  243.  
  244. ; branch by DBCS character or SBCS character
  245.         push    ax                      ; keep ah(trailing byte)
  246.         xor     ah,ah                   ; can ignore lcid because of
  247.                                         ; char code only
  248.         push    ds
  249.         push    si
  250.         lds     si,[bp].lpNLSExt
  251.         CheckLeadByte                   ; is it leading byte?
  252.         pop     si
  253.         pop     ds
  254.         pop     ax
  255.  
  256. ; write DBCS characters
  257.         .if     <c>                     ; yes
  258.             mov     dl,DBCSFlag         ; system byte
  259.             mov     dh,TrailByteFlag OR DBCSFlag
  260.             push    ds                  ; save source selector
  261.             mov     ds,[bp].j_dbcslvbsel; use DBCS flag LVB
  262.             shr     cx,1                ; CX = a pair of lead and trail byte
  263.             pushf                       ; save frag whether DBCS bisect
  264.             jcxz    @F                  ; 1990-08-02 updated
  265.                                         ;     fix for starting from max point
  266.             .repeat
  267.                 stosb                           ; copy leading character
  268.                 mov     byte ptr ds:[di],dl     ; store leading system byte
  269.                 inc     di
  270.                 xchg    ah,al                   ; flip lead/trail char
  271.                 stosb                           ; copy trailing character
  272.                 mov     byte ptr ds:[di],dh     ; store trailing system byte
  273.                 inc     di
  274.                 xchg    ah,al                   ; flip lead/trail char
  275.             .loop
  276.  
  277. ; if the char count cause DBCS bisecting, store blank character
  278. @@:                                     ; 1990-08-02 updated
  279.                                         ;     fix for starting from max point
  280.             popf                        ; restore frag whether DBCS bisect
  281.             .if     <c>                 ; last char is pointed to lead byte
  282.                 mov     al,CharBlank    ; last character is blank
  283.                 stosb                   ; copy blank character
  284. ;@A04           mov     byte ptr ds:[di],SBCS_BYTE      ; store system byte
  285.                 and     byte ptr ds:[di],NOT DBCSFlag+TrailByteFlag     ;@A04
  286.                 inc     di
  287.             .endif
  288.             pop     ds                  ; restore source selector
  289.  
  290. ; write SBCS characters
  291.         .else short                     ; no
  292.             push    ds                  ; save source selector
  293.             mov     ds,[bp].j_dbcslvbsel; use DBCS flag LVB
  294.             .repeat
  295.                 stosb                           ; copy char
  296.                 mov     byte ptr ds:[di],dl     ; store system byte
  297.                 inc     di
  298.             .loop
  299.             pop     ds                  ; restore source selector
  300.         .endif
  301.  
  302. ; Check if next cell contains a trail byte, if so, erase
  303.         Erase2x
  304.  
  305.         ret
  306. UBNCharToLVB1   ENDP
  307.  
  308.  
  309. ;Entry
  310. ;  al    - 1st attribute
  311. ;  ds:si - 2nd attribute pointer
  312. ;  es:di - LVB pointer
  313. ;  cx    - attr count
  314.  
  315.  
  316. UBNAttToLVB1    PROC NEAR
  317.         public  UBNAttToLVB1
  318.  
  319. ; write attributes
  320.         .repeat
  321.             inc     di                  ; skip character
  322.             stosb                       ; copy attribute
  323.         .loop
  324.  
  325.         ret
  326. UBNAttToLVB1    ENDP
  327.  
  328.  
  329. ;Entry
  330. ;  al    - character
  331. ;  ah    - 1st attribute
  332. ;  ds:si - Trailing byte character or 2nd attribute pointer
  333. ;  es:di - LVB pointer
  334. ;  cx    - cell count
  335.  
  336.  
  337. UBNCellToLVB1   PROC
  338.         public  UBNCellToLVB1
  339.  
  340. ; check to see whether we are about to overwrite to a trailing byte
  341. ; and if so, erase preceding lead byte.
  342.         Erase1x
  343.  
  344.         xor     dx,dx                   ; clear DX (system byte)
  345.  
  346. ; branch by DBCS character or SBCS character
  347.         push    ax                      ; keep ah(trailing byte)
  348.         xor     ah,ah                   ; Don't need lcid check ;@AN01
  349.         push    ds
  350.         push    si
  351.         lds     si,[bp].lpNLSExt
  352.         CheckLeadByte                   ; is it leading byte?
  353.         pop     si
  354.         pop     ds
  355.         pop     ax
  356.  
  357. ; write DBCS cells
  358.         .if     <c>                     ; yes
  359.             xchg    ax,bx               ; BX = Leading Byte
  360.             mov     dl,DBCSFlag         ; system byte
  361.             mov     dh,TrailByteFlag OR DBCSFlag
  362.             lodsw                       ; AX = Trailing Byte
  363.             push    ds                  ; save source selector
  364.             mov     ds,[bp].j_dbcslvbsel; use DBCS flag LVB
  365.             shr     cx,1                ; CX = a pair of lead and trail byte
  366.             pushf                       ; save frag whether DBCS bisect
  367.             jcxz    @F                  ; 1990-08-02 updated
  368.                                         ;     fix for starting from max point
  369.             .repeat
  370.                 xchg    ax,bx                   ; flip trail/lead byte
  371.                 stosw                           ; copy leading char and 1st attr
  372.                 mov     byte ptr ds:[di-1],dl   ; store leading system byte
  373.                 xchg    ax,bx                   ; flip lead/trail byte
  374.                 stosw                           ; copy trailing char and 1st attr
  375.                 mov     byte ptr ds:[di-1],dh   ; store trailing system byte
  376.             .loop
  377.  
  378. ; if the cell count cause DBCS bisecting, store attribute only.
  379. @@:                                     ; 1990-08-02 updated
  380.                                         ;     fix for starting from max point
  381.             popf                        ; restore frag whether DBCS bisect
  382.             .if     <c>                 ; last cell is pointed to lead byte
  383.                 mov     al,CharBlank    ; last character is blank
  384.                 mov     ah,bh           ; last attribute is leading it
  385.                 stosw                   ; copy char and 1st attr
  386. ;@A04           mov     byte ptr ds:[di-1],SBCS_BYTE
  387.                 and     byte ptr ds:[di-1],NOT DBCSFlag+TrailByteFlag   ;@A04
  388.                                         ; store and system byte
  389.             .endif
  390.             pop     ds                  ; restore source selector
  391.  
  392. ; write SBCS characters
  393.         .else short                     ; no
  394.             push    ds                  ; save source selector
  395.             mov     ds,[bp].j_dbcslvbsel; use DBCS flag LVB
  396.             .repeat
  397.                 stosw                           ; copy char and 1st attr
  398.                 mov     byte ptr ds:[di-1],dh   ; store system byte
  399.             .loop
  400.             pop     ds                  ; restore source selector
  401.         .endif
  402.  
  403. ; Check if next cell contains a trail byte, if so, erase
  404.         Erase2x
  405.  
  406.         ret
  407. UBNCellToLVB1   ENDP
  408.  
  409.  
  410. ;Entry
  411. ;  ds:si - LVB pointer
  412. ;  es:di - user buffer pointer
  413. ;  cx    - char length (in byte)
  414.  
  415.  
  416. LVBCharToUB1    PROC
  417.         public  LVBCharToUB1
  418.  
  419. ; Check if first cell to copy contains a trail byte, if so, erase
  420.         mov     al,byte ptr [si]        ; AL = first character
  421.         Erase5x                         ; replace AL by blank if trail byte
  422.         dec     cx                      ; count down this character
  423.  
  424.         .if     <ncxz>                  ; branch if only 1 char total
  425.             stosb                       ; store character
  426.             add     si,2                ; skip 2 attributes
  427.             jmp short @F                ; jump into loop to do cx-1 iterations
  428.  
  429.             .repeat
  430.                 movsb                   ; copy character
  431.                 inc     si              ; skip 1 attribute
  432. @@:
  433.             .loop
  434.  
  435. ; Check if last cell to copy contains lead byte, if so, erase
  436. ; We check the source before copy, as then the following trail byte
  437. ; is still attached and we can use the system byte TrailByteFlag to check.
  438.             mov al,[si]                 ; last character
  439.         .endif
  440.         Erase6x                         ; replace AL by blank if lead byte
  441.         stosb                           ; store character
  442.  
  443.         ret
  444. LVBCharToUB1    ENDP
  445.  
  446.  
  447. ;Entry
  448. ;  ds:si - LVB pointer
  449. ;  es:di - user buffer pointer
  450. ;  cx    - cell length (in byte) / 2
  451.  
  452.  
  453. LVBCellToUB1    PROC
  454.         public  LVBCellToUB1
  455.  
  456. ; Check if first cell to copy contains a trail byte, if so, erase
  457.         mov     ax,[si]                 ; AL = first char, AH = first attr
  458.         Erase5x                         ; replace AL by blank if trail byte
  459.         dec     cx                      ; count down this cell
  460.  
  461.         .if     <ncxz>                  ; branch if this only cell to copy
  462.             stosw                       ; store character and attribute
  463.             add     si,2                ; skip first cell
  464.             jmp short @F                ; do cx-1 iterations
  465.  
  466.             .repeat
  467.                 movsw                   ; copy character and attribute
  468. @@:
  469.             .loop
  470.  
  471. ; Check if last cell to copy contains lead byte, if so, erase
  472. ; We check the source before copy, as then the following trail byte
  473. ; is still attached and we can use the system byte TrailByteFlag to check.
  474.             mov     ax,[si]             ; last cell
  475.         .endif
  476.         Erase6x                         ; replace AL by blank if lead byte
  477.         stosw                           ; store character and attribute
  478.  
  479.         ret
  480. LVBCellToUB1    ENDP
  481.  
  482.  
  483. ;Entry
  484. ;  ds:si - source LVB pointer
  485. ;  es:di - destination LVB pointer
  486. ;  cx    - cell length (in byte) / 2
  487. ;  dx    - reserved
  488.  
  489.  
  490. LVBCellToLVB1I  PROC NEAR
  491.         public  LVBCellToLVB1I
  492.  
  493. ; Check if first source cell to copy contains a trail byte
  494. ; and if so, erase this DBCS character.
  495.         push    es                      ; save dest sel
  496.         mov     es,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  497.         .if     <si ae 2> and
  498.         .if     <bit <byte ptr es:[si+1]> and TrailByteFlag>
  499.             mov     byte ptr ds:[si],CharBlank
  500.                                         ; copy blank into this trailing char
  501. ;@A04       mov     byte ptr es:[si+1],SBCS_BYTE
  502.             and     byte ptr es:[si+1],NOT DBCSFlag+TrailByteFlag       ;@A04
  503.                                         ; and clear trailing bit
  504.             mov     byte ptr ds:[si-2],CharBlank
  505.                                         ; copy blank into this leading char
  506. ;@A04       mov     byte ptr es:[si-1],SBCS_BYTE
  507.             and     byte ptr es:[si-1],NOT DBCSFlag+TrailByteFlag       ;@A04
  508.                                         ; and clear leading bit
  509.             or      [bp].j_dbcsstatus,BisectDBCS_LEFT
  510.         .endif
  511.         pop     es                      ; restore dest sel
  512.  
  513. ; check to see whether we are about to overwrite to a trailing byte
  514. ; and if so, erase preceding lead byte.
  515.         push    ds                      ; save src sel
  516.         mov     ds,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  517.         .if     <di ae 2 > and
  518.         .if     <bit <byte ptr ds:[di+1]> and TrailByteFlag>
  519.             mov     byte ptr es:[di-2],CharBlank
  520.                                         ; copy blank into this leading char
  521. ;@A04       mov     byte ptr ds:[di-1],SBCS_BYTE
  522.             and     byte ptr ds:[di-1],NOT DBCSFlag+TrailByteFlag       ;@A04
  523.  
  524.                                         ; and clear leading bit
  525.             or      [bp].j_dbcsstatus,BisectDBCS_LEFT
  526.         .endif
  527.         pop     ds                      ; restore src sel
  528.  
  529. ; move cells and DBCS flags
  530.         push    si
  531.         push    di
  532.         push    cx
  533.         rep     movsw                   ; copy all remaining cells
  534.         pop     cx
  535.         pop     di
  536.         pop     si
  537.  
  538.         push    ds
  539.         push    es
  540.         mov     ds,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  541.         mov     es,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  542.         rep     movsw                   ; copy all remaining DBCS flags
  543.         pop     es
  544.         pop     ds
  545.  
  546. ; Check if last source cell to copy contains a lead byte
  547. ; and if so, erase this DBCS character and leading character stored.
  548.         push    es                      ; save dest sel
  549.         mov     es,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  550.         .if     <si b [bp].j_lvbsize> and
  551.         .if     <bit <byte ptr es:[si+1]> and TrailByteFlag>
  552.             mov     byte ptr ds:[si],CharBlank
  553.                                         ; copy blank into this trailing char
  554. ;@A04       mov     byte ptr es:[si+1],SBCS_BYTE
  555.             and     byte ptr es:[si+1],NOT DBCSFlag+TrailByteFlag       ;@A04
  556.                                         ; and clear trailing bit
  557.             mov     byte ptr ds:[si-2],CharBlank
  558.                                         ; copy blank into this leading char
  559. ;@A04       mov     byte ptr es:[si-1],SBCS_BYTE
  560.             and     byte ptr es:[si-1],NOT DBCSFlag+TrailByteFlag       ;@A04
  561.                                         ; and clear leading bit
  562. ;@A04       mov     byte ptr es:[di-1],SBCS_BYTE
  563.             and     byte ptr es:[di-1],NOT DBCSFlag+TrailByteFlag       ;@A04
  564.                                         ; and clear stored leading bit
  565.             pop     es                  ; restore dest sel
  566.             mov     byte ptr es:[di-2],CharBlank
  567.                                         ; copy blank into stored leading char
  568.             push    es                  ; for adjust stack
  569.             or      [bp].j_dbcsstatus,BisectDBCS_RIGHT
  570.         .endif
  571.         pop     es                      ; restore dest sel
  572.  
  573. ; Check if next destination cell contains a trail byte, if so, erase
  574.         push    ds                      ; save src sel
  575.         mov     ds,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  576.         .if     <di b [bp].j_lvbsize> and
  577.         .if     <bit <byte ptr ds:[di+1]> and TrailByteFlag>
  578.             mov     byte ptr es:[di],CharBlank
  579.                                         ; copy blank into this trailing char
  580. ;@A04       mov     byte ptr ds:[di+1],SBCS_BYTE
  581.             and     byte ptr ds:[di+1],NOT DBCSFlag+TrailByteFlag       ;@A04
  582.                                         ; and clear trailing bit
  583.             or      [bp].j_dbcsstatus,BisectDBCS_RIGHT
  584.         .endif
  585.         pop     ds                      ; restore src sel
  586.  
  587.         ret
  588. LVBCellToLVB1I  ENDP
  589.  
  590.  
  591. ;Entry
  592. ;  ds:si - source LVB pointer
  593. ;  es:di - destination pointer
  594. ;  cx    - cell length (in byte) / 2
  595. ;  dx    - reserved
  596.  
  597.  
  598. LVBCellToLVB1D  PROC
  599.         public  LVBCellToLVB1D
  600.  
  601. ; calculate the valid last cell pointer
  602.         mov     ax,[bp].j_lvbsize
  603.         .if     <ax eq 0FFFFh>          ; 64KB on AVIO
  604.             sub     ax,1
  605.         .else
  606.             sub     ax,2
  607.         .endif
  608.         push    ax                      ; save valid last cell pointer
  609.  
  610. ; Check if first source cell to copy contains a lead byte
  611. ; and if so, erase this DBCS character.
  612.         push    es                      ; save dest sel
  613.         mov     es,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  614.         .if     <si b ax> and
  615.         .if     <bit <byte ptr es:[si+3]> and TrailByteFlag>
  616.             mov     byte ptr ds:[si],CharBlank
  617.                                         ; copy blank into this leading char
  618. ;@A04       mov     byte ptr es:[si+1],SBCS_BYTE
  619.             and     byte ptr es:[si+1],NOT DBCSFlag+TrailByteFlag       ;@A04
  620.                                         ; and clear leading bit
  621.             mov     byte ptr ds:[si+2],CharBlank
  622.                                         ; copy blank into this trailing char
  623. ;@A04       mov     byte ptr es:[si+3],SBCS_BYTE
  624.             and     byte ptr es:[si+3],NOT DBCSFlag+TrailByteFlag       ;@A04
  625.                                         ; and clear trailing bit
  626.             or      [bp].j_dbcsstatus,BisectDBCS_RIGHT
  627.         .endif
  628.         pop     es                      ; restore dest sel
  629.  
  630. ; check to see whether we are about to overwrite to a leading byte
  631. ; and if so, erase next trail byte.
  632.         pop     ax                      ; restore valid last cell pointer
  633.         push    ds                      ; save src sel
  634.         mov     ds,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  635.         .if     <di b ax > and
  636.         .if     <bit <byte ptr ds:[di+3]> and TrailByteFlag>
  637.             mov     byte ptr es:[di+2],CharBlank
  638.                                         ; copy blank into this leading char
  639. ;@A04       mov     byte ptr ds:[di+3],SBCS_BYTE
  640.             and     byte ptr ds:[di+3],NOT DBCSFlag+TrailByteFlag       ;@A04
  641.                                         ; and clear leading bit
  642.             or      [bp].j_dbcsstatus,BisectDBCS_RIGHT
  643.         .endif
  644.         pop     ds                      ; restore src sel
  645.  
  646. ; move cells and DBCS flags
  647.         push    si
  648.         push    di
  649.         push    cx
  650.         rep     movsw                   ; copy all remaining cells
  651.         pop     cx
  652.         pop     di
  653.         pop     si
  654.  
  655.         push    ds
  656.         push    es
  657.         mov     ds,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  658.         mov     es,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  659.         rep     movsw                   ; copy all remaining DBCS flags
  660.         pop     es
  661.         pop     ds
  662.  
  663. ; Check if last source cell to copy contains a trail byte
  664. ; and if so, erase this DBCS character and trailing character stored.
  665.         push    es                      ; save dest sel
  666.         mov     es,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  667.         .if     <si ge 0> and
  668.         mov     al,byte ptr es:[si+1]
  669.         and     al,(TrailByteFlag or DBCSFlag)
  670.         .if     <al eq DBCSFlag>
  671.             mov     byte ptr ds:[si],CharBlank
  672.                                         ; copy blank into this leading char
  673. ;@A04       mov     byte ptr es:[si+1],SBCS_BYTE
  674.             and     byte ptr es:[si+1],NOT DBCSFlag+TrailByteFlag       ;@A04
  675.                                         ; and clear leading bit
  676.             mov     byte ptr ds:[si+2],CharBlank
  677.                                         ; copy blank into this trailing char
  678. ;@A04       mov     byte ptr es:[si+3],SBCS_BYTE
  679.             and     byte ptr es:[si+3],NOT DBCSFlag+TrailByteFlag       ;@A04
  680.                                         ; and clear trailing bit
  681. ;@A04       mov     byte ptr es:[di+3],SBCS_BYTE
  682.             and     byte ptr es:[di+3],NOT DBCSFlag+TrailByteFlag       ;@A04
  683.                                         ; and clear stored trailing bit
  684.             pop     es                  ; restore dest sel
  685.             mov     byte ptr es:[di+2],CharBlank
  686.                                         ; copy blank into stored trailing char
  687.             push    es                  ; for adjust stack
  688.             or      [bp].j_dbcsstatus,BisectDBCS_LEFT
  689.         .endif
  690.         pop     es                      ; restore dest sel
  691.  
  692. ; Check if next destination cell contains a lead byte, if so, erase
  693.         push    ds                      ; save src sel
  694.         mov     ds,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  695.         .if     <di ge 0> and
  696.         mov     al,byte ptr ds:[di+1]
  697.         and     al,(TrailByteFlag or DBCSFlag)
  698.         .if     <al eq DBCSFlag>
  699.             mov     byte ptr es:[di],CharBlank
  700.                                         ; copy blank into this leading char
  701. ;@A04       mov     byte ptr ds:[di+1],SBCS_BYTE
  702.             and     byte ptr ds:[di+1],NOT DBCSFlag+TrailByteFlag       ;@A04
  703.                                         ; and clear trailing bit
  704.             or      [bp].j_dbcsstatus,BisectDBCS_LEFT
  705.         .endif
  706.         pop     ds                      ; restore src sel
  707.  
  708.         ret
  709. LVBCellToLVB1D  ENDP
  710.  
  711.  
  712. ; support CheckCharType of DBCS
  713. ;Entry
  714. ;  ds:si - LVB pointer
  715. ;  es:di - user buffer pointer
  716.  
  717. TypeSBCS        equ     0
  718. TypeDBCSLead    equ     2
  719. TypeDBCSTrail   equ     3
  720.  
  721.  
  722. LVBCharTypeToUB1 PROC
  723.         public  LVBCharTypeToUB1
  724.  
  725.         push    ds                      ; save src sel
  726.         mov     ds,[bp].j_dbcslvbsel    ; use DBCS flag LVB
  727.         mov     ah,byte ptr ds:[si+1]   ; get DBCS flag
  728.         pop     ds                      ; restore src sel
  729.         and     ah,(TrailByteFlag or DBCSFlag)
  730.                                         ; mask
  731.  
  732.         mov     al,TypeSBCS             ; default SBCS
  733.         .if     <ah eq DBCSFlag>
  734.             mov     al,TypeDBCSLead     ; leading byte
  735.         .elseif <ah eq <TrailByteFlag or DBCSFlag>>
  736.             mov     al,TypeDBCSTrail    ; trailing byte
  737.         .endif
  738.  
  739.         xor     ah,ah
  740.         stosw                           ; store character type
  741.  
  742.         ret
  743. LVBCharTypeToUB1        ENDP
  744.  
  745. ;@AN01 12Feb92 AN jc20 js02683
  746.