Announcement

Collapse
No announcement yet.

ASM Equivalent Of DOS "CLS"?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ASM Equivalent Of DOS "CLS"?

    What I am looking for is an INT that will clear the screen for a
    DOS program, both in windowed mode and in full screen mode.
    I have looked through Ralf Brown's Interrupt Lists, and did not
    see anything obvious. Can anybody point me in the right direction?
    Or would I have to use the screen page number, and manually clear
    the screen? The reason I wish to know is that I have written a
    procedure in an OBJ file to be included in my applicable PB/DOS EXE's.
    The procedure takes the number of whichever runtime error occurred
    and outputs a message stating that a runtime error has occurred
    and then displays a plain English description of the error. It contains
    descriptions for every runtime error listed in the PB/DOS manual.
    Well, it looks pretty tacky to have this information displayed in
    addition to the EXE's normal display output. So, I wish for the
    procedure to be able to clear the screen before it displays its
    information. Currently I am using a hack to do it - I always have ANSI.SYS
    loaded, because of my DOS BBS, so the procedure simply outputs the
    clear screen ANSI escape code sequence. However, this might not always
    be the case, so I would like a REAL method of doing it.

    Any assistance gratefully received.


    ------------------


    [This message has been edited by Clay Clear (edited April 22, 2003).]

  • #2
    Code:
    I haven't look at this one in a long time.  
    But it sure did receive heavy use.
       
    '=========================
    SUB FancyClr()
    LOCAL xy%, numchars%, fore%, back%, attr%
    fore% = 15 : back%=3
    if istrue(bit(pbvScrnCard,0)) then fore% = 0 : back% = 7    'if mono
    attr% = fore% + (back% * 16)
    numchars% = pbvScrnRows * pbvScrnCols         'fill entire screen
    !  push  bp
       
    !  mov   ah, 3             ;get cursor loc
    !  mov   bh, pbvScrnVpage  ;use visible page
    !  int   &h10
    !  mov   xy%, dx           ;save loc, dh=row, dl=col
       
    '-- Move cursor to upper left
    !  mov   ah, 2             ;function
    !  mov   bh, pbvScrnVpage  ;use visible page
    !  xor   dx, dx            ;dh=row, dl=col
    !  int   &h10
       
    '-- Write to entire screen
    !  mov   ah, &h09          ;function
    !  mov   al, 191           ;char to print <-- your choice here
    !  mov   cx, attr%
    !  mov   bl, cl            ;now bl = attribute
    !  mov   bh, pbvScrnVpage  ;use visible page
       
    !  mov   cx, NumChars%    ;how many chars
    !  int   &h10
       
    !  mov   ah, 2             ;set cursor loc
    !  mov   bh, pbvScrnVpage  ;use visible page
    !  mov   dx, xy%           ;set loc, dh=row, dl=col
    !  int   &h10
       
    !  pop   bp
    END SUB

    [This message has been edited by Greg Turgeon (edited April 25, 2003).]

    Comment


    • #3
      Thanks, Greg!


      ------------------

      Comment


      • #4
        Thanks also Greg!

        You know, I've done the same thing high level to do the same sort of
        thing for various purposes for years. But it never dawned on me that a
        'better' way to do this that was perhaps more portable in some platforms
        might be assembled for such use.

        I think it is reported to have been Jimmy Durante, who when mugged and
        demanded, "Your money or your life!", hesitated, then replied, "I'm
        thinking! I'm thinking!"

        You know, I'm thinking about what you posted Clay and Greg...

        ------------------
        Mike Luther
        [email protected]
        Mike Luther
        [email protected]

        Comment


        • #5
          A "quick-and-dirty" method (decide yourself if you want to take
          it serious): Just change the video mode using Interrupt 10h.

          Hans Ruegg.

          ------------------

          Comment


          • #6
            See the BIOS int &H10 "scroll" functions.

            ------------------
            Tom Hanlin
            PowerBASIC Staff

            Comment


            • #7
              See the BIOS int &H10 "scroll" functions.
              Yes. The simple, standard call. But a routine called
              FancyClr()--consider the implications.


              ------------------
              -- gturgeon at compuserve dot com --

              Comment


              • #8
                .

                [This message has been edited by Karl Lessmann (edited September 23, 2003).]

                Comment


                • #9
                  Thanks Karl

                  I make more mistakes than anyone else I know, but I try.
                  Next time I'll get that part right, grin!


                  ------------------
                  Mike Luther
                  [email protected]
                  Mike Luther
                  [email protected]

                  Comment


                  • #10
                    <withdrawn - decided to do more experimental test coding before
                    asking for assistance>


                    [This message has been edited by Clay Clear (edited April 25, 2003).]

                    Comment


                    • #11
                      Mr. Luther,

                      I decided to adopt my own "strategy" for clearing the screen. It
                      directly writes to the screen buffer (as pointed to by pbvScrnBuff).
                      Greg: I did not do this out of disrespect for your code or
                      dissatisfaction with it - I did it for increased speed. I figured it'd take
                      less time to directly access memory locations with indexed es:[di]
                      than it would to run an INT.

                      Anyway, I digress. Mike, if you want, I'll post my code here. But,
                      be forewarned, it is written for the MASM 6.14 compiler, to be compiled
                      as an OBJ file. If you're interested, but would rather have it as
                      code that can be compiled as a PB/DOS UNIT, let me know.




                      ------------------

                      Comment


                      • #12
                        Clay ..

                        A Benny shaved is a Benny urned! I'm thinking, I'm thinking!

                        I'd almost like to see it both ways. This is much like Alice and the
                        Caterpillar. Alice says, 'Which way should I go?'. Answer, 'That depends
                        on where you are going!' Notice I used half quotes, lest I provoke
                        yet another carol here, chuckle.

                        At least, so I recall, MASM 6.14 will assemble for OS/2, said the White
                        Rabbit, nervously looking at his watch!



                        By the way, never smoke an ancient hookah, even if the Caterpillar
                        were to offer it. The TB issue is still there after a hundred years
                        of OS/2, right?



                        ------------------
                        Mike Luther
                        [email protected]
                        Mike Luther
                        [email protected]

                        Comment


                        • #13
                          Mike,

                          I have discovered a problem with Greg's approach, my approach,
                          Tom's approach (using the "scroll" INT 10h services), and even
                          with using the ANSI.SYS clear screen sequence. The problem is, even
                          though the screen is completely cleared, the PB/DOS PRINT statement
                          still prints based on the LAST LOGICAL LINE PRINTED, as far as
                          where it starts printing its next lines after clearing the screen.
                          I tried using the INT 10h/service 2 that Greg used to set the
                          cursor back to screen position 0,0, but the PRINT statement still
                          prints the new screen based on the last logical line printed. So,
                          apparently the PB/DOS engine PRINT's based on its own internal
                          links/tables. My workaround was quite simple, 'though I am not
                          comfortable with it - I wrote two ASM functions to replace the
                          PB/DOS PRINT statement. One function prints the input string verbatim,
                          the second function appends a CRLF to the text to be printed.
                          However, PB's builtin commands are much more capable and broader
                          in functionality than anything I can come up with, so I do not really
                          want to give up my PB PRINT statement. Tom, Lance, can you think of any
                          ASM trick to get the PB PRINT statement to start over at screen position 0,0?
                          On the other hand, my two PRINT replacement functions are not
                          DANGEROUS - they simply take the incoming string and output it to
                          the currently defined STDOUT device/file using INT 21h, service 40,
                          with %BX set to 1. And they WORK (however, they are only set up to
                          print out strings, not numbers (e.g., I can't do a PRNT I%)).

                          At any rate, Mike, all 3 screen-clearing techniques I've tried WORK,
                          in that they do indeed clear the screen. My method of directly writing
                          to the screen buffer might be the FASTEST method, but all 3 are viable
                          techniques. However, my technique also requires the most bytes of
                          code. The screen buffer is set up with each CHR$() being immediately
                          followed by its ATTRIBUTES byte. In other words, my code cannot do
                          a simple ! rep stosb.

                          ADDED: I just realized that I *can* reduce my method's code size a great
                          deal - load AL with the fill char, AH with the fill attribute,
                          populate %CX with the number of screen cells, and do a ! rep stosw.

                          ------------------




                          [This message has been edited by Clay Clear (edited April 25, 2003).]

                          Comment


                          • #14
                            ASM trick, no. However, PB has this wonderful statement, LOCATE...

                            ------------------
                            Tom Hanlin
                            PowerBASIC Staff

                            Comment


                            • #15
                              Tom,

                              Thank you for your reply. However, I am aware of the LOCATE
                              command. My goal was to make my OBJ files procedures that do
                              display printouts so they were self-contained. Ahhhh, well,
                              the solution, 'though it ain't as "pretty" as I had wanted, is
                              simple: I shall go back to using a PB/DOS UNIT that contains one
                              line of code: CLS. Then, my OBJ file procedures can call it as
                              an EXTRN proc. So, consider this thread as closed & completed.
                              And thanks to everybody who helped.

                              Mike,

                              I'll hold onto my method for clearing the screen with direct
                              memory access until tomorrow (Saturday), in case you want a copy of the
                              code. Since your last posting, I considerably cleaned up the code
                              by replacing the "grunt work" code with a single ! rep stosw.
                              If you don't say that you want a copy sometime today, I will permanently
                              delete the code. Personally, I recommend that you use my new strategy about
                              using CLS in a UNIT. That takes care of BOTH clearing the screen, AND
                              homing the cursor. My two PRINT replacement functions are useless,
                              as I did not account for the programmer's/user's attributes desires.
                              I realized this when I recoded one of my production BBS doors so it
                              used them for its local screen printouts - even though I kept the
                              PB COLOR statements in the program, the lines still printed out in
                              standard DOS color. So, am going to permanently delete that code, too.

                              I apologize to everybody for my longwinded postings in this overnight/AM hours.


                              ------------------

                              Comment


                              • #16
                                I've revised the routine. It now saves and restores the cursor
                                location.


                                ------------------
                                -- gturgeon at compuserve dot com --

                                Comment


                                • #17
                                  .

                                  [This message has been edited by Karl Lessmann (edited April 27, 2003).]

                                  Comment

                                  Working...
                                  X