0% found this document useful (0 votes)
100 views

Ascending Order:-Address Label Mnemonics Opcod E Comments

This document describes the steps to convert a BCD (Binary Coded Decimal) number stored at memory location 9000 to its equivalent binary number. It loads the upper and lower nibbles of the BCD number separately, rotates the upper nibble 4 times to multiply it by 10, adds it to the lower nibble, and stores the result in the accumulator. It uses registers B, C, D, E in the process. The algorithm separates the nibbles, performs multiplication by 10 on the upper nibble, and adds it to the lower nibble to get the final binary equivalent.

Uploaded by

vnareshmca
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views

Ascending Order:-Address Label Mnemonics Opcod E Comments

This document describes the steps to convert a BCD (Binary Coded Decimal) number stored at memory location 9000 to its equivalent binary number. It loads the upper and lower nibbles of the BCD number separately, rotates the upper nibble 4 times to multiply it by 10, adds it to the lower nibble, and stores the result in the accumulator. It uses registers B, C, D, E in the process. The algorithm separates the nibbles, performs multiplication by 10 on the upper nibble, and adds it to the lower nibble to get the final binary equivalent.

Uploaded by

vnareshmca
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

ASCENDING ORDER:-

OPCOD
ADDRESS LABEL MNEMONICS COMMENTS
E
9100   LDA 9400 3A 00 94 Load the accumulator direct
9103   SUI 01 D6 01 Subtract 01 from A
9105   MOV D,A 57 Move the A value to D register
9106   MOV E, A 5F Move the A value to E register
9107 LOOP2 MOV B,D 42 Move the D register value to B
9108   LXI H 9200 21 00 92 Load HL pair indirect

910B LOOP1 MOV A,M 7E Move the M value to


accumulator
910C   INX H 23 Increment the HL pair
910D   CMP M BE Compare the HL pair
910E   JC LOOP DA 14 91 Jump on carry to 9114
9111   MOV C,A 4F Move the A value to C register
Move the M value to A
9112   MOV A,M 7E
register
Move the C register value to
9113   MOV M,C 71
M
9114 LOOP DCX H 2B Decrement HL pair
9115   MOV M,A 77 Move the accumulator to M
9116   INX H 23 Increment HL pair
9117   DCR B 5 Decrement B register
9118   JNZ LOOP1 C2 0B 91 Jump on no zero to 910A
911B   DCR E 1D Decrement E register value
911C   JNZ LOOP2 C2 07 91 Jump on no zero to 9107
911F   HLT 76 Stop the program
         
DESCENDING ORDER:-

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


9100   LDA 9400 3A 00 94 Load the accumulator direct
9103   SUI 01 D6 01 Subtract 01 from A
9105   MOV D,A 57 Move the A value to D
register
9106   MOV E, A 5F Move the A value to E
register
9107 LOOP2 MOV B,D 42 Move the D register value to
B
9108   LXI H 9200 21 00 92 Load HL pair indirect
910B LOOP1 MOV A,M 7E Move the M value to
accumulator
910C   INX H 23 Increment the HL pair
910D   CMP M BE Compare the HL pair
910E   JNC LOOP D2 14 91 Jump on carry to 9114
9111   MOV C,A 4F Move the A value to C
register
9112   MOV A,M 7E Move the M value to A
register
9113   MOV M,C 71 Move the C register value to
M
9114 LOOP DCX H 2B Decrement HL pair
9115   MOV M,A 77 Move the accumulator to M
9116   INX H 23 Increment HL pair
9117   DCR B 5 Decrement B register
9118   JNZ LOOP1 C2 0B 91 Jump on no zero to 910A
911B   DCR E 1D Decrement E register value
911C   JNZ LOOP2 C2 07 91 Jump on no zero to 9107
911F   HLT 76 Stop the program
         
FIBONACCI SERIES:-

