Retro prof in the lab University of Washington Computer Science & Engineering
 CSE 378 Spring 2006
  CSE Home   About Us    Search    Contact Info 

 Home
Administrative
 Syllabus
 Office Hours
 Mailing List
 Wiki
Assignments
 Reading
 Homework
 Labs
 Exams
Resources
 Lecture Slides
 Handouts
 MIPS Resources
 AHDL Resources
Anonymous Feedback
 Feedback Form
    Homework #3
To be done individually. Due April 19th

Implement Strstr in x86 assembly.

To find out the semantics of Strstr, on any UNIX system, type "man strstr".

Try and follow x86 calling conventions.

 

Here is a set of files that you can use to test your code, as well as a template to write it in. Instructions on how to test your code are included in the file: HW3.tar.bz2

To extract the file, put it in a directory on attu and run "tar -xjvf HW3.tar.bz2" and it will put the files in a HW3 directory.

About x86: 

Familiarize yourself with x86

The following is a table of the more common/basic instructions. NOTE: the table gives the CORRECT operand ordering. FOLLOW IT!
Opcode Description
Copying values
mov src, dest Copies a value from a register, immediate value or memory address to a register or memory address.
cmove %src, %dest Copies from register %src to register %dest if the last comparison operation had the corresponding result (cmove: equality, cmovne: inequality, cmovg: greater, cmovl: less, cmovge: greater or equal, cmovle: less or equal).
cmovne %src, %dest
cmovg %src, %dest
cmovl %src, %dest
cmovge %src, %dest
cmovle %src, %dest
Stack management
enter $x, $0 Sets up a procedure’s stack frame by first pushing the current value of %rbp on to the stack, storing the current value of %esp in %ebp, and finally decreasing %esp to make room for x quadword-sized local variables.
leave Removes local variables from the stack frame by restoring the old values of %rsp and %rbp.
push src Decreases %rsp and places src at the new memory location pointed to by %rsp. Here, src can be a register, immediate value or memory address.
pop dest Copies the value stored at the location pointed to by %rsp to dest and increases %rsp. Here, dest can be a register or memory location.
Control flow
jmp target Jump unconditionally to target, which is specified as a memory location (for example, a label).
je target Jump to target if the last comparison had the corresponding result (je: equality; jne: inequality).
jne target
Arithmetic and logic
add src, dest Add src to dest.
sub src, dest Subtract src from dest.
imul src, dest Multiply dest by src.
idiv src, dest Divide dest by src.
shr src, dest Shift dest to the left or right by src bits.
shl src, dest
ror src, dest Rotate dest to the left or right by src bits.
cmp src, dest Set flags corresponding to whether dest is less than, equal to, or greater than src


If the instruction that you're looking for is not in the table, you may visit this site for a more complete list of instructions.

NOTE: the instructions on this site have the WRONG operand ordering! FLIP THEM if you use them!!!

 


CSE logo Computer Science & Engineering
University of Washington
Box 352350
Seattle, WA  98195-2350
(206) 543-1695 voice, (206) 543-2969 FAX
[comments to Shen]