-
April 14th, 2009, 05:03 PM
#1
how to print a string with frame
i need to write a prog in assembly language that prints a frame around a string after inputing it with the keyboard.
example
input string:hello
*********
*hello *
*********
the lenght of the frame increases with the lenght of the string. i wrote this but i cannot output the string with the frame
TEXTOUT MACRO TEXT
MOV AH, 09
LEA DX, TEXT
INT 21H
ENDM
TEXTIN MACRO BUF
MOV AH, 0AH
LEA DX, BUF
INT 21H
ENDM
StackS SEGMENT PARA STACK 'STACK'
DW 32 DUP(?)
StackS ENDS
MAX_TEXT EQU 10
DATA SEGMENT PARA PUBLIC 'DATA'
MESS1 DB 0AH,0DH,"input string: $"
BUF1 DB MAX_TEXT
QNT1 DB 0
TEXT1 DB MAX_TEXT DUP(?)
DATA ENDS
CODE SEGMENT PARA PUBLIC 'CODE'
ASSUME CS:CODE, DSATA, SS:StackS
start:MOV AX, DATA
MOV DS, AX
MOV ES, AX
TEXTOUT MESS1
TEXTIN BUF1
MOV AH,1
INT 21H
XOR CH, CH
MOV CL, QNT1
LEA DI, TEXT1
XOR BX,BX
mov dl,al
mov ah, 2
int 21h
MOV AH, 4CH
code ends
end start
pls i need help
-
April 15th, 2009, 02:59 PM
#2
Re: how to print a string with frame
I will not give you the exact code this time. Here are the steps you can do.
Code:
PRINT NEWLINE CHARACTER 0ah to move down the cursor
GET THE CONTENT OF "QNT1" AND ADD 4 to it (2 additional for left and right)
PRINT THAT MANY "*"s (QNT1 + 4) - you can use CX and LOOP combination to do this
PRINT NEWLINE CHARACTER 0ah to move down the cursor
PRINT 1 '*' for the left side asterisk
PRINT 1 space (' ') for the space between the first asterisk and the text
GET THE CONTENT OF "QNT1" and iterate as many times while printing the content of [DI]
PRINT 1 space (' ') for the space between the text and the last asterisk
PRINT 1 '*' for the right side asterisk
FOR THE BOTTOM ASTERISKs, do the same as the top asterisks
Or in pseudo code, it would be something like
Code:
PRINT "\n"
PRINT '*' (QNT1 + 4 TIMES)
PRINT "\n"
PRINT "*"
PRINT " "
PRINT TEXT1
PRINT " "
PRINT "*"
PRINT "\n"
PRINT '*' (QNT1 + 4 TIMES)
You can use interrupt 21h function 2 for printing and CX/LOOP combination for iterations
-
April 16th, 2009, 08:29 PM
#3
Re: how to print a string with frame
I dnt understand where and how to start
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|