HW08: Macros and The Stack due Mon 28 Oct 23:59

Purpose

This assignment gives practice writing x86_64 assembly code that:

Allowed and Disallowed Resources

In completing this assignment you MAY use/access the following resources:

You may NOT use/access:

Failure to abide by these guidelines will result in a zero for the assignment and the incident will be reported to the university provost as a violation of the university academic integrity policy. A second incident of academic dishonesty (whether from this course or another computer science course) will result in an F in the course.

Problem Description

In a separate source file (i.e., not in labday.asm) write a macro called cmp_str that accepts two arguments. Both arguments should be 64-bit addresses of null-terminated strings. The macro should work whether the addresses are stored in registers or in labels.

The macro should perform a byte-wise comparison of the individual bytes of the two strings and should finish with the status flags set so that the conditional jump commands will work properly if issued directly after the macro call.

The macro should preserve registers with the possible exception of one register that you may destroy.

Your program should allow the user to enter two strings and then should use the macro to determine whether the the strings are equal or if the first is less than the second or if the first is greater than the second. The input and output should be performed in the main program (not in the macro).

Examples

Suppose your program contains the following statements:
   cmp_str  A,B
   jl	      fun
   jmp      superfun

This table shows expected results for various values of A and B. REMEMBER: A and B could be labels or registers containing the address of a string. NOTE: This is NOT a complete list of test value, but rather some examples to illustrate what is expected.

A B Comparison Result
ABE LINCOLN ABE $<$ LINCOLN jump to fun
ABE AB ABE $>$ AB jump to superfun
ZZTOP abe ZZTOP $<$ abe jump to fun
(empty string) A `' $<$ A jump to fun
SUPERFUN SUPERFUNNY SUPERFUN $<$ SUPERFUNNY jump to fun
ABE ABE ABE $==$ ABE jump to superfun

Grading

Your program will be graded according to the following criteria:
Correctness/Completeness 16 pts
Documentation 2 pts
x86 Conventions 2 pts
Total 20 pts

See Homework #6 for instructions on proper documentation and on x86 assembly language conventions.

Assembly Language

Segmentation Fault Counter

1779736902