Jump to content

Output help

- - - - -

  • Please log in to reply
1 reply to this topic

#1
ahmed

ahmed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
My assembly language course just started in uni and i want to get a quick head start. Teacher has just taught how to display on screen . I am having problem in making program that takes a string as an input and displays it . Now i can take the input and i read that 0AH takes input in AH and then returns offset to DX. Now how can i get that string from DX ?

.model small

 d_s segment 'data'

 st1 db "Enter your string : ",13,10,'$'
 st2 db ""
 d_s ends


 c_s segment 'code'

  assume cs:c_s,ds:d_s

 main proc far

 mov Ax,d_s
 mov Ds,Ax
 mov AH,09
 mov dx,offset st1
 int 21H

 mov AH,0AH          #  [B]input[/B]
 int 21H
 

 mov Ds,Dx               [B]# the problem part[/B]
 mov AH,09
 mov Dx,offset Dx
 int 21h

 mov AH,4CH
 int 21H

 main endp

 c_s ends

end main


#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,705 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
You need to pass in your own buffer to the interrupt in DS:DX before you call it; it won't construct one for you. Take a look:

Interrupt Jump Table - INT 21H AH=0AH

Clearly you're using MASM which I'm not really familiar with, but this is somewhat how you'd do it generically. Do not copy this verbatim, it's only for demonstrative purposes.

; first byte is the number of characters the buffer can hold

; the interrupt code will fill the second byte with the number of characters

; actually read, and the next 16 are the actual buffer.


buffer db 16, 0, 16 dup (?)


mov     ah, 0ah

mov     dx, seg buffer

mov     ds, dx

mov     dx, offset buffer

int     21h


Edited by dargueta, 26 October 2010 - 11:51 AM.
Readability

sudo rm -rf /




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users