Click to See Complete Forum and Search --> : Set Cursor Help


bevanrus99
May 8th, 2008, 12:52 AM
My program prints a string, then reverses it into another string and displays it, then reverses it back to a 3rd string and displays it again. The program works, but now I am trying to make all three strings display on seperate lines and put a background color in it. I know how to do these things, but when I try it just gives me an error. Is there something wrong with my code.


TITLE TEST1
.MODEL SMALL
.STACK 64
;-------------------------------------------------------------
.DATA
STRING1 DB 'ABCDEFGHIJKLMNOPQ','$'
STRING2 DB 17 DUP('*'),'$'
STRING3 DB 17 DUP('*'),'$'
;-------------------------------------------------------------
.CODE
A10MAIN PROC FAR
MOV AX,@data
MOV DS,AX
MOV ES,AX

MOV CX,17
LEA SI,STRING1
LEA DI,STRING2+16
LEA BX,STRING3+16

MOV AH,09H
LEA DX,STRING1
INT 21H

A2: LODSB
MOV [DI],AL
DEC DI
LOOP A2

MOV AH,09H
LEA DX,STRING2
INT 21H

A3: LODSB
MOV [BX],AL
DEC BX
LOOP A3

MOV AH,09H
LEA DX,STRING3
INT 21H


MOV AX,4C00H
INT 21H
A10MAIN ENDP
END A10MAIN

S_M_A
May 8th, 2008, 03:42 AM
What kind of error do you get?

Can't really say that I remember DOS interrupts that well but shouldn't there be a CR/LF termination of each line to acheive what you want?

Regarding the color (weak memory also here), you have to switch to graphic mode to be able to use colors at all.

bevanrus99
May 8th, 2008, 03:50 AM
The program works, but when I try to add color and display it using int 10h the hole program stops working. It won't display one of the strings, or it won't end. I get various results depending on where I place the color code.

S_M_A
May 8th, 2008, 03:56 AM
Have you set display to graphic mode? Int 10h, ah=0, al=mode see here http://www.ctyme.com/intr/cat-003.htm

Edit: Man I really regret discarding my old 16 bit TurboX.Y packages. Are those free for download these days?

bevanrus99
May 8th, 2008, 05:11 AM
Here is the new code, I got the set cursor to work. Just need color. Everytime I try, it messes up something else. Someone help if you can please. Thanks.

TITLE TEST1
.MODEL SMALL
.STACK 64
;-------------------------------------------------------------
.DATA
STRING1 DB 'I FINALLY GOT IT!!','$'
STRING2 DB 18 DUP('*'),'$'
STRING3 DB 18 DUP('*'),'$'
;-------------------------------------------------------------
.CODE
A10MAIN PROC FAR
MOV AX,@data
MOV DS,AX
MOV ES,AX

MOV CX,18
LEA SI,STRING1
LEA DI,STRING2+17
LEA BX,STRING3+18


MOV AH,02H
MOV BH,00
MOV DH,01
MOV DL,19
INT 10H
MOV AH,09H
LEA DX,STRING1
INT 21H


CLD
A2: LODSB
MOV [DI],AL
DEC DI
LOOP A2


MOV AH,02H
MOV BH,00
MOV DH,11
MOV DL,28
INT 10H
MOV AH,09H
LEA DX,STRING2
INT 21H

STD
A3: LODSB
MOV [BX],AL
DEC BX
LOOP A3


MOV AH,02H
MOV BH,00
MOV DH,22
MOV DL,19
INT 10H
MOV AH,09H
LEA DX,STRING3
INT 21H
POP DS

MOV AX,4C00H
INT 21H
A10MAIN ENDP
END A10MAIN

S_M_A
May 8th, 2008, 06:32 AM
Think I have to try to find an old Turbo package and try this myself. Did you know if it was free for download anywhere? On what platform do you run this by the way? It could be that some things aren't supported in XP.

bevanrus99
May 8th, 2008, 12:20 PM
I use MASM and I've had it for a long time so I don't know if it is free or not. I have Windows Xp, but I don't think that is the case since I have never had troulbe inputting color before.

S_M_A
May 9th, 2008, 06:29 AM
Masm is free for non-commercial use. I've downloaded it, hope I can find some time this weekend to look into it if you still haven't debugged it.

BytePtr
May 9th, 2008, 07:12 AM
I would fix your program instantly, coz i love DOS (16bit) assembly but you have no comments in your source. I don't understand how you are remembering what each line in your program does.

I would comment almost every line so i could look through them and i could find bug. But seems that you don't love commenting sources.

Another way is that i will rewrite whole app for you.

bevanrus99
May 9th, 2008, 07:42 PM
How would you do it? I don't have time to comment it right now, but I can later. I'd like to hear if you have a different way though.