# MASM 101 (in Visual studio 2019) MASM is Microsoft Macro Assebler. ## 下載與安裝 1. Download Visual Studio 2019 community version https://visualstudio.microsoft.com/zh-hant/downloads/ 2. Install Visual Studio 2019 3. Download Irvine's library http://asmirvine.com/gettingStartedVS2017/index.htm ![](https://i.imgur.com/ht7wH53.png) ## 建置環境 ![](https://i.imgur.com/trjprCO.png) Open your Visual Studio 2019 then creat a new project and select the blank solution. 完成專案建置。 ### 環境設定 1. 在**專案名稱**按下右鍵,在選單中的**組件相依性**裡選擇**組件自訂...** ![](https://i.imgur.com/gtMz6ML.png) 2. 跳出來的視窗選擇 **masm** ![](https://i.imgur.com/qOodfJC.png) 3. 設定 Irvine's library 使用 接著在**專案名稱**再按下右鍵選擇**屬性** ![](https://i.imgur.com/n6mUguD.png) ### 必須先建立 .asm 檔案 新增 asm 檔案 在**來源檔案**中選擇**新增項目**,**檔案名稱** 的副檔名要改成 \[.asm\] Hit: 必須先建立一個 \*.asm 的檔案,否則專案設定執行 assably code 的環境時,``Microsoft Macro Assembler`` 在專案屬性頁中找不到 ![](https://i.imgur.com/PUXXmZ4.png) ### 設定專案屬性對應參數 在屬性頁中分別加入相對應的參數與設定 1. Microsoft Macro Assembler 中 1. **General** 加入 **\[Irvine’s library path\]** ![](https://i.imgur.com/zYhGvyX.png) 2. **Listing file** 加入 **\$(ProjectName).lst** ![](https://i.imgur.com/YtC5bjL.png) 2. 在連結器中 1. **一般**裡面的**個別使用者重新導向**加入 **\[Irvine’s library path\]** ![](https://i.imgur.com/9xIVOsS.png) 2. **輸入**裡面的**其他相依性**加入**Irvine32.lib;** ![](https://i.imgur.com/Iv7tXx1.png) 3. **偵錯**中**產生對應檔**設定為**是(/MAP)** ![](https://i.imgur.com/yC9yvUn.png) 4. **系統**中**子系統**設定為**主控台(SUBSYSTEMCONSOLE)** ![](https://i.imgur.com/rumrjFT.png) ### MASM 的第一個 Hello World 貼上你的 Assembly code 做測試 ``` include Irvine32.inc .data String byte "Hello World!",0 .code main PROC mov edx,offset String call writestring invoke ExitProcess,0 main ENDP END main ``` 按下執行,如果出現``Hello World!``的小黑窗,恭喜你成功完成環境設定。 ### 完成設定卻無法執行 Assembly code 的十萬個可能之一 ![](https://i.imgur.com/zI6dWLz.png) 如果顯示上面訊息請選擇``否``(防止因為改變編碼問題,導致程式碼內容產生錯誤,造成 Visual Studio 2019 一直無法編譯 Assembly code) ---- ###### tags: `Assembly code`, `MASM`, `Tutorial`, `VisualStudio`, `80x86`