求助 汇编翻译成C语言
下面是关于DS18B20的汇编语言,我想把它翻译成C语言,哪位大侠能帮帮忙,在此先行谢过。命令 功能描述 命令代码
CONVERT 开始温度转换 44H
READ SCRATCHPAD 读温度寄存器(共9字节) BEH
READ ROM 读DS18B20序列号 33H
WRITE SCRATCHPAD 将警报温度值写如暂存器第2、3字节 4EH
MATCH ROM 匹配ROM 55H
SEARCH ROM 搜索ROM F0H
ALARM SEARCH 警报搜索 ECH
SKIP ROM 跳过读序列号的操作 CCH
READ POWER SUPPLY 读电源供电方式:0为寄生电源,1为外电源 B4H
主要程序如下:
…
MAIN: ;初始化
LCALL RST_DS18B20
LCALL GET_TEMPER
MOV A,20H
MOV C,08H
RRC A
MOV C,09H
RRC A
MOV C,10H
RRC A
MOV C,11H
RRC A
MOV 20H,A
LCALL DISPLAY
AJMPMAIN
RST_DS18B20:
SETB P3. 7
NOP
CLR P3. 7
MOV R1, #3
RST1:MOV R0, #110
DJNZ R0, $
DJNZ R1,RST1
SETB P3. 7
NOP
NOP
MOV R0, #25H
RST2:JNB P3. 7,RST3
DJNZ R0,RST2
LJMP RST4
RST3: SETB FLAG
LJMP RST5
RST4:CLR FLAG
LJMP RST7
RST5:MOV R0, #115
RST6:DJNZ R0, $
RST7: SETB P3. 7
RET
WR_DS18B20: ;写数据子程序
MOV R2, #8
CLR C
WR1: CLR P3. 7
MOV R3, #6
DJNZ R3, $
RRC A
MOV P3. 7,C
MOV R3, #25
DJNZ R3, $
SETB P3. 7
NOP
DJNZ R2,WR1
SETB P3. 7
RET
RD_DS18B20: ;读数据子程序
MOV R4, #2
MOV R1, #20H
READ1:
MOV R2, #8
READ2:
CLR C
SETB P3. 7
NOP
NOP
CLR P3. 7
NOP
NOP
NOP
SETB P3. 7
MOV R3, #9
READ3:
DJNZ R3,READ3
MOV C, P3. 7
MOV R3, #23
READ4:
DJNZ R3,READ4
RRC A
DJNZ R2,READ2
MOV @R1,A
INC R1
DJNZ R4,READ1
RET
下面是关于单片机外部中断INT0的汇编程序
ORG 0003H
INTD0:
PUSH ACC
PUSH PSW
PUSH DPH
PUSH DPL
SETB 24H.0
MOV A, 5FH
JZ TING1
DEC A
MOV 5FH,A
LJMP FAN2
TING1: …
FAN2:
MOV A, 5BH
JZ TING2
DEC A
MOV 5BH, A
LJMP ZONG
TING2:…
ZONG:
MOV A, 59H
JZ KAI
DEC A
MOV 59H, A
LJMP EXIT
KAI:
CLR 24H.0
JB 26H.0, KAI2
KAI2:
MOV A, 66H
JZ EXIT1
EXIT1:
MOV 5FH,5AH
MOV 5BH,66H
MOV 59H,#100
EXIT:
POP DPL
POP DPH
POP PSW
POP ACC
RETI