I have a NASM Assembly Language lab that Im working on and I
I have a NASM Assembly Language lab that Im working on, and I really need some help with it. If anyone could help me that would be great!
I have to write an 8086 nasm program which does the following:
1) Sets aside two buffers of 100 bytes each to hold input strings.
2) Write a function INSTRING which accepts the address of a string buffer on the stack, and uses int 21h, function 1 and an appropriate string instruction to read a string from the keyboard and store it in the buffer. The string is to be terminated with an ASCII NULL character (character code 0) as the end-of-string marker
3) Write a function LENGTH which accepts the address of a string buffer on the stack and returns the number of characters (not including the end-of-string character) in ax. You may use either based mode, indexed mode, or string instructions to accomplish this task.
4) Write a function WCOUNT which accepts the address of a string buffer on the stack and returns the number of words in the string in the ax register. A \"word\" will be considered to be a sequence of characters not including an ASCII space character (ASCII code 20h.)
 
 5) Write a function PRINTLN which will accept to address of a string buffer containing a zero-terminated string on the stack and prints all the characters in the string, followed by a carriage return and a linefeed.
6) Write a function NUMOUT which will accept a number on the stack and prints it as a base 10 integer.
All your functions should save and restore all the register used except for those used in returning values. You main program will call these functions, prompting for the input of each string. Use INSTRING to input two separate strings into your two buffers. It will then use LENGTH, WCOUNT, NUMOUT, and PRINTLN to produce input similar to the following sample output:
Sample output:
Please enter the first string: Able was I ere I saw Elba
 Please enter the second string: The amount owed is $100
 
 The first string has a length of 25
The second string has a length of 23
 The first string has a word count of 7
 The second string has a word count of 5
The first string is: Able was I ere I saw Elba
 The second string is: The amount owed is $100
I am stuck on the main fucntion and writing most of the other functions because the user is inputing two strings instead of one.
Solution
DATA SEGMENT
        STR1 DB \"ENTER FIRST STRING HERE ->$\"
        STR2 DB \"ENTER SECOND STRING HERE ->$\"
        STR11 DB \"FIRST STRING : ->$\"
        STR22 DB \"SECOND STRING: ->$\"
        INSTR1 DB 20 DUP(\"$\")
        INSTR2 DB 20 DUP(\"$\")
        NEWLINE DB 10,13,\"$\"
        N DB ?
        S DB ?
        MSG1 DB \"LENGTH OF THE STRING 1 IS :- $\"
        MSG2 DB \"BOTH STRING ARE DIFFERENT$\"
 
 DATA ENDS
 
 CODE SEGMENT
 
        ASSUME DS:DATA,CS:CODE
 START:
 
        MOV AX,DATA
        MOV DS,AX
 
        LEA SI,INSTR1
        LEA DI,INSTR2
 
 ;GET STRING
        MOV AH,09H
        LEA DX,STR1
        INT 21H
 
        MOV AH,0AH
        MOV DX,SI
        INT 21H
 
 
        MOV AH,09H
        LEA DX,NEWLINE
        INT 21H
 
        MOV AH,09H
        LEA DX,STR2
        INT 21H
 
        MOV AH,0AH
        MOV DX,DI
        INT 21H
 
 
        MOV AH,09H
        LEA DX,NEWLINE
        INT 21H
 
 
 ;PRINT THE STRING
 
        MOV AH,09H
        LEA DX,STR11
        INT 21H
 
        MOV AH,09H
        LEA DX,INSTR1+2
        INT 21H
 
        MOV AH,09H
        LEA DX,NEWLINE
        INT 21H
 
        MOV AH,09H
        LEA DX,STR22
        INT 21H
 
        MOV AH,09H
        LEA DX,INSTR2+2
        INT 21H
 
        MOV AH,09H
        LEA DX,NEWLINE
        INT 21H
 DISPLAY MSG1
 
 MOV AL,LEN1
 ADD AL,30H
 
 MOV DL,AL
 MOV AH,2
 INT 21H
 
 LEA DI,STR2
 NEXT2:
 CMP [DI],\'$\'
 JE DONE2
 INC LEN2
 INC DI
 JMP NEXT2
 DONE2:
 DISPLAY MSG2
 
 MOV AL,LEN2
 ADD AL,30H
 
 MOV DL,AL
 MOV AH,2
 INT 21H
 
 MOV AL,LEN1
 CMP AL,LEN2
 JE EQUAL
 
 EXIT:
 MOV AH,4CH
 INT 21H
 CODE ENDS
 
 END START



