home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / VDH / WDHWRITE.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  23KB  |  578 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.         PAGE    60,132
  13.         TITLE   WDHWRITE.ASM -- Buffer Write Routines for Windowable sessions
  14.  
  15. ;/*****************************************************************************
  16. ;*
  17. ;* SOURCE FILE NAME = WDHWRITE.ASM
  18. ;*
  19. ;* DESCRIPTIVE NAME = BUFFERUPDATE write routines
  20. ;*
  21. ;*
  22. ;* VERSION      V2.0
  23. ;*
  24. ;* DATE
  25. ;*
  26. ;* DESCRIPTION  Buffer Write Routines for Windowable sessions
  27. ;*
  28. ;* FUNCTIONS    WriteCellStr, WriteCharStr, WriteCharStrAttr,
  29. ;*              WriteNChar, WriteNAttr, WriteNCell
  30. ;*
  31. ;* NOTES        NONE
  32. ;*
  33. ;* STRUCTURES   NONE
  34. ;*
  35. ;* EXTERNAL REFERENCES  LocateBuffAddr           (in WDHREAD.ASM)
  36. ;*
  37. ;* EXTERNAL FUNCTIONS
  38. ;*
  39. ;*              NONE
  40. ;*
  41. ;* CHANGE ACTIVIY =
  42. ;*   DATE      FLAG       APAR    CHANGE DESCRIPTION
  43. ;*   --------  ---------- -----   --------------------------------------
  44. ;*   mm/dd/yy  @Vr.mpppxx xxxxx   xxxxxxx
  45. ;*   09/14/94  @95837             WKB, pmwinp.inc -> pmwinx.inc
  46. ;****************************************************************************/
  47.  
  48.         .286c                                     ; 286 protect mode instructions
  49.  
  50.         .xlist
  51.         include pmwinx.inc                        ; @95837
  52.         include pmaviop.inc
  53.  
  54.         INCLUDE struc.inc                         ; Structure macro
  55.         INCLUDE error2.inc                        ; Subsystem error equates
  56.         INCLUDE vdhstruc.inc                      ; Buffer update data structures
  57.         INCLUDE vdhequ.inc                        ; Buffer update equates
  58.         .list
  59.  
  60.         EXTRN   LocateBuffAddr:NEAR               ; Determine target/source buffer
  61.  
  62. R2CSEG  SEGMENT WORD    PUBLIC 'CODE'
  63.         ASSUME  CS:R2CSEG,DS:NOTHING,ES:NOTHING
  64.  
  65. ;/****************************************************************************
  66. ;*
  67. ;* SUBROUTINE NAME:     WriteCellStr
  68. ;*
  69. ;* DESCRIPTIVE NAME:    Video device handler write cells
  70. ;*
  71. ;* FUNCTION:    Process write cells sub-function.
  72. ;*              The cells are written to the LVB and/or PVB
  73. ;*              starting at the specified row, column location.
  74. ;*              Line wrap occurs if the end of a line is reached.
  75. ;*              Write function is terminated if the end of PVB or
  76. ;*              LVB is reached.  The number of the char/attr cells
  77. ;*              written is returned in the RepeatFactor field of
  78. ;*              the paramter block.
  79. ;*
  80. ;* ENTRY POINT: WriteCellStr
  81. ;*   LINKAGE:   Near Call from BUFFERUPDATE routine
  82. ;*
  83. ;* INPUT:
  84. ;*
  85. ;* SS:BP  --->  Stack frame                        (see VDHSTRUC.INC)
  86. ;* DS:SI  --->  Parameter block buffer            (see WDHBUFUP.ASM)
  87. ;* ES:DI  --->  Mode data in environment buffer (see WDHBUFUP.ASM)
  88. ;*
  89. ;* PARAMETER BLOCK FORMAT:
  90. ;*
  91. ;*   SIZE   DESCRIPTION
  92. ;*   ----   -----------
  93. ;*
  94. ;*   WORD   Parameter length
  95. ;*   WORD   Flags                                      (target data buffer - LVB, PVB)
  96. ;*   DWORD  Application data address  (source data buffer)
  97. ;*   DWORD  Application data2 address (not used in this call)
  98. ;*   WORD   Index (7)
  99. ;*   WORD   Starting row                               (target row)
  100. ;*   WORD   Starting column                            (target column)
  101. ;*   WORD   Secondary row                              (not used in this call)
  102. ;*   WORD   Secondary column                           (not used in this call)
  103. ;*   WORD   RepeatFactor                               (input and output length)
  104. ;*   WORD   LogicalBufSel
  105. ;*
  106. ;* OUTPUT:      LVB and/or PVB = new attributes
  107. ;*              RepeatFactor = sum of char/attr pairs written
  108. ;*
  109. ;* EXIT-NORMAL: AX = 0
  110. ;*
  111. ;* EXIT-ERROR:  AX = Error from LocateBuffAddr
  112. ;*
  113. ;* EFFECTS:     All
  114. ;*
  115. ;* INTERNAL REFERENCES: None
  116. ;*
  117. ;* EXTERNAL REFERENCES: LocateBuffAddr            (in VDHREAD.ASM)
  118. ;*
  119. ;****************************************************************************/
  120.  
  121.         PUBLIC  WriteCellStr
  122. WriteCellStr PROC NEAR
  123.  
  124.         mov     bx, 1                             ; Set indicator for word move
  125.         call    LocateBuffAddr                    ; On exit: BX = sel, AX = off
  126.         .if     <nc>                              ; Continue?
  127.             shr     cx, 1                         ; Adjust for word move
  128.             lds     si, [si].AppDataAddr          ; Setup source address
  129.             mov     es, bx                        ; Setup destination selector
  130.             mov     di, ax                        ; Setup destination offset
  131.             rep     movsw                         ; Copy cell from DS:SI to ES:DI
  132.             sub     ax, ax                        ; Clear return code
  133.         .endif                                    ; 
  134.         ret                                       ; 
  135.  
  136. WriteCellStr ENDP
  137.  
  138. ;/****************************************************************************
  139. ;*
  140. ;* SUBROUTINE NAME:     WriteCharStr
  141. ;*
  142. ;* DESCRIPTIVE NAME:    Video device handler write characters
  143. ;*
  144. ;* FUNCTION:    Process write characters sub-function.
  145. ;*              The characters are read from a user supplied
  146. ;*              buffer which to be placed starting a the
  147. ;*              specified row, column location within the PVB
  148. ;*              and/or LVB.  Line wrap occurs if the end of a
  149. ;*              line is reached.  Write function is terminated
  150. ;*              if the end of PVB or LVB is reached.  The number
  151. ;*              of characters written is returned in the
  152. ;*              RepeatFacter field of the parameter block.
  153. ;*
  154. ;* ENTRY POINT: WriteCharStr
  155. ;*   LINKAGE:   Near Call from BUFFERUPDATE routine
  156. ;*
  157. ;* INPUT:
  158. ;*
  159. ;* SS:BP  --->  Stack frame                        (see VDHSTRUC.INC)
  160. ;* DS:SI  --->  Parameter block buffer            (see WDHBUFUP.ASM)
  161. ;* ES:DI  --->  Mode data in environment buffer (see WDHBUFUP.ASM)
  162. ;*
  163. ;* PARAMETER BLOCK FORMAT:
  164. ;*
  165. ;*   SIZE   DESCRIPTION
  166. ;*   ----   -----------
  167. ;*
  168. ;*   WORD   Parameter length
  169. ;*   WORD   Flags                                      (target data buffer - LVB, PVB)
  170. ;*   DWORD  Application data address  (source data buffer)
  171. ;*   DWORD  Application data2 address (not used in this call)
  172. ;*   WORD   Index (8)
  173. ;*   WORD   Starting row                               (target row)
  174. ;*   WORD   Starting column                            (target column)
  175. ;*   WORD   Secondary row                              (not used in this call)
  176. ;*   WORD   Secondary column                           (not used in this call)
  177. ;*   WORD   RepeatFactor                               (input and output length)
  178. ;*   WORD   LogicalBufSel
  179. ;*
  180. ;* OUTPUT:      PVB and/or LVB = new characters
  181. ;*              RepeatFactor = number of characters written
  182. ;*
  183. ;* EXIT-NORMAL: AX = 0
  184. ;*
  185. ;* EXIT-ERROR:  AX = Error from LocateBuffAddr
  186. ;*
  187. ;* EFFECTS:     AX, BX, DI, SI, DS, ES
  188. ;*
  189. ;* INTERNAL REFERENCES: None
  190. ;*
  191. ;* EXTERNAL REFERENCES: LocateBuffAddr           (in WDHREAD.ASM)
  192. ;*
  193. ;****************************************************************************/
  194.  
  195.         PUBLIC  WriteCharStr
  196. WriteCharStr PROC NEAR
  197.  
  198.         sub     bx, bx                            ; Set indicator for byte move
  199.         call    LocateBuffAddr                    ; On exit: BX = sel, AX = off
  200.         .if     <nc>                              ; Continue?
  201.             lds     si, [si].AppDataAddr          ; Setup source address
  202.             mov     di, ax                        ; Setup destination offset
  203.  
  204.             cmp     [bp].Retrace,4
  205.             mov     es, bx                        ; Setup destination selector
  206.             .if     <eq>                          ;4-byte cells
  207.                 .repeat                           ; Copy char from DS:SI to ES:DI
  208.                     movsb
  209.                     add     di,3                  ;Skip over the attribute
  210.                 .loop
  211.             .else                                 ;2-byte cells
  212.                 .repeat                           ; Copy char from DS:SI to ES:DI
  213.                     movsb
  214.                     inc     di
  215.                 .loop
  216.             .endif
  217.             sub     ax, ax                        ; Clear return code
  218.         .endif                                    ; 
  219.         ret                                       ; 
  220.  
  221. WriteCharStr ENDP
  222.  
  223. ;/****************************************************************************
  224. ;*
  225. ;* SUBROUTINE NAME:     WriteCharStrAttr
  226. ;*
  227. ;* DESCRIPTIVE NAME:    Video device handler write characters
  228. ;*                      with a constant attribute
  229. ;*
  230. ;* FUNCTION:    Process write characters, attribute sub-function.
  231. ;*              The characters and attribute are read from user
  232. ;*              supplied buffers which will be placed starting
  233. ;*              at the specified row, column location within the
  234. ;*              PVB and/or LVB.  Line wrap occurs if the end of
  235. ;*              a line is reached.  Write function is terminated
  236. ;*              if the end of PVB or LVB is reached.  The number
  237. ;*              of char/attr pairs written is returned in the
  238. ;*              RepeatFacter field of the parameter block.
  239. ;*
  240. ;* ENTRY POINT: WriteCharStrAttr
  241. ;*   LINKAGE:   Near Call from BUFFERUPDATE routine
  242. ;*
  243. ;* INPUT:
  244. ;*
  245. ;* SS:BP  --->  Stack frame                        (see VDHSTRUC.INC)
  246. ;* DS:SI  --->  Parameter block buffer            (see WDHBUFUP.ASM)
  247. ;* ES:DI  --->  Mode data in environment buffer (see WDHBUFUP.ASM)
  248. ;*
  249. ;* PARAMETER BLOCK FORMAT:
  250. ;*
  251. ;*   SIZE   DESCRIPTION
  252. ;*   ----   -----------
  253. ;*
  254. ;*   WORD   Parameter length
  255. ;*   WORD   Flags                                      (target data buffer - LVB, PVB)
  256. ;*   DWORD  Application data address  (source data buffer)
  257. ;*   DWORD  Application data2 address (source attribue buffer)
  258. ;*   WORD   Index (9)
  259. ;*   WORD   Starting row                               (target row)
  260. ;*   WORD   Starting column                            (target column)
  261. ;*   WORD   Secondary row                              (not used in this call)
  262. ;*   WORD   Secondary column                           (not used in this call)
  263. ;*   WORD   RepeatFactor                               (input and output length)
  264. ;*   WORD   LogicalBufSel
  265. ;*
  266. ;* OUTPUT:      PVB and/or LVB = new characters
  267. ;*              RepeatFactor = sum of char/attr pairs written
  268. ;*
  269. ;* EXIT-NORMAL: AX = 0
  270. ;*
  271. ;* EXIT-ERROR:  AX = Error from LocateBuffAddr
  272. ;*
  273. ;* EFFECTS:     AX, BX, DI, SI, DS, ES
  274. ;*
  275. ;* INTERNAL REFERENCES: None
  276. ;*
  277. ;* EXTERNAL REFERENCES: LocateBuffAddr           (in WDHREAD.ASM)
  278. ;*
  279. ;****************************************************************************/
  280.  
  281.         PUBLIC  WriteCharStrAttr
  282. WriteCharStrAttr PROC NEAR
  283.  
  284.         sub     bx, bx                            ; Setup for byte read
  285.         call    LocateBuffAddr                    ; On exit: BX = sel, AX = off
  286.         .if     <nc>                              ; Continue?
  287.             mov     di, ax                        ; Setup destination offset
  288.             lds     si, [si].AppCellAddr          ; Setup address to attribute
  289.             lodsb                                 ; Get attribute
  290.             mov     ah,al
  291.  
  292.             cmp     [bp].Retrace,4
  293.             mov     es, bx                        ; Setup destination selector
  294.             .if     <eq>                          ;4-byte cells
  295.                 mov     dx,ax
  296.                 lodsw
  297.                 lds     si, [bp].ParmBuf          ; Setup parameter buffer addr
  298.                 lds     si, [si].AppDataAddr      ; Setup source address
  299.                 .repeat                           ; Copy attr from AL:DX to ES:DI
  300.                     xchg    ax,dx
  301.                     lodsb
  302.                     stosw                         ;Move first word of cell
  303.                     xchg    ax,dx
  304.                     stosw                         ;Move last word of cell
  305.                 .loop
  306.             .else                                 ;2-byte cells
  307.                 lds     si, [bp].ParmBuf          ; Setup parameter buffer addr
  308.                 lds     si, [si].AppDataAddr      ; Setup source address
  309.                 .repeat                           ; Copy byte with attr to ES:DI
  310.                     lodsb
  311.                     stosw
  312.                 .loop
  313.             .endif
  314.             sub     ax, ax                        ; Clear return code
  315.         .endif                                    ; 
  316.         ret                                       ; 
  317.  
  318. WriteCharStrAttr ENDP
  319.  
  320. ;/****************************************************************************
  321. ;*
  322. ;* SUBROUTINE NAME:     WriteNChar
  323. ;*
  324. ;* DESCRIPTIVE NAME:    Video device handler repeat characters
  325. ;*
  326. ;* FUNCTION:    Process write character sub-function.
  327. ;*              The characters are written to either PVB or LVB
  328. ;*              starting at the specified row, column location.
  329. ;*              Line wrap ocurrs if the end of a line is reached.
  330. ;*              Write function is terminated if the end of PVB or
  331. ;*              LVB is reached.  The number of characters written
  332. ;*              is returned in the RepeatFacter field of the
  333. ;*              parameter block.
  334. ;*
  335. ;* ENTRY POINT: WriteNChar
  336. ;*   LINKAGE:   Near Call from BUFFERUPDATE routine
  337. ;*
  338. ;* INPUT:
  339. ;*
  340. ;* SS:BP  --->  Stack frame                        (see VDHSTRUC.INC)
  341. ;* DS:SI  --->  Parameter block buffer            (see WDHBUFUP.ASM)
  342. ;* ES:DI  --->  Mode data in environment buffer (see WDHBUFUP.ASM)
  343. ;*
  344. ;* PARAMETER BLOCK FORMAT:
  345. ;*
  346. ;*   SIZE   DESCRIPTION
  347. ;*   ----   -----------
  348. ;*
  349. ;*   WORD   Parameter length
  350. ;*   WORD   Flags                                      (target data buffer - LVB, PVB)
  351. ;*   DWORD  Application data address  (source character buffer)
  352. ;*   DWORD  Application data2 address (not used in this call)
  353. ;*   WORD   Index (10)
  354. ;*   WORD   Starting row                               (target row)
  355. ;*   WORD   Starting column                            (target column)
  356. ;*   WORD   Secondary row                              (not used in this call)
  357. ;*   WORD   Secondary column                           (not used in this call)
  358. ;*   WORD   RepeatFactor                               (input and output length)
  359. ;*   WORD   LogicalBufSel
  360. ;*
  361. ;* OUTPUT:      PVB or LVB = new characters
  362. ;*              RepeatFactor = number of characters written
  363. ;*
  364. ;* EXIT-NORMAL: AX = 0
  365. ;*
  366. ;* EXIT-ERROR:  None
  367. ;*
  368. ;* EFFECTS:     AX, BX, DI, SI, DS, ES
  369. ;*
  370. ;* INTERNAL REFERENCES: None
  371. ;*
  372. ;* EXTERNAL REFERENCES: LocateBuffAddr           (in WDHREAD.ASM)
  373. ;*
  374. ;****************************************************************************/
  375.  
  376.         PUBLIC  WriteNChar
  377. WriteNChar PROC NEAR
  378.  
  379.         sub     bx, bx                            ; Setup indicator for byte move
  380.         call    LocateBuffAddr                    ; On exit: BX = sel, AX = off
  381.         .if     <nc>                              ; Continue?
  382.             lds     si, [si].AppDataAddr          ; Setup source address
  383.             mov     di, ax                        ; Setup destination offset
  384.             lodsb                                 ; Get source character
  385.  
  386.             mov     dx,[bp].Retrace
  387.             dec     dx                            ;Compute attribute size
  388.  
  389.             mov     es, bx                        ; Setup destination selector
  390.             .repeat                               ; Copy char from AL to ES:DI
  391.                 stosb
  392.                 add     di,dx                     ;Skip over the attribute
  393.             .loop
  394.             sub     ax, ax                        ; Clear return code
  395.         .endif
  396.         ret
  397.  
  398. WriteNChar ENDP
  399.  
  400. ;/****************************************************************************
  401. ;*
  402. ;* SUBROUTINE NAME:     WriteNAttr
  403. ;*
  404. ;* DESCRIPTIVE NAME:    Video device handler repeat attributes
  405. ;*
  406. ;* FUNCTION:    Process repeat write attributes sub-function.
  407. ;*              The attributes are written to either PVB or LVB
  408. ;*              starting at the specified row, column location.
  409. ;*              Line wrap occurs if the end of a line is reached.
  410. ;*              Write function is terminated if the end of PVB or
  411. ;*              LVB is reached.  The number of the attributes
  412. ;*              written is returned in the RepeatFactor field
  413. ;*              of the paramter block.
  414. ;*
  415. ;* ENTRY POINT: WriteNAttr
  416. ;*   LINKAGE:   Near Call from BUFFERUPDATE routine
  417. ;*
  418. ;* INPUT:
  419. ;*
  420. ;* SS:BP  --->  Stack frame                        (see VDHSTRUC.INC)
  421. ;* DS:SI  --->  Parameter block buffer            (see WDHBUFUP.ASM)
  422. ;* ES:DI  --->  Mode data in environment buffer (see WDHBUFUP.ASM)
  423. ;*
  424. ;* PARAMETER BLOCK FORMAT:
  425. ;*
  426. ;*   SIZE   DESCRIPTION
  427. ;*   ----   -----------
  428. ;*
  429. ;*   WORD   Parameter length
  430. ;*   WORD   Flags                                      (target data buffer - LVB, PVB)
  431. ;*   DWORD  Application data address  (source attribute buffer)
  432. ;*   DWORD  Application data2 address (not used in this call)
  433. ;*   WORD   Index (11)
  434. ;*   WORD   Starting row                               (target row)
  435. ;*   WORD   Starting column                            (target column)
  436. ;*   WORD   Secondary row                              (not used in this call)
  437. ;*   WORD   Secondary column                           (not used in this call)
  438. ;*   WORD   RepeatFactor                               (input and output length)
  439. ;*   WORD   LogicalBufSel
  440. ;*
  441. ;* OUTPUT:      LVB and/or PVB = new attributes
  442. ;*              RepeatFactor = number of attributes written
  443. ;*
  444. ;* EXIT-NORMAL: AX = 0
  445. ;*
  446. ;* EXIT-ERROR:  AX = Error from LocateBuffAddr
  447. ;*
  448. ;* EFFECTS:     All
  449. ;*
  450. ;* INTERNAL REFERENCES: None
  451. ;*
  452. ;* EXTERNAL REFERENCES: LocateBuffAddr            (in WDHREAD.ASM)
  453. ;*
  454. ;****************************************************************************/
  455.  
  456.         PUBLIC  WriteNAttr
  457. WriteNAttr PROC NEAR
  458.  
  459.         sub     bx, bx                            ; Set indicator for byte move
  460.         call    LocateBuffAddr                    ; On exit: BX = sel, AX = off
  461.         .if     <nc>                              ; Continue?
  462.             lds     si, [si].AppDataAddr          ; Setup source address
  463.             mov     di, ax                        ; Setup destination offset
  464.             lodsb                                 ; Get source attribute
  465.  
  466.             cmp     [bp].Retrace,4
  467.             mov     es, bx                        ; Setup destination selector
  468.             .if     <eq>                          ;4-byte cells
  469.                 mov     dl,al
  470.                 lodsw
  471.                 .repeat                           ; Copy attr from AL:DX to ES:DI
  472.                     inc     di
  473.                     xchg    ax,dx
  474.                     stosb                         ;Move first byte of attribute
  475.                     xchg    ax,dx
  476.                     stosw                         ;Move last word of attribute
  477.                 .loop
  478.             .else                                 ;2-byte cells
  479.                 .repeat                           ; Copy attr from AL to ES:DI
  480.                     inc     di
  481.                     stosb
  482.                 .loop
  483.             .endif
  484.             sub     ax, ax                        ; Clear return code
  485.         .endif
  486.         ret
  487.  
  488. WriteNAttr ENDP
  489.  
  490. ;/****************************************************************************
  491. ;*
  492. ;* SUBROUTINE NAME:     WriteNCell
  493. ;*
  494. ;* DESCRIPTIVE NAME:    Video device handler repeat cells
  495. ;*
  496. ;* FUNCTION:    Process write cells sub-function.
  497. ;*              The cells are written to either PVB or LVB
  498. ;*              starting at the specified row, column location.
  499. ;*              Line wrap ocurrs if the end of a line is reached.
  500. ;*              Write function is terminated if the end of PVB
  501. ;*              or LVB is reached.  The number of cells written
  502. ;*              is returned in the RepeatFacter field of the
  503. ;*              parameter block.
  504. ;*
  505. ;* ENTRY POINT: WriteNCell
  506. ;*   LINKAGE:   Near Call from BUFFERUPDATE routine
  507. ;*
  508. ;* INPUT:
  509. ;*
  510. ;* SS:BP  --->  Stack frame                        (see VDHSTRUC.INC)
  511. ;* DS:SI  --->  Parameter block buffer            (see WDHBUFUP.ASM)
  512. ;* ES:DI  --->  Mode data in environment buffer (see WDHBUFUP.ASM)
  513. ;*
  514. ;* PARAMETER BLOCK FORMAT:
  515. ;*
  516. ;*   SIZE   DESCRIPTION
  517. ;*   ----   -----------
  518. ;*
  519. ;*   WORD   Parameter length
  520. ;*   WORD   Flags                                      (target data buffer - LVB, PVB)
  521. ;*   DWORD  Application data address  (source cell buffer)
  522. ;*   DWORD  Application data2 address (not used in this call)
  523. ;*   WORD   Index (12)
  524. ;*   WORD   Starting row                               (target row)
  525. ;*   WORD   Starting column                            (target column)
  526. ;*   WORD   Secondary row                              (not used in this call)
  527. ;*   WORD   Secondary column                           (not used in this call)
  528. ;*   WORD   RepeatFactor                               (input and output length)
  529. ;*   WORD   LogicalBufSel
  530. ;*
  531. ;* OUTPUT:      PVB or LVB = new characters
  532. ;*              RepeatFactor = sum of char/attr pairs written
  533. ;*
  534. ;* EXIT-NORMAL: AX = 0
  535. ;*
  536. ;* EXIT-ERROR:  AX = Error from LocateBuffAddr
  537. ;*
  538. ;* EFFECTS:     AX, BX, DI, SI, DS, ES
  539. ;*
  540. ;* INTERNAL REFERENCES: None
  541. ;*
  542. ;* EXTERNAL REFERENCES: LocateBuffAddr           (in WDHREAD.ASM)
  543. ;*
  544. ;****************************************************************************/
  545.  
  546.         PUBLIC  WriteNCell
  547. WriteNCell PROC NEAR
  548.  
  549.         sub     bx, bx                            ; Set indicator for byte move
  550.         call    LocateBuffAddr                    ; On exit: BX = sel, AX = off
  551.         .if     <nc>                              ; Continue?
  552.             lds     si, [si].AppDataAddr          ; Setup source address
  553.             mov     di, ax                        ; Setup destination offset
  554.             lodsw                                 ; Get source character
  555.  
  556.             cmp     [bp].Retrace,4
  557.             mov     es, bx                        ; Setup destination selector
  558.             .if     <eq>                          ;4-byte cells
  559.                 mov     dx,ax
  560.                 lodsw                             ;Get second word of cell
  561.                 .repeat
  562.                     xchg    ax,dx
  563.                     stosw                         ;Move first word of cell
  564.                     xchg    ax,dx
  565.                     stosw                         ;Move second word of cell
  566.                 .loop
  567.             .else                                 ;2-byte cells
  568.                 rep     stosw                     ; Copy cell from DS:SI to ES:DI
  569.             .endif
  570.             sub     ax, ax                        ; Clear return code
  571.         .endif
  572.         ret
  573.  
  574. WriteNCell ENDP
  575.  
  576. R2CSEG  ENDS
  577.         END
  578.