Read String From Keyboard

is there a way to read a string from a keyboard? based from what i have researched, what's possible is only per character!

basically, what i want to do is read a string from a keyboard, and send that string to com1. and from com1, com2 will read it. this is via serial port. i have already tried character sending, and up until now i'm researching on how to send and read strings.

help! thanks!
[422 byte] By [toxicboy] at [2007-11-20 9:39:20]
# 1 Re: Read String From Keyboard
Which operating system? Which CPU? Which assembler?

If you are using DOS, take a look at int 21h and other interruption numbers.
olivthill at 2007-11-10 3:55:11 >
# 2 Re: Read String From Keyboard
toxicboy
i assume you are using DOS
Read the post by rxbagain
http://www.dev-archive.com/forum/showpost.php?p=1257185&postcount=3

It uses DOS function 0Ah to get string from user.
BytePtr at 2007-11-10 3:56:11 >
# 3 Re: Read String From Keyboard
thanks byteptr, i will be checkin it out

olivthill, i am using windows xp, nasm. i checked out int 21 and it only allows characters, and the only function which involvs strings is printing it to the screen...

update:

the code is full of errors! i think it's not in nasm. and also, i think i've stumbled upon a code like this before, but not on this site, and MOV DX, STRING1 for example is not supported by COFF format.

what i basically want to do is read a string from a user, store it in memory, and send each character from that string to a serial port.
toxicboy at 2007-11-10 3:57:10 >
# 4 Re: Read String From Keyboard
Yes, its for TASM. I fully understand what you want to do but it seems difficult with NASM.

I also use TASM/MASM always for DOS programming.
And MASM32 for Win32.

Well i have checked NASMW (NASM for windows 32bit) but it has no libs for different useful things.

I dont know what XP thinks about app that uses IN/OUT for writing to COM port. With MASM32 you have more power. It has libs, tuts, big help files with great documentation and everything you need to do such app.

In NASMW packages i dont see any libs or im blind?
If anyone finds such libs then let me know.

So in NASMW you must write all by yourself.
Thats why i dont use NASMW.
BytePtr at 2007-11-10 3:58:17 >
# 5 Re: Read String From Keyboard
oh man, we are required to do things in nasm, plus it's what's been taught to us.

i wrote this, and i'm having trouble checkin if it's workin or not, does this code make sense?

instead of working with strings, i just worked with an array, that is in essence, my "string"

segment .bss
chars resb 5 ;array with 5 characters

segment .text
global _asm_main

_asm_main:
enter 0,0
pusha

xor ecx,ecx ;counter for how many characters are there in the string

repeat:
mov ah, 00h ;ask for character
int 16h

mov ah,02h ;prints the character to the screen
mov dl,al
int 21h

mov [chars+ecx], al ;puts the characters in the array
add ecx,1

cmp al,'x' ;x signifies end of string
jne repeat ;repeat until the user does not enterx

je cont

cont:
mov ebp, chars ;point ebp to the array
xor ebx,ebx ;used as counter to traverse the array

com1:
mov dx,0 ;send the first value in the array to com1
mov ah,1
mov al, [ebp+ebx]
add ebx,1
int 14h

mov dx,1 ;com2 will read the sent character
mov ah,2
int 14h

mov dl,al ;prints the sent character to the screen
int 21h

loop com1 ;loop until there are characters to be sent

popa
mov eax,0
leave
ret

update:
i tried this code, and it printed e! which means there's some sort of error in my cable, or in my hardware, i dunno!

segment .text
global _asm_main

_asm_main:
enter 0,0
pusha

mov dx,0
mov al,'a'
mov ah,1
int 14h
test ah,80h
jnz error

error:
mov ah,02
mov dl,'e'
int 21h

popa
mov eax,0
leave
ret
toxicboy at 2007-11-10 3:59:16 >