Analysis of 3-byte and 4-byte floating point number calculation program of MSC-51 single-chip microcomputer

MSC-51 3-byte and 4-byte floating point number calculation program, mainly used for data acquisition and uploading, after IEEE conversion, directly displayed on the host computer.

;This is the MSC-51 3-byte and 4-byte floating point number calculation program I use, mainly used for data acquisition and uploading, after IEEE conversion, it is directly displayed on the host computer.


Analysis of 3-byte and 4-byte floating point number calculation program of MSC-51 single-chip microcomputer

; FLOATING PROGRAM

;###############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################

;###############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################

;---------------------------------------------------------

; IEEE754 FLOAT CONVERT TO 4 BYTES FLOAT

; INPUT: ((R0))((R0)+1)((R0)+2)((R0)+3) IEEE-754 FLOAT

; OUTPUT: R4 R5R6R7 4 BYTES FLOAT

;---------------------------------------------------------

IEE_F: MOV A, @R0

JNZ CON_0

INC R0

MOV A, @R0

JNZ CON_1

INC R0

MOV A, @R0

JNZ CON_2

INC R0

MOV A, @R0

JNZ CON_3

MOV R4, #0

MOV R5, #0

MOV R6, #0

MOV R7, #0

DEC R0

DEC R0

DEC R0

RET

CON_3:DEC R0

CON_2:DEC R0

CON_1:DEC R0

CON_0:CLR FLAG_0

INC R0

MOV A, @R0

RLC A

MOV R5, A

DEC R0

MOV A, @R0

RLC A

MOV R4, A

JNC SA_IE

SETB FLAG_0

SA_IE: CLR C

MOV A, R4

SUBB A, #7FH

CLR C

INC A

MOV C, ACC.7

MOV ACC.6, C

MOV C, FLAG_0

MOV ACC.7, C

MOV R4, A

MOV A, R5

SETB C

RRC A

MOV R5, A

INC R0

INC R0

MOV A, @R0

MOV R6, A

INC R0

MOV A, @R0

MOV R7, A

DEC R0

DEC R0

DEC R0

RET

;--------------------------------------------

; 4 BYTES FLOAT CONVERT TO IEEE754 FLOAT

; INPUT: ((R0)) R2R3R4 4 BYTES FLOAT

; OUTPUT: ((R1)) ((R1)+1) ((R1)+2) ((R1)+3)

; IEEE-754 FLOAT

;--------------------------------------------

F_IEE:

INC R0

MOV A, @R0

MOV R2, A

INC R0

MOV A, @R0

MOV R3, A

INC R0

MOV A, @R0

MOV R4, A

DEC R0

DEC R0

DEC R0

MOV A, R2

JZ ZERO_IEE

MOV A, @R0

MOV C, ACC.7

MOV FLAG_0, C

CLR ACC.7

MOV C, ACC.6

JC F_FF

DEC A

CLR C

ADD A, #7FH

LJMP F_TR

F_FF: CLR C

SUBB A, #02H

F_TR: MOV C, FLAG_0

RRC A

MOV @R1, A

INC R1

MOV A, R2

MOV ACC.7, C

MOV @R1, A

INC R1

MOV A, R3

MOV @R1, A

INC R1

MOV A, R4

MOV @R1, A

FIEE_OFF: DEC R1

DEC R1

DEC R1

RET

ZERO_IEE:MOV @R1,A

INC R1

MOV @R1, A

INC R1

MOV @R1, A

INC R1

MOV @R1, A

SJMP FIEE_OFF

;==============================================

; 2 BYTE MUL

; 0.R2R3 * 0.R4R5→0.R2R3R7

;--------------------------------------------

D2_MUL: MOV A, R3

MOV B, R5

MUL AB

MOV R7, B

MOV A, R3

MOV B, R4

MUL AB

ADD A, R7

MOV R7, A

CLR A

ADDC A, B

MOV R3, A

MOV A, R2

MOV B, R5

MUL AB

ADD A, R7

MOV A, R3

ADDC A, B

MOV R3, A

MOV PSW.5, c

MOV A, R2

MOV B, R4

MUL AB

ADD A, R3

MOV R3, A

CLR A

ADDC A, B

MOV C, PSW.5

ADDC A, #0

MOV R2, A

RET

;--------------------------------------------

; 2 BYTE DIV

; 0.R2R3R7R6 / 0.R4R5→0.R2R3

; INPUT 0.R2R3 < 0.R4R5

;--------------------------------------------

D2_DIV: MOV A, R1

PUSH ACC

MOV B, #10H

A2O: CLR C

MOV A, R6

RLC A

MOV R6, A

MOV A, R7

RLC A

MOV R7, A

MOV A, R3

RLC A

MOV R3, A

XCH A, R2

RLC A

XCH A, R2

MOV PSW.5, C

CLR C

SUBB A, R5

MOV R1, A

MOV A, R2

SUBB A, R4

JB PSW.5, A2S

JC A2R

A2S: MOV R2, A

MOV A, R1

MOV R3, A

INC R6

A2R: DJNZ B, A2O

POP ACC

MOV R1, A

MOV A, R7

MOV R2, A

MOV A, R6

MOV R3, A

RET

;------------------------------------------------

; 3 BYTE FLOAT LOAD

; ((R0))→R6, ((R0)+1)→R2, ((R0)+2)→R3

; ((R1))→R7, ((R1)+1)→R4, ((R0)+2)→R5

;------------------------------------------------

F3_MLD: MOV A, @R0

MOV R6, A

INC R0

MOV A, @R0

MOV R2, A

INC R0

MOV A, @R0

MOV R3, A

DEC R0

DEC R0

MOV A, @R1

MOV R7, A

INC R1

MOV A, @R1

MOV R4, A

INC R1

MOV A, @R1

MOV R5, A

DEC R1

DEC R1

RET

;------------------------------------------------

; 3 BYTE FLOAT STANDED

;------------------------------------------------

F3_SDT: JC M3A

MOV C, FLAG39

JB PSW.5, M3B

MOV A, R2

RRC A

MOV R2, A

MOV A, R3

RRC A

MOV R3, A

INC R6

RET

M3B: MOV A, R4

RRC A

MOV R4, A

MOV A, R5

RRC A

MOV R5, A

INC R7

RET

M3A: MOV A, R2

JNZ M3C

CJNE R3, #0, M3D

MOV R6, #41H

M3E: RET

M3C: JB ACC.7, M3E

M3D: MOV C, PSW.5

MOV A, R3

RLC A

MOV R3, A

MOV A, R2

RLC A

MOV R2, A

CLR PSW.5

DEC R6

SJMP M3A

RET

;------------------------------------------------

; 3 BYTE FLOAT ADD OR SUB

; R6R2R3 + R7R4R5→R4R2R3

; R6R2R3 - R7R4R5→R4R2R3

; FLAG3A = 0 ADD FLAG3A = 1 SUB

;------------------------------------------------

F3_ABP: MOV A, R6

MOV C, ACC.7

MOV FLAG38, C

XRL A, R7

JNB ACC.7, SQ

CPL FLAG3A

MOV A, R6

MOV C, ACC.6

MOV ACC.7, C

3V Lithium Fluorocarbon TPMS Button Batteries

3V Lithium Fluorocarbon TPMS Button Batteries use fluorocarbon material as the battery positive electrode. The fluorocarbon material has high thermal and chemical stability. It does not decompose at high temperature ≤600℃, and does not crystallize at low temperature. The battery operating temperature range can reach -40~125℃ ; Its chemical stability ensures the safety of the battery, so that the battery has a higher safety performance when short-circuit, collision, and extrusion, and has the characteristics of explosion-proof and spontaneous combustion. Our company uses self-developed electrolyte to make the battery life more than 10 years.

Our BR series button batteries are conventional high and low temperature resistant button batteries, and the working temperature is -40℃~+85℃
Accepts customized upgraded version of high and low temperature resistant button battery, working temperature is -40℃~ +125℃

Battery application range: It can be used in fields that have strict requirements for high and low temperatures and high energy density. For example, automobile tire pressure gauge (TPMS) battery, industrial control motherboard battery, computer motherboard battery, smart instrument battery, oil field drilling platform emergency equipment power supply, marine life-saving flasher, implantable medical battery, etc.



3V Lithium Fluorocarbon Tpms Button Batteries,Long Lasting Coin Battery For Tvremote,Button Cells For Toys,Coin Battery For Car Keys

Shandong Huachuang Times Optoelectronics Technology Co., Ltd. , https://www.dadncell.com