5214 views|3 replies

3

Posts

0

Resources
The OP
 

Newbie wants to convert assembly language to C language [Copy link]

汇编源程序:
          ST         BIT       P3.0
          OE         BIT        P3.1
          ORG       0000H
LJMP     MAIN
ORG       0030H
MAIN:    CLR        P2.0
CLR        P2.2
LCALL    DELAY
CLR       ST
SETB      ST
CLR       ST
LCALL    DELAY
SETB      OE
MOV       P1,#0FFH
MOV       A,P1
CLR       OE
          CLR      C
          SUBB      A,#67H              ;报警值
          JNC       ALERM
SJMP      MAIN
ALERM:    SETB     P2.2
  SETB    P2.0
MOV      R4,#255
         DJNZ      R4,$
         CLR       P2.0
         MOV       R5,#255
         DJNZ      R5,$
         SJMP      ALERM
DELAY:   MOV      R2,#250
AA:   MOV      R3,#255
         DJNZ     R3,$
         DJNZ      R2,AA
         RET
         END

基于单片机一氧化碳报警器设计.doc

239.5 KB, downloads: 1

This post is from 51mcu

Latest reply

It is not possible to convert it by tools. You can only rewrite it in C after understanding the original assembly program, or figure out the specific application requirements and write it directly in C. Of course, the necessary homework before that is to master C language programming first.  Details Published on 2018-12-17 11:24
 

85

Posts

0

Resources
2
 
  1. //Assembly source program: //ST BIT P3.0 //OE BIT P3.1 // Header file in KEIL C51, adjust the others by yourself #include "reg51.h" void delay(); // Bit definition, KEIL C51 special mode sbit ST = P3^0; sbit OE = P3^1; sbit P20 = P2^0; sbit P21 = P2^1; sbit P22 = P2^2; sbit P23 = P2^3; sbit P24 = P2^4; sbit P25 = P2^5; sbit P26 = P2^6; sbit P27 = P2^7; //ORG 0000H //LJMP MAIN //ORG 0030H //MAIN: int main() { unsigned char tempA; while(1) { // CLR P2.0 // CLR P2.2 P20 = 0; P22 = 0; // LCALL DELAY // CLR ST // SETB ST // CLR ST delay(); ST = 0; ST = 1; ST = 0; // LCALL DELAY // SETB OE // MOV P1,#0FFH // MOV A,P1 // CLR OE delay(); OE = 1; P1 = 0xFF; tmpA = P1; OE = 0; // CLR C // SUBB A,#67H ;Alarm value // JNC ALERM // SJMP MAIN if(tmpA >= 0x67) // I forgot a lot of assembly, if it is greater than or less than, change it yourself { unsigned char i; while(1) { // ALERM: SETB P2.2 // SETB P2.0 P22 = 1; P20 = 1; // MOV R4,#255 // DJNZ R4,$ // CLR P2.0 i = 255; while(--i); P20 = 0; // MOV R5,#255 // DJNZ R5,$ i = 255; while(--i); // SJMP ALERM } } } } void delay() { // DELAY: // MOV R2,#250 // AA: // MOV R3,#255 // DJNZ R3,$ // DJNZ R2,AA // RET unsigned char t2, t3; t2 = 250; while(--t2) { t3 = 250; while(--t3); } } //END
复制代码
This post is from 51mcu

赞赏

1

查看全部赞赏

 
 
 

269

Posts

0

Resources
3
 
Write it yourself after you understand it, it can't be automatically transferred
This post is from 51mcu
 
 
 

1w

Posts

142

Resources
4
 
It is not possible to convert it by tools. You can only rewrite it in C after understanding the original assembly program, or figure out the specific application requirements and write it directly in C. Of course, the necessary homework before that is to master C language programming first.
This post is from 51mcu
 
Personal signature上传了一些书籍资料,也许有你想要的:http://download.eeworld.com.cn/user/chunyang
 
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list