flat assembler
Message board for the users of flat assembler.

Index > DOS > How do I Screen delay and Cls

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 07 Mar 2010, 19:34
Ahh, I see. These are all the deterrents of DOS programming - it's a headache. But as I go along, I pick up a few stuff here and there. Thanks alot guys.

One more question: How do you know when your advanced in programming?
Post 07 Mar 2010, 19:34
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 07 Mar 2010, 20:02
MeshNix,

It's simple: when you stop asking yourself such questions. Wink
Post 07 Mar 2010, 20:02
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4352
Location: Now
edfed 07 Mar 2010, 20:49
and i can say more:

when you can answer to advanced questions.

one thing is sure, you SHOULD code A LOT to become an advanced programmer
Post 07 Mar 2010, 20:49
View user's profile Send private message Visit poster's website Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 09 Mar 2010, 21:09
Thanks guys, I think i've got a grip of the concept
Post 09 Mar 2010, 21:09
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4352
Location: Now
edfed 12 Mar 2010, 17:05
cool, welcome to code addicts. Smile
Post 12 Mar 2010, 17:05
View user's profile Send private message Visit poster's website Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 17 Mar 2010, 20:47
Thanks Guys
Post 17 Mar 2010, 20:47
View user's profile Send private message Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 04 Nov 2010, 03:32
OLD POST

Ok guys, I'm back again with the same question, but this time, a little less vague.
I would like to know how to do a screen delay? Meaning, the program waiting for a given time before continuing onto the next instruction. For example:

algorithm:

    1. print "Please wait for 5 seconds..."
    2. call delay(5000) ; do delay for 5000 microseconds
    3. print "Thank you. The 5 seconds have passed."

I want to know how to do something like that.

(Thank in advance)
Post 04 Nov 2010, 03:32
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 04 Nov 2010, 09:17
MeshNix,

For a simple solution you may wait for 5*18.2 timer ticks to pass using 0:46Ch in BIOS data area. RTC can be used too (ports 70h/71h).

There is int 15h/86h BIOS service.
Post 04 Nov 2010, 09:17
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1397
Location: Piraeus, Greece
Picnic 05 Nov 2010, 08:12
Quick & dirty solution with this old gem.
Notice that both this and baldr's suggestion won't work on XP.

Code:
mov cx, 18   ; 1-second delay
hlt
loop $-1     
    
Post 05 Nov 2010, 08:12
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 05 Nov 2010, 08:46
Picnic,

You should mask all IRQs except IRQ0 for this to work as expected. "Work on XP" — did you mean "in NTVDM"? It works there.
Post 05 Nov 2010, 08:46
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1397
Location: Piraeus, Greece
Picnic 05 Nov 2010, 08:59
I think that Windows XP does not support this interrupt 15h/86h.
Post 05 Nov 2010, 08:59
View user's profile Send private message Visit poster's website Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 08 Nov 2010, 00:32
Unfortunately, I use XP.

I cannot recall properly, but I saw someone using a code similar to this, to delay the computer:
Code:
mov ax,0
mov cx,65365
.loop:
mov [es:di],ax
loop .loop    

[Don't quote me on this]
Post 08 Nov 2010, 00:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20416
Location: In your JS exploiting you and your system
revolution 08 Nov 2010, 01:50
MeshNix wrote:
[Don't quote me on this]
Hehe, couldn't resist quoting you on that. Wink
Post 08 Nov 2010, 01:50
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4060
Location: vpcmpistri
bitRAKE 08 Nov 2010, 04:10
http://ip-tietgennet.tietgen.dk/staff/mlha/PC/Prog/asm/int/21/index.htm#2C

DOS Services INT 21, AH=2C

Should work from dosbox on WinXP.

Get time, add delay, and wait for projected time.
Post 08 Nov 2010, 04:10
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 08 Nov 2010, 15:07
Sorry guys, been preoccupied these past few days, kept forgetting to post this, hope it helps:

Code:
; wait_for_me
wait_for_me:
        push cx                        ; CX = seconds to wait (max. 59)
        call scroll                    ; only scroll if at screen bottom

        mov si,offset pauze_msg
        call getlen

;        mov bp,si
;        add bp,ax
;        dec bp
;        dec bp
        xchg ax,bx
        lea bp,[si+bx-2]               ; saves two bytes

        test word ptr [suboptions],(SUBOPT_H or SUBOPT_Y)
        jnz wait_for_me_no_msg

        cmp byte ptr [scroll_status],1 ; if scrolled, don't print CR+LF
        jz wait_for_me_no_crlf

        call print_crlf2               ; (non-redirectable)

wait_for_me_no_crlf:
        call print2                    ; (non-redirectable)
wait_for_me_no_msg:
        pop cx
        cmp cl,60

;        jnb wait_for_me_goto_end       ; (won't fit w/ some asms)
        jb wait_for_me_here
        jmp wait_for_me_ret            ; cheesy workaround  Razz
wait_for_me_here:
        xor ch,ch
        mov bx,cx
        mov ah,2Ch
        int 21h                        ; get current DOS time
        add bl,dh                      ; DH = seconds
        cmp bl,60
        jb wait_for_me_check
        sub bl,60
wait_for_me_check:
        int 21h
        push ax
        push bx
        cmp bl,dh
        jae wait_for_me_okay
        add bl,60
wait_for_me_okay:
        sub bl,dh
        mov al,bl

;        xor ah,ah                      ; =
;        mov cl,10                      ; =
;        div cl                         ; = 6 bytes
        aam                            ; =
        xchg ah,al                     ; = 4 bytes

        or ax,'00'                     ; convert to ASCII

        mov di,bp
        mov si,di

        scasw                          ; prevents cursor flickering
        jz wait_for_me_no_print
        mov di,si
        stosw

;        push ax                        ; this helps prove that it doesn't
;        mov al,BEEP                    ;   display more often than needed
;        int 29h                        ;   (i.e. only when secs. changed)
;        pop ax

        test word ptr [suboptions],(SUBOPT_H or SUBOPT_Y)
        jnz wait_for_me_no_print

        mov al,BACKSPACE
        mov bx,offset print_char2
        call bx
        call bx                        ; backup the cursor twice
        lodsb
        call bx                        ; overwrite countdown digits
        lodsb
        call bx

wait_for_me_no_print:
        pop bx
        mov ah,0Bh
        int 21h                        ; check for keypress
        test al,al                     ;  (and eat extended byte, if exists)
        pop ax
        jz wait_for_me_compare
        mov ah,8
        int 21h                        ; get keypress w/o echo
        cmp al,ESCAPE_KEY              ; on Esc, disable pauzing (/P)
        jnz wait_for_me_test
        or word ptr [options],OPT_P
        and word ptr [suboptions],not SUBOPT_H
wait_for_me_test:
        cmp al,'p'                     ; 'p' or 'P' pauzes the countdown
        jz wait_for_me_really_wait
        cmp al,'P'
        jnz wait_for_me_test2
wait_for_me_really_wait:
        push ax
;        mov ah,8
wait_for_me_test_again:
        int 21h                        ; get keypress w/o echo
        test al,al
        jz wait_for_me_test_again
        pop ax
wait_for_me_test2:
        test al,al                     ; if zero, extended keypress
        jnz wait_for_me_ret
        int 21h                        ; so, eat next (extended) byte
wait_for_me_goto_end:
        jmp short wait_for_me_ret
wait_for_me_compare:
        cmp bl,dh

        jnz wait_for_me_check         ; used to be too big for short jump
;        jz wait_for_me_ret
;        jmp wait_for_me_check
wait_for_me_ret:
        ret
    
Post 08 Nov 2010, 15:07
View user's profile Send private message Visit poster's website Reply with quote
adroit



Joined: 21 Feb 2010
Posts: 252
adroit 10 Nov 2010, 01:41
lol Laughing [b]revolution Laughing

bitRake, I'll see what I can do

rugxolu, i've got to analyze this code

...ill be back
Post 10 Nov 2010, 01:41
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.