Skip to main content

Code Conversions



AIM:
To write an 8085 assembly language program that executes the following conversions
  1. BCD TO BINARY.
  2. Binary to BCD
  3. Binary to ASCII
  4. ASCII to Binary

APPARATUS REQUIRED:
8085 microprocessor kit, Power supply.

ALGORITHM:


BCD TO BINARY:

Step 1: Initialize stack pointer
Step 2: Initialize HL register pair with a source pointer.
Step 2: Initialize BC register pair with a destination pointer.
Step 3: Move contents of memory pointer to accumulator.
Step 4: Call subroutine BCD BIN.
Step 5: Store the content of Accumulator in destination pointer.
Step 6: End of execution.

SUBROUTINE:
  1. Push the content of BC & DE register pair to stack pointer.
  2. Logically AND the number 0F with accumulator to get LSB
  3. Again logically AND the number F0with accumulator and rotate the content to the right four times to get MSB
  4. Multiply the MSB with 0A and add with LSB

Memory Location Machine code Label Mnemonics Comment
4100 31,FF,4F

LXI SP, 4FFF Initialize stack pointer
4103 21, 00, 42

LXI H, 4200 Initialize HL register pair with a source pointer
4106 01,00,43

LXI B 4300 Load BC register pair with destination pointer
4109 7E

MOV A,M Move [M] to Accumulator
410A CD, 0F,41

CALL BCD BIN Call sub routine BCD BIN
410D 02

STAX B Store the Binary number in the destination location
410E 76

HLT End of execution

SUBROUTINE
Memory Location Machine code Label Mnemonics Comment
410F C5 BCD BIN PUSH B Push [B C ] into stack pointer
4110 D5

PUSH D Push [D E] into stack pointer
4111 47

MOV B,A Move [A] to B register
4112 E6,0F

ANI 0F And immediate the accumulator with 0F
4114 4F

MOV C,A Move[A] to C register
4115 78

MOV A,B Move[B] to Accumulator
4116 E6,F0

ANI F0 And immediate accumulator with F0
4118 CA,28,41

JZ BCD Jump on zero to BCD loop
411B 0F

RRC Rotate accumulator content to right
411C 0F

RRC Rotate accumulator content to right
411D 0F

RRC Rotate accumulator content to right
411E 0F

RRC Rotate accumulator content to right
411F 57

MOV D,A Move [A] to D register
4120 AF

XRA A Clear accumulator
4121 1E, 0A

MVI E, 0A Move 0A to E register
4123 83 SUM ADD E Add E with accumulator content
4124 15

DCR D Decrement D register.
4125 C2,23,41

JNZ SUM Jump on no zero to sum
4128 81 BCD ADD C Add C to accumulator
4129 D1

POP D Retrieve the content of D from stack
412A C1

POP B Retrieve the content of B from stack
412B C9

RET Return to main program
b) Binary to BCD:-

Algorithm:
Step 1: Initialize stack pointer
Step 2: Initialize the register pair as memory pointer.
Step 3: Move Binary number to accumulator
Step 4: Call subroutine 1
Step 5:End of the execution

SUBROUTINE 1:

Step 1: Load HL register pair with MP
Step 2: Store 64h in B register.
Step 3: Call subroutine 2.
Step 4: Store 0Ah in B register & call subroutine2
Step 5: Store accumulator contents in next memory location
Step 6: Return to Main program.

SUB ROUTINE 2:
Step 1: Clear Memory location
Step 2: Subtract the B register from accumulator
Step 3: If the subtraction results a carry add B register content with accumulator and increment memory pointer.
Step 4: return to subroutine1


Memory Location Machine code Label Mnemonics Comment
4100 31,FF,4F

LXI SP, 4FFF Initialize stack pointer
4103 21, 00, 42

LXI H,4200 Initialize HL register pair with a source pointer
4106 7E

MOV A,M Move [M] to Accumulator
4107 CD, 0B,41

CALL PWRTEN Call sub routine PWRTEN
410A 76

HLT End the execution

Subroutine 1

Memory Location Machine code Label Mnemonics Comment
410B 21,00,43 PWRTEN LXIH, 4300 Load HL register pair with 4300
410E 06,64

MVI B,64 Move 64h to B register
4110 CD,1A,41

CALL BIN BCD Call subroutine BIN BCD
4113 06,0A

MVI B,0A Move 0A to B register
4115 CD,1A,41

CALL BIN BCD Call subroutine BIN BCD
4118 77

MOV M,A Move[A] to memory location
4119 C9

RET Return to main program

Subroutine 2


Memory Location Machine code Label Mnemonics Comment
411A 36,FF BIN BCD MVI M, FF Move FFh to memory location
411C 34 NXTBUF INR M Increment memory pointer
411D 90

SUB B Subtract B from accumulator
411E D2, 1C, 41

JNC NXT BUF Jump on no carry to NXT BUF
4121 80

ADD B Add the content of B register with accumulator
4122 23

INX H Increment memory pointer
4123 C9

RET Return to subroutine1
c) Binary to ASCII

ALGORITHM:

  • Initialize stack pointer
  • Initialize register pair as source pointer
  • Initialize DE register pair with destination pointer
  • Move contents of memory pointer to accumulator
  • Shift higher order nibble to lower order nibble by rotating the accumulator contents to right for 4 times
  • Call subroutine
  • Store the converted number in memory location 4300 and 4301
  • End of execution

SUBROUTINE
  • And immediately the binary data with 0Fh & mask the higher order bit & store it in the accumulator.
  • Compare the accumulator content with 07
  • If caryt results add 30h to the number else add 37h to the number
  • Return to main program


Memory Location Machine code Label Mnemonics Comment
4100 31,FF,4F

LXI SP, 4FFF Initialize stack pointer
4103 21, 00, 42

LXI H,4200 Initialize HL register pair with a source pointer
4106 11,00,43

LXI D 4300 Initialize DE reg pair with destination pointer
4109 7E

MOV A,M Move M to accumulator
410A 47

MOV B,A Move A to B register
410B 0F

RRC Rotate the accumulator content to right
410C 0F

RRC Rotate the accumulator content to right
410D 0F

RRC Rotate the accumulator content to right
410E 0F

RRC Rotate the accumulator content to right
410F CD,1A,41

CALL SUB Call subroutine SUB
4112 12

STAX D ` Store the first ASCII value in 4300
4113 13

INX D Increment memory pointer
4114 78

MOV A,B Move B to accumulator
4115 CD,1A, 41

CALL SUB Call subroutine SUB
4118 12

STAX D Store the second ASCII value in 4301
4119 76

HLT End of execution


SUBROUTINE


Memory Location Machine code Label Mnemonics Comment
411A E6,0F SUB ANI 0F Mask higher order nibble
411C FE,0A

CPI 0A Compare A with 0A
411E DA, 23, 41

JC loop Jump on carry loop
4121 C6,07

ADI 07 Add immediately 07
4123 C6,30 Loop ADI 30 Add immediately 30 with accumulator
4125 C9

RET Return to main program


d. ASCII to Binary

ALGORITHM:

  • Initialize stack pointer
  • Initialize register pair as source pointer
  • Initialize DE register pair with destination pointer
  • Move contents of memory pointer to accumulator
  • Call subroutine
  • Store the result in destination address
  • End of execution

SUBROUTINE

  • Subtract 30h from accumulator
  • If the result is less that 0A, return to main program
  • Else subtract 07h from the result
  • Return to main program


Memory Location Machine code Label Mnemonics Comment
4100 31,FF,4F

LXI SP, 4FFF Initialize stack pointer
4103 21, 00, 42

LXI H,4200 Initialize HL register pair with a source pointer
4106 11,00,43

LXI D 4300 Initialize DE reg pair with destination pointer
4109 7E

MOV A,M Move M to accumulator
410A CD,0F,41

CALL SUB Call subroutine SUB
410D 12

STAX D Store the result in 4300
410E 76

HLT End of execution

SUBROUTINE


Memory Location Machine code Label Mnemonics Comment
410F D6,30 SUB SUI 30 Subtract 30h from accumulator
4111 FE,0A

CPI 0A Compare 0A with accumulator content
4113 D8

RC Move the smallest number to memory location
4114 C6,07

SUI 07 Subtractiimmediately 07
4116 C9

RET Return to main program


Result:

Thus the assembly language program for code conversion like BCD to binary, Binary to BCD, Binary to ASCII and ASCII to Binary were performed.

Comments

Popular posts from this blog

Installing and Activating KEIL uVision

*** NOTE: Click on the images to view them in full resolution Download: Download Keil from the link below: Keil Latest Version Free download with keygen After Installation: 1. File -> License Management 2. Open Keygen from the folder where rar file is unpacked 3. Copy computer ID ( CID ) to clipboard 4. Paste CID in KEYGEN exe, Press generate, copy generated serial and paste in new license textbox of Licence management. *** NOTE: Click on the images to view them in full resolution

Average and Square Root Using 8085

AVERAGE OF N NUMBERS AIM:       To write an assembly language program that finds the average of N numbers and executes the program using 8085 microprocessor kit. APPARATUS REQUIRED: 8085 microprocessor kit, power supply. ALGORITHM: STEP 1: Load HL register pair with a memory pointer. STEP 2: Get the count to B register and clear accumulator. STEP 3: Push the count to stack pointer. STEP 4: Increment memory pointer. STEP 5: Add the content of memory location to accumulator. STEP 6: If carry results increment D register. STEP 7: Decrement count. If it is not zero go to STEP 4. STEP 8: Else move the sum to E register. STEP 9: Get the count from stack pointer. STEP10: Subtract the count from sum(content of DE pair). STEP11:If the subtraction results a carry add the count to the result and get the remainder STEP12: Otherwise increment B register content and go to STEP10. STEP 13: Store the quotient and remainder in successive memory location. PROGRAM:

Laws of Thermocouple

The Seebeck Effect A German physician turned physicist named Thomas Johann Seebeck took two different metals, with one at a higher temperature than the other, and made a series circuit by joining them together to form a junction. He found that by doing so he was able to generate an electromotive force (emf). Emfs are voltages. Seebeck found that the larger the temperature differences between the metals, the higher the generated voltage, regardless of their shapes. His discovery is called the Seebeck effect, and it is the basis of all thermocouples. Background Seebeck, H.G. Magnus, and A.C. Becquerel proposed the empirical rules of thermoelectric circuits. Lord Kelvin explained their thermodynamic basis, and W.F. Roesser compiled them into a set of three fundamental laws. They have all been verified experimentally. The second law is sometimes broken up into three parts by modern day researchers, to give a total number of five, but Roesser's are still the standar