Hello, I just created a digital thermometer using a 8085 microprocessor. But the problem is we only had LM36 which measures temperauture in celsius, so we had to convert form celsius to farenheit, using hardware. But on a lab question the teacher wants us to convert the tempauture using software and not hardware, but I have no clue as how to do this in software, can somebdoy point me in the right direction to do this. Thanks in advance.

Dani AI

Generated

started from a Celsius-only sensor and asked for a software-only conversion on the 8085. pointed out that the conversion is a linear scale plus an offset, and offered an 8086-style snippet. The 8085 has no MUL/DIV instructions, so the practical 8085 pattern is: form 9*C with shift-and-add, perform an integer divide-by-5 with a small loop, then add the offset — all in 16-bit space to avoid overflow.

Below is an 8085-friendly routine that implements that idea. It assumes an 8-bit Celsius byte at label Celsius and stores the 16-bit Fahrenheit result at Fahrenheit (low) / FahrenheitHi (high). The code uses three doubles (DAD H) to get 8*C, adds C (via BC), divides by 5 by repeated subtraction counting into DE, then adds the offset.

; input:  Celsius    DB value at label Celsius
; output: Fahrenheit DB (low) at Fahrenheit, high at FahrenheitHi

        LDA Celsius       ; A = Celsius
        MOV C, A          ; BC = 0x00C after next step
        MVI B, 0
        MOV L, A
        MVI H, 0

        ; HL = C * 8 (three doubles)
        DAD H
        DAD H
        DAD H

        DAD B              ; HL = 8*C + BC = 9*C

        ; optional rounding: add 2 before dividing (uncomment to enable)
        ; INX H
        ; INX H

        MVI D, 0           ; DE = 0  (quotient)
        MVI E, 0

DivLoop:
        MOV A, H
        CPI 0
        JNZ Subtract
        MOV A, L
        CPI 5
        JC DoneDiv

Subtract:
        MOV A, L
        SUI 5
        MOV L, A
        MOV A, H
        SBB B
        MOV H, A
        INX D              ; DE++
        JMP DivLoop

DoneDiv:
        MOV A, E
        ADI 32             ; add offset to low byte
        MOV E, A
        MOV A, D
        ADC B              ; add carry into high byte (B == 0)
        MOV D, A

        MOV A, E
        STA Fahrenheit
        MOV A, D
        STA FahrenheitHi

        RET

Notes and cautions: the routine keeps intermediates in 16 bits; if the Celsius source is an ADC with fractional readings, use fixed-point scaling (e.g., store tenths or hundredths) and adjust the divisor/offset accordingly. For nearest-integer rounding add (divisor/2) before the divide (shown as the optional two INX H). Also check assembler syntax for DAD H/DAD B variants. This approach avoids multiply/divide opcodes and directly addresses the 8085 constraint called out by .

Recommended Answers

All 4 Replies

The formula itself is quite simple:

F = (9/5)*C+32

Not sure if you want to do this in 8085 assembly?

Yeah, I already knew what the formula was, I just can't figure out on how to do it on a 8085 microprocessor.

Hello, I just created a digital thermometer using a 8085 microprocessor. But the problem is we only had LM36 which measures temperauture in celsius, so we had to convert form celsius to farenheit, using hardware. But on a lab question the teacher wants us to convert the tempauture using software and not hardware, but I have no clue as how to do this in software, can somebdoy point me in the right direction to do this. Thanks in advance.

...........................:-| ;)

Yeah, I already knew what the formula was, I just can't figure out on how to do it on a 8085 microprocessor.

If 8085 is anything like 8086 it goes:

xor ah,ah
mov al, celcius
mov bh, 9
mul bh
mov bh, 5
div bh
add al, 32
mov farenheit, al

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.