Hey forum, our professor assigned us a program we have to write in assembly language and I would love to have help on it.
Write an upper-to-lower case and lower-to-upper case conversion program.
When the user inputs a letter, your program should convert it to upper case if it is in lower case, or to lower case if it is a capital letter. Continue converting and displaying the results until the user presses the ‘enter’ key with no input. (You can do these conversions by adding or subtracting the appropriate hex value. Check your ASCII chart).
If the user inputs a key that is not A-Z or a-z, display a warning. When the user presses the enter key the warning should disappear and the program goes back to waiting for the user to input another character.
Supply appropriate prompts to the user.
Now, I have some of it figured out until the Code Segment. I wrote my logic in a different language to show what I am trying to do down below.
Assembly Source
;
; INSERT NAME HERE
;
PAGE 80,140
TITLE LAB2-PROGRAM TO ACCEPT A STRING AND CONVERT ALL CHARACTERS TO UPPERCASE
;
STACKSG SEGMENT PARA STACK
DW 32 DUP(?)
STACKSG ENDS
;
DATASG SEGMENT PARA
STRING LABEL BYTE
MAX DB 18 ;maximum input length
ACTUAL DB ?
DATASTR DB 20 DUP(' ') ;size is inputlength+2
DATASG ENDS
;
CODESG SEGMENT PARA
BEGIN PROC FAR ;Start main procedure
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG,ES:NOTHING
MOV AX,DATASG ;Set up DS and ES to point
MOV DS,AX ; to beginning of the
MOV ES,AX ; Data Segment
;[I]All logic code goes after this semi-colon.[/I]
C++ Logic
#include <iostream>
using namespace std;
int main()
{
//Declare variables
char input = ' ';
cout << "Input a character to convert the case of it." << endl;
cout << "Type '!' to stop processing." << endl;
cout << endl;
while(input != '!')
{
//Get character to convert from user.
cin >> input;
//Check to see if input is UPPERCASE
if(input > 40 && input < 91)
{
cout << char(input + 32);
cout << endl;
}
//Or if input is LOWERCASE
else if(input > 60 && input < 123)
{
cout << char(input - 32);
cout << endl;
}
//If user did not input a character that can be converted.
else
{
if (input != '!')
{
cout << "Error! Try again.";
cout << endl;
}
}
}
system("pause");
return 0;
}
Now, if anyone would be willing to assist me I would greatly appreciate it! Thanks! :)