汇编比C语言更节省空间吗?(内面内容值得探讨,欢迎行家发表意见)
我在学校时刚开始用汇编,但后来老师说用C更方便,更好。我就顶着头皮有C,后来觉得C太好了。但现在出来工作,我是在家电公司格兰仕工作,但他们都在用汇编。因为他们说汇编节省空间,他们一般在家电方面的单片机空间只有4~6K,此类的MCU价格一般不超过大概5块钱。几乎家电业都是如此。我想问下,像这么4K的汇编代码用C来写大约要多少空间呢?还有一个问题就是请问行家:有没有5~10块钱的ATMEL公司生产的单片机呢?此类的单片机有多大的空间呢?
望大家踊跃的探讨啊?我不想以后也想他们的现在软件工程师一样写4000多行的汇编代码啊? 怎么没有人说话啊/
自己顶了! 答案是肯定的, 很明显! 有个分水岭,对51来说就是4K,4K以下程序用汇编省时,比这多且经常要升级或修改,C的好处就发挥出来了. 5~10块钱的ATMEL公司生产的单片机
mega48mega8 ,邮购部的信息查询一下就知道了
家电的产品里面的控制芯片都是用最便宜的,呵呵 小家电类很多还在用4bit的单片机,像我现在主要的工作就是这个....
这么小的空间当然用汇编方便,而且我用的根本没有c编译器。 of course 哎!汇编的代码好痛苦啊!主要是重复性太厉害!搞死人啊!
怎么没有那位行家高手客观的分析分析啊?
我觉得C语言是将来发展的趋势,不知道对不对? 我觉得
不太会用的人用C好,上手快,考虑的问题少
会用的人用汇编好,对所用的东西都能一把掌控,
比会用的人再厉害点的也是用C好,能用C把所用的东西都掌控在手,需要很多技巧
最厉害的是两个混着用,能根据实际情况分别对待,能扬长避短
个人看法,欢迎拍砖 用c写一个带有参数和局部变量的小程序然后在main中调用,avrstudio调试,查看其disassembler 仔细看一下编译器生成的汇编,参数和局部变量都保存在了堆栈中,其实我们在做汇编的时候也可以借鉴这种思路,照搬当然是不行的那样会浪费很多的处理器时间和寄存器 根据这个思想自己设计一套程序的设计规范,自己用着舒服也方便移植别人的程序
汇编复杂很多时候就是复杂在变量,寄存器,参数传递等的协调和处理上,好好解决一下这个问题很有用 8楼说得很有道理! 该用汇编的地方用汇编,没必要用汇编的地方都用C,但无论如何,都应该把汇编部分和C部分从文件上区分开来
狭义的“两个混着用”,恰好是最差的编程习惯 我在学习中颖和三星的单片机,现在漫漫的对那些几千行的汇编代码没有那么陌生了。觉得汇编不弄懂,根本上谈不上说学会了单片机,当然你不一定要用汇编。不信去问问马老师是怎么说的,我觉得很有道理。
我不知道有论坛有没有人在用中颖和三星的单片机,大家来讨论讨论交流啊!!!
不知道有没有人对汇编感兴趣,有的话,我就传一个上来大家谈论。 你这的这二款单片机很少人用的,你上传一个汇编的,可能能看懂的人不会很多的! 对于TINY13这类只有1k的容量,用C很难实现的项目,使用汇编,还能剩1/3的空间。
但对于大项目,汇编的生产效率就明显低了。
优势可以互补的。 今天我特意问了一下,我问他们工程师们为什么不用51系列的单片机,得到的答复是:51的抗干扰性差。
而难道用什么SAMSUNG,NTK,TOSHIBA,他们的价格和抗干扰性以及可靠性就真的很好吗?
谁能回答这个问题?
传一段中颖单片机的程序上来,汇编的高手来指教指教,如果有人肯发表高论,那我就全部帖出来了。
例外有没有高手和老手可以说说现在市面上单片机,各个厂家的每个型号的单片机在那一个领域最有
优势。这样我们也可以整体提高大家的成本意识。
-----此内容被lixu于2006-10-20,20:11:09编辑过 这是一段家电控制上的汇编源程序,大家就悠着点看吧!眼睛痛不要找我啊!呵呵……
补充说明一点,是中颖的四位机,价格很便宜不超过4RMB。
;OSCILLATOR TYPE: Crystal oscillator
;WATCH DOG TIMER: Enable
;LVR VOLTAGE RAMGE:High LVR voltage
;OSCILLATOR RANGE:2~8MHZ
;LOW VOLTAGE RESET:Enable
;**********************************************
;*************************************
;SYSTEM REGISTER DEFINE
;*************************************
IE EQU 00H ;INTERRUPT ENABLE FLAG
IRQ EQU 01H ;INTERRUPT REQUEST
T0M EQU 02H ;TIMER O SET
T1M EQU 03H ;TIMER 1 SET
T0L EQU 04H
T0H EQU 05H
T1L EQU 06H
T1H EQU 07H
PORTA EQU 08H ;PORT A
PORTB EQU 09H
PORTC EQU 0AH
PORTD EQU 0BH
PORTE EQU 0CH
PORTF EQU 0DH
TBR EQU 0EH ;TABLE BRANCH REGISTER
INX EQU 0FH ;PSEUDO INDEX REGISTER
DPL EQU 10H ;DATA POINTER FOR INX LOW NIBBLE
DPM EQU 11H ;DATA POINTER FOR INX MIDDLE NIBBLE
DPH EQU 12H ;DATA POINTER FOR INX HIGH NIBBLE
CMP_CONTROL EQU 13H ;COMPARATOR CONTROL REGISTER
CMP_STATUS EQU 14H ;COMPARATOR SUATUS REGISTER
T2SET EQU 15H ;TIMER2 SET
PAOUT EQU 16H ;PORT A INPUT/OUTPUT SET
PBOUT EQU 17H
PCOUT EQU 18H
PDOUT EQU 19H
PEOUT EQU 1AH
PFOUT EQU 1BH
T2_SIGNAL_SET EQU 1CH ;TIMER2 EXTERNAL SIGNAL SOURCE SET
;1DH RESERVED
WDT EQU 1EH ;WATCH DOG TIMER
ROM_BANK EQU 1FH ;BANK REGISTER FOR ROM
PGOUT EQU 20H ;PORT G INPUT/OUTPUT SET
PHOUT EQU 21H ;PORT H INPUT/OUTPUT SET
PORTG EQU 22H ;PORTG
PORTH EQU 23H ;PORTH
PA_PULL_HIGH EQU 24H ;PORTA PULL-HIGH CONTROL
PB_PULL_HIGH EQU 25H ;PORTB PULL-HIGH CONTROL
PC_PULL_HIGH EQU 26H ;PORTC PULL-HIGH CONTROL
PD_PULL_HIGH EQU 27H ;PORTD PULL-HIGH CONTROL
PE_PULL_HIGH EQU 28H ;PORTE PULL-HIGH CONTROL
PF_PULL_HIGH EQU 29H ;PORTF PULL-HIGH CONTROL
PG_PULL_HIGH EQU 2AH ;PORTG PULL-HIGH CONTROL
PH_PULL_HIGH EQU 2BH ;PORTH PULL-HIGH CONTROL
TONE1_VOLUME_L EQU 2CH ;TONE GENERATOR 1 VOLUME LOW NIBBLE
TONE1_VOLUME_H EQU 2DH ;TONE GENERATOR 1 VOLUME HIGH NIBBLE
TONE2_VOLUME_L EQU 2EH ;TONE GENERATOR 2 VOLUME LOW NIBBLE
TONE2_VOLUME_H EQU 2FH ;TONE GENERATOR 2 VOLUME HIGH NIBBLE
RB7_RDT_L EQU 00H ;ROM DATA TABLE ADDRESS/DATA REGISTER LOW NIBBLE
RB7_RDT_ML EQU 01H ;ROM DATA TABLE ADDRESS/DATA REGISTER MIDDLE LOW NIBBLE
RB7_RDT_MH EQU 02H ;ROM DATA TABLE ADDRESS/DATA REGISTER MIDDLE HIGH NIBBLE
RB7_RDT_H EQU 03H ;ROM DATA TABLE ADDRESS/DATA REGISTER HIGH NIBBLE
RB7_T2L EQU 04H ;TIMER2 LOAD/COUNTER REGISTER(LOW NIBBLE)
RB7_T2ML EQU 05H ;TIMER2 LOAD/COUNTER REGISTER(MIDDLE LOW NIBBLE)
RB7_T2MH EQU 06H ;TIMER2 LOAD/COUNTER REGISTER(MIDDLE HIGH NIBBLE)
RB7_T2H EQU 07H ;TIMER2 LOAD/COUNTER REGISTER(HIGH NIBBLE)
RB7_TONE1_L EQU 08H ;TONE GENERATOR 1 LOW NIBBLE
RB7_TONE1_M EQU 09H ;TONE GENERATOR 1 MIDDLE NIBBLE
RB7_TONE1_H EQU 0AH ;TONE GENERATOR 1 HIGH NIBBLE
RB7_TONE2_L EQU 0BH ;TONE GENERATOR 2 LOW NIBBLE
RB7_TONE2_M EQU 0CH ;TONE GENERATOR 2 MIDDLE NIBBLE
RB7_TONE2_H EQU 0DH ;TONE GENERATOR 2 HIGH NIBBLE
RB7_T2_PRE EQU 0EH ;TIMER2 PRE-SCALER REGISTER
RB7_COMPARATOR_SET EQU 0FH ;COMPARATOR CHANNEL SELECT & COMPARATOR OUTPUT DATA
RB7_PF_IE_FLAG EQU 10H ;PORTF INTERRUPT ENABLE FLAGS
RB7_PG_IE_FLAG EQU 11H ;PORTG INTERRUPT ENABLE FLAGS
RB7_PF_IRQ_FLAG EQU 12H ;PORTF INTERRUPT REQUEST FLAGS
RB7_PG_IRQ_FLAG EQU 13H ;PORTG INTERRUPT REQUEST FLAGS
RB7_CMP_IE_IRQ_F EQU 14H ;CMP INTERRUPT ENABLE FLAG
;***************************************
;DATA MEMORY DEFINE
;***************************************
;-------------BANK 0--------------------
ACC EQU 30H
;PROTECT ACCUMULATER REGISTER(ONLY TIMER0 USED)
TEMP EQU 31H
;TEMP REGISTER
CLRACC EQU 32H
;CLEAR ACCUMULATER USED REGISTER
RELAY_FLAG EQU 33H
;BIT0:BUZZER OUTPUT FLAG
;BIT1:WAVE OUTPUT FLAG
;BIT2:GRILL OUTPUT FLAG
;BIT3:LIGHT OUTPUT FLAG
MACHINE_TYPE EQU 34H
;MACHINE TYPE REGISTER
GRILL_CT0 EQU 35H
GRILL_CT1 EQU 36H
GRILL_CT2 EQU 37H
;GRILL WORK TIME TIMER USED REGISTERS
LONG_PRESS_EACH_CT EQU 38H
;LONG PRESS EACH TIME COUTER 0(BASE ON 12.25MS KEY SCAN TIMER)
TEMP_M EQU 39H
;MACRO PART USED TEMP REGISTER
TIMER_CLOCK_CT0 EQU 3AH
TIMER_CLOCK_CT1 EQU 3BH
TIMER_CLOCK_CT2 EQU 3CH
TIMER_CLOCK_CT3 EQU 3DH
TIMER_CLOCK_CT4 EQU 3EH
TIMER_CLOCK_CT5 EQU 3FH
;CLOCK TIMER USED REGISTERS
TIMER_5MIN_CT0 EQU 40H
;WORK TIME LONGER(EQUAL) THAN 5 MINUTES TIMER USED REGISTER 0
TIMER_5MIN_CT1 EQU 41H
;WORK TIME LONGER(EQUAL) THAN 5 MINUTES TIMER USED REGISTER 0
TIMER_5MIN_CT2 EQU 42H
;WORK TIME LONGER(EQUAL) THAN 5 MINUTES TIMER USED REGISTER 0
DEFROST_P EQU 43H
;DEFROST PERIOD REGISTER
TEMP_R0 EQU 44H
;TEMP REGISTER 0
TEMP_R1 EQU 45H
;TEMP REGISTER 1
TEMP_R2 EQU 46H
;TEMP REGISTER 2
TEMP_R3 EQU 47H
;TEMP REGISTER 3
TEMP_R4 EQU 48H
;TEMP REGISTER 4
TEMP_R5 EQU 49H
;TEMP REGISTER 5
TEMP_R6 EQU 4AH
;TEMP REGISTER 6
WORK_TYPE EQU 4BH
;00H:NOT WORK TYPE 01H:CLOCK TYPE 02H:PRESET TYPE 03H:MICRO TYPE
;04H:FAST COOK TYPE 05H:DEFROST 06H:GRILL COMBI TYPE 07H:AUTO COOK TYPE
;08H:NO GRILL,FAST COOK 09H:CHILD LOCK 0AH:NOT USED 0BH:NOT USED
;0CH:NOT USED 0DH:NOT USED 0EH:NOT USED 0FH:COOK FINISH TYPE
KEY_VALUE EQU 4CH
;ONE REAL KEY VALUE
KEY_VALUEH EQU 4DH
;WORK TYPE NUMBER HIGH NIBBLE
KEY_VALUEL EQU 4EH
;WORK TYPE NUMBER LOW NIBBLE
CODING_VALUEH EQU 4FH
;CODING VALUE HIGH NIBBLE
CODING_VALUEL EQU 50H
;CODING VALUE LOW NIBBLE
RELAY_ON_TIMEH EQU 51H
;WAVE/GRILL/ RELAY ON TIME HIGH NIBBLE
RELAY_ON_TIMEL EQU 52H
;WAVE/GRILL RELAY ON TIME LOW NIBBLE
KEY_LS EQU 53H
;0CH:CHILD LOCK KEY
;0EH:NO KEY 0FH:KEY ALREADY PROCESS
BUZZER_TYPE EQU 54H
;BUZZER TYPE REGISTER
BUZZER_TIMES EQU 55H
;BUZZER DEGREE REGISTER
DOOR_T EQU 56H
;SCAN KEY TIMES
KEY_T EQU 57H
;KEY SCAN TIMES
DISPLAY_BIT EQU 58H
;DISPLAY BIT REGISTER
LEVEL EQU 59H
;MICROWAVE/AUTOFUNCTION LEVEL REGISTER
AUTO_CONFIRM_CT EQU 5AH
;CLOCK AUTO CONFIRM TIMER USED REGISTER(BASED ON 500MS)
WORK_MINH EQU 5BH
;WORK TIME NINUTE HIGH NIBBLE
WORK_MINL EQU 5CH
;WORK TIME MINUTE LOW NIBBLE
WORK_SECH EQU 5DH
;WORK TIME SECOND HIGH NIBBLE
WORK_SECL EQU 5EH
;WORK TIME SECOND LOW NIBBLE
TIME_HORH EQU 5FH
;CLOCK HOUR HIGH NIBBLE
TIME_HORL EQU 60H
;CLOCK HOUR LOW NIBBLE
TIME_MINH EQU 61H
;CLOCK MINUTE HIGH NIBBLE
TIME_MINL EQU 62H
;CLOCK MINUTE LOW NIBBLE
PRE_TIME_MINH EQU 63H
;PRESET TIME MINUTE HIGH NIBBLE
PRE_TIME_MINL EQU 64H
;PRESET TIME MINUTE LOW NIBBLE
PRE_TIME_HORH EQU 65H
;PRESET TIME HOUR HIGH NIBBLE
PRE_TIME_HORL EQU 66H
;PRESET TIME HOUR LOW NIBBLE
WORK_FLAG8 EQU 67H
;BIT0:set_timer
;BIT1:auto_start
;BIT2:DURING KEY SCAN FLAG
;BIT3:POWER ON ALL LED ON FLAG
WORK_FLAG0 EQU 68H
;BIT0:LOOK POWER FLAG
;BIT1:1S DISPLAY RAY FLAG
;BIT2:500MS TIMER FLAG
;BIT3:500MS DISPLAY RAY FLAG
WORK_FLAG1 EQU 69H
;BIT0:START KEY INVILID FLAG
;BIT1:1S TIMER FLAG
;BIT2:50MS LONG PRESS KEY EACH FLAG
;BIT3:CLOCK ALREADY SET FLAG
WORK_FLAG2 EQU 6AH
;BIT0:CODE SWITCH IS "01"
;BIT1:CODE SWITCH IS "10"
;BIT2:CODE SWITCH DISABLE FLAG
;BIT3:5MS SCAN KEY FLAG
WORK_FLAG3 EQU 6BH
;BIT0:CHECK PRESET CLOCK CHECK
;BIT1:WORK START FLAG
;BIT2:WORK PAUSE FLAG
;BIT3:DOOR OPEN FLAG
WORK_FLAG4 EQU 6CH
;BIT0:SET TIME
;BIT1:run_timer
;BIT2:PRESET FLAG
;BIT3:LONG PRESS KEY ON FLAG
WORK_FLAG7 EQU 6DH
;BIT0:GRILL TYPE FLAG
;BIT1:TIMER1S
;BIT2:set_clock_start
;BIT3:LOCK_FIRST
NOW_COOK_TYPE_L EQU 6EH
;NOW COOK TYPE REGISTER LOW NIBBLE
CS_BUFFER EQU 70H
;CODDING SWITCH LAST STATE REGISTER
POWER_ON_LCD_ON_TIMER EQU 71H
;POWER ON LCE ON TIMER USED REGISTER(BASED ON 500MS)
TIMER_KEY_CT0 EQU 72H
;SCAN KEY TIMER USED REGISTER 0
TIMER_KEY_CT1 EQU 73H
;SCAN KEY TIMER USED REGISTER 1
TIMER_RAY_CT0 EQU 74H
;DISPLAY PART RAY TIMER USED REGISTER 0
TIMER_RAY_CT1 EQU 75H
;DISPLAY PART RAY TIMER USED REGISTER 1
TIMER_RAY_CT2 EQU 76H
;DISPLAY PART RAY TIMER USED REGISTER 2
TIMER_CODE_CT EQU 77H
;CODDING SWITCH SCAN TIMER USED REGISTER
TIMER_WT_CT0 EQU 78H
;WORK TIME TIEMR USED REGISTER 0
TIMER_WT_CT1 EQU 79H
;WORK TIME TIEMR USED REGISTER 1
TIMER_WT_CT2 EQU 7AH
;WORK TIME TIEMR USED REGISTER 2
TIMER_WT_CT3 EQU 7BH
;WORK TIME TIMER USED REGISTER 3
DIS_DATA_BUFFER_L EQU 7CH
;DISPLAY DATA BUFFER LOW NIBBLE
DIS_DATA_BUFFER_H EQU 7DH
;DISPLAY DATA BUFFER HIGH NIBBLE
TIMER_DIS_CT EQU 7EH
;DISPLAY TIMER USED REGISTER
SET_STATE EQU 7FH
;MICRO WAVE/GRILL/COMBI SET STATE(SOFT KEY MACHINE)
;------------------------------------------
;----------RAM BANK 1(80H--FFH)------------
;------------------------------------------
MUL_WORK_MINH1 EQU 00H
;MUL COOK WORK TIME MINUTE HIGH BANK 1
MUL_WORK_MINL1 EQU 01H
;MUL COOK WORK TIME MINUTE LOW BANK 1
MUL_WORK_SECH1 EQU 02H
;MUL COOK WORK TIME SECOND HIGH BANK 1
MUL_WORK_SECL1 EQU 03H
;MUL COOK WORK TIME SECOND LOW BANK 1
MUL_WORK_MINH3 EQU 08H
;MUL COOK WORK TIME MINUTE HIGH BANK 3
MUL_WORK_MINL3 EQU 09H
;MUL COOK WORK TIME MINUTE LOW BANK 3
MUL_WORK_SECH3 EQU 0AH
;MUL COOK WORK TIME SECOND HIGH BANK 3
MUL_WORK_SECL3 EQU 0BH
;MUL COOK WORK TIME SECOND LOW BANK 3
MUL_WORK_MINH4 EQU 0CH
;MUL COOK WORK TIME MINUTE HIGH BANK 4
MUL_WORK_MINL4 EQU 0DH
;MUL COOK WORK TIME MINUTE LOW BANK 4
MUL_WORK_SECH4 EQU 0EH
;MUL COOK WORK TIME SECOND HIGH BANK 4
MUL_WORK_SECL4 EQU 0FH
;MUL COOK WORK TIME SECOND LOW BANK 4
MUL_COOK_TYPE4H EQU 10H
;MUL COOK TYPE BANK 4 HIGH NIBBLE
MUL_COOK_TYPE4L EQU 11H
;MUL COOK TYPE BANK 4 LOW NIBBLE
MUL_COOK_TYPE3L EQU 12H
;MUL COOK TYPE BANK 3 LOW NIBBLE
MUL_COOK_TYPE3H EQU 13H
;MUL COOK TYPE BANK 3 HIGH NIBBLE
MUL_COOK_TYPE2L EQU 14H
;MUL COOK TYPE BANK 2 LOW NIBBLE
MUL_COOK_TYPE2H EQU 15H
;MUL COOK TYPE BANK 2 HIGH NIBBLE
MUL_COOK_TYPE1L EQU 16H
;MUL COOK TYPE BANK 1 LOW NIBBLE
MUL_COOK_TYPE1H EQU 17H
;MUL COOK TYPE BANK 1 HIGH NIBBLE
RB1_TIMER_BUZ_CT0 EQU 18H
;BUZZER TIME TIMER USED REGISTER 0
RB1_TIMER_BUZ_CT1 EQU 19H
;BUZZER TIME TIMER USED REGISTER 1
RB1_TIMER_BUZ_CT2 EQU 1AH
;BUZZER TIME TIMER USED REGISTER 2
RB1_TIMER_BUZ_CT3 EQU 1BH
;BUZZER TIME TIMER USED REGISTER 3
RB1_TIMER_SHARE_CT0 EQU 1CH
;LOOK STATE/CHILDLOCK TIMER USED REGISTER 0
RB1_TIMER_SHARE_CT1 EQU 1DH
;LOOK STATE/CHILDLOCK TIMER USED REGISTER 1
RB1_TIMER_SHARE_CT2 EQU 1EH
;LOOK STATE/CHILDLOCK TIMER USED REGISTER 2
RB1_TIMER_SHARE_CT3 EQU 1FH
;LOOK STATE/CHILDLOCK TIMER USED REGISTER 3
DEFROST_CT0 EQU 20H
;DEFROST 1/4 TIME 0.1 SECONDBIT NIBBLE
DEFROST_CT1 EQU 21H
;DEFROST 1/4 TIME SECOND BIT LOWNIBBLE
DEFROST_CT2 EQU 22H
;DEFROST 1/4 TIME SECOND BIT HIGH NIBBLE
DEFROST_CT3 EQU 23H
;DEFROST 1/4 TIME MINUTE BIT NIBBLE
DISPLAY_VALUE EQU 24H
;DISPLAY VAULE
RB1_DOOR_OPEN_CT3 EQU 25H
;500MS TIMER USED REGISTER
RB1_DOOR_OPEN_CT4 EQU 26H
;500MS TIMER USED REGISTER
RB1_DOOR_OPEN_CT5 EQU 27H
;500MS TIMER USED REGISTER
RB1_OPTION_PE_LAST EQU 2AH
RB1_OPTION_PC_LAST EQU 2BH
;MACHINE TYPE OPTION LAST STATE
RB1_GET_OPTION_TIME EQU 2CH
;MACHINE TYPE OPTION CHECK TIMES
DIS_LINE1H EQU 30H
;DISPLAY PART:LINE1HIGH PART NIBBLE
DIS_LINE1L EQU 31H
;DISPLAY PART:LINE1LOW PART NIBBLE
DIS_LINE2H EQU 32H
;DISPLAY PART:LINE2HIGH PART NIBBLE
DIS_LINE2L EQU 33H
;DISPLAY PART:LINE2LOW PART NIBBLE
DIS_LINE3H EQU 34H
;DISPLAY PART:LINE3HIGH PART NIBBLE
DIS_LINE3L EQU 35H
;DISPLAY PART:LINE3LOW PART NIBBLE
DIS_LINE4H EQU 36H
;DISPLAY PART:LINE4HIGH PART NIBBLE
DIS_LINE4L EQU 37H
;DISPLAY PART:LINE4LOW PART NIBBLE
DIS_LINE5H EQU 38H
;DISPLAY PART:LINE5HIGH PART NIBBLE
DIS_LINE5L EQU 39H
;DISPLAY PART:LINE5LOW PART NIBBLE
DIS_LINE6H EQU 3AH
;DISPLAY PART:LINE6HIGH PART NIBBLE
DIS_LINE6L EQU 3BH
;DISPLAY PART:LINE7LOW PART NIBBLE
DEF_AUTO EQU 3CH
RB1_END_CT0 EQU 40H
;AFTER COOK END,3 MINUTES TIMER USED REGISTER 0
RB1_END_CT1 EQU 41H
;AFTER COOK END,3 MINUTES TIMER USED REGISTER 1
RB1_END_CT2 EQU 42H
;AFTER COOK END,3 MINUTES TIMER USED REGISTER 2
RB1_RELAY_CHANGE_CT0 EQU 43H
;RELAY CHANGE DELAY 100MS TIMER USED REGISTER
RB1_RELAY_CHANGE_CT1 EQU 44H
;RELAY CHANGE DELAY 100MS TIMER USED REGISTER
RB1_RELAY_CHANGE_CT2 EQU 45H
;RELAY CHANGE DELAY 100MS TIMER USED REGISTER
AUTO_CANCEL_CT0 EQU 48H
;PRESET CLOCK 10SECONDS CANCEL REGISTER(BASED ON 500MS)
AUTO_CANCEL_CT1 EQU 49H
;PRESET CLOCK 10SECONDS CANCEL REGISTER(BASED ON 500MS)
LONG_PRESS_TIME_CT EQU 4AH
;LONG PRESS KEY TIMER USED COUNTER(BASED ON 500MS)
LONG_PRESS_EACH_CT1 EQU 4BH
;LONG PRESS KEY TIMER USED COUNTER(BASED ON 500MS)
START_2_MINUTES_CT0 EQU 4CH
;START KEY 2 MINUTES NOT VILID TIMER USED REGISTER(BASED ON 500MS)
START_2_MINUTES_CT1 EQU 4DH
;START KEY 2 MINUTES NOT VILID TIMER USED REGISTER(BASED ON 500MS)
TIMER_NOTON_CT0 EQU 50H
;SET FUNCTION & NOT START TIMER USED REGISTER 0(BASED ON 500MS)
TIMER_NOTON_CT1 EQU 51H
;SET FUNCTION & NOT START TIMER USED REGISTER 1(BASED ON 500MS)
TIMER_NOTON_CT2 EQU 52H
;SET FUNCTION & NOT START TIMER USED REGISTER 2(BASED ON 500MS)
LINE1_CURRENT_DATA_B EQU 60H
;THE FIRST LINE KEY CURRENT NIBBLE(PORTB)
LINE1_CURRENT_DATA_D EQU 61H
;THE FIRST LINE KEY CURRENT NIBBLE(PORTD)
LINE1_CURRENT_DATA_H EQU 62H
;THE FIRST LINE KEY CURRENT NIBBLE(PORTH)
LINE2_CURRENT_DATA_B EQU 63H
;THE SECOND LINE KEY CURRENT NIBBLE(PORTB)
LINE2_CURRENT_DATA_D EQU 64H
;THE SECOND LINE KEY CURRENT NIBBLE(PORTD)
LINE2_CURRENT_DATA_H EQU 65H
;THE SECOND LINE KEY CURRENT NIBBLE(PORTH)
LINE3_CURRENT_DATA_B EQU 66H
;THE THIRD LINE KEY CURRENT NIBBLE(PORTB)
LINE3_CURRENT_DATA_D EQU 67H
;THE THIRD LINE KEY CURRENT NIBBLE(PORTD)
LINE3_CURRENT_DATA_H EQU 68H
;THE THIRD LINE KEY CURRENT NIBBLE(PORTH)
LINE4_CURRENT_DATA_B EQU 69H
;THE FOURTH LINE KEY CURRENT NIBBLE(PORTB)
LINE4_CURRENT_DATA_D EQU 6AH
;THE FOURTH LINE KEY CURRENT NIBBLE(PORTD)
LINE4_CURRENT_DATA_H EQU 6BH
;THE FOURTH LINE KEY CURRENT NIBBLE(PORTH)
LINE5_CURRENT_DATA_B EQU 6CH
;THE FIFTH LINE KEY CURRENT NIBBLE(PORTB)
LINE5_CURRENT_DATA_D EQU 6DH
;THE FIFTH LINE KEY CURRENT NIBBLE(PORTD)
LINE5_CURRENT_DATA_H EQU 6EH
;THE FIFTH LINE KEY CURRENT NIBBLE(PORTH)
LINE1_LAST_DATA_B EQU 70H
;THE FIRST LINE KEY LAST NIBBLE(PORTB)
LINE1_LAST_DATA_D EQU 71H
;THE FIRST LINE KEY LAST NIBBLE(PORTD)
LINE1_LAST_DATA_H EQU 72H
;THE FIRST LINE KEY LAST NIBBLE(PORTH)
LINE2_LAST_DATA_B EQU 73H
;THE SECOND LINE KEY LAST NIBBLE(PORTB)
LINE2_LAST_DATA_D EQU 74H
;THE SECOND LINE KEY LAST NIBBLE(PORTD)
LINE2_LAST_DATA_H EQU 75H
;THE SECOND LINE KEY LAST NIBBLE(PORTH)
LINE3_LAST_DATA_B EQU 76H
;THE THIRD LINE KEY LAST NIBBLE(PORTB)
LINE3_LAST_DATA_D EQU 77H
;THE THIRD LINE KEY LAST NIBBLE(PORTD)
LINE3_LAST_DATA_H EQU 78H
;THE THIRD LINE KEY LAST NIBBLE(PORTH)
LINE4_LAST_DATA_B EQU 79H
;THE FOURTH LINE KEY LAST NIBBLE(PORTB)
LINE4_LAST_DATA_D EQU 7AH
;THE FOURTH LINE KEY LAST NIBBLE(PORTD)
LINE4_LAST_DATA_H EQU 7BH
;THE FOURTH LINE KEY LAST NIBBLE(PORTH)
LINE5_LAST_DATA_B EQU 7CH
;THE FIFTH LINE KEY LAST NIBBLE(PORTB)
LINE5_LAST_DATA_D EQU 7DH
;THE FIFTH LINE KEY LAST NIBBLE(PORTD)
LINE5_LAST_DATA_H EQU 7EH
;THE FIFTH LINE KEY LAST NIBBLE(PORTH)
;------------------------------------------
;----------RAM BANK 2(100H--167H)----------
;------------------------------------------
TEMP_DEF_NUM EQU 00H
PAUSE_DEF_SECL EQU 01H
PAUSE_DEF_SECH EQU 02H
PAUSE_DEF_MINL EQU 03H
PAUSE_DEF_MINH EQU 04H
Time_second_timerL equ 05H
Time_second_timerH equ 06H
Time_minute_timerL equ 07H
Time_minute_timerH equ 08H
Time_disp_timer equ 09H
LOCK_COUNT equ 0aH
LOCK_BACK_COUNT equ 0bh
AUTO_START_COUNT equ 0ch
TIMER_PAUSE equ 0dh
BANK0 equ 0
BANK1 equ 1
BANK2 equ 2
;***************************************
; MACROPART
;***************************************
INC8 MACRO B0XH ,B0XL
ADIM B0XL ,01H
LDI TEMP_M ,00H
ADCM B0XH ,00H
ENDM
;====================================
DEC8 MACRO B0XH ,B0XL
SBIM B0XL ,01H
LDI TEMP_M ,00H
SBCM B0XH ,00H
ENDM
;======================================
ADD8 MACRO B0XH,B0XL,IYH,IYL ;( XH,XL IS BANK0 )
ADIM B0XL ,IYL
LDI TEMP_M ,IYH
ADCM B0XH ,00H
ENDM
;=========================================
SUB8 MACRO B0XH,B0XL,IYH,IYL ;( XH,XL IS BANK0 )
SBIM B0XL ,IYL
LDI TEMP_M ,IYH
SBCM B0XH ,00H
ENDM
;=====================================
CJB4 MACRO B0X ,IY ,ADDR
SBI B0X ,IY
BAZ $+2
BC ADDR
ENDM
;=====================================
CJB8 MACRO B0XH,B0XL,IYH,IYL,ADDR
SBI B0XH ,IYH
BAZ $+3
BC ADDR
JMP $+4
SBI B0XL ,IYL
BAZ $+2
BC ADDR
ENDM
;=====================================
CJBE4 MACRO B0X ,IY ,ADDR
SBI B0X ,IY
BC ADDR
ENDM
;====================================
CJBE8 MACRO B0XH,B0XL,IYH,IYL,ADDR
SBI B0XH ,IYH
BAZ $+3
BC ADDR
JMP $+3
SBI B0XL ,IYL
BC ADDR
ENDM
;====================================
CJS4 MACRO B0X ,IY ,ADDR
SBI B0X ,IY
BNC ADDR
ENDM
;====================================
CJS8 MACRO B0XH,B0XL,IYH,IYL,ADDR
SBI B0XH ,IYH
BAZ $+3
BNC ADDR
JMP $+3
SBI B0XL ,IYL
BNC ADDR
ENDM
;====================================
;CJSE4 MACRO B0X ,IY ,ADDR
SBI B0X ,IY
BAZ ADDR
BNC ADDR
ENDM
;====================================
CJSE8 MACRO B0XH,B0XL,IYH,IYL,ADDR
SBI B0XH ,IYH
BAZ $+3
BNC ADDR
JMP $+4
SBI B0XL ,IYL
BAZ ADDR
BNC ADDR
ENDM
;====================================
CJE4 MACRO B0X ,IY ,ADDR
SBI B0X ,IY
BAZ ADDR
ENDM
;====================================
CJNE4 MACRO B0X ,IY ,ADDR
SBI B0X ,IY
BNZ ADDR
ENDM
;====================================
CJE8 MACRO B0XH,B0XL,IYH,IYL,ADDR;( XH,XL IS BANK0 )
SBI B0XH ,IYH
BNZ $+3
SBI B0XL ,IYL
BAZ ADDR
ENDM
;===================================
CJNE8 MACRO B0XH,B0XL,IYH,IYL,ADDR;( XH,XL IS BANK0 )
SBI B0XH ,IYH
BNZ ADDR
SBI B0XL ,IYL
BNZ ADDR
ENDM
;====================================
DJZ4 MACRO B0X ,ADDR ;REALLY DECRESE 1
SBIM B0X ,01H
BAZ ADDR
ENDM
;====================================
DJNZ4 MACRO B0X ,ADDR ;REALLY DECRESE 1
SBIM B0X ,01H
BNZ ADDR
ENDM
;***************************************
; VECTOR ADDRESS
;***************************************
ORG 00H
JMP RESET
JMP TIMER0INT ;TIMER 0 INTERRUPT
RTNI
RTNI
RTNI
;***********************************************************************************
;SUBROUTINE NAME:TIMER0 INTERRUPT SERVICE SUBROUTINE
;FUNCTION:TIMER0 INTERRUPT SERVICE SUBROUTINE
;INPUT PARAMETER:RELAY_FLAG,WORK_FLAG0,WORK_FLAG1,WORK_FLAG2,WORK_FLAG3,NOW_COOK_TYPE
;OUTPUT PARAMETER:WORK_FLAG0,WORK_FLAG1,WORK_FLAG2,WORK_FLAG4
;USED REGISTERS:ACC,CLRACC,TEMP,RB1_TIMER_BUZ_CT0~RB1_TIMER_BUZ_CT2
; :TIMER_RAY_CT0~TIMER_RAY_CT2,TIMER_CS_CT,TIMER_WT_CT0~TIMER_WT_CT3
; :RB1_TIMER_SHARE_CT0~RB1_TIMER_SHARE_CT3,RB1_TIMER_SHARE_CT0~RB1_TIMER_SHARE_CT3
; :TIMER_KEY_CT0~TIMER_KEY_CT1,RB1_TIMER_HF_CT0~TIMER_HF_CT3
; :TIMER_CLOCK_CT0~TIMER_CLOCK_CT4,TIMER_PZ_CT0~TIMER_PZ_CT1,RB7_ALARM_SET,RB7_ALARM_ENV
; :TIMER_DY_CT0~TIMER_DY_CT1,CS_BUFFER,DOOR_T,DIS_LINE1H,DIS_LINE1L
; :DIS_LINE2H,DIS_LINE2L,DIS_LINE3H,DIS_LINE3L,DIS_LINE4H,DIS_LINE4L
; :DIS_LINE5H,DIS_LINE5L,DIS_LINE6H,DIS_LINE6L,RB1_WAIT_TIME_CT0~2
;**********************************************************************************
TIMER0INT:
STA ACC ,00H
ANDIM IRQ ,0111B ;CLEAR TIMER0 IRQ
BUZZER_OUTPUT_PART:
LDA RELAY_FLAG ,00H ;BUZZER CHECK
BA0 BUZZER_OUTPUT_PART10
ANDIM PORTF ,1110B ;SET PF.0AS LOW STATE
JMP BUZZER_OUTPUT_PART20
BUZZER_OUTPUT_PART10:
ORIM PFOUT ,0001B ;SET PF.0 AS OUTPUT I/O
EORIM PORTF ,0001B ;OPEN BUZZER
BUZZER_OUTPUT_PART20:
LDI TEMP ,01H
ADDM RB1_TIMER_BUZ_CT0 ,01H ;BUZZER TIMETIMER PART
LDI CLRACC ,00H ;页间处理
ADCM RB1_TIMER_BUZ_CT1 ,01H
LDI CLRACC ,00H
ADCM RB1_TIMER_BUZ_CT2 ,01H
LDI CLRACC ,00H
ADCM RB1_TIMER_BUZ_CT3 ,01H
BUZZER_OUTPUT_PART99:
;=========================================
RELAY_OUTPUT_PART: ;OPEN & CLOSE RELAY PART
CLOSE_WAVE_OUTPUT_PART:
LDA WORK_FLAG3 ,00H
BA1 CLOSE_WAVE_OUTPUT_PART_LIGHTON ;WORK START
LDA WORK_FLAG3 ,00H ;LIGHT RELAY STATE CHECK
BA3 CLOSE_WAVE_OUTPUT_PART_LIGHTON
JMP CLOSE_WAVE_OUTPUT_PART10
CLOSE_WAVE_OUTPUT_PART_LIGHTON:
ORIM PFOUT ,1000B ;SET PF.3 AS OUTPUT I/O
ORIM PORTF ,1000B;CLOSE LIGHT RELAY
CLOSE_WAVE_OUTPUT_PART10:
LDA RELAY_FLAG ,00H ;CHECK MICRO-WAVE STATE
BA1 CLOSE_WAVE_OUTPUT_PART99
ORIM PFOUT ,0100B ;SET PF.2 AS OUTPUT I/O
ANDIM PORTF ,1011B;CLOSE MICRO-WAVE RELAY
JMP CLOSE_WAVE_OUTPUT_PART99
CLOSE_WAVE_OUTPUT_PART99:
OPEN_WAVE_OUTPUT_PART:
LDA RELAY_FLAG ,00H ;CHECK MICRO-WAVE STATE
BA1 OPEN_WAVE_OUTPUT_PART10
JMP OPEN_WAVE_OUTPUT_PART99
OPEN_WAVE_OUTPUT_PART10:
ORIM PFOUT ,0100B ;SET PF.2 AS OUTPUT I/O
ORIM PORTF ,0100B;OPEN MICRO-WAVE RELAY
JMP OPEN_WAVE_OUTPUT_PART99
OPEN_WAVE_OUTPUT_PART99:
CLOSE_GRILL_OUTPUT_PART:
LDA WORK_FLAG3 ,00H
BA3 CLOSE_GRILL_OUTPUT_PART_LIGHTON
ORIM PFOUT ,1000B ;SET PF.3 AS OUTPUT I/O
ANDIM PORTF ,0111B;CLOSE LIGHT RELAY
JMP CLOSE_GRILL_OUTPUT_PART10
CLOSE_GRILL_OUTPUT_PART_LIGHTON:
ORIM PFOUT ,1000B ;SET PF.3 AS OUTPUT I/O
ORIM PORTF ,1000B;CLOSE LIGHT RELAY
;CLOSE_GRILL_OUTPUT_PART: ;GRILL RELAY OPEN/CLOSE PART
; LDA RELAY_FLAG ,00H ;LIGHT RELAY STATE CHECK
; BA3 CLOSE_GRILL_OUTPUT_PART10
; ORIM PFOUT ,1000B ;SET PF.3 AS OUTPUT I/O
; ANDIM PORTF ,0111B;CLOSE LIGHT RELAY
CLOSE_GRILL_OUTPUT_PART10:
LDA RELAY_FLAG ,00H ;CHECK GRILL REALY STATE
BA2 CLOSE_GRILL_OUTPUT_PART99
ORIM PFOUT ,0010B ;SET PF.1 AS OUTPUT I/O
ANDIM PORTF ,1101B;CLOSE GRILL RELAY
JMP CLOSE_GRILL_OUTPUT_PART99
CLOSE_GRILL_OUTPUT_PART99:
OPEN_GRILL_OUTPUT_PART:
LDA RELAY_FLAG ,00H ;CHECK GRILL REALY STATE
BA2 OPEN_GRILL_OUTPUT_PART10
JMP OPEN_GRILL_OUTPUT_PART99
OPEN_GRILL_OUTPUT_PART10:
ORIM PFOUT ,0010B ;SET PF.1 AS OUTPUT I/O
ORIM PORTF ,0010B;OPEN GRILL RELAY
JMP OPEN_GRILL_OUTPUT_PART99
OPEN_GRILL_OUTPUT_PART99:
RELAY_OUTPUT_PART99:
;========================================
LOOK_TIME_POWER_TIMER_PART: ;LOOK TIME(POWER)/CHILD LOCK TIMER PART
LDI TEMP ,01H
ADDM RB1_TIMER_SHARE_CT0 ,01H ;RAM BANK 1 REGISTER
LDI CLRACC ,00H
ADCM RB1_TIMER_SHARE_CT2 ,01H ;RAM BANK 1 REGISTER
LDI CLRACC ,00H
ADCM RB1_TIMER_SHARE_CT3 ,01H ;RAM BANK 1 REGISTER
;================================================
RELAY_CHANGE_DELAY_TIMER_PART: ;WAVE,GRILL RELAY CHANGE DELAY 100MS TIMER PART
LDA PORTF ,00H ;GRILL RELAY
BA1 RELAY_CHANGE_DELAY_TIMER_PART10
;WAVE RELAY
BA2 RELAY_CHANGE_DELAY_TIMER_PART10
LDI TEMP ,01H
ADDM RB1_RELAY_CHANGE_CT0 ,01H ;BANK 1 REGISTER
LDI CLRACC ,00H
ADCM RB1_RELAY_CHANGE_CT1 ,01H ;BANK 1 REGISTER
LDI CLRACC ,00H
ADCM RB1_RELAY_CHANGE_CT2 ,01H ;BANK 1 REGISTER
JMP RELAY_CHANGE_DELAY_TIMER_PART99
RELAY_CHANGE_DELAY_TIMER_PART10:
LDI CLRACC ,00H
STA RB1_RELAY_CHANGE_CT0 ,01H ;BANK 1 REGISTER
STA RB1_RELAY_CHANGE_CT1 ,01H ;BANK 1 REGISTER
STA RB1_RELAY_CHANGE_CT2 ,01H ;BANK 1 REGISTER
RELAY_CHANGE_DELAY_TIMER_PART99:
;========================================
RAY_DISPLAY_TIMER_PART: ;DISPLAY RAY TIMER PART
ADIM TIMER_RAY_CT0 ,01H
LDI CLRACC ,00H
ADCM TIMER_RAY_CT1 ,00H
LDI CLRACC ,00H
ADCM TIMER_RAY_CT2 ,00H
CJS8 TIMER_RAY_CT2,TIMER_RAY_CT1,07H,0DH,RAY_DISPLAY_TIMER_PART99 ;500MS
LDI TIMER_RAY_CT0 ,00H ;CLEAR DISPLAY RAY TIMER
LDI TIMER_RAY_CT1 ,00H
LDI TIMER_RAY_CT2 ,00H
EORIM WORK_FLAG0 ,1000B;SET 500MS DISPLAY RAY FLAG
BA3 RAY_DISPLAY_TIMER_PART99
EORIM WORK_FLAG0 ,0010B ;SET 1S DISPLAY RAY FLAG
RAY_DISPLAY_TIMER_PART99:
;============================================
CLOCK_TIMER_PART: ;CLOCK TIMER PART
LDA WORK_FLAG1 ,00H
BA3 CLOCK_TIMER_PART10 ;CLOCK ALREADY SET
JMP CLOCK_TIMER_PART99
CLOCK_TIMER_PART10:
ADIM TIMER_CLOCK_CT0 ,01H
LDI CLRACC ,00H
ADCM TIMER_CLOCK_CT1 ,00H
LDI CLRACC ,00H
ADCM TIMER_CLOCK_CT2 ,00H
LDI CLRACC ,00H
ADCM TIMER_CLOCK_CT3 ,00H
LDI CLRACC ,00H
ADCM TIMER_CLOCK_CT4 ,00H
CLOCK_TIMER_PART99:
;============================================
TIMER_500MS_PART: ;500MS TIMER PART
LDI TEMP ,01H
ADDM RB1_DOOR_OPEN_CT3 ,01H
LDI CLRACC ,00H
ADCM RB1_DOOR_OPEN_CT4 ,01H
LDI CLRACC ,00H
ADCM RB1_DOOR_OPEN_CT5 ,01H
STA TEMP ,00H
LDA RB1_DOOR_OPEN_CT4 ,01H
STA CLRACC ,00H
CJS8 TEMP,CLRACC,07H,0DH,TIMER_500MS_PART99 ;500MS
LDI CLRACC ,00H
STA RB1_DOOR_OPEN_CT3 ,01H ;CLEARTIMER
STA RB1_DOOR_OPEN_CT4 ,01H
STA RB1_DOOR_OPEN_CT5 ,01H
ORIM WORK_FLAG0 ,0100B ;SET 500 MS FLAG
TIMER_500MS_PART99:
;============================================
TIMER_1000MS_PART:
LDA LOCK_COUNT ,BANK2
BNZ TIMER_1000MS_PART10
LDA WORK_FLAG4 ,00H
BA1 TIMER_1000MS_PART10
SBI WORK_TYPE ,07H
BNZ $+4
LDA WORK_FLAG8 ,BANK0
BA1 $+2
JMP TIMER_1000MS_PART10
LDA WORK_FLAG3 ,00H ;WORK START CHECK
BA1 TIMER_1000MS_PART10 ;START STATE
BA2 TIMER_1000MS_PART99
LDI TIMER_WT_CT0 ,00H
LDI TIMER_WT_CT1 ,00H
LDI TIMER_WT_CT2 ,00H
LDI TIMER_WT_CT3 ,00H
ANDIM WORK_FLAG1 ,1101B ;CLEAR 1S FLAG
JMP TIMER_1000MS_PART99
TIMER_1000MS_PART10: ;WORK ALREADY START
ADIM TIMER_WT_CT0 ,01H
LDI CLRACC ,00H
ADCM TIMER_WT_CT1 ,00H
LDI CLRACC ,00H
ADCM TIMER_WT_CT2 ,00H
LDI CLRACC ,00H
ADCM TIMER_WT_CT3 ,00H
CJS8 TIMER_WT_CT2,TIMER_WT_CT1,0FH,0AH,TIMER_1000MS_PART99
LDI TIMER_WT_CT0 ,00H
LDI TIMER_WT_CT1 ,00H
LDI TIMER_WT_CT2 ,00H
LDI TIMER_WT_CT3 ,00H
ORIM WORK_FLAG1 ,0010B ;SET 1S FLAG
ORIM WORK_FLAG7 ,0010B
TIMER_1000MS_PART99:
;=======================================
KEY_SCAN_TIMER_PART: ;5MS KEY SCAN TIMER PART
ADIM TIMER_KEY_CT0 ,01H
LDI CLRACC ,00H
ADCM TIMER_KEY_CT1 ,00H
CJS8 TIMER_KEY_CT1,TIMER_KEY_CT0,03H,01H,KEY_SCAN_TIMER_PART99 ;12.25MS CHECK
ORIM WORK_FLAG2 ,1000B;SET 12.25 MS SCAN KEY FLAG
LDI TIMER_KEY_CT0 ,00H
LDI TIMER_KEY_CT1 ,00H
ADIM LONG_PRESS_EACH_CT ,01H ;LONG PRESS EACH TIME TIMER USED REGISTER
CJS4 LONG_PRESS_EACH_CT,04H,KEY_SCAN_TIMER_PART99
LDI LONG_PRESS_EACH_CT ,00H
ORIM WORK_FLAG1 ,0100B ;SET 50MS(49MS) LONG PRESS KEY ENABLE FLAG
KEY_SCAN_TIMER_PART99:
;=======================================
DISPLAY_OUTPUT_PART: ;DISPLAY OUTPUTPART
ADIM TIMER_DIS_CT ,01H ;1MS CHECK
CJS4 TIMER_DIS_CT,07H,DISPLAY_OUTPUT_PART05
LDI TIMER_DIS_CT ,00H
ADIM DISPLAY_BIT ,01H
CJS4 DISPLAY_BIT,07H,DISPLAY_OUTPUT_PART05
LDI DISPLAY_BIT ,00H
JMP DISPLAY_OUTPUT_PART99
DISPLAY_OUTPUT_PART05: ;DISPLAY LINE SELECT
LDA WORK_FLAG8 ,00H ;SCAN KEY CHECK
BA2 DISPLAY_OUTPUT_PART99
LDI PBOUT ,0FH ;CLOSE DISPLAY
LDI PDOUT ,0FH
LDI PHOUT ,0FH
LDI PORTB ,00H
ANDIM PORTD ,0011B
LDI PORTH ,00H
CJE4 DISPLAY_BIT,01H,DISPLAY_OUTPUT_PART10
CJE4 DISPLAY_BIT,02H,DISPLAY_OUTPUT_PART20
CJE4 DISPLAY_BIT,03H,DISPLAY_OUTPUT_PART30
CJE4 DISPLAY_BIT,04H,DISPLAY_OUTPUT_PART40
CJE4 DISPLAY_BIT,05H,DISPLAY_OUTPUT_PART50
CJE4 DISPLAY_BIT,06H,DISPLAY_OUTPUT_PART60
JMP DISPLAY_OUTPUT_PART99
DISPLAY_OUTPUT_PART10: ;THE FIRST LINE OUTPUT
LDI PAOUT ,0FH
LDI PORTA ,0111B ;SET PA.3 AS LOW STATE
ORIM PDOUT ,0011B
ORIM PORTD ,0011B
LDA DIS_LINE6H ,01H ;BANK 1 REGISTER
STA PORTH ,00H
STA TEMP ,00H
ANDIM TEMP ,1100B
ORM PORTD ,00H
LDA DIS_LINE6L ,01H ;BANK 1 REGISTER
STA PORTB ,00H
JMP DISPLAY_OUTPUT_PART99
DISPLAY_OUTPUT_PART20: ;THE SECOND LINE OUTPUT
LDI PAOUT ,0FH
LDI PORTA ,1011B ;SET PA.2 AS LOW STATE
ORIM PDOUT ,0011B
ORIM PORTD ,0011B
LDA DIS_LINE5H ,01H ;BANK 1 REGISTER
STA PORTH ,00H
STA TEMP ,00H
ANDIM TEMP ,1100B
ORM PORTD ,00H
LDA DIS_LINE5L ,01H ;BANK 1 REGISTER
STA PORTB ,00H
JMP DISPLAY_OUTPUT_PART99
DISPLAY_OUTPUT_PART30: ;THE THIRD LINE OUTPUT
LDI PAOUT ,0FH
LDI PORTA ,1101B ;SET PA.1 AS LOW STATE
ORIM PDOUT ,0011B
ORIM PORTD ,0011B
LDA DIS_LINE4H ,01H ;BANK 1 REGISTER
STA PORTH ,00H
STA TEMP ,00H
ANDIM TEMP ,1100B
ORM PORTD ,00H
LDA DIS_LINE4L ,01H ;BANK 1 REGISTER
STA PORTB ,00H
JMP DISPLAY_OUTPUT_PART99
DISPLAY_OUTPUT_PART40: ;THE FOUTRH LINE OUTPUT
LDI PAOUT ,0FH
LDI PORTA ,1110B ;SET PA.0 AS LOW STATE
ORIM PDOUT ,0011B
ORIM PORTD ,0011B
LDA DIS_LINE3H ,01H ;BANK 1 REGISTER
STA PORTH ,00H
STA TEMP ,00H
ANDIM TEMP ,1100B
ORM PORTD ,00H
LDA DIS_LINE3L ,01H ;BANK 1 REGISTER
STA PORTB ,00H
JMP DISPLAY_OUTPUT_PART99
DISPLAY_OUTPUT_PART50: ;THE FIFTH LINE OUTPUT
LDI PAOUT ,0FH
LDI PORTA ,0FH
ORIM PDOUT ,0011B
ANDIM PORTD ,1110B
ORIM PORTD ,0010B
LDA DIS_LINE2H ,01H ;BANK 1 REGISTER
STA PORTH ,00H
STA TEMP ,00H
ORM PORTD ,00H
LDA DIS_LINE2L ,01H ;BANK 1 REGISTER
STA PORTB ,00H
JMP DISPLAY_OUTPUT_PART99
DISPLAY_OUTPUT_PART60: ;THE SIXTH LINE OUTPUT
LDI PAOUT ,0FH
LDI PORTA ,0FH
ORIM PDOUT ,0011B
ANDIM PORTD ,1101B
ORIM PORTD ,0001B
LDA DIS_LINE1H ,01H ;BANK 1 REGISTER
STA PORTH ,00H
ORM PORTD ,00H
LDA DIS_LINE1L ,01H ;BANK 1 REGISTER
STA PORTB ,00H
JMP DISPLAY_OUTPUT_PART99
DISPLAY_OUTPUT_PART99:
JMP TIMER0INT99
;=======================================
TIMER0INT99:
LDI IE ,1000B ;OPEN TIMER0 INT
LDA ACC ,00H
RTNI
;**********************************************************
;SUBROUTINE NAME:INT DATA MEMORY
;FUNCTION:INT DATA MEMORY REGISTERS(030H--16FH)
;INPUT PARAMETER:NO PARAMETER
;OUTPUT PARAMETER:NO PARAMETER
;USED REGISTERS:CLRACC
;**********************************************************
INTDMR: ;INT DATA MEMORY REGISTERS(030H--16FH)
LDI DPH ,00H
LDI DPM ,03H
LDI DPL ,00H
INT0:
LDI INX ,00H
ADIM DPL ,01H
LDI CLRACC ,00H
ADCM DPM ,00H
LDA DPM ,00H
BNZ INT1
LDA DPL ,00H
BNZ INT1
ADIM DPH ,01H
INT1:
SBI DPH ,02H
BNZ INT0
SBI DPM ,06H
BNZ INT0
SBI DPL ,0FH
BNZ INT0
RTNI
;**********************************************************
; INT DISPLAY DATA
;**********************************************************
INT_DIS_DATA:
LDI TEMP_R0 ,0FH
STA DIS_LINE1H ,01H ;RAM BANK 1 REGISTER
STA DIS_LINE1L ,01H
STA DIS_LINE2H ,01H
STA DIS_LINE2L ,01H
STA DIS_LINE3H ,01H
STA DIS_LINE3L ,01H
STA DIS_LINE4H ,01H
STA DIS_LINE4L ,01H
STA DIS_LINE5H ,01H
STA DIS_LINE5L ,01H
STA DIS_LINE6H ,01H
STA DIS_LINE6L ,01H
RTNI
;**********************************************************
; DELAY PART
;**********************************************************
DELAY:
LDI TEMP_R2 ,0FH
LDI TEMP_R1 ,0FH
LDI TEMP_R0 ,0FH
DELAY1:
LDI WDT ,0101B ;CLEAR WATCH DOG(16MS)
NOP
NOP
NOP
NOP
NOP
SBIM TEMP_R0 ,01H
LDI TEMP_R3 ,00H
SBCM TEMP_R1 ,00H
LDI TEMP_R3 ,00H
SBCM TEMP_R2 ,00H
BC DELAY1
RTNI
KEY_DELAY:
LDI TEMP_R0 ,0AH ;DELAY
SBIM TEMP_R0 ,01H
BC $-1
RTNI
;***********************************************************
; MAINPROGRAMMEPART
;***********************************************************
RESET:
NOP
LDI IE ,00H
LDI T0M ,0111B ;4MHZ,0.25MS,SET TO SHARED WITH PORTC.3
LDI T0L ,06H
LDI T0H ,00H
LDI CMP_CONTROL ,00H ;COMPARATOR OUTPUT FALLING EDGE GENERATE INTERRUPT,PORTE.0 IS SHARED AS I/O,INTERNAL REFERENCE VOLTAGE(VDD/2) IS SELECTED AS COMPARATOR NEGATIVE INPUT,COMPARATOR DISABLE
LDI CMP_STATUS ,00H ;COMPARATOR0 IS NOT OPERATION,COMPARATOR POSITIVE INPUT IS FROM CMPP1
LDI T2SET ,00H ;TIMER2 TIMER/COUNTER STOPS
LDI T2_SIGNAL_SET ,00H ;NO EXTERNAL SIGNAL SOURCE IS SELECTED
LDI TONE1_VOLUME_H ,00H ;TONE GENERATOR 1 DISABLE
LDI TONE1_VOLUME_L ,00H
LDI TONE2_VOLUME_H ,00H ;TONE GENERATOR 2 DISABLE
LDI TONE2_VOLUME_L ,00H
LDI PORTA ,0FH ;CLOSE DISPLAY
LDI PORTB ,00H
LDI PORTC ,00H
LDI PORTD ,0011B
LDI PORTE ,00H
LDI PORTF ,00H ;CLOSE RELAY,BUZZER
LDI PAOUT ,0FH ;SET PORTA AS OUTPUT I/O
LDI PBOUT ,0FH ;SET PORTB AS OUTPUT I/O
LDI PCOUT ,00H ;SET PORTC AS INPUT I/O
LDI PDOUT ,0FH ;SET PORTD AS OUTPUT I/O
LDI PEOUT ,00H ;SET PORTE AS INPUT I/O
LDI PFOUT ,1111B;SET PORTF AS OUTPUT I/O
CALL DELAY
CALL DELAY
CALL INTDMR ;CLEAR DATA MEMORY REGISTERS
LDI BUZZER_TYPE ,01H ;SET POWER ON BUZZER FLAG
ORIM WORK_FLAG2 ,0100B;SET CODDING SWITCH DISABLE FLAG
CALL INT_DIS_DATA
ORIM WORK_FLAG8 ,1000B ;SET POWER ON LCD ON FLAG
LDI TIME_HORH ,01H
LDI TIME_HORL ,02H
LDI TIME_MINH ,00H
LDI TIME_MINL ,00H
ORIM WORK_FLAG1 ,1000B;SET CLOCK ALREADY SET FLAG
;*******************2006/4/5 15:08**********************
LDI T0M ,0111B ;4MHZ,0.25MS,SET TO SHARED WITH PORTC.3
LDI T0L ,06H
LDI T0H ,00H
;*******************2006/4/5 15:08**********************
LDI WDT ,0101B ;CLEAR WATCH DOG(16MS)
LDI IRQ ,00H ;CLEAR INTERRUPT REQUEST
;*******************2006/4/7 09:00**********************
LDI KEY_LS ,0FH
;*******************2006/4/7 09:00**********************
MAINPART:
LDI WDT ,0101B ;CLEAR WATCH DOG(16MS)
LDI IE ,1000B ;OPEN TIMER0 INT
LDI T0M ,0111B ;4MHZ,0.25MS
;**************************************************************************
;SUBROUTINE NAME:KEY SCAN AND PROCESS PART
;FUNCTION:SCAN ALL KEY AND PROCESS
;INPUT PARAMETER:WORK_FLAG2,WORK_FLAG3,WORK_FLAG4,RB1_TIMER_SHARE_CT0~RB1_TIMER_SHARE_CT3
;WORK_FLAG7
;OUTPUT PARAMETER:WORK_TYPE,BUZZER_TYPE
;USED REGISTERS:TEMP_R0~TEMP_R5,DOOR_T,KEY_LS,KEY_T,KEY_VALUE,KEY_VALUEL,KEY_VALUEH
; :CODING_VALUEL,CODING_VALUEH,NOW_COOK_TYPE,MUL_COOK_TYPE1~MUL_COOK_TYPE3
; :MUL_WORK_MINH1~3,MUL_WORK_MINL1~3,MUL_WORK_SECH1~3,MUL_WORK_SECL1~3
; :MUL_ORDER1~3
;***************************************************************************
KEY_SCAN:
LDA WORK_FLAG2 ,00H ;12.25 MS?NO,GOTO OUT KEYSCAN
BA3 READKEY
JMP OUT_KEY_PART
READKEY:
ANDIM WORK_FLAG2 ,0111B ;CLEAR 12.25 MS FLAG
ORIM WORK_FLAG8 ,0100B ;SET KEY SCAN FLAG
LDI PAOUT ,0FH ;CLOSE DISPLAY
LDI PORTA ,0FH
LDI PBOUT ,0FH
LDI PORTB ,00H
LDI PDOUT ,0FH
LDI PORTD ,0011B
LDI PHOUT ,0FH
LDI PORTH ,00H
NOP
LDI PBOUT ,00H ;SET PB AS INPUT I/O
LDI PDOUT ,0011B ;SET PD.3 PD.2 AS INPUT I/O
LDI PHOUT ,00H ;SET PH AS INPUT I/O
LDI PB_PULL_HIGH ,0FH ;SET PB PULL HIGH
LDI PD_PULL_HIGH ,1100B ;SET PD.3 PD.2 PULL HIGH
LDI PH_PULL_HIGH ,0FH ;SET PH PULL HIGH
READ_LINE1:
LDI PEOUT ,0FH ;SET PE AS OUTPUT I/O
LDI PORTE ,0FH
ORIM PCOUT ,0100B ;SET PC.2 AS OUTPUT I/O
ORIM PORTC ,0100B
LDI PEOUT ,00H
LDI PE_PULL_HIGH ,0FH ;SET PE PULL HIGH
ORIM PCOUT ,0100B ;SET PC.2 AS OUTPUT I/O
ANDIM PORTC ,1011B ;SET PC.2 AS LOW STATE
CALL KEY_DELAY
LDA PORTB ,00H ;READ THE FIRST LINE
STA LINE1_CURRENT_DATA_B ,01H ;BANK 1 REGISTER
LDA PORTD ,00H
STA LINE1_CURRENT_DATA_D ,01H ;BANK 1 REGISTER
READ_LINE2:
LDI PEOUT ,0FH ;SET PE AS OUTPUT I/O
LDI PORTE ,0FH
ORIM PCOUT ,0100B ;SET PC.2 AS OUTPUT I/O
ORIM PORTC ,0100B
LDI PEOUT ,0100B ;SET PE.2 AS OUTPUT I/O
ANDIM PCOUT ,1011B ;SET PC.2 AS INPUT I/O
LDI PC_PULL_HIGH ,0100B ;PC.2 PULL HIGH
LDI PE_PULL_HIGH ,1011B ;SET PE.3 PE.1 PE.0 PULL HIGH
ANDIM PORTE ,1011B ;SET PE.2 AS LOW STATE
CALL KEY_DELAY
LDA PORTB ,00H ;READ THE SECOND LINE
STA LINE2_CURRENT_DATA_B ,01H ;BANK 1 REGISTER
LDA PORTD ,00H
STA LINE2_CURRENT_DATA_D ,01H ;BANK 1 REGISTER
READ_LINE3:
LDI PEOUT ,0FH ;SET PE AS OUTPUT I/O
LDI PORTE ,0FH
ORIM PCOUT ,0100B ;SET PC.2 AS OUTPUT I/O
ORIM PORTC ,0100B
LDI PEOUT ,0010B ;SET PE.1 AS OUTPUT I/O
ANDIM PORTE ,1101B ;SET PE.1 AS LOW STATE
ANDIM PCOUT ,1011B ;SET PC.2 AS INPUT I/O
LDI PC_PULL_HIGH ,0100B ;PC.2 PULL HIGH
LDI PE_PULL_HIGH ,1101B ;SET PE.3 PE.2 PE.0 PULL HIGH
CALL KEY_DELAY
LDA PORTB ,00H ;READ THE THIRD LINE
STA LINE3_CURRENT_DATA_B ,01H ;BANK 1 REGISTER
LDA PORTD ,00H
STA LINE3_CURRENT_DATA_D ,01H ;BANK 1 REGISTER
READ_LINE4:
LDI PEOUT ,0FH ;SET PE AS OUTPUT I/O
LDI PORTE ,0FH
ORIM PCOUT ,0100B ;SET PC.2 AS OUTPUT I/O
ORIM PORTC ,0100B
LDI PEOUT ,0001B ;SET PE.0 AS OUTPUT I/O
ANDIM PORTE ,1110B ;SET PE.0 AS LOW STATE
ANDIM PCOUT ,1011B ;SET PC.2 AS INPUT I/O
LDI PC_PULL_HIGH ,0100B ;PC.2 PULL HIGH
LDI PE_PULL_HIGH ,1110B ;SET PE.3 PE.2 PE.1 PULL HIGH
CALL KEY_DELAY
LDA PORTB ,00H ;READ THE FOURTH LINE
STA LINE4_CURRENT_DATA_B ,01H ;BANK 1 REGISTER
LDA PORTD ,00H
STA LINE4_CURRENT_DATA_D ,01H ;BANK 1 REGISTER
READ_LINE5:
LDI PEOUT ,0FH ;SET PE AS OUTPUT I/O
LDI PORTE ,0FH
ORIM PCOUT ,0100B ;SET PC.2 AS OUTPUT I/O
ORIM PORTC ,0100B
LDI PEOUT ,1000B ;SET PE.3 AS OUTPUT I/O
ANDIM PORTE ,0111B ;SET PE.3 AS LOW STATE
ANDIM PCOUT ,1011B ;SET PC.2 AS INPUT I/O
LDI PC_PULL_HIGH ,0100B ;PC.2 PULL HIGH
LDI PE_PULL_HIGH ,0111B ;SET PE.0 PE.2 PE.1 PULL HIGH
CALL KEY_DELAY
LDA PORTB ,00H ;READ THE FIFTH LINE
STA LINE5_CURRENT_DATA_B ,01H ;BANK 1 REGISTER
LDA PORTD ,00H
STA LINE5_CURRENT_DATA_D ,01H ;BANK 1 REGISTER
;==========================================================
DOOR_CHECK:
LDI PAOUT ,0FH ;CLOSE DISPLAY
LDI PORTA ,0FH
LDI PBOUT ,0FH
LDI PORTB ,00H
LDI PDOUT ,0FH
LDI PORTD ,0011B
LDI PHOUT ,0FH
LDI PORTH ,00H
ANDIM PAOUT ,1101B ;SET PA.1 AS INPUT I/O
LDI PA_PULL_HIGH ,1101B ;CLOSE PORTA.1 PULL HIGH
NOP
CALL KEY_DELAY
NOP
LDA PORTA ,00H ;SCAN DOOR STATE
BA1 DOOR_CHECK4
JMP DOOR_CHECK3
DOOR_CHECK3: ;DOOR CLOSE STATE
LDI DOOR_T ,00H ;CLEAR DOOR CHECK TIMES
ANDIM WORK_FLAG3 ,0111B ;CLEAR DOOR OPEN FLAG
JMP DOOR_CHECK99
DOOR_CHECK4:
ADIM DOOR_T ,01H ;DOOR OPEN STATE
CJS4 DOOR_T,08H,DOOR_CHECK99 ;CHECK DOOR STATE 8 TIMES
ORIM WORK_FLAG3 ,1000B ;SET DOOR OPEN FLAG
DOOR_CHECK99:
LDI PEOUT ,0FH ;SET PE AS OUTPUT I/O
LDI PORTE ,00H ;SET PE AS LOW STATE
ORIM PCOUT ,0100B ;SET PC.2 AS OUTPUT I/O
ANDIM PORTC ,1011B ;SET PC.2 AS LOW STATE
ORIM PDOUT ,0011B ;SET PD.1,PD.0 AS OUTPUT I/O
ORIM PORTD ,0011B ;SET PD.1,PD.0 AS HIGH STATE
ANDIM WORK_FLAG8 ,1011B ;CLEAR KEY SCAN FLAG
;===============================================
LDA MACHINE_TYPE ,00H ;TEST MODE CHECK
BA0 KEY_CHECK99
;=================================================
KEY_CHECK:
LDA LINE1_CURRENT_DATA_D ,01H ;BANK 1 REGISTER
STA TEMP_R0 ,00H
ANDIM TEMP_R0 ,1100B ;CLEAR BIT1 BIT0
STA LINE1_CURRENT_DATA_D ,01H
LDA LINE2_CURRENT_DATA_D ,01H ;BANK 1 REGISTER
STA TEMP_R0 ,00H
ANDIM TEMP_R0 ,1100B ;CLEAR BIT1 BIT0
STA LINE2_CURRENT_DATA_D ,01H
LDA LINE3_CURRENT_DATA_D ,01H ;BANK 1 REGISTER
STA TEMP_R0 ,00H
ANDIM TEMP_R0 ,1100B ;CLEAR BIT1 BIT0
STA LINE3_CURRENT_DATA_D ,01H
LDA LINE4_CURRENT_DATA_D ,01H ;BANK 1 REGISTER
STA TEMP_R0 ,00H
ANDIM TEMP_R0 ,1100B ;CLEAR BIT1 BIT0
STA LINE4_CURRENT_DATA_D ,01H
LDA LINE5_CURRENT_DATA_D ,01H ;BANK 1 REGISTER
STA TEMP_R0 ,00H
ANDIM TEMP_R0 ,1100B ;CLEAR BIT1 BIT0
STA LINE5_CURRENT_DATA_D ,01H
LDI TEMP_R0 ,0FH ;NO KEY PRESS CHECK
SUB LINE1_CURRENT_DATA_B ,01H ;BANK 1 REGISTER
BNZ KEY_CHECK01
LDI TEMP_R0 ,0FH
SUB LINE2_CURRENT_DATA_B ,01H ;BANK 1 REGISTER
BNZ KEY_CHECK01
LDI TEMP_R0 ,0FH
SUB LINE3_CURRENT_DATA_B ,01H ;BANK 1 REGISTER
BNZ KEY_CHECK01
LDI TEMP_R0 ,0FH
SUB LINE4_CURRENT_DATA_B ,01H ;BANK 1 REGISTER
BNZ KEY_CHECK01
LDI TEMP_R0 ,0FH
SUB LINE5_CURRENT_DATA_B ,01H ;BANK 1 REGISTER
BNZ KEY_CHECK01
LDI TEMP_R0 ,0CH
SUB LINE1_CURRENT_DATA_D ,01H
BNZ KEY_CHECK01
LDI TEMP_R0 ,0CH
SUB LINE2_CURRENT_DATA_D ,01H
BNZ KEY_CHECK01
LDI TEMP_R0 ,0CH
SUB LINE3_CURRENT_DATA_D ,01H
BNZ KEY_CHECK01
LDI TEMP_R0 ,0CH
SUB LINE4_CURRENT_DATA_D ,01H
BNZ KEY_CHECK01
LDI TEMP_R0 ,0CH
SUB LINE5_CURRENT_DATA_D ,01H
BNZ KEY_CHECK01
CALL SAVE_KEY_SCAN_VALUE ;SAVE CURRENT KEY SCAN VALUE
LDI KEY_LS ,0EH ;NO KEY
LDA WORK_FLAG3 ,00H
BA0 KEY_CHECK00 ;CHECK LOOK TIME/PRE-TIME FLAG
LDA WORK_FLAG0 ,00H
BA0 KEY_CHECK00 ;CHECK LOOK POWER FLAG
CALL CLEAR_LOOK_TIME ;CLEAR LONG PRESS(CHILD LOCK) TIME
LDI LONG_PRESS_EACH_CT ,00H ;CLEAR LONG PRESS KEY USED COUNTER
STA LONG_PRESS_TIME_CT ,01H
STA LONG_PRESS_EACH_CT1 ,01H
ANDIM WORK_FLAG4 ,0111B ;CLEAR LONG PRESS KEY ON FLAG
-----此内容被lixu于2006-10-20,20:12:41编辑过
-----此内容被lixu于2006-10-20,20:15:27编辑过 中颖的指令少,简单,66之后性能已经够用,我也在用。 各有优劣。我不知道你们那行都写些什么样的程序。人不可能总是面对一种类型的工作。要是用习惯了C,写汇编就会不习惯了。但我还是觉得用C好些,可能是自已的方向决定的。另外,芯片的价格越来越低,空间越来越大,这是趋势。很多功能强大的芯片不一定用得到。倒是很老的型号,可以实现功能的,又低价的,现在倒不为首选了。呵呵。 支持C 对于AVR的Mega16,我做过这样的对比:
M16的汇编语言我照抄了《AVR单片机实用程序设计》的一些内容,那本书上汇编语言写得不错,同样实现一个功能,我采用汇编和fastavr编写,结果很有意思,居然无论执行速度还是代码效率,avrasm和fastavr都几乎一样,而后来学了一点点cvavr,又编写了一个类似的测试程序,发现代码长度有大幅度下降,下降可达50%,而执行速度也有所提高,平均提高30%左右,经过观察三者的asm输出,发现如下事实:
1。如果c语言不优化,代码长度与代码执行效率与通常的basic和asm差不多;
2。如果c语言优化合适,则无论代码长度还是执行效率比basic都要好;
3。basic优化和不优化一个样子;
4。如果不采用宏汇编和宏定义,只采用基本汇编语言,那么汇编语言的执行效率与代码长度同basic区别不大
5。c语言优化以后的代码和未优化的代码,都大量调用宏汇编和宏定义,这也是c语言能够比基本汇编语言代码长度和执行效率都要好的最关键之处,而avr的basic,我所知道的有三种,都没有这样调用宏汇编命令和宏定义。
代码的问题,仁者见仁智者见智,不能以偏概全。
【16楼】 lixu贴出来的程序,以及《AVR单片机实用程序设计》里面的所有程序,都是基本汇编语言,不是宏汇编语言。
另外据确认,我国单兵火箭筒上面的简易火控系统采用的是基本汇编语言编写的,并没用到宏汇编。而很多进口重型机械,比如现在开挖隧道使用的盾构机,其部分控制系统也采用的是基本汇编语言所写,MC68HC908的。
我从不认为哪种语言会有优势,除非是同样的语言类型而产生了很不同的效果(这在basic里面存在,Mikrobasicavr比bascom和fastavr代码长度大一倍,都是basic),编译语言是为系统服务的,能完成系统指标,就是个好语言。 JAMESKING 兄 说得极是。
呵呵,我觉得适用就好。 抱歉,下午看花眼了,15楼的程序应该说是“部分宏汇编”,比C语言里面纯粹调用宏语句还是有些差别的,但不管怎么说,宏汇编确实能有效缩短代码长度,我觉得宏汇编似乎是以时间换取空间的优化。
我个人的偏好喜欢使用基本汇编语言,而且对控制速度没有过分的要求,所以似乎一些basic编译器也能满足要求。
另外,avr还有梯形图编译器,可以直接用梯形图编译代码,直接输出HEX文件,虽然还不是很完善,但也很有意思。 我是先学汇编,在学C,很长时间就用汇编,后来慢慢转用C,想想以前都是些小东西,用汇编没有觉得可读性的问题,现在打死我也要C,习惯了, 我用过T13,就几片而已,就是用的GCC,使用了800字节的HEX。程序很简单,2个输入,2个输出而已。那么几个脚能做什么复杂的东西呢? 汇编是靠人脑优化的,C是由电脑优化的。
电脑相同,人脑有差异。量力而行。 抱歉, 我一直以为 宏汇编就是 在 基本的汇编指令中加入 宏, 也就是把一些常用的小代码断用 宏来替代.当然也可以是复杂的循环. 宏的展开最终是用代码替代的, 并不能起到减少代码的作用.
如果说 汇编 在执行速度和代码长度上与中高级语言没有优势的话, 我真不知道它的存在还有什么意义了. 家电行业的量都是非常大的,动不动就是500K采购,1000K的采购,如果一颗芯片可以省下一毛钱的话,500K可以节约5万块,1000K可以节约10万块。如果把节约的钱奖给开发人员20%,大家会有多高兴啊。
家电里的MCU都比较小,而且是ROM的居多。由于偏移所以很多搞家电的工程师都会三星、飞斯卡尔、瑞萨、合泰、富士通等。我们以前还用中颖的4位机,现在想想也是市场竞争太激烈没办法啊。好好研究MCU汇编指令,用汇编确实可以压缩大量得程序空间。
不过汇编的程序移植性太差,时间长了程序就忘了,得重新读。如果没有备注就倒霉了。
我现在把程序全部改成C,遇到新产品开发时,项目进展速度就快很多。 你们真厉害 聆听。。。听高手们说话真是一种享受。。。 【16楼】 lixu贴的是中颖的汇编,我也在用中颖的芯片,因为没用多久不敢有太多的评价。我觉得对于内存跨页的芯片,最好把内存和页标志一起定义在头文件中,这样就算以后跨区调配内存也不需要很麻烦。
DIS_LINE1L EQU 00H
DIS_LINE1L_BKEQU 01H ;BANK 1 REGISTER
LDA DIS_LINE1L,DIS_LINE1L_BK 家电行业就是这样,价格竞争太厉害。以前还在家电公司的时候,用三星9228编了一个程序,用C弄的,出货也出了几十万了吧,后来客户增加功能,还要成本下调,只能更换芯片,又把汇编拿起来了。而且,小家电行业里面的程序都不是很复杂,没有烦人的数据结构,汇编已经能够搞定,处于成本考虑,何必用C呢。
所以说,在家电行业,很多时候都在和成本打交道,郁闷,这不,自己就跑出来了。 其实都是成本在作怪,做事的是我们,谁不喜欢容易的C呀,但是现实与实际总是有差距的。如果8K的ROM空间和2K的ROM的单片机价格相等的话,我想大家都会用C,除非你对速度和时序有明显的要求。 很多低档4位机程序通过烧内部熔丝的办法存储下来,这样做稳定性比Flash高,价格又比Flash的低,小家电行业老板都喜欢呀。 用汇编的原因可能是因为没有找到好的编译器吧。就像合泰,听说支持它的C编译器不多,效果不太好。但如果用pic我会用picc不用汇编,就算是12c508. 用汇编最烦没有好的汇编器
如果汇编器能增加局部标号和局部变量功能,那么我认为它就是好的汇编器了,我会选择汇编而不是C
像AVR的avrasm32.exe不支持上述两点
而WIN32的很多汇编器(如masm)就支持上述两点 这其实是个哲学命题:
汇编毕竟比C更“原始”。好比修房子,以前就是用砖块垒。现在的楼房都是钢筋水泥的搭框架,把房屋支撑的受力、压强、结构和屋面防水室内装潢分开来做。更系统化,特别是对于大系统来说。比如几十层的高楼用砖一直垒上去就很悬。如果只是修点小房子,一时间又找不到更好的建材那么用砖头当然是经济之选。
希望以后大家都能用上更高级的语言,一般这样描述的:“小X(或者X工)!你来负责YY项目的代码编写” 我觉得开发时间与程序空间历来都是互斥的关系,至于想要什么要自己考虑了。 合泰自带的IDE3000就可以直接编译C。
小家电行业里面基本上都是用一些低成本的芯片,台系的就很多人用啊,像HT,中颖,易隆等,比起来AVR的价格是偏高了些的。
但如果,这个产品的附加值高,能接收这个芯片上的差价,当然原意用AVR这些芯片啦。 我51汇编算是初级水平吧,汇编也有宏定义,就像15楼贴的前半段都是宏定义,这样可以提高程序的可读性和更清晰的安排变量的存储空间。
其实只要入门一种单片机的汇编,其他的也就不是很难了,汇编有两个技术含量高的地方:一个是合理分配数据的存储和寄存空间,一个是用汇编来实现以及优化比较复杂的算法。 用C吧,用汇编的话,写得头都大都写不出来。 我用汇编的,程序空间只有500行,也就是0.5K,用汇编200行就够了,不过同事用的是C,但编译后也就300到400行的样子,
所以你写C的时候注意一下结构,不会说不够用的。 学校时用汇编,现在工作了就用C。
还是C好啊。
写了5000多行的C
如果用汇编会跳楼。 去年年度我也干样的事情, PIC 芯片 32K flash,另一个同事 用汇编 写了 1.6万的行的代码, 我后来改用C写, 写了5千多行代码,高度优化,勉强够空间, 吐血好几次才完成....我真不知道那个同事这汇编代码是怎么熬出来的.... 不一定的,说汇编比C空间少,那是理论情况下的
因为实际情况是:使用汇编,7、8K的代码的时候,重复代码会有很多,而且很多在C常用的算法,像加减乘除,都要自己再写,而且写出来的代码不一定高效。。。。。
两种情况下,汇编会少:
1、一个超级牛人汇编
2、程序简单
3、给足够时间,对完成的代码进行足够的优化
但是,一般情况,下,只有2成立。。。。 回复【33楼】vivalite
-----------------------------------------------------------------------
现在大部分的C编译都支持汇编的,像Keil C51就可以全部用汇编写或C和汇编混合写。 同在家电的也是被汇编整的没脾气咯,主要看编排吧我觉得 这个主要还是开发时间和维护时间的博弈!汇编开发慢,维护也麻烦! 2013年了 冒个泡吧 hangw1984 发表于 2006-10-18 14:31 static/image/common/back.gif
用c写一个带有参数和局部变量的小程序然后在main中调用,avrstudio调试,查看其disassembler 仔细看一下编 ...
深有同感!大学时候就是汇编很顺手,就是变量空间不好协调,程序稍微复杂点,就不知道怎么用汇编了
后来切换到c,就再也不想汇编了
那时候,一直想学混合编程,苦于没有好的案例工参考学习 其实汇编用习惯了和你们用C的感觉是一样的!
页:
[1]