|
|||||||||||
| 技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng) 驅(qū)動編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機 | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計 | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe |
我覺得MPASM匯編器對標(biāo)號處理的不夠好. |
| 作者:liao_43 欄目:單片機 |
雖然MPASM匯編器有LOW、HIGH 和UPPER 操作數(shù)對程序地址進行操作.但我還是覺得不夠. 在使用匯編進行編寫一些子程序模塊時,經(jīng)常需要用loop,PART等一些標(biāo)號,一來方便在子程中跳轉(zhuǎn),不用$+X偏移;二來增加程序的可讀性.但是有個問題,就是一個子程序用的loop的標(biāo)號,以后的子程序就不能用這個標(biāo)號了,只能用loop1,loop2---loopx.這樣一來對子程序的模塊化很不好. 在MPASM匯編器中,只全局性的標(biāo)號,沒有局部性標(biāo)號的定義.我覺得TechTools TDE 中的Assembler:CVASM(pic16系列的類51語言編譯器,支持類51語言和pic匯編語言混編)就做得很好,在兩個全局性標(biāo)號之間,可以使帶冒號的標(biāo)號作為局部標(biāo)號,例如:loop這個標(biāo)號,可以使用在任可子程序之間,或程序之間,準(zhǔn)確來說,可以在任可兩個全局局性標(biāo)號之間. 不知MICROCHIP公司能否在MPASM匯編器中增加局部標(biāo)號的功能,而且可以應(yīng)用到宏的使用中. 下面有一段TechTools的匯編語言(在網(wǎng)上下載的,不是我寫的) ; PROGRAM: RCV232.SRC ; Taken from TechTools PIC Application Note: Receiving RS-232 Serial Data ; Written July 15, 1993 ; Revised February 24, 1996 (to accomodate SPASM v4.2) ; Revised May 3, 2000 ; This program receives a byte of serial data and displays it on eight LEDs ; connected to PORT rb. The receiving baud rate is determined by the VALUE of ; the constant bit_K and the clock speed of the PIC. See the table in the ; application note (above) for VALUEs of bit_K. For example, with the clock ; running at 4 MHz and a desired receiving rate of 4800 baud, make bit_K 50. DEVICE PIC16C54,xt_osc,wdt_off,protect_off reset begin bit_K = 24 ;Change this VALUE for desired baudrate half_bit = bit_K/2 ;as shown in table. serial_in = ra.2 data_out = rb org 8 ;Start of available RAM delay_cntr ds 1 ;Counter for serial delay routines bit_cntr ds 1 ;NUMBER of received bits rcv_byte ds 1 ;The received byte org 0 ;Start of code space ; Remember to change DEVICE info if PROGRAMMING a different PIC. Do not use RC ; DEVICEs. Their clock speed is not sufficiently accurate or stable for serial ; communication. ; Set up I/O PORTs. begin mov !ra, #00000100b ;Use ra.2 for serial input. mov !rb, #0 ;OUTPUT to LEDs. :start_bit snb serial_in ;Detect start bit. Change to ;sb serial_in if using 22k RESISTOR ;input. jmp :start_bit ;No start bit yet? KEEP watching. call start_delay ;Wait one-half bit time to the middle ;of the start bit. jb Serial_in,:start_bit ;If the start bit is still GOOD, ;continue. Otherwise, resume waiting. ;Change to jnb Serial_in, :start_bit ;if using 22k RESISTOR input. mov bit_cntr, #8 ;Set the counter to receive 8 data bits clr rcv_byte ;Clear the receive byte to get ready ;for new data. :receive call bit_delay ;Wait one bit time. movb c,Serial_in ;Put the data bit into carry. ;Change to movb c,/Serial_in if using ;22k RESISTOR input. rr rcv_byte ;Rotate the carry bit into the receive ;byte. djnz bit_cntr,:receive ;Not eight bits yet? Get next bit. call bit_delay ;Wait for stop bit. mov data_out, rcv_byte ;DISPLAY data on LEDs. goto begin:start_bit ;Receive next byte. ; This delay loop takes four instruction cycles per loop, plus eight ; instruction cycles for other operations (call, mov, the final djnz, and ret). ; These extra cycles become significant at higher baud rates. The VALUEs for ; bit_K in the table take the time required for additional instructions into ; account. bit_delay mov delay_cntr,#bit_K :loop nop djnz delay_cntr, : |
| 2樓: | >>參與討論 |
| 作者: backupyan 于 2006/2/16 8:25:00 發(fā)布:
好想法,建議對匯編了解一些后,改用c吧,性能差不多少 |
|
| 3樓: | >>參與討論 |
| 作者: liao_43 于 2006/2/16 22:23:00 發(fā)布:
時間要求很精確時,我覺得C比較難寫. |
|
|
|
| 免費注冊為維庫電子開發(fā)網(wǎng)會員,參與電子工程師社區(qū)討論,點此進入 |
Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號 |