We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6
Finding Greatest Common Divisor (GCD) and Least
Common Multiplier (LCM)
Tasks: To write a 8086 ASM program to find the GCD of the given two numbers To write a 8086 ASM program to find the LCM of the given two numbers Greatest Common Divisor (GCD) Memory Address Label Opcode Operand
1000 Start: MOV SI, (1500)H
1004 MOV AX, (0006)H 1008 MOV BX, (0008)H 100C Loop2: CMP AX, BX 100E JE Halt 1010 JA Loop1 1012 XCHG AX, BX Memory Address Output 1014 Loop1: SUB AX, BX 1500 1016 JMP Loop2 1501 1019 Halt: MOV [SI], AX 101B End: HLT Least Common Multiplier (LCM) Memory Address Label Opcode Operand 1000 Start: MOV SI, (1500)H 1004 MOV AX, (0012)H 1008 MOV BX, (0008)H 100C Loop2: CMP AX, BX 100E JE Halt 1010 JA Loop1 1012 XCHG AX, BX 1014 Loop1: SUB AX, BX 1016 JMP Loop2 1019 Halt: MOV [SI], AX 101B MOV AX, (0012)H Memory Address Output 101E MOV BX, (0008)H 1021 MUL BX 1500 1024 MOV BL, [SI] 1501 1027 DIV BL 1502 102A MOV [SI+02], AX 102C End: HLT 1503 Interfacing Seven Segment Display with 8086 Tasks: To write a 8086 ASM program to display the characters in seven segment display Code Memory Address Label Opcode Operand BAT 1000 Label2 MOV SI, 1200H 1004 MOV BL, 03H Memory Address Label Opcode Operand 1007 Label1 DEC BL 1009 MOV AL, BL 101E Delay MOV CX, 0FFH 100B OUT C0, AL 1022 Label3 LOOP Label3 100D MOV AL, [SI] 1024 RET 100F OUT C8,AL 1011 CALL Delay 1014 INC SI 1200: 7C 1015 CMP BL, 00H 1019 JNZ Label1 1201: 5F 101A JMP Label2 1202: 78 101D HLT L1:1023 L2:1026