首页 > 生活

VScode配置MASM32运行环境(断点/运行/debug/配合emu8086(非DOSBox))

更新时间:2025-05-08 02:09:04 阅读: 评论:0

一、之所以不用DOSBox

不利于集成到VScode,执行代码需要新开窗口,配置繁琐。ps日语三级考试:而且加断点和调试复杂。

感谢masm-code插件的作者,终于可以补全啦qaq

添加关于调试的一些建议

二、步骤

0.网络状况不好可以用度盘资源:

//20200403 update

dos-player

masm32

1.安装VScode

2.安装masm-code, code runner插件

3.从masm32 sdk ver11下载所需的masm,如果下载不了可以自行换镜像,或者百度下载。

3.1.解压,然后换路径,一路yes就可以了。

3.2.记下安装位置,比如我的在g盘根目录。

4.百度或谷歌搜索ms-dos player,下载这个软件,或者从链接的GitHub上面下载源码,编译安装。

4.1.解压里面的msdos到X:\Program Files (x86),X为想安装到的盘符。

4.2.记下安装位置。

5.添加环境变量:对于win10,win+R输入SystemPropertiesAdvanced>环境变量>系统变量>找到Path变量>打开>添加如下两个变量(根据安装masm和msdos的位置不同前面的路径要调整):

*note:如果不是64位系统就在binary文件夹下选择相应的文件夹

*note:可以测试,如果加入Path成功,在PowerShell里面输入msdos , ml /? 以及link16 /?会有出现相应的信息。如果没有可以尝试重启。

6.打开VScode, ctrl+shift+P打开搜索json,选择:

7.在末尾添加设置:

*经评论中 @影生 提出,将选项/AT去除然后将输出文件的扩展名改为.EXE,这样可以用伪指令格式书写程序。

"code-runner.executorMap": { "javascript": "node", "java": "cd $dir && javac $fileName && java $fileNameWithoutExt", "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt &&apue; $dir$fil高中函数eNameWithoutExt", "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", "php": "php", "python": "python -u", "perl": "perl", "perl6": "perl6", "ruby": "ruby", "go": "go run", "lua": "lua", "groovy": "groovy", "powershell": "powershelsol君l -ExecutionPolicy ByPass -File", "bat": "cmd /c", "shellscript": "bash", "fsharp": "fsi", les电视剧4;csharp": "scriptcs", "vbscript": "cscript //Nologo", "typescript&#冷水洗脸34;: "ts-node", "coffeescript": "coffee香港生孩子4;, "scala": 二极管参数"scala", "swift": "swift", "julia": "julia", "crystal": "crystal", "ocaml": "ocaml", "r": "Rscript", "applescript": "osascript", "clojure": "上班族副业lein e滴水观音xec车库装修4;, "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt", "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt", "racket": "racket", "scheme": "csi -script", "ahk": "auto智能化hotkey", "autoit": "autoit3", "dart": "dart", "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt", "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt", "haskell": "runhaskell", "nim": "nim compile --verbosity:0 --hints:off --run", "lisp": "sbcl --script", "kit": "kitc --run", "v": "v run", "masm":"cls && cd $dir &&ml /nologo /Bl link16.exe /AT ./$fileName /link /NOLOGO *>null && msdos ./$fileNameWithoutExt" }, "code-runner.clearPreviousOutput": true, "code-runner.saveFileBeforeRun": true三、helloworld测试; *************************************************************************; 16-bit MS-DOS COM Hello World Application; COM File size: 26 Bytes; Created by Visual MASM (www.visualmasm); For 16-bit DOS running restricts under Windows 2000/XP see below. ; For more information about DOS interrupts, see:; spike.scu.edu.au/~barry/interrupts.html; *************************************************************************.model tiny; MASM's support for COM files.do保钓运动sseg; Make sure you are using dos segment CODE, DATA + STACK; *************************************************************************; Our data section. Here we declare our strings for our console message; *************************************************************************.datastrMessageDB "Hello world", 0Dh, 0Ah, '$'; *************************************************************************; Our executable assembly code startpoe交换机s here in the .code section; *************************************************************************.code信贷员.startup; **********************************; Prepare our message to the console; **********************************movah, 09h; Write string to standard output movdx, offset strM米粒网essage int21h; Call DOS interrupt 21h; ************************************************; Get ready to exit and return control back to DOS; ************************************************ movah, 4Ch ; Exit with return code (AL = return code) int21h; Call DOS interrupt 21hend

这里的.code 写法相当于 :

_TEXT SEGMENT WORD PUBLIC 'CODE'

详细如下:

输出:

一键运行。

//20200403 update

利用emu8086完成复杂的调试:

**先安装open插件**

在emu8086设置中设置(工具栏)默认打开(右下角)

emu8086 for win10

在vsc里面编辑好文件后利用ctrl+alt+O用emu8086打开,然后进行各种调试

note:如果要不锈钢酸洗钝化液链接额外的文件可以参考官方文档:

ML and ML64 Command-Line Referencenote华泰论坛:

MSVC Linker options:

匈牙利机票

*note:链接器的选项要写在/link选项

三、关于调试

最近又找到了一个调试汇编的方案,如果成功的话可以用vscode的native debug来调试:

路线1:编译安装djgpp版本的gdb -- 安装到dos里面 --利用里面的gdbserver连接虚拟机的COM端口 -- vsocde里面用native debug 连接,调试

路线2(最接近完成):利用上面dosbox-x 的patch --编译dosbox-x --连接gdbserver -- vscode 用native deb美甲diyug连接

路线3:利用wsl或者msys2安装或者编译qemu -- 利用gdbserver连接COM口 -- 连接vscode

但是现在的难点是找不到相应dosbox-x的版本,如果有找到的大佬麻烦留言呀!

后续应该会怎加一些汇编的例子和专门讲比较c和汇编的文章。(20201108)

本文发布于:2023-06-04 08:17:08,感谢您对本站的认可!

本文链接:http://www.ranqi119.com/ge/85/214850.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:运行环境   断点   VScode   debug   DOSBox
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 站长QQ:55-9-10-26|友情:优美诗词|电脑我帮您|扬州装修|369文学|站长工具|软件玩家|水木编程|编程频道