OPCOD
ADDRESS LABEL MNEMONIC E COMMENTS
8000   LXI D,FA02 11 02 FA Load DE pair immediately
8003   MVI B,00 06 00 Move immediate 00 to B
register
8005   MVI C,01 0E 01 Move immediate 01 to C
register
8007   LDA FAOO 3A 00 FA Directly load accumulator
800A   MOV H,A 67 Move content of acc. To H
800B LOOP MOV A,B 78 Move content of B register to
acc.
800C   STAX D 12 Store accumulator indirect
800D   INX D 13 Increment DE pair by 01
800E   ADD C 81 Add content of C register to
acc.
800F   MOV B,C 41 Move content of C to B register
8010   MOV C,A 4F Move content of acc. To C
register
8011   DCR H 25 Decrement H register by 01
8012   JNZ LOOP C2 0C 80 Jump on no zero loop
8015   HLT 76 Stop the program
         
PRIME NUMBER SERIES:-

ADDRESS LABEL MNEMONIC OP CODE COMMENTS


8000   LXI H,9100 21 00 91 Load the data 9100 to HL register pair
8003   LDA 9000 3A 00 90 Load the accumulator directly
8006   MOV B,A 47 Move the content of B register to
accumulator.
8007   DCR B 5 Decrement B register
8008   JZ END CA 32 80 Jump to address 8032 if zero flag is 1
800D   MOV M,A 77 Move the content of accumulator to
memory addressed by HL registerpair.
800E   INX H 23 Increment HL register pair
800F   DCR B 5 Decrement B register
8010   JZ END CA 32 80 Jump to address 8032 if zero flag is 1
8013   MVI E,02 16 02 Move immediately 02 to E register
8015 DD MVI D,00 16 00 Move immediately 00 to D register
8017   MOV C,E 4B Move the content of E register to C
register
8018 XX MOV A,E 7B Move the content of accumulator to E
register
8019 BB SUB C 91 Subtract the data in c register from
accumulator
801A   JNZ AA C2 1E 80 Jump to address 801E if zero flag is 0
801D   INR D 14 Increment D register
801E AA JNC BB D2 19 80 Jump to address 8019 if carry flag is 0
8021   DCR C 0D Decrement C register
8022   JNZ XX C2 18 80 Jump to address 8018 if zero flag is 0
8025   MOV A,D 7A Move the content of D register to
accumulator
8026   CPI 02 FE 02 Compare with 02
8028   JNZ CC CD 2D Jump to address 801E if zero flag is 0
80
802B   MOV M,E 73 Move the content of memory addressed
by HL register pair to accumulator
802C   INX H 23 Increment HL register pair
802D CC INR E 1C Increment E register
802E   DCR B 5 Decrement B register
802F   JNZ DD C2 15 80 Jump to address 8015 if zero flag is 0
8032 END HLT 76 Stop.
         
BCD TO BINARY:-

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


8000   MVI E, 0A 1E 0A Move 0A to E register to
multiply the upper nibble of
BCD number by 10.
8002   MVI C, 04 0E 04 Move 04 to C register to
rotate the upper nibble four
times.
8004   LDA 9000 3A 00 90 Load the BCD number to
ACC.
8007   ANI F0 E6 F0 Perform AND operation with
0F to separate upper nibble.
8009 JUMP RRC 0F Rotate content to right side
without carry.
800A   DCR C 0D Decrement the value of C reg.
800B   JNZ JUMP C2 09 80 Rotate content to right side if
count not zero.
800E   MOV B, A 47 Else move the upper nibble to
reg B.
800F   LDA 9000 3A 00 90 Load the original BCD
number to acc.
8012   ANI 0F E6 0F Perform AND operation with
F0 to separate lower nibble.
8013   MOV D, A 57 Move the lower nibble to D
register.
8014   MVI A, 00 3E 00 Clear the contents of
accumulator.
8016 STEP ADD B 80 Add the upper nibble of BCD
number to accumulator.
8017   DCR E 10 Decrement the E register
value by 1.
8018   JNZ STEP C2 16 80 Jump to add the upper nibble
to accumulator if count not
zero.
801B   ADD D 82 Add the lower nibble of BCD
number with accumulator.
801C   STA 9001 32 01 90 Store the binary value in
address.
801F   HLT 76 Stop the program.
         
BINARY TO ASCII:-

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


8150   LDA 9150 3A 50 91 Load the binary
number to
accumulator.
8153   MOV B, A 47 Move the original
binary number to B
reg.
8154   CPI OA FE 0A Check if the binary
value is less than 0A.
         
8159   ADI 37 C6 37 Else, Add the content
of acc with 37.
815B   JMP LOOP C3 60 81 Jump unconditionally
to address.
815E LOOP1 ADI 30 C6 30 Add immediately
value 30 to acc.
8160 LOOP STA 9151 32 51 81 Store the ASCII value
to address.
8163   HLT 76 Stop the program.
BINARY TO BCD:-

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


8050   MVI E, 00 1E 00 Clear the contents of E register.

8052   MOV D, E 53 Clear the contents of D register.

8053   LDA 9050 3A 50 90 Load the binary number to


accumulator.
8056 HUND CPI 64 FE 64 Check if binary number is less
than !00.
8058   JC TEN DA 61 80 Jump to check the ten’s place if
carry is set .
805B   SUI 64 D6 64 Subtract 64 immediately from
binary number.
805D   INR E 1C Increment the value of hundreds
digit.
805E   JMP HUND C3 56 80 Jump to check if number is less
than hundred.
8061 TEN CPI 0A FE 0A Check if the binary number is less
than ten.
8063   JC UNIT DA 6C 80 Jump to check the unit’s place if
carry is set.
8066   SUI 0A D6 0A Subtract 0AH immediately from
binary number.
8068   INR D 14 Increment the value of tens digit.
8069   JMP TEN C3 61 80 Jump to check again if number is
less than 10.
806C UNIT MOV C, A 4F Move content of accumulator
with register C.
806D   MOV A, D 7A Move the number of ten’s to
accumulator.
806E   RLC 7 Rotate the content of acc to left
without carry.
806F   RLC 7 Rotate the content of acc to left
without carry.
8070   RLC 7 Rotate the content of acc to left
without carry.
8071   RLC 7 Rotate the content of acc to left
without carry.
8072   ADD C 81 Add the unit’s place to the ten’s
place.
8073   STA 9051 32 51 90 Store the content of accumulator.
8076   MOV A, E 7B Move content of register E with
accumulator.
8077   STA 9052 32 52 90 Store the content of accumulator
807A   HLT 76 Stop the program.
BINARY TO OCTAL:-

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


8000   LDA 9000 3A 00 90 Load the binary number to be
converted into A register.
8003   MOV B, A 47 Move the original binary
number to B reg.
8004   ANI 07 E6 07 Perform AND operation of
acc with 07.
8006   STA 9001 32 01 90 Store the first digit of octal
number to address.
8009   MOV A, B 78 Move the original binary
number to accumulator.
800A   ANI 38 E6 38 Perform AND operation of
accumulator with 38.
800C   RRC 0F Rotate content of
accumulator to right side
without carry.
800D   RRC 0F Rotate content of
accumulator to right side
without carry.
800E   RRC 0F Rotate content of
accumulator to right side
without carry.
800F   STA 9002 32 02 90 Store the second digit of
octal number to memory
address.
8012   MOV A, B 78 Move the original binary
number to accumulator.
8013   ANI C0 E6 C0 Perform AND operation of
accumulator with C0.
8015   RLC 7 Rotate the content of
accumulator to left without
carry.
8016   RLC 7 Rotate the content of
accumulator to left without
carry.
8017   STA 9003 32 03 90 Store the third digit of octal
number to memory address.
801A   HLT 76 Stop the program
OCTAL TO BINARY:-

ADDRESS LABEL MNEMONICS OPCODE COMMENTS


8050   LDA 9050 3A 50 90 Load the octal number
to accumulator.
8053   MOV B, A 47 Move original octal
number to reg B.
8054   ANI 07 E6 07 Perform AND operation
with 07 to separate the
first digit.
8056   MOV C, A 4F Move the content of acc.
to reg. C.
8057   MOV A, B 78 Move original octal
number to acc.
8058   ANI 10 E6 10 Perform AND operation
with 10 to separate the
second digit.
805A   RRC 0F Rotate content to right
side without carry.
805B   ADD C 81 Add the first digit with
the accumulator.
805C   MOV D, A 57 Move content of acc. to
register D.
805D   MOV A, B 78 Move the original octal
number to acc.
805E   ANI 60 E6 60 Perform AND operation
with 60.
8060   RRC 0F Rotate content to right
side without carry.
8061   ADD D 82 Add content of register
D with the acc.
8062   STA 9052 32 52 90 Store the binary number
in address.
8065   HLT 76 Stop the program.

You might also like