http://people.cs.und.edu/~userid/250/ .
 lab5 .
 +: string concatenation.
    For example,
    "abc"+"xyz" = "abcxyz"
/: string removal.
    It removes the first occurrence of the pattern from the string.
    For example,
    "abcxyz"/"cx" = "abyz"and
"xabyabz"/"ab" = "xyabz"
main.cpp, which manages the stack, handles the parentheses, and calls the lab3.asm,
   lab3.h, which is a declaration, and
   lab3.asm, which calculates a string expression without parentheses.
   ("abc"+"xyz")/("c"+"xy").
The final string is calculated as follows (the italic string with a yellow-color background is in the stack):
   $("abc"+"xyz")/("c"+"xy")
 
    $("abc"+"xyz")/("c"+"xy")
    $/("c"+"xy")
 "abc"+"xyz" inside the first pair of parentheses to the Lab3 for calculation. 
 
  Push the result string "abcxyz" back to the stack. 
     $"abcxyz"/("c"+"xy")
    $"abcxyz"/("c"+"xy")
  
    $"abcxyz"/ 
 
 "c"+"xy" inside the second pair of parentheses to the Lab3 for calculation.
 
  Push the result string "cxy" back to the stack.
     $"abcxyz"/"cxy"
 
    $ 
 
 "abcxyz"/"cxy" to the Lab3 for calculation.
 
  Push the result string "abz" back to the stack. 
 
     $"abz"
 "abz".
 | Examples of Laboratory 5 Execution | |
|---|---|
    
  | 
  
C:\Irvine\examples\ch12\VisualCPP\FindArray to another folder such as c:\250\lab\5\.
   AsmFindArray.asm to lab3.asm and findarr.h to lab3.h, and remove findArr.cpp.
   op BYTE '+'will set the variable
op to + only at the first call from C++.
  The next calls will not re-set the op value.
 str = "a ", then strlen(str) = 2.
   str = "a", then strlen(str) = 3.
   stack[count++] = '\"';You have to define the double quote as a character before using it:
     char  dquote = '\"';
     stack[count++] = dquote;
 
main.cpp.
 For a C/C++ tutorial, you may check Programming in C:  A Tutorial.
 The following C/C++ commands may be used in this lab:
 | No. | Command | Description | 
|---|---|---|
| 1 | char | Defining characters | 
| 2 | cin | The standard input | 
| 3 | const int | Defining integer constants | 
| 4 | cout | The standard output | 
| 5 | extern "C" | C++ linkage declaration | 
| 6 | for | loop | 
| 7 | if | if statement | 
| 8 | #include <iostream> | Input/Output stream class | 
| 9 | #include <string> | Standard C library to manipulate C strings. | 
| 10 | return | Stops execution and returns to the calling function. | 
| 11 | strlen( const char * string ); | Returns the number of characters in string before the terminating null-character. | 
| 12 | unsigned int | Defining unsigned integers | 
| 13 | using namespace std; | Uses standard namespaces. | 
| 14 | void | If you do not want to return a value, you must use the return type void and miss out the return statement. | 
  
| 15 | while | loop | 
str in place:
     for ( int i=0, j=strlen(str)-1;  i < j;  i++, j-- ) {
      char c = str[i];
      str[i] = str[j];
      str[j] = c;
   }
 You may use an array to simulate a stack.
| No. | Operators/ Directives/ Commands  | 
     Description | Textbook Page Numbers  | 
    
|---|---|---|---|
| 1 | .586 | 
     Target processor | 409 | 
| 2 | add | 
     Addition | 87 – 88 | 
| 3 | BYTE | 
     Directive of defining byte | 66 – 67 | 
| 4 | cmp | 
     Performs an implied subtraction of a source operand from a destination operand. | 156 | 
| 5 | .code | 
     Marks the beginning of the code segment. | 55 | 
| 6 | dec | 
     Decrement | 87 | 
| 7 | DWORD | 
     Directive of defining doubleword | 68 | 
| 8 | END | 
     Marks the last line of the program to be assembled. | 59 | 
| 9 | ENDP | 
     Marks the end of a procedure. | 59 | 
| 10 | .IF | 
     IF statement | 
     184 – 186 | 
| 11 | inc | 
     Increment | 87 | 
| 12 | je | 
     Jump if equal | 158 – 162 | 
| 13 | jmp | 
     Causes an unconditional transfer to a target location inside the code segment. | 104 | 
| 14 | jne | 
     Jump if not equal | 158 – 162 | 
| 15 | loop | 
     Loop. ECX is automatically used as a counter and is decremented each time the loop repeats. | 
     105 – 106 | 
| 16 | .MODEL  flat, C | 
     Uses the flat memory model and C calling conventions. | 246 – 248 | 
| 17 | mov | 
     Move | 81 – 82 | 
| 18 | OFFSET | 
     Returns the offset of a data label. | 94 | 
| 19 | PROC | 
     Identifies the beginning of a procedure. | 59 | 
| 20 | PROC … USES | 
     Lists the names of all registers modified within a procedure. | 140 – 142 | 
| 21 | PROTO | 
     Creates a prototype for an existing procedure. | 253 – 255 | 
| 22 | PTR | 
     Override the declared size of an operand. | 95 – 96 | 
| 23 | ret | 
     Pops the return address from the stack into the instruction pointer. | 136 | 
| 24 | sub | 
     Subtraction | 88 | 
http://people.cs.und.edu/~userid/250/ or a CD is not submitted.
    For security, perform the following operation:
gandalf> chmod 700 lab?.asm* *.cpp *.hto block all read/write accesses from others to the files
lab?.asm*, *.cpp, and *.h .
   Firefox will be used to download code.
   Be sure your system is working on Firefox 3.0 or above.