1. Most low level programming is carried out using assembly language. What typical scenario might mean that a program has to be written in machine code?
Someone who uses a program frequently may use machine code because it is 2 or 3 times quicker than using high level languages.
2. Why do assembly language instructions written for one type of machine not run on another?
The memory locations may store different things on a different computer therefore the assembly language will not be compatiable.
3. What is the purpose of the following parts of a typical assembly language instruction? (a)label (b)operation code (c)operands (d)comments.
Label: the leftmost item (e.g. Reset), it identifies each section of code and can be used as a pointer to show a jump command where to move to.
Operation (Op) code: the command to be carried out, usually shown as a mnemonic (e.g. ADD, MOV, etc).
Operands: the parts that the operation will be carried out on, they may have two parts (e.g. Acc 45 means the contents of the accumulator are moved to memory location 45).
Comments: assembly language code can be very long, so comments are used to explain what each command does as an aid to the programmer.
4. Why are different modes of addressing encountered when programming in assembly language?.
Different modes of addressing allow data to be manipulated if different ways according to the users requirements.
Explain what is meant by immediate, direct, indirect and indexed addressing.
Immediate addressing - this is where the data apperas immediately after the op code.
Direct addressing - refers directly to a specific memory location.
Indirect addressing - uses a number inside a register( usually an index register) to point to the memory location of interest where the actual data can be found.
Indexed addressing - a number conatained in one register is usually used in combination with the number in another register to point to the actual memory location where the data is stored.
5.AN assembly language instruction set may be broken down into subsets like 'logical', 'arithmetical' and 'control'. Making use of the arithmetical subset outlined in this chapter, show how two simple one-byte integer binary numbers may be added together.
[add] [al,bl] - [;Add bl to al and store the result in al] al = 00000001 bl= 00000010 al now = 00000011
6. Explain how a mask may be used to prevent alteration of the top(most significant) three bits and the bottom(least significant) two bits but set the rest of the bits in the register to 1. We use the or function. or al, bl in this example the first 3bits and last 2 bits are kept the same and the rest are rest to one. The or function means an output of 1 in either al or bl register or both will mean an output of one in the result.
1st operand al = 10101010
2nd operand bl = 10111110
result in al register 10111110
Wednesday, 7 November 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment