Cramster.com - Homework Solutions, Lecture Notes, Exams, and Free Online Homework Help
Sign Up Now! Login Customer Support Cramster Blog
McAfee Secure sites help keep you safe from identity theft, credit card fraud, spyware, spam, viruses and online scams
Problem Solved.
    Home    
    Homework Help    
   Answer Board   
    Resources (Beta)    
   
Member's Topic Headline:

Assembly

Know the answer? Have a better solution? Share it.
Get Help Now.
View homework problems
explained for free!
Member Testimonials

Question:

Advertisement:

Answer | Ask New Question | Customize Profile | Leaderboards | 
FAQ

Member's Avatar

Rookie
Karma Points: 0
Respect (79%):
Date Posted: 5/21/2008 11:28:31 AM  Status: Live
Assembly
Course Textbook Chapter Problem
N/A N/A N/A N/A
Question Details:
 

Give short answers to the following questions, each question carries equal marks.

                         
What is the purpose of direction flag?

 
What is an assembly language directive
 

What is the difference between a TEST and AND instruction?

Answers:

Cramster Expert

Member's Avatar

(Cramster SME)
Cramster In-House Subject Matter Expert
Date Posted: 5/22/2008 7:42:02 AM  Status: Live
Asker's Rating: Helpful   
Response:
Dear,
 

Direction Flag 

The direction flag is a CPU flag specific to Intel 80x86 processors. It applies to all assembly instructions that use the REP (repeat) prefix, such as MOVS, MOVSD, MOVSW, and others. Addresses provided to applicable instructions are increased if the direction flag is cleared.

Assembly languages have extra directives for assembling blocks of data, and assigning address locations for instructions or code.

TEST

The test instruction logically ands its two operands and sets the flags but does not save the result. Test and and share the same relationship as cmp and sub. Typically you would use this instruction to see if a bit contains one. Consider the following instruction:

                        test      al

1

This instruction logically ands al with the value one. If bit zero of al contains a one the result is non-zero and the 80x86 clears the zero flag. If bit zero of al contains zero then the result is zero and the test operation sets the zero flag. You can test the zero flag after this instruction to decide whether al contained zero or one in bit zero.

The test instruction can also check to see if one or more bits in a register or memory location are non-zero. Consider the following instruction:

                        test      dx

105h

This instruction logically ands dx with the value 105h. This will produce a non-zero result (and therefore clear the zero flag) if at least one of bits zero two or eight contain a one. They must all be zero to set the zero flag.

The test instruction sets the flags identically to the and instruction:

It clears the carry flag.

It clears the overflow flag.

It sets the zero flag if the result is zero they clear it otherwise.

It copies the H.O. bit of the result into the sign flag.

It sets the parity flag according to the parity (number of one bits) in the L.O. byte of the result.

It scrambles the auxiliary carry flag.

AND         Logical AND between all bits of two operands. Result is stored in operand1.

kashmala's Comment:
Thanxxxx




By reading or posting messages on these forums, you are agreeing to the Answer Board's Terms of Service and Conduct (TSC).


About Cramster | Terms of Use | Privacy Policy | Contact Us | Press Room | Site Map | Support | Anti-Cheating Policy

Cramster.com is not affiliated with any publisher. Book covers, title and author names appear for reference only.
Copyright © 2008 Cramster, Inc.