Syntax: SBB R Where R can be any of the general purpose registers (A,B,C,D,E,H andL) Byte: 1byte Addressing Mode: Register Addressing Working: 1. 2. A= A- R-b 3. 4. Flag Example: SBB D where [D] = 10H , [A]= 22H and [c flag]= 1 After execution of SBB B [A] = 11H [D] = 10H // A= A-R-b => 22-10-1 =11H Program: write an ALP for subtraction of values present in Registers A ,B and C. Where A carries 44H and B carries 30H and C carries 10H. Store result at memory location 5000H. Label Mnemonics Comments Start: SUB B ; a=a - b// 44-30= 14h SBB C ; a= a - c - cy... A= 14-10-0 = 4h STA 5000H Stop: HLT Output: [5000H]= 04H
Syntax: SUB R Where R can be any of the general purpose registers (A,B,C,D,E,H andL) Byte: 1byte Addressing Mode: Register Addressing Working: 1. 2. 3. 4. Flag Example: SUB B where [B] = 11H and [A]= 22H After execution of SUB B [A] = 11H [B] = 22H Program: write an ALP for 8bit subtraction of values present in Registers A and B where A carries 44H and B carries 30H. Store result at memory location 5000H. Label Mnemonics Comments Start: SUB B STA 5000H Stop: HLT Output: [5000H]= 14H LXI H, 4000H ; 4000= 90h MOV A,M ; a = 90h INX H ; 4001h where 4001= 40h MOV B, M ; b= 4 0h SUB B ; a = a - b ... A = 90 - 40= 50h INX H ; 4002h MOV M,A ; 4002h = 50h HLT
Syntax: CMP R Where R can be any of the general purpose registers (A,B,C,D,E,H and L) Byte: 1byte Addressing Mode: Register Addressing Working: 1. This is one byte instruction. 2. microprocessor will allocate one byte for opcode CMP and operands are registers i.e. operands don't need memory allocations for execution here. 3. T his instruction compares the content of the register R with content of the Accumulator. The comparison is done using subtraction of the content of register from the Accumulator . The content of Accumulator remains unchanged . Conditions of Comarison: 1. If [A] < [R] then Cy flag is set i.e. Cy =1 . 2. If [A] = [R] then Z flag is set i.e Z=1. 3. If [A] > [R] then Cy and Z flags are reset. i.e Cy = 0 and Z = 0 4. Flag Example: CMP B where [B] = 22H and [A]= 11H After execution of CMP B [A] = 11H [B] = 22H 2's complement subtraction: A= 11 = 0001 0001 B= 22 = 0010 0010 1'...
Comments
Post a Comment