⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 console.c

📁 dos下一个强大的文本编辑器,支持多文档、多窗口、二进制文件编辑。
💻 C
📖 第 1 页 / 共 4 页
字号:
        mov     dl, al                  /* keep it in dl */
        mov     ax, WORD PTR block      /* get block attribute */
        mov     dh, al                  /* keep it in dh */
        mov     ax, WORD PTR max_col    /* get max number columns on screen */
        mov     ch, al                  /* keep it in ch */
        xor     cl, cl                  /* col = 0, keep col in cl */
/*
;
; load screen and text pointer
;
*/
        mov     di, WORD PTR screen_ptr         /* load OFFSET of screen ptr */
        add     di, WORD PTR off                /* add offset of line */
        mov     ax, WORD PTR screen_ptr+2       /* load SEGMENT of screen ptr */
        mov     es, ax
        mov     si, WORD PTR text       /* load OFFSET of text ptr */
        mov     ax, WORD PTR text+2     /* load SEGMENT of text ptr */
        mov     ds, ax                  /* move segment of text in ds */
        cmp     si, 0                   /* is offset of text ptr == NULL? */
        jne     not_null                /* no, output string */
        cmp     ax, 0                   /* is segment of text ptr == NULL? */
        je      dspl_eol                /* yes, clear end of line */
   }
not_null:

   ASSEMBLE {
        cmp     cl, ch                  /* is col == max_col? */
        jge     getout                  /* yes, thru with line */
        cmp     cl, BYTE PTR len        /* is col == len? */
        je      dspl_eol                /* yes, must check block past eol */
   }
top:

   ASSEMBLE {
        lodsb                   /* get next char in string */
        mov     ah, dl          /* assume normal attribute */
        cmp     cl, bl          /* is col < bc? (less than beginning col) */
        jl      ch_out1         /* yes, show char and normal attribute */
        cmp     cl, bh          /* is col > ec? (greater than ending col) */
        jg      ch_out1         /* yes, show char and normal attribute */
        mov     ah, dh          /* must be in a block - block attribute */
   }
ch_out1:

   ASSEMBLE {
        stosw                   /* now show char on screen w/ attribute */
        inc     cl              /* ++col */
        cmp     cl, ch          /* is col == max_col? */
        jge     getout          /* yes, thru with line */
        cmp     cl, BYTE PTR len        /* is col == len? */
        jl      top             /* yes, must check block past eol */
   }
dspl_eol:

   ASSEMBLE {
        cmp     WORD PTR show_eol, FALSE        /* look at the show_eol flag */
        je      block_eol       /* show_eol flag is FALSE, blank line */
        mov     al, EOL_CHAR    /* load some eol indicator */
        mov     ah, dl          /* assume normal attribute */
        cmp     cl, bl          /* is col < bc? (less than beginning col) */
        jl      ch_out2         /* yes, show char and normal attribute */
        cmp     cl, bh          /* is col > ec? (greater than ending col) */
        jg      ch_out2         /* yes, show char and normal attribute */
        mov     ah, dh          /* must be in a block - show block attribute */
   }
ch_out2:

   ASSEMBLE {
        stosw                   /* write eol and attribute to screen */
        inc     cl              /* ++col */
        cmp     cl, ch          /* is col == max_col? */
        je      getout          /* yes, we're done */
   }
block_eol:

   ASSEMBLE {
        mov     al, ' '         /* clear rest of line w/ spaces */
   }
b1:

   ASSEMBLE {
        mov     ah, dl          /* assume normal attribute */
        cmp     cl, bl          /* is col < bc? (less than beginning col) */
        jl      ch_out3         /* yes, show char and normal attribute */
        cmp     cl, bh          /* is col > ec? (greater than ending col) */
        jg      ch_out3         /* yes, show char and normal attribute */
        mov     ah, dh          /* must be in a block - show block attribute */
   }
ch_out3:

   ASSEMBLE {
        stosw                   /* write blank and attribute to screen */
        inc     cl              /* ++col */
        cmp     cl, ch          /* is col == max_col? */
        jl      b1              /* while less output block */
   }
getout:

   ASSEMBLE {
        pop     di
        pop     si
        pop     ds
      }

/*
      screen_ptr += off;
      bcol = window->start_col;
      for (col=0; col < max_col; col++, bcol++) {
         attr = normal;
         if (col >= bc && col <= ec)
            attr = block;
         if (col < len)
            c = *text++;
         else if (col == len && show_eol)
            c = EOL_CHAR;
         else
            c = ' ';
         *screen_ptr++ = c;
         *screen_ptr++ = attr;

         c_output( c, bcol, line, attr );
      }
*/
   } else if (block_line == TRUE && file->block_type == STREAM &&
              (rline == file->block_br || rline == file->block_er)) {
      if (rline == file->block_br)
         bc = file->block_bc;
      else {
         bc = file->block_ec + 1;
         ec = normal;
         normal = block;
         block = ec;
      }
      if (bc < bcol)
         bc = 0;
      else if (bc < bcol + max_col)
         bc = bc - bcol;
      else
         bc = max_col + 1;


   ASSEMBLE {
        /*
        ; Register strategy:
        ;   bl == beginning column
        ;   bh == relative line length
        ;   dl == normal text attribute
        ;   dh == block attribute
        ;   cl == current virtual column
        ;   ch == maximum columns in window
        ;   ES:DI == screen pointer (destination)
        ;   DS:SI == text pointer (source)
        ;   [bp+show_eol]  == access for local C variable
        */

        push    ds                      /* MUST save ds - push it on stack */
        push    si                      /* save si on stack */
        push    di                      /* save di on stack */

/*
;
; set up local register variables
;
*/
        mov     ax, WORD PTR bc         /* get beginning column */
        mov     bl, al                  /* keep it in bl */
        mov     ax, WORD PTR len        /* get relative line length */
        mov     bh, al                  /* keep it in bh */
        mov     ax, WORD PTR normal     /* get normal attribute */
        mov     dl, al                  /* keep it in dl */
        mov     ax, WORD PTR block      /* get block attribute */
        mov     dh, al                  /* keep it in dh */
        mov     ax, WORD PTR max_col    /* get max number columns on screen */
        mov     ch, al                  /* keep it in ch */
        xor     cl, cl                  /* col = 0, keep col in cl */
/*
;
; load screen and text pointer
;
*/
        mov     di, WORD PTR screen_ptr         /* load OFFSET of screen ptr */
        add     di, WORD PTR off                /* add offset of line */
        mov     ax, WORD PTR screen_ptr+2       /* load SEGMENT of screen ptr */
        mov     es, ax
        mov     si, WORD PTR text       /* load OFFSET of text ptr */
        mov     ax, WORD PTR text+2     /* load SEGMENT of text ptr */
        mov     ds, ax                  /* move segment of text in ds */
        cmp     si, 0                   /* is offset of text ptr == NULL? */
        jne     nott_null               /* no, output string */
        cmp     ax, 0                   /* is segment of text ptr == NULL? */
        je      ddspl_eol               /* yes, clear end of line */
   }
nott_null:

   ASSEMBLE {
        cmp     cl, ch          /* is col == max_col? */
        je      ggetout         /* yes, thru with line */
        cmp     cl, bh          /* is col == len? */
        je      ddspl_eol       /* yes, check eol display */
   }
ttop:

   ASSEMBLE {
        lodsb                   /* get next char in string */
        mov     ah, dl          /* assume normal attribute */
        cmp     cl, bl          /* is col < bc? (less than beginning col) */
        jl      str_out1        /* yes, show char and normal attribute */
        mov     ah, dh          /* must be in a block - show block attribute */
   }
str_out1:

   ASSEMBLE {
        stosw                   /* else show char on screen */
        inc     cl              /* ++col */
        cmp     cl, ch          /* is col == max_col? */
        je      ggetout         /* yes, thru with line */
        cmp     cl, bh          /* is col == len? */
        jl      ttop            /* yes, check eol display */
   }
ddspl_eol:

   ASSEMBLE {
        cmp     WORD PTR show_eol, FALSE        /* look at the show_eol flag */
        je      stream_eol      /* show_eol flag is FALSE, blank line */
        mov     al, EOL_CHAR    /* load some eol indicator */
        mov     ah, dl          /* assume normal attribute */
        cmp     cl, bl          /* is col < bc? (less than beginning col) */
        jl      str_out2        /* yes, show char and normal attribute */
        mov     ah, dh          /* must be in a block - show block attribute */
   }
str_out2:

   ASSEMBLE {
        stosw                   /* write blank and attribute to screen */
        inc     cl              /* ++col */
        cmp     cl, ch          /* is col == max_col? */
        jge     ggetout         /* yes, we're done */
   }
stream_eol:

   ASSEMBLE {
        mov     al, ' '         /* clear rest of line w/ spaces */
   }
c1:

   ASSEMBLE {
        mov     ah, dl          /* assume normal attribute */
        cmp     cl, bl          /* is col < bc? (less than beginning col) */
        jl      str_out3        /* yes, show char and normal attribute */
        mov     ah, dh          /* must be in a block - show block attribute */
   }
str_out3:

   ASSEMBLE {
        stosw                   /* write blank and attribute to screen */
        inc     cl              /* ++col */
        cmp     cl, ch          /* is col == max_col? */
        jl      c1              /* while less output block */
   }
ggetout:

   ASSEMBLE {
        pop     di
        pop     si
        pop     ds
      }

/*
      screen_ptr += off;
      bcol = window->start_col;
      for (col=0; col < max_col; col++, bcol++) {
         attr = normal;
         if (col >= bc && col <= ec)
            attr = block;
         if (col < len)
            c = *text++;
         else if (col == len && show_eol)
            c = EOL_CHAR;
         else
            c = ' ';
         *screen_ptr++ = c;
         *screen_ptr++ = attr;
         c_output( c, bcol, line, attr );
      }
*/
   } else {
      if (block_line)
         attr = block;
      else
         attr = normal;

      assert( len >= 0 );
      assert( len <= MAX_COLS );

   ASSEMBLE {
        /*
        ; Register strategy:
        ;   bl == normal text attribute
        ;   bh == relative line length
        ;   cl == current virtual column
        ;   ch == maximum columns in window
        ;   ES:DI == screen pointer (destination)
        ;   DS:SI == text pointer (source)
        ;   [bp+show_eol]  == access for local C variable
        */

        mov     dx, ds          /* MUST save ds - keep it in dx */
        push    di              /* save di on stack */
        push    si              /* save si on stack */


        mov     bx, WORD PTR attr               /* keep attribute in bl */
        mov     ax, WORD PTR len                /* get normalized len */
        mov     bh, al                          /* keep len in bh */
        mov     cx, WORD PTR max_col            /* get max_col in cx */
        mov     ch, cl                          /* keep it in ch */
        xor     cl, cl                          /* zero out cl */
        mov     di, WORD PTR screen_ptr         /* load OFFST of screen ptr */
        add     di, WORD PTR off                /* add offset of line */
        mov     ax, WORD PTR screen_ptr+2       /* load SEGMENT of screen ptr */
        mov     es, ax
        mov     si, WORD PTR text       /* load OFFSET of text ptr */
        mov     ax, WORD PTR text+2     /* load SEGMENT of text ptr */
        mov     ds, ax                  /* move segment of text in ds */
        cmp     si, 0                   /* is offset of pointer == NULL? */
        jne     nnot_null               /* no, output string */
        cmp     ax, 0                   /* is segment of pointer == NULL? */
        je      normeol                 /* yes, then clear rest of line */
   }
nnot_null:

   ASSEMBLE {
        mov     ah, bl                  /* get attribute */
        cmp     cl, ch          /* compare count with max columns */
        jge     getoutt         /* yes, thru with line */
        cmp     cl, bh          /* compare count with len */
        je      normeol         /* yes, clear end of line */
   }
topp:

   ASSEMBLE {
        lodsb                   /* get next char in string */
        stosw                   /* else show char on screen */
        inc     cl              /* ++col, count up to max_column */
        cmp     cl, ch          /* compare count with max columns */
        jge     getoutt         /* yes, thru with line */
        cmp     cl, bh          /* compare count with len */
        jl      topp            /* yes, clear end of line */
   }
normeol:

   ASSEMBLE {
        cmp     WORD PTR show_eol, FALSE        /* look at the show_eol flag */
        je      clreol          /* show_eol flag is FALSE, blank line */
        mov     al, EOL_CHAR    /* load some eol indicator */
        mov     ah, bl          /* assume normal attribute */
        stosw                   /* write blank and attribute to screen */
        inc     cl              /* ++col */
        cmp     cl, ch          /* is col == max_col? */
        jge     getoutt         /* yes, we're done */
   }
clreol:

   ASSEMBLE {
        mov     ah, bl          /* get attribute */
        mov     al, ' '         /* clear eol with ' ' */
        sub     ch, cl          /* find number of columns left */
        mov     cl, ch          /* put number of column left in cl */
        xor     ch, ch          /* clear ch */
        rep     stosw           /* count is in cx - set rest of line to ' ' */
   }
getoutt:

   ASSEMBLE {
        pop     si
        pop     di

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -