[問題] 如何把函式分開寫在獨立的檔案?

看板ASM作者 (紫雁)時間17年前 (2007/05/06 04:09), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
這學期修了組合語言這門課 但覺得自己有一個寫法很不好: 不管是主程式、一大堆副程式 通通都塞在同一個檔案裡面 寫到後來 動輒上百行的程式 自己都看得煩了... 因此想學著把副程式盡量獨立撰寫 等到組譯與連結的時候再結合起來就好 就像C/C++把function/class獨立寫出來一樣 但是卻不知道應該要怎麼做... 我寫了兩個檔案:test.asm、test2.asm 想要把程式啟始點寫在test.asm裡 在test2.asm裡寫了一個 mytest 的簡單函式 呼叫 Irvine 所寫的 lib 裡的 WriteString 之後返回主程式 但是卻碰上了困難... 我把兩個檔案的內容,與組譯時所出現的錯誤訊息附在後面 想請教我應該要怎麼修改我的程式,或我的組譯參數呢? 先說一聲謝謝 :) 我在命令提示字元下,使用 masm32 裡提供的 ml(應該是masm 6.14?) 如果在VS.NET 2005也有方法可以把副程式分別寫出來的話 那就再好不過了!!!! test.asm ========== INCLUDE Irvine32.inc .code main PROC call mytest2 exit main ENDP end main ========== test2.asm ========== INCLUDE Irvine32.inc .const TestMessage BYTE "There is in the function",0 .code mytest PROC uses edx mov edx, OFFSET TestMessage call WriteString ret mytest ENDP ========== D:\asm_code\test>ml test.asm /c /coff Microsoft (R) Macro Assembler Version 6.14.8444 Copyright (C) Microsoft Corp 1981-1997. All rights reserved. Assembling: test.asm test.asm(8) : error A2006: undefined symbol : mytest2 D:\asm_code\test>ml test2.asm /c /coff Microsoft (R) Macro Assembler Version 6.14.8444 Copyright (C) Microsoft Corp 1981-1997. All rights reserved. Assembling: test2.asm test2.asm(10) : error A2088: END directive required at end of file -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 221.169.109.146 ※ 編輯: james732 來自: 221.169.109.146 (05/06 04:14)
文章代碼(AID): #16FEHttn (ASM)
文章代碼(AID): #16FEHttn (ASM)