I need to write a program that can input a string. And the program can display the string on the monitor will different color for each character.
The result will like that
ABC

I have but not success.Here is the code that i tried.
Please help me.

PUTSTR MACRO STRING ; put a string on the screen macro
MOV DX,OFFSET STRING ;macro show the string of DX
MOV AH,09H
INT 21H
ENDM


PUTCHAR MACRO CHAR ;put a character on the screen macro
MOV DL,CHAR
MOV AH,02H ;show char
INT 21H
ENDM


GETSTR MACRO ;get a string macro
MOV AH,0AH
INT 21H
ENDM


EXIT MACRO ;end of progam
MOV AH,4CH
INT 21H
ENDM


.MODEL SMALL
.STACK 100H ;size of stack = 100

.DATA
BUFFER DB 19,20 DUP(0), '$'
MSG1 DB 'Please enter a string: $'



.CODE
BEG: MOV AX,@DATA
MOV DS,AX

PUTSTR MSG1 ;show message

LEA DX,BUFFER ;setup a string
GETSTR ;get a string from keyboard

MOV AX,0B800H
MOV ES,AX
MOV DI,0

LEA BX,BUFFER ;count the string and loop
ADD BX,1
MOV CL,BYTE PTR DS: ;loop correct


LEA BX,BUFFER ;put the string to AL
ADD BX,2
NEXT:

MOV DL,BYTE PTR DS: ;move the to byte char 

MOV AL,DL ;move the byte char out one by one


MOV AH,4H ;attributes

MOV WORD PTR ES:[0B800H],AX

;MOV AL,20H


 
;MOV AH,02H ;show char 
;INT 21H



INC BX ;jump to next char 
INC AH ;jump to next color 


LOOP NEXT

EXIT
END BEG
Posted on 2006-05-05 22:14:03 by wkawaii
It is normal that with MASM 32 it doesn't work...

cause with MASM 32 it is impossible to use interrupts...

Try to use TASM or GoAsm.....(one can use int with them)

The why MASM doesn't support int is in the aim to diminuish
the probabilities to create little programs serving like virus...
By using the ints which permit to use an enumeration of files....

( Table_interrupt)
Interrupt_21__AH=11h
Interrupt_21__AH=12h


Then try to use TASM or GoAsm...

Normally in USA it is forbidden to use TASM cause of that....

I think my answer is good....

Good enjoy...
-----
Gerard

Posted on 2006-05-06 03:29:59 by gerard
I have no idea what gerard speaks of, as I am a US resident.

What he is trying to do is use DOS interrupts. MASM32 generally commits itself to the Windows API. MASM, however, does appease to 16-bit code and does generally allow interrupts, which is what I think wkawaii is trying to do.

If I wasn't so busy with my OS dev stuff ATM (just checking up here), I would be more than happy to pick through your code. I will consider it later if someone else hasn't helped by that time.
Posted on 2006-05-06 04:19:17 by SpooK
Whoa, Gerards post was about 100% nonsense :-s

wkawaii, masm will do fine for assembling 16bit code, but you'll need a 16bit linker. The linker from the MASM32 package (which you're probably using?) only supports 32bit programs. Get Link version 5.63 here: http://spiff.tripnet.se/~iczelion/download.html

EDIT: farrier has raised the question whether obtaining the 16bit linker from the above link is legitimate. Fair question, if you're worried get it directly from Microsoft: ftp://ftp.microsoft.com/softlib/MSLFILES/LNK563.EXE .
Posted on 2006-05-06 04:51:42 by f0dder
Gerard, wherever you heard that from, I can assure you it is entirely unfounded :)

PS: Remember, "Words fly." ;)
Posted on 2006-05-06 05:34:13 by SpooK
Sorry dude i havent got enough time to code it the way i like. but anyway, it works

Posted on 2006-05-06 22:43:11 by XCHG
Thankyou XCHG!

It work!
Posted on 2006-05-07 02:30:23 by wkawaii