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

hello,
my program work but the prolem is when the second become 59 the text stoped why this is my problem


msg               db            'welcome$'
s                 db              0
c                 db              70
---------------------------------------

repeat:
        mov  ah,2ch
        int  21h
        cmp  dh,60
        je   x
        add     dh,1
        mov  byte ptr,dh
        jmp  time
x:
      mov  byte ptr,1      ;here is the problem

time:
        mov   ah,2ch
        int   21h
        cmp   dh,s
        jl    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
        jg    repeat
        mov   ah,4ch
        int   21h

welcome
i tried with many forms but the problem still the same!!!  :'(
i'm realy need your help



MichaelW

I'm not sure what your code is supposed to do, but one problem is that the seconds will be in the range 0-59, and you are testing for the value 60.
eschew obfuscation

HATEM

thank you MichaelW for your post
the function of my program is shift the texte from colone 70 to 10 one time
like this
welcome
Quotebut one problem is that the seconds will be in the range 0-59
yes i forget but still the same problem !!
my program work well i tested it without time but the problem in this part

        mov  ah,2ch
        int  21h
        cmp  dh,59
        je   x
        add     dh,1
        mov  byte ptr[s],dh
        jmp  time
x:
      mov  byte ptr[s],0      ;here is the problem becose while the dh less than 59 it works well

time:
        mov   ah,2ch
        int   21h
        cmp   dh,s
        jl    time


FORTRANS

HATEM wrote:


        cmp  dh,59
        je   x
        add     dh,1
        mov  byte ptr[s],dh
        jmp  time
x:
      mov  byte ptr[s],0      ;here is the problem becose while the dh less than 59 it works well

time:
        mov   ah,2ch
        int   21h
        cmp   dh,s
        jl    time


As MichaelW wrote, DH is 0 - 59, it will never be less than zero.
Go back to putting 1 into .

HTH,

Steve N.

HATEM

thank you FORTRANS  for your reply

QuoteAs MichaelW wrote, DH is 0 - 59, it will never be less than zero.
Go back to putting 1 into .


        cmp  dh,59
        je   x
        add     dh,1
        mov  byte ptr[s],dh
        jmp  time
x:
      mov  byte ptr[s],1      ; i puted 1 in [s] but not wrk too and puted 0 it's the same !!
time:
        mov   ah,2ch
        int   21h
        cmp   dh,s
        jl    time

Who can solve this diffecult problem ? it's realy difficult because there is no error in the code

MichaelW

I took the first code you posted, changed the 60 to 59, changed two of the names to avoid MASM reserved words, and added code to wait for a keystroke before exiting, and the result does what you describe. Are you sure that the error is not somewhere in the code that you did not post?

.model small
.stack
.data
  msg db 'welcome$'
  s   db 0
  _c  db 70
.code
.startup

_repeat:
        mov  ah,2ch
        int  21h
        cmp  dh,59
        je   x
        add  dh,1
        mov  byte ptr[s],dh
        jmp  time
x:
      mov  byte ptr[s],1      ;here is the problem

time:
        mov   ah,2ch
        int   21h
        cmp   dh,s
        jl    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
        jg    _repeat

        ; Wait for a key press before exiting.
        mov ah, 0
        int 16h

        mov   ah,4ch
        int   21h
.exit
end

eschew obfuscation

HATEM

I still have the same problem when the second dh=59 it will exit the program  :'(
test it and don't forget to see the second in the time when you excute the program

[attachment deleted by admin]

MichaelW

Under Windows 2000 the code I posted scrolls from column 70 to column 10, then waits for a key press before exiting. The EXE you posted does the same. The only problem I see is that the scrolling is not synchronized with the seconds, so unless you start the program at second 0, the scrolling will skip some of the positions, moving to the final position when the seconds reach 59.
eschew obfuscation

HATEM

thank you MichaelW  for your help

Quote
the scrolling will skip some of the positions, moving to the final position when the seconds reach 59.

this is what i mean why skip some of the positions!!!

FORTRANS

Hi,

   The problem with the code is the test for less than 1 (when DH is 59).


;        cmp  dh,59    ; get rid of this
;        je   x
;        add  dh,1
        mov  byte ptr[s],dh
;        jmp  time
;x:
;      mov  byte ptr[s],1      ;here is the problem

time:
        mov   ah,2ch
        int   21h
        cmp   dh,s
        JE    time  ; Try this


HATEM

thank you very much FORTRANS
it's a better than what i did and a short code you are a clever   :clap:
i saw your programs here http://www.masm32.com/board/index.php?topic=9510.msg69297#msg69297in graphic and i want you to teach me please because i want to learn how can i draw in assembly and this is my first program in graphic "scrolling text"


FORTRANS

Hi HATEM,

   You are welcome.  Glad you liked my little programs.
Your best bet for learning graphics is getting a good book.

   One of my favorites is:
;    "Programmer's Guide to PC Video Systems"
; Second Edition, by Richard Wilton.

   The text and code of the first edition are available
as ZIP files.  VGAGUIDE.ZIP  VGAG-SRC.ZIP

   Another book is:
;   "The Revolutionary Guide to Bitmapped Graphics"
;   by Control Zed

   Ralf Brown;s Interrupt List explains the BIOS video
services.

   Here are the remains of a small program that I was
using to find an answer to what a strange statement
in one of my books really meant.

        PAGE ,132
        TITLE Mode 13H Test
        NAME TEST13

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CODE    SEGMENT
        ORG     100H ; COM file opening
        ASSUME  CS:CODE,DS:CODE,ES:NOTHING
Start   PROC    FAR     ; apparently needed for ORG to work?

        MOV     AX,13H  ; Set 256 color graphics
        INT     10H

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

        XOR     BX,BX     ; 30
        MOV     CX,255
Loop_1:
;        MOV     BX,CX
        MOV     ES:[BX],CL
        INC     BX        ; 30
        LOOP    Loop_1

        MOV     CX,255
;        MOV     DI,OFFSET TestData

Loop_2:
;        MOV     BX,CX
;        MOV     AL,ES:[BX]
;        MOV     [DI],AL
;        INC     DI
;        LOOP    Loop_2

        MOV     AX,ES   ; 30 October 2007
        MOV     DS,AX
        MOV     DI,640
        XOR     SI,SI
    REP MOVSB

        MOV     AH,1    ; Console IN
        INT     21H     ; wait for keypress

        MOV     AX,3    ; reset to test mode.
        INT     10H

        MOV     AX,04C00H ; Exit
        INT     21H

;TestData DB     255 DUP( 0 )
Start   ENDP
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CODE    ENDS
        END     Start


Regards,

Steve N.

HATEM


HATEM

hello,
I have two questions and i need your help

1- i want to let the text scorll untill key pressed but i didn't know please tell me which interrupt can i use?

2- there is two ways to print text on the screen the first one is with using interrupt like in the example above(scroll text).and the second one which i'm asking about how ? which is reach to  the graphic card directly!!  :(

regards

FORTRANS

Quote from: HATEM on September 04, 2008, 04:46:09 PM
1- i want to let the text scorll untill key pressed but i didn't know please tell me which interrupt can i use?

BIOS function 1, or 11H, test for a keystroke.  Zero is if no key has been hit
Non-zero if one is ready.  DOS function 6 works the same if DL is 0FFH.

Quote
2- there is two ways to print text on the screen the first one is with using interrupt like in the example above(scroll text).and the second one which i'm asking about how ? which is reach to  the graphic card directly!!  :(

0B0000H for MDA text 0B8000H for CGA text.  Set segment register
to 0B000H or 0B800H.

HTH,

Steve N.

Edit: BIOS Int 16H Function 1 ro 10H.