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
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.
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
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.
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
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
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]
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.
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!!!
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
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"
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.
thank you very much Steve :U
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
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.
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
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.
thank you very much :U
It has helped me greatly this program :clap:
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.
thank you very much for your help
yes you did it ,display a text without interrupt :U
(http://www.monsterup.com/upload/1220657165.jpg) (http://www.monsterup.com)
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:
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.
thank you very much MichaelW :cheekygreen: