home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / CEXPRESS.ZIP / SCREEN.ASM / WRTENDB.ASM < prev    next >
Assembly Source File  |  1989-05-03  |  3KB  |  91 lines

  1. ;void  write_end_b(strg,col,row,length,color);
  2. ;  unsigned char  *strg,col,row,length,color;
  3.  
  4.     EXTRN  _memory_model:byte
  5.     EXTRN  _error_code:byte
  6.     EXTRN  _video_page:byte
  7.  
  8. _TEXT    SEGMENT BYTE PUBLIC 'CODE'
  9.     ASSUME CS:_TEXT
  10.     PUBLIC _write_end_b
  11. _write_end_b proc near
  12.     push bp            ;
  13.     mov  bp,sp        ;set up stack frame
  14.     push di            ;
  15.     push si            ;
  16.     cmp  _memory_model,0    ;near or far?
  17.     jle  begin        ;jump if near
  18.     inc  bp            ;else add 2 to BP
  19.     inc  bp            ;
  20. begin:    mov  bh,_video_page    ;set video page
  21.     push ds            ;save DS
  22.     cmp  _memory_model,2    ;data near or far?
  23.     jb   L0            ;jump if near
  24.     lds  si,dword ptr[bp+4] ;DS:SI pts to Strg
  25.     inc  bp            ;add 2 to BP since dword ptr    
  26.     inc  bp            ;
  27.     jmp  short L00        ;
  28. L0:    mov  si,[bp+4]        ;near case
  29. L00:    mov  byte ptr[bp+4],1    ;_error_code 1 = 0 Length
  30.     push si            ;must find string length
  31.     sub  cx,cx        ;count in CX
  32. L000:    inc  si            ;forward strg ptr
  33.     inc  cx            ;inc counter
  34.     cmp  byte ptr[si],0    ;end of string?
  35.     jne  L000        ;loop if not
  36.     pop  si            ;SI back to start of string
  37.     sub  dx,dx        ;
  38.     mov  dl,[bp+10]        ;length of line
  39.     or   dx,dx        ;test for zero Length
  40.     jnz  L1            ;jump if nonzero
  41.     mov  byte ptr[bp+4],0    ;0 = no error
  42. L1:    sub  ax,ax        ;AX holds number trailing spaces
  43.     cmp  cx,dx        ;strg >= Length?
  44.     jae  L2            ;jump ahead if so
  45.     sub  dx,cx        ;minus Strg length
  46.     mov  ax,dx        ;number trailing spaces
  47. L2:    mov  di,cx        ;DI holds Strg Length
  48.     mov  dh,[bp+8]        ;Row to DH
  49.     dec  dh            ;count from 0
  50.     mov  dl,[bp+6]        ;Col to DL
  51.     dec  dl            ;count from 0
  52.     mov  bl,[bp+12]        ;Attribute to BL
  53.     mov  bp,ax        ;number trailing chars
  54.     mov  cx,1        ;chars to wrt each time
  55.     mov  ah,2        ;func to set cursor
  56.     int  10h        ;set initial cursor pos
  57.     or   di,di        ;test for zero strg len
  58.     jz   L4            ;jump ahead if null
  59. L3:    mov  al,[si]        ;get a char
  60.     inc  si            ;forward string ptr for next time
  61.     mov  ah,9        ;function to write char
  62.     int  10h        ;write the char
  63.     inc  dl            ;forward column pos
  64.     mov  ah,2        ;function to set cursor
  65.     int  10h        ;reset cursor
  66.     dec  di            ;end of string?
  67.     jnz  L3            ;loop till finished
  68. L4:    or   bp,bp        ;test for no chars clear
  69.     jz   L6            ;jump ahead if none
  70. L5:    mov  al,32        ;now write space char
  71.     mov  ah,9        ;function to write char
  72.     int  10h        ;write the char
  73.     inc  dl            ;forward column pos
  74.     mov  ah,2        ;function to set cursor
  75.     int  10h        ;reset cursor
  76.     dec  bp            ;end of line?
  77.     jnz  L5            ;loop till end of line
  78. L6:    pop  ds            ;restore DS
  79.     mov  al,[bp+4]        ;fetch _error_code
  80.     mov  _error_code,al    ;set it
  81.     pop  si            ;
  82.     pop  di            ;
  83.     pop  bp            ;
  84.     cmp  _memory_model,0    ;quit
  85.     jle  quit        ;
  86.     db   0CBh        ;RET far
  87. quit:    ret            ;RET near
  88. _write_end_b endp
  89. _TEXT    ENDS
  90.     END
  91.