flat assembler
Message board for the users of flat assembler.

Index > DOS > key I/O..

Author
Thread Post new topic Reply to topic
abuashraf



Joined: 11 Nov 2006
Posts: 88
abuashraf 04 Feb 2008, 16:33
Hi...

I'm trying to enter a string and then print it again
this small program let you enter number of chars and exit after pressing enter
so my problem is how to save this chars in an array and after pressing enter
I want to print the whole string agin using int 33.

please note that I don't want to use any other ints except int 16h,int 33


Thanx.
Code:
org 256

xor cx,cx
start:
xor ah,ah       ;input from keyboard
int 16h
cmp al,0x0d  ;is it enter
je exit         ;yes get out

call putc
jmp start      ;repeat

exit:
int 32

putc:
 push ax cx dx
 mov ah,2
 mov dl,al
 int 33
 pop dx cx ax 
ret
    
Post 04 Feb 2008, 16:33
View user's profile Send private message Reply with quote
michalll



Joined: 01 Mar 2007
Posts: 7
michalll 04 Feb 2008, 18:37
Wouldn't it be easier using ah=10 and ah=9?
Post 04 Feb 2008, 18:37
View user's profile Send private message Reply with quote
abuashraf



Joined: 11 Nov 2006
Posts: 88
abuashraf 05 Feb 2008, 00:42
I know that but I only want to use int 33,int 16h
Post 05 Feb 2008, 00:42
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 05 Feb 2008, 00:49
so, to memorise a sequence, two solutions:

a simple buffer, null terminated, to build an asciiZ string, and print it via int21h
read the values on the text screen and transfert copy them to another location , screen or else. need to read the video memory @ 0B8000h linear.
Post 05 Feb 2008, 00:49
View user's profile Send private message Visit poster's website Reply with quote
abuashraf



Joined: 11 Nov 2006
Posts: 88
abuashraf 05 Feb 2008, 01:06
My problem ,how to copy this chars to the buffer,and then after that
getting them one after another,and print them,
would you please show me a simple code.
Post 05 Feb 2008, 01:06
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 05 Feb 2008, 01:30
Code:
      org 100h 
      xor cx,cx 
start: 
      mov si,buffer
      xor ah,ah       ;input from keyboard 
      int 16h 
      cmp al,0x0d     ;is it enter 
      je exit         ;yes get out 
      mov [si],al
      inc si
      cmp si,buffer+100h
      je @f
      dec si   ; to force the string leng to 256 chars
@@:
      call putc 
      jmp start       ;repeat 

exit: 
     mov di,(80*xx+yy)*2
     mov si,buffer
     call txt
     int 20h 

putc: 
      push ax cx dx 
      mov ah,2 
      mov dl,al 
      int 21h
      pop dx cx ax  
      ret 
txt:
      mov ax,0b800h
      mov es,ax
      mov ah,71h ; blue text on grey 
@@:
      mov al,[si]
      or al,al
      je .end
      inc si
      mov [es:di],al
      add di,2
      jmp @b
.end:
      ret
buffer rb 100h  ;to memorise up to 256 chars
         db 0   ; for asciiZ formating
    
Post 05 Feb 2008, 01:30
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1398
Location: Piraeus, Greece
Picnic 06 Feb 2008, 18:08
Hello abuashraf, these two links might help, it's about input and output string.

http://board.flatassembler.net/topic.php?t=316
http://board.flatassembler.net/topic.php?t=4338

Also see about INT 21h / AH=0Ah it's a fast way to input a string.
Post 06 Feb 2008, 18:08
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.