
November 12th, 2006, 10:08 AM
|
|
|
|
8086 String Input
For one of my classes we got an assignment of emulating the MIPS IO functions into the 8086 intsruction set the problem im having is that in mips you can input an aparently endless string while i haven't been able to find a way to this in 8086. I someone could give me some info on string handling on 8086 much apreciated.
My idea:
1. get char one by one
2. store in memory one after another and end with $ sign
The problem:
Not really sure how to do the second.
I think the second time calling the proc it would get erased since it would write in the same place.
Code:
.model small
.stack 100h
.data
endline db 10 , 13 ,'$'
mess db 'Got Micro?$'
marca db 'A$'
.code
main proc
mov ax,@data ;moves data into ax
mov ds,ax ;places it in the data segment
mov dx, OFFSET mess ;places in dx address from the start of mess
mov ah,9 ; puts in ah the value for call to display a string
int 21h
mov dx, OFFSET endline
mov ah,9 ; puts in ah the value for call to display a enterline
int 21h
;mov ah,2 moves cursor
;int 10h
mov di, 0 ; makes cx a 0
pur:
mov ah,1 ; takes a char from the input
int 21h
mov marca[bx+di] , Al
inc di
cmp Al , 13
JNE pur
mov marca[bx+di] , '$'
mov dx, OFFSET marca ;places in dx address from the start of mess
mov ah,9 ; puts in ah the value for call to display a string
int 21h
;jnz pur
mov ax, 4c00h ; return to ms-dos
int 21h
main endp
end main
|