1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AUTOSAR CountdownAdvent Calendar 2022

Day 24

MacintoshでMS-DOSのdebugコマンドの動作確認をするのにどうしたらいいか悩んでいた。

Last updated at Posted at 2018-07-14

MacintoshでMS-DOSのdebugコマンドの動作確認をするのにどうしたらいいか悩んでいた。

windowsでも64bitだとdebugコマンドをどう動かしたらいいか、よくわからなかった。16bitモードらしい。

ネットで検索すると

FreeDOSもLinuxも動く、JavaScriptで作られた x86エミュレータがスゴイ件
https://www.softantenna.com/wp/software/x86-emulator/

virtual X86
http://copy.sh/v86/

ReactOS(32MB) - Restored from snapshot
Windows95(6.7MB) - Restored from snapshot
FreeBSD 10.2(13.0MB) - Restored from snapshot
Oberon(16.0Mb) - Native Oberon 2.3.6 (via)
Windows 98(12.0MB) - Including Minesweeper and audio, additional sectors are loaded as needed
Arch Linux (10.1MB) - A complete Arch Linux restored from a snapshot, additional files are loaded as needed
KolibriOS(1.4MB) - Graphical OS, takes about 60 seconds to boot
Linux 2.6(5.4MB) - With busybox, Lua interpreter and test cases, takes about 20 seconds to boot
Linux 3.18(8.3MB) - With internet access, telnet, ping, wget and links. Takes about 60 seconds to boot. Run udhcpc for networking. Exchange files through /mnt/.
Windows 1.01(1.4MB) - Takes 1 second to boot
MS-DOS 6.22(3.4MB) - Takes 10 seconds to boot. With Enhanced Tools, QBasic and everything from the FreeDOS image
FreeDOS(0.7MB) - With nasm, vim, debug.com, some games and demos, takes 1 second to boot
OpenBSD(1.4MB) - Random boot floppy, takes about 60 seconds
olar OS(1.4MB) - Simple graphical OS
Bootchess(0.2MB) - A tiny chess program written in the boot sector 

MS-DOSのライセンスがどうなっているか調べてなかったので、Freedosを押して見た。

SeaBIOS (version rel-1.10.0-39-g3fdabae-dirty-20170530_144256-nyu)              
Booting from Floppy...                                                          
FreeDOS kernel - SVN (build 2040 OEM:0xfd) [compiled Apr  7 2012]               
Kernel compatibility 7.10 - WATCOMC - FAT32 support                             
                                                                                
(C) Copyright 1995-2011 Pasquale J. Villani and The FreeDOS Project.            
All Rights Reserved. This is free software and comes with ABSOLUTELY NO         
WARRANTY; you can redistribute it and/or modify it under the terms of the       
GNU General Public License as published by the Free Software Foundation;        
either version 2, or (at your option) any later version.                        
 - InitDiskno hard disks detected                                               
Can't disable A20 - ignored                                                     
FreeDOS HIMEM 2.07 [Feb 13 2003] (c) 1995, Till Gerken 2001-2003 tom ehlert     
Interface : XMS 2.00 80386 64MB                                                 
Kernel: allocated 46 Diskbuffers = 24472 Bytes in HMA                           
                                                                                
FreeCom version 0.82 pl 3 XMS_Swap [Dec 10 2003 06:49:21]                       
                                                                                
                                                                                
Welcome to FreeDOS (http://www.freedos.org)!                                    
Running on copy.sh/v86/                                                         
                                                                                
Try 'invaders' or 'snake' or 'tetris' for fun.                                  
                                                                                
A:\>  

debugコマンド起動。D(dump)

A:\>debug                                                                       
-d                                                                              
099F:0100  75 02 EB F2 FF 76 0C E8-70 81 59 8B 1E A8 00 89   u....v..p.Y.....   
099F:0110  47 08 0B C0 74 12 FF 76-04 E8 5E 81 59 8B 1E A8   G...t..v..^.Y...   
099F:0120  00 89 47 0A 0B C0 75 05-E8 C7 49 EB 0D 8D 86 F0   ..G...u...I.....   
099F:0130  FE 50 E8 82 B7 59 0B C0-75 05 E8 32 B8 EB B7 8B   .P...Y..u..2....   
099F:0140  1E A8 00 C7 47 1A 01 00-33 C0 8B E5 5D C3 55 8B   ....G...3...].U.   
099F:0150  EC 83 EC 0A 8D 46 F6 50-8D 46 FA 50 8D 46 F8 50   .....F.P.F.P.F.P   
099F:0160  8D 46 04 50 8D 46 FC 50-8D 46 FE 50 FF 76 04 E8   .F.P.F.P.F.P.v..   
099F:0170  E0 FD 83 C4 0E 48 8B D8-83 FB 04 77 23 D1 E3 2E   .....H.....w#...  

u(dis assemble)

-u                                                                              
099F:0100 7502          JNZ     0104                                            
099F:0102 EBF2          JMP     00F6                                            
099F:0104 FF760C        PUSH    WORD PTR [BP+0C]                                
099F:0107 E87081        CALL    827A                                            
099F:010A 59            POP     CX                                              
099F:010B 8B1EA800      MOV     BX,[00A8]                                       
099F:010F 894708        MOV     [BX+08],AX                                      
099F:0112 0BC0          OR      AX,AX                                           
099F:0114 7412          JZ      0128                                            
099F:0116 FF7604        PUSH    WORD PTR [BP+04]                                
099F:0119 E85E81        CALL    827A                                            
099F:011C 59            POP     CX                                              
099F:011D 8B1EA800      MOV     BX,[00A8]                   

おお、動く。

#算譜(source)

copy/v86
https://github.com/copy/v86

cpu.js
"use strict";

/** @const */
var CPU_LOG_VERBOSE = false;


// Resources:

で始まっている。続いて次の3つのURLを示している。

https://pdos.csail.mit.edu/6.828/2006/readings/i386/toc.htm
https://www-ssl.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html
http://ref.x86asm.net/geek32.html

参考資料(reference)

FreeDOS
http://www.freedos.org

debugコマンド(MS DOS)
https://qiita.com/kaizen_nagoya/items/31542d281d16d135df66

文書履歴(document history)

ver. 0.10 初稿 20180714
ver. 0.11 参考資料追記 20180716
ver. 0.12 ありがとう追記 20230413

最後までおよみいただきありがとうございました。

いいね 💚、フォローをお願いします。

Thank you very much for reading to the last sentence.

Please press the like icon 💚 and follow me for your happy life.

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?