• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: 請問一下~有關ASM30~MACRO的寫法
#8
版主
版主


查看用戶資訊
C30 因為沒用組語所以沒試過,但 PIC 的 Assembly 裡 macro 可以使用 local 的宣告來設定使用 變數及Label :
Simple Example 
<main code segment>
      :
      :
len   equ 10           ; global version
size  equ 20           
note that a local variable
                       
may now be created and modified
test  macro size
      local len
label local len and label
len   set size         
modify local len
label res len          
reserve buffer
len   set len
-20
endm                   
end macro

發表於: 2009/1/5 10:36
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問一下~有關ASM30~MACRO的寫法
#7
初級會員
初級會員


查看用戶資訊
這幾天我自己又在試了一下
發現
只要我的MACRO裡面有label
然後在主程式只要連續使用此macro 二次
就會發生以下的錯誤訊息
macro_main.s: Assembler messages:
macro_main.s:0: Warning: end of file not at end of a line; newline inserted
macro_main.s:28: Error: symbol `test1' is already defined
macro_main.s:28: Error: symbol `test2' is already defined

如果只使用一次的話是可以使用的

我想問~是不是要額外的對macro裡面的label做什麼定義
請有經驗的人可以幫我解答一下

發表於: 2009/1/5 10:31
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問一下~有關ASM30~MACRO的寫法
#6
初級會員
初級會員


查看用戶資訊
參照:

jjj555 寫道:
其實我主要的目的~是想將常用的應用程式
變成一個指令
這樣可以讓我寫程式更快速以及除錯更容易

目前我的進度已經連結好了
那又發生另外一個問題了
就是我定好的MACRO無法在主程式連續用2次
.nolist

.macro OK_int input fb result
mov \input,w0
goto test1
test1:
mov \fb,w1
goto test2
test2:
sub w0,w1,w2
mov w2,\result
.endm

以上是我的MACRO
以下是我的主程式
__reset:
MOV #__SP_init,w15
MOV #__SPLIM_init,W0
MOV W0,SPLIM
CLR aaa
clr yang
MOV #100,W3
MOV W3,aaa
mov #50,w4
OK_int aaa w4 yang
OK_int w4 aaa yang
loop:
nop
nop
nop
bra loop

組譯的時候會發生以下的錯誤訊息
macro_main.s: Assembler messages:
macro_main.s:0: Warning: end of file not at end of a line; newline inserted
macro_main.s:29: Error: symbol `test1' is already defined
macro_main.s:29: Error: symbol `test2' is already defined

請有經驗的人可以幫我看一下要怎麼改嗎
謝謝

發表於: 2009/1/3 2:16
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問一下~有關ASM30~MACRO的寫法
#5
初級會員
初級會員


查看用戶資訊
其實我主要的目的~是想將常用的應用程式
變成一個指令
這樣可以讓我寫程式更快速以及除錯更容易

目前我的進度已經連結好了
那又發生另外一個問題了
就是我定好的MACRO無法在主程式連續用2次
.nolist

.macro OK_int input fb result
mov \input,w0
goto lala
test1:
mov \fb,w1
goto popop
test2:
sub w0,w1,w2
mov w2,\result
.endm

以上是我的MACRO
以下是我的主程式
__reset:
MOV #__SP_init,w15
MOV #__SPLIM_init,W0
MOV W0,SPLIM
CLR aaa
clr yang
MOV #100,W3
MOV W3,aaa
mov #50,w4
OK_int aaa w4 yang
OK_int w4 aaa yang
loop:
nop
nop
nop
bra loop

組譯的時候會發生以下的錯誤訊息
macro_main.s: Assembler messages:
macro_main.s:0: Warning: end of file not at end of a line; newline inserted
macro_main.s:29: Error: symbol `test1' is already defined
macro_main.s:29: Error: symbol `test2' is already defined

請有經驗的人可以幫我看一下要怎麼改嗎
謝謝

發表於: 2009/1/2 18:27
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問一下~有關ASM30~MACRO的寫法
#4
資深會員
資深會員


查看用戶資訊
include 應該就可以了,但(執行的)code size問題並不會解決.
(還是你說的"程式很大",是說(source code)"檔案很大"問題--這你已解決)

發表於: 2009/1/2 13:24
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問一下~有關ASM30~MACRO的寫法
#3
初級會員
初級會員


查看用戶資訊
恩~我知道
但是重複的程式太多了
又不想用CALL的方式
所以要用MACRO

那現在我MACRO的語法會了
但是現在我是寫在同一個.s檔裡
要是寫在不同的.s檔~我不知道要如何做連結

我貼上我目前的測試程式

.equ __30f2023,1
.include "p30f2023.inc"

.global __reset


.macro OK_int input
mov \input,w0

.endm

.section .plplp,bss,address(0x850)
aaa: .space 2
.text

__reset:
MOV #__SP_init,w15
MOV #__SPLIM_init,W0
MOV W0,SPLIM
CLR aaa
MOV #100,W3
MOV W3,aaa

OK_int aaa
loop:

nop
bra loop

目前我的想法是想把.MACRO的部分寫在另外的*.s檔
但是我試了之後沒辦法執行
所以想請會的人幫我寫一下
謝謝

發表於: 2008/12/31 15:45
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請問一下~有關ASM30~MACRO的寫法
#2
版主
版主


查看用戶資訊
程式大的話用 MARCO 並不會減少Code Size,應該是改用呼叫副程式的方式,可以的話將你的 Marco 或一些重覆動作的程式改成副程式,這樣才能減少 Code Size 的。

MARCO 是標準的語法,只要打開 ASM30 User's Guide 用 Search 找一下marco 就知道怎樣用了。

發表於: 2008/12/29 22:06
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


請問一下~有關ASM30~MACRO的寫法
#1
初級會員
初級會員


查看用戶資訊
如題
因為程式很大
所以想把部分的程式MACRO化
不過我找不到範例可以參考
希望有誰幫我指引個方向
或者是可以告訴我該如何寫

PS: 我用的是組語~不是C
謝謝

發表於: 2008/12/29 20:24
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------