70 likes | 195 Views
Assembly Microprocessors session 5. ing. Ernst E. Mak MSc. Generic Instructions Taxonomy. input/output data load a value(register) into a register arithmetic jumping / subroutine control bitwise operators : Boolean, Register shifts interrupt handling stacking. SHIFT RIGHT. CarryFlag.
E N D
Assembly Microprocessorssession 5 ing. Ernst E. Mak MSc
Generic Instructions Taxonomy • input/output data • load a value(register) into a register • arithmetic • jumping / subroutine • control • bitwise operators : Boolean, Register shifts • interrupt handling • stacking
SHIFT RIGHT CarryFlag 1 1 0 0 1 0 0 0 c 0 1 1 0 0 1 0 0 0 1 1 0 0 1 0 0 1 c 0 1 1 0 0 1 0 0 1
SHIFT LEFT CarryFlag 1 1 0 0 1 0 0 0 c 1 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 0 c 1 0 0 1 0 0 0 0 0
ROTATE CarryFlag 0 1 0 0 1 0 0 0 1 RL 1 0 0 1 0 0 0 1 0 CarryFlag 0 1 0 0 1 0 0 0 1 RLC 1 0 0 1 0 0 0 0 0
multiply 33 0 0 1 0 0 0 0 1 5 1 0 1 * 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 + 0 0 0 1 0 1 0 0 1 0 1 165
Multiplication using shift ;multiplication using shift-operators ;original numbers in B and C ;thus multiplication is B*C ;answer in HL register start: ld hl,0 ;initialize HL to 0 loop: srl c ;shift rightwards, least sign bit falls ; into carry jp nc,skip ;if the bit was 0,skip next lines ld a,l ;add B into HL using A add a,b ;.. ld l,a ;.. ld a,h ;.. adc a,0 ;.. ld h,a ;.. skip: ld a,0 ;reset A to zero cp c ;compare C to 0 jp z,end ;if C=zero, the job is done sla b ;shift b leftward, ignore carry jp loop ;jump to next loop end: halt ;end reached