News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

scroll text but there is a problem?

Started by HATEM, August 26, 2008, 10:30:13 PM

Previous topic - Next topic

HATEM

thank you FORTRANS

i'm new in asm programming and i didn't understand you very well for the seconde one i think it's difficult to me
and about the first quesion you mean
mov ax,1
int 16h


repeat1:
mov  byte ptr[c],70
repeat:

mov ax,1  ; I put it here but it doesn't work?
int 16h   ; i want when i press any key i return to the dos (exit the program)

        mov  ah,2ch
        int  21h
        mov  byte ptr[s],dl
time:
        mov   ah,2ch
        int   21h
        cmp   dl,s
        JE    time

        mov   ah,06h           
        mov   al,01h
        mov   bh,0eh   
        mov   ch,13       
        mov   cl,10     
        mov   dh,13       
        mov   dl,c         
        add   dl,7           
        int   10h
        mov   bh,0     
        mov   dh,13   
        mov   dl,c     
        mov   ah,02
        int   10h
        lea   dx,msg
        mov   ah,9
        int   21h
        dec   byte ptr[c]
        cmp   byte ptr[c],10 ; 10
        jg    repeat

jmp    repeat1

MichaelW

This code will loop, displaying the characters A to Z until you press a key.

.model small
.stack
.data
.code
.startup
    mov dl, 'A'   ; start with character A
  looper:
    mov ah, 2     ; display the character
    int 21h       ; . . .
    inc dl        ; increment to next character
    cmp dl, 'Z'   ; if next character > Z
    jna @F        ; . . .
    mov dl, 'A'   ; start again with character A
  @@:
    mov ah, 1     ; check for keystroke
    int 16h       ; . . .
    jz  looper    ; continue looping of no keystroke
.exit
end


Also, repeat is a MASM reserved word.

eschew obfuscation

HATEM

thank you very much  :U
It has helped me greatly this program  :clap:

FORTRANS

Quote from: HATEM on September 04, 2008, 10:22:12 PM
i'm new in asm programming and i didn't understand you very well for the seconde one i think it's difficult to me

   MichaelW answered your other question.  Here is an example
of writing to the screen.


        PAGE ,132
        TITLE Test Text Display
        NAME TESTTEXT

        COMMENT *
5 September 2008, example for MASM Forum question.
SRN as FORTRANS.
   Write text directly to mode 3 vidieo screen.
MASM Testtext;
LINK Testtext;
EXE2BIN Testtext.exe Testtext.com
*

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CODE    SEGMENT
        ORG     100H ; COM file opening
        ASSUME  CS:CODE,DS:CODE
Start   PROC    FAR

; Initialization
        MOV     AX,CS   ; Save someone from foot shooting if they
        MOV     DS,AX   ; don't EXE2BIN and run the EXE.

        MOV     AX,3H   ; Probably not really needed, but it
        INT     10H     ; clears the screen.

        MOV     AX,0B800H ; Point to video memory.
        MOV     ES,AX

; Write the text

        XOR     DI,DI   ; Point to upper left on screen.
        MOV     SI, OFFSET MsgText1     ; Point to message
        MOV     CX,LenText1             ; and get its length.
        MOV     AH,07                   ; Text attribute, white.

        CALL PutText    ; Call a subroutine to print the text
                        ; since we will do this more than once.

        MOV     AH,10H  ; Pause for user input
        INT     16H     ; Read Extended Keyboard Input.

        MOV     DI,160  ; Point to next line.
        MOV     SI, OFFSET MsgText2
        MOV     CX,LenText2
        MOV     AH,05   ; Text attribute, yellow.  Erm, no it isn't...

        CALL PutText    ; And print it

        MOV     AH,10H  ; Pause for user input
        INT     16H     ; Read Extended Keyboard Input.

        MOV     DI,320  ; Point to third line.
        MOV     SI, OFFSET MsgText3
        MOV     CX,LenText3
        MOV     AH,019H ; Text attribute, BBlue on blue.

        CALL PutText    ; And print it

        MOV     AH,10H  ; Pause for user input
        INT     16H     ; Read Extended Keyboard Input.

        MOV     AX,04C00H ; Exit
        INT     21H

Start   ENDP

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;    Example of writing text to CGA screen.  Note each character
; is two bytes, the character and an attribute byte.
; 5 September 2008, SRN.
;
;  INPUT:   DI = Byte count to locate text on screen.
;           SI = Text to display.
;           CX = Length of text.
;           AH = Text attribute.
PutText:

Loop_1:
        LODSB   ; Get byte (char).
        STOSW   ; Write word (char+attrib).
        LOOP    Loop_1

        RET

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LenText1 DW     10
MsgText1 DB     ' Code it. '
LenText2 DW     11
MsgText2 DB     ' Learn it. '
LenText3 DW     11
MsgText3 DB     ' Enjoy it! '

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CODE    ENDS
        END     Start


   If I understood your question, the above should
help.  But you should get a book, this is pretty
basic stuff.

Regards,

Steve N.

HATEM

thank you very much for your help

yes you did it ,display a text without interrupt  :U


HATEM

Quote from: MichaelW on September 05, 2008, 02:14:51 AM
This code will loop, displaying the characters A to Z until you press a key.

.model small
.stack
.data
.code
.startup
    mov dl, 'A'   ; start with character A
  looper:
    mov ah, 2     ; display the character
    int 21h       ; . . .
    inc dl        ; increment to next character
    cmp dl, 'Z'   ; if next character > Z
    jna @F        ; . . .
    mov dl, 'A'   ; start again with character A
  @@:
    mov ah, 1     ; check for keystroke
    int 16h       ; . . .
    jz  looper    ; continue looping of no keystroke
.exit
end


Also, repeat is a MASM reserved word.



in your code it work well but when i put it in my code always ask me to press the keyboard!!

repeat1:
mov  byte ptr[_c],70
_repeat:

;-------------------------------------------------
mov ax,1 
int 16h   ;here it is ,but why it ask me to press keyboard !! normally the program work untill i press any key to exit it
jnz  exit
;-------------------------------------------------

        mov  ah,2ch
        int  21h
        mov  byte ptr[s],dl
time:
        mov   ah,2ch
        int   21h
        cmp   dl,s
        JE    time

        mov   ah,06h           
        mov   al,01h
        mov   bh,0eh   
        mov   ch,13       
        mov   cl,10     
        mov   dh,13       
        mov   dl,_c         
        add   dl,7           
        int   10h
        mov   bh,0     
        mov   dh,13   
        mov   dl,_c     
        mov   ah,02
        int   10h
        lea   dx,msg
        mov   ah,9
        int   21h
        dec   byte ptr[_c]
        cmp   byte ptr[_c],10 ; 10
        jg    _repeat
jmp    repeat1
exit:


MichaelW

The function number for the BIOS keyboard functions goes in AH not AX. Loading 1 into AX sets AH to 0, so your code is calling function 0. Functions 0 and 10h get a keystroke from the keyboard buffer. If no keystroke is available, the functions wait for a keystroke before returning. Functions 1 and 11h check for a keystroke in the keyboard buffer and return immediately.
eschew obfuscation

HATEM

thank you very much MichaelW  :cheekygreen: