Assembly Language 2

19
Course Name : Computer Organisation Course Code : TDB1123/TCB1043 Date Assigned : Week 10 ________________________________________________________________________ 1.0 Flag Register The Flags register is a special 16-bit register with individual bit positions assigned to show the status of the CPU or the results of arithmetic operations. Each relevant bit position is given a name; other positions are undefined: Bit Position 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 x x x x O D I T S Z x A x P x C O = Overflow D = Direction I = Interrupt T = Trap X = undefined Fortunately we do not have to memorize each flag position. Instead, there are special instructions designed to test and manipulate the flags. A flag or bit is set when it equals 1; it is clear (to reset) when it equals 0. The CPU sets flags by turning on individuals bits in the flags register. There are two basic types of flags: control flags and status flags. a. Control Flags Individual bits may be set in the Flags register by the programmer to control the CPU’s operation. These are the Direction, Interrupt, and Trap flags. The Direction flag controls the assumed direction used by string processing instructions. The flags values are 1= up and 0= down. The programmer controls this flag, using the STD and CLD instructions. The Interrupt flag makes it possible for external interrupts to occur. These interrupts are caused by hardware devices such as keyboard, disk drives, and the system clock timer. Often we briefly disable interrupts when performing some critical operation that cannot be interrupted. The flag values are 1= enabled, and 0= disabled; they are controlled by the CLI and STI instructions. __________________________________________________________________________________________ __________________ Saipunidzam Mahamad @ Computer Organisation © S = Sign Z = Zero A = Auxiliary Carry P = Parity

description

Computer is very interesting if you know the assembly language

Transcript of Assembly Language 2

Course Name : Computer OrganisationCourse Code : TDB1123/TCB1043Date Assigned : Week 10________________________________________________________________________1.0 Flag RegisterThe Flags register is a special 16-bit register with individual bit positions assigned to show the status of theCPU or the results of arithmetic operations. Each relevant bit position is given a name; other positions areundefined!it Position1" 1# 1$ 1% 11 1& ' ( ) 6 " # $ % 1 &* * * * +, - T . /*0 * P * C+ 1 +verflow, 1 ,irection - 1 -nterruptT 1 Trap2 1 undefined3ortunatel4 we do not have to memori5e each flag position. -nstead6 there are special instructions designedto test and manipulate the flags. 0 flag or bit is set when it e7uals 1; it is clear 8to reset9 when it e7uals &.The CPU sets flags b4 turning on individuals bits in the flags register. There are two basic t4pes of flagscontrol flags and status flags.a. Control Flags-ndividual bits ma4 be set in the 3lags register b4 the programmer to control the CPU:s operation.These are the Direction, Interrupt6 and Trap flags. The Direction flag controls the assumed direction used b4 string processing instructions. The flagsvalues are 11 up and &1 down. The programmer controls this flag6 using the .T, and C;, instructions.The Interrupt flag ma