Assembly Microprocessors session 5
This resource provides an in-depth overview of essential assembly programming instructions for microprocessors. Covering key topics such as input/output data handling, arithmetic operations, control structures, jumping and subroutines, and interrupt handling, it highlights the use of bitwise operators and the importance of register management. Understanding the concepts of shifting and rotating bits, including carry flag manipulation, is crucial for efficient programming and algorithm implementation. Explore techniques like multiplication using shift operators and learn how to optimize operations for better performance.
Assembly Microprocessors session 5
E N D
Presentation Transcript
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