×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Text display

Text display

Text display

(OP)
Hi everyone!

I'm pretty new to assembler and I need your help to solve the following problem. I would like to create a DOS program which will display "Hello world" message with typewriter effect.
I'm not asking to provide me with solution, merely to direct me in the right way so I can learn how it can be done.

Thanks in advance and have a nice day!

RE: Text display

This -> http://www.ctyme.com/intr/rb-0100.htm
Plus a delay between characters.
Plus a loop to print the whole string.
 

--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

RE: Text display

(OP)
Thanks Salem!

So far I've managed to print string character by character but I'm having trouble with the delay part! Here's the code:

code    segment

    assume cs:code,ds:code

    org 100h

Typewriter:
        mov     si, 0 ; setting the index register

print_next:
        mov al,MyString[si]  ; obtaining the character to print
        cmp al,0  ; is it a 0? If yes that means I've reached
        je quit_typing  ; the end of my string and should stop

        mov ah, 0eh  ; writing character in
        int 10h      ; a teletype mode

    mov cx,000fh  ; This part is giving me the headache!
    mov dx,4240h  ; It should cause the delay of half a
    mov ah,086h   ; second (1000000 msecs), right?
    int 15h       ; NOT WORKING!! PLEASE HELP!!

        inc si  ; increment index register to get the next character

        jmp next_char  ; continue with printing next char


quit_typing:
        mov ah, 0  ; wait for user to press some key
        int 16h    ; and when that happens
        ret  ; exit and return control to DOS

MyString db 'Hello world!', 0

code ends

end Typewriter

The following link shows exactly what I'm trying to achieve:

http://www.youtube.com/watch?v=oMURyUP1s1Y

You see how that text is being printed? Thanks in advance!

RE: Text display

(OP)
Hi everyone!

I've managed to finish this little program ;) I would like you to tell me if there is a way (and need) to optimize the code so that it works faster. Here's the code:


code segment
     assume cs:code,ds:code
     org 100h

Typewriter_pocetak:
        xor si,si
    mov dh,10
    mov dl,25
    mov ah,02h
    int 10h        
sljedeci_znak:
        mov al,J3l3n4[si]
        cmp al,0
        je kraj_ispisa    
    mov di,5
    cmp al,32
    je Ispisi
    Nastavi_ispis:
        mov ah,0eh
        int 10h
    xor ah,ah
    int 1ah
    mov bx,dx
    Pauza:
        xor ah,ah
        int 1ah
        sub dx,bx
        cmp di,dx
        ja Pauza
        inc si
        jmp sljedeci_znak
kraj_ispisa:    
    int 20h

J3l3n4 db 'Dear user!',10,13,10        
         db '                      Whish you a good day :)',10,10,13,0

Ispisi:
    mov di,1
    jmp Nastavi_ispis

code ends
end Typewriter_pocetak

As you can see I'm willing to learn and that's the reason why I'm asking you to help me. I hope that with your help I'll be able to write better and efficient Assembly code. Thanks in advance!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close