将 WordStar 从 CP/M 移植到 DOS 的单字节更改是什么?

发布于 2024-07-14 18:45:04 字数 348 浏览 9 评论 0原文

我正在重读 Joel 的策略信 II:先有鸡还是先有蛋的问题,并发现了这个有趣的内容引用:

事实上,WordStar 已移植到 DOS 通过改变一个字节 代码。 (真正的程序员可以告诉你 那个字节是什么,我早就知道了 忘记了)。

我通过快速谷歌搜索找不到任何其他参考资料。 这是真的还是只是一种比喻? 为了成为一名“真正的程序员”,单字节的变化是什么?

I was re-reading Joel's Strategy Letter II: Chicken and Egg problems and came across this fun quote:

In fact, WordStar was ported to DOS
by changing one single byte in the
code. (Real Programmers can tell you
what that byte was, I've long since
forgotten).

I couldn't find any other references to this with a quick Google search. Is this true or just a figure of speech? In the interest of my quest to become a "Real Programmer", what was the single byte change?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

撩心不撩汉 2024-07-21 18:45:04

听起来有点夸张,在这里找到了一些WordStar历史

MS-DOS 版 WordStar 3.0

1982 年 4 月

在一次通宵会议中,Jim Fox 对 CP/M-86 版本的 WordStar 进行了修补,使其能够在 IBM PC 上的 MS-DOS 下运行,以便向 Rubenstein 进行演示。 实际的移植是由一群爱尔兰程序员使用英特尔开发系统完成的,该系统运行 ISIS II 操作系统。 软件构建在 8 英寸软盘上完成,然后通过串行电缆将二进制(可执行)文件传输到 IBM PC。

但是……Joel 的意思可能是 MS-DOS 1.0 / QDOS

MS-DOS 1.0 实际上是 QDOS(Quick and Dirty Operating System)的重命名版本,微软于 1981 年 7 月从一家西雅图公司(恰当地命名为 Seattle Computer Products)购买了该操作系统。QDOS 是作为 CP 的克隆而开发的。 /M 八位操作系统,以提供与当今流行的商业应用程序(例如 WordStar 和 dBase)的兼容性。 CP/M(微型计算机控制程序)由 Digital Research 的 Gary Kildall 几年前编写,成为第一个通用的微型计算机操作系统。

Sounds a bit exaggerated, found some WordStar history here

WordStar 3.0 for MS-DOS

Apr 1982

In one single all-night session Jim Fox patched the CP/M-86 version of WordStar to make it run under MS-DOS on the IBM PC so that it could be demonstrated to Rubenstein. The actual port was done by a group of Irish programmers using Intel development systems, which ran the ISIS II operating system. The software build was done on 8" floppies and the binary (executable) files were then transferred to the IBM PC by serial cable.

But...Joel maybe meant MS-DOS 1.0 / QDOS

MS-DOS 1.0 was actually a renamed version of QDOS (Quick and Dirty Operating System), which Microsoft bought from a Seattle company, appropriately named Seattle Computer Products, in July 1981. QDOS had been developed as a clone of the CP/M eight-bit operating system in order to provide compatibility with the popular business applications of the day such as WordStar and dBase. CP/M (Control Program for Microcomputers) was written by Gary Kildall of Digital Research several years earlier and had become the first operating system for microcomputers in general use.

千と千尋 2024-07-21 18:45:04

您必须更改多个字节。 CP/M-86 可执行文件 (.CMD) 均具有 128-字节标头,它与 .EXE 标头不同。

如果将所有 API 调用限制为 CP/M 和 DOS 的公共子集,则可以使用条件汇编从同一源构建 CP/M 和 DOS 版本:

bdos:
       if CPM86
         int 0E0h
       else
         mov ah, cl
         int 21h
       endif

You'd have to change more than one byte. CP/M-86 executables (.CMD) all have a 128-byte header, which isn't anything like the .EXE header.

If you restrict all your API calls to the common subset of CP/M and DOS, then you can use conditional assembly to build CP/M and DOS versions from the same source:

bdos:
       if CPM86
         int 0E0h
       else
         mov ah, cl
         int 21h
       endif
不即不离 2024-07-21 18:45:04

此维基百科条目声称 CP/M 和 MS-DOS 共享二进制格式。 它接着说:

虽然文件格式是一样的
在 MS-DOS 和 CP/M 中,这并不意味着
CP/M程序可以直接
在 MS-DOS 下执行,反之亦然;
MS-DOS COM 文件包含 x86
指令,而 CP/M COM 文件
包含 8080、8085 或 Z80
说明。

在 CP/M 3 下,如果 a 的第一个字节
COM 文件是 0xC9 那么这表明
存在 256 字节标头;
因为0xC9对应于8080
指令RET,这意味着
COM 文件将立即终止,如果
在早期版本的 CP/M 上运行
不支持此扩展。

这意味着修复/移植可能正在将第一条指令更改为其他指令,从而允许其余指令执行。 但不确定,这似乎意味着二进制文件一定是“胖”的,这对于遗留二进制文件来说似乎不合理。

This Wikipedia entry claims that CP/M and MS-DOS share binary formats. It goes on to say:

Although the file format is the same
in MS-DOS and CP/M, this does not mean
that CP/M programs can be directly
executed under MS-DOS or vice versa;
MS-DOS COM files contain x86
instructions, while CP/M COM files
contain 8080, 8085 or Z80
instructions.

Under CP/M 3, if the first byte of a
COM file is 0xC9 then this indicates
the presence of a 256-byte header;
since 0xC9 corresponds to the 8080
instruction RET, this means that the
COM file will immediately terminate if
run on an earlier version of CP/M that
does not support this extension.

This implies that perhaps the fix/port was changing this first instruction into something else, that alowed the rest to execute. Not sure though, that seems to imply that the binary must have been "fat", which seems unreasonable for a legacy binary.

千寻… 2024-07-21 18:45:04

WordStar 是用 8080 汇编程序编写的,当时有工具可以将 8080 汇编程序转换为 8086 汇编程序(8086 指令集旨在允许这样做),如果所有代码都可以放入单个段中,那么这是完全可能的。

我第一次使用 WordStar 是在 1979 年,当时是在 Z80 CP/M 盒子上。 今天的人们可能没有意识到他们是多么幸运 - 有多少 MS Word 用户在安装文字处理器时的第一个任务是必须编写几个小型汇编程序例程(十六进制!)以有效地连接文字处理器(您可以在屏幕和键盘上使用 CP/M 例程,但它们太慢而且无法正常工作? 快乐的时光...

WordStar was written in 8080 assembler, and there were tools back then to convert 8080 to 8086 assembler (the 8086 instruction set was designed to allow this) if all the code could fit into a single segment, so this is quite possible.

I first used WordStar in 1979, on a Z80 CP/M box. People today might not realise how lucky they are - how many MS Word users would be prepared as the first task on installing their word processor to have to write a couple of small assembler routines (in hex!) to interface the word processor efficiently (you could use the CP/M routines but they were dog slow and didn't work properly) with the screen and keyboard? Happy days...

2024-07-21 18:45:04

“事实上,WordStar 是通过更改代码中的一个字节而移植到 DOS 的。(真正的程序员可以告诉你那个字节是什么,我早已忘记了)。”

2009 年 6 月 8 日星期一下午 6:27。 我的假设是 Spolsky 正在谈论 8080 CP/M 到 8086 MSDOS,这个故事可能是假的。 8086 CP/M 从来就不是一个大项目——我的意思是,它被 MSDOS 彻底压垮了——而且有人可能通过重新组装将 WordStar 从 8080-CPM 转换为 8086-CPM,如下所示其他人指出,使用特殊的 8080 到 8086 转换器——然后也许只需要更改一个字节。

"In fact, WordStar was ported to DOS by changing one single byte in the code. (Real Programmers can tell you what that byte was, I've long since forgotten)."

Mon 6/08/2009 6:27 pm. My assumption was Spolsky was talking about 8080 CP/M to 8086 MSDOS, and that the story is probably bogus. 8086 CP/M was never a big item -- I mean, it was crushed utterly by MSDOS -- and someone may have converted WordStar from 8080-CPM to 8086-CPM -- by reassembling it, as others have noted, using a special 8080-to-8086 translator thingey -- and then perhaps only a single byte had to be changed.

伏妖词 2024-07-21 18:45:04

我不确定乔尔的说法是否准确。 也许他指的是吉姆·福克斯制作的演示版本?

请参阅http://www.wordstar.org/wordstar/history/history.htm

我将引用相关部分:

MS-DOS 版 WordStar 3.0

1982 年 4 月

吉姆在一次通宵训练中
Fox 修补了 CP/M-86 版本
WordStar 使其在 MS-DOS 下运行
在IBM PC上,这样它就可以
向鲁宾斯坦展示了。 实际上
港口是由一群爱尔兰人完成的
使用英特尔开发的程序员
运行 ISIS II 的系统
操作系统。 软件构建
是在 8 英寸软盘和二进制文件上完成的
(可执行)文件然后
通过串口传输到IBM PC
电缆。

(编辑:哎呀,太晚了。其他人已经发现了完全相同的事情:-/请随意忽略我。)

I'm not sure whether Joel's statement is accurate or not. Perhaps he meant the demonstration version that Jim Fox made?

See http://www.wordstar.org/wordstar/history/history.htm

I'll quote the pertinent section:

WordStar 3.0 for MS-DOS

Apr 1982

In one single all-night session Jim
Fox patched the CP/M-86 version of
WordStar to make it run under MS-DOS
on the IBM PC so that it could be
demonstrated to Rubenstein. The actual
port was done by a group of Irish
programmers using Intel development
systems, which ran the ISIS II
operating system. The software build
was done on 8" floppies and the binary
(executable) files were then
transferred to the IBM PC by serial
cable.

(Edit: Oops, too late. Someone else already found the exact same thing :-/ Feel free to ignore me.)

花间憩 2024-07-21 18:45:04

需要了解的重要一点是,当时 16 位 8086 机器刚刚问世,以取代当前的 8 位机器,其中 CP/M 操作系统就是当时的 Windows。 一切带有用于工作的磁盘驱动器的东西都运行 CP/M。 该版本后来被称为 CP/M-80,以区别于 8086 处理器的 CP/M-86。

不幸的是,它花了很长时间才上市,以至于 QDOS 被编写为可以运行程序的东西,而这本质上是 CP/M 函数的快速重新实现(但使用不同的语法)。 QDOS后来被微软收购并制成MS-DOS。 因此,MS-DOS 实际上有一个 CP/M 核心,因此使 CP/M-86 程序在 MS-DOS 下运行所需的工作量是有限的(不是单个字节,但可以管理)。

我很高兴使用 CCP/M-86 工作了几年,它允许的多任务处理与今天 Linux 文本模式(带有虚拟控制台)允许的多任务处理非常相似。 不幸的是它从未流行起来。 哦,好吧,我们有 Linux :)

An important thing to understand is that at the time 16-bit 8086 machines was just coming out to replace the current 8-bit machines, where the CP/M operating system was the Windows of the day. Everything with a disk drive intended for work ran CP/M. That version was later called CP/M-80 to differentiate it from CP/M-86 for the 8086 processor.

Unfortunately that took so long to get to market that QDOS was written to have SOMETHING to run programs on, and that was essentially a quick reimplementation of the CP/M functions (but with a different syntax). QDOS was later bought by Microsoft and made into MS-DOS. Hence MS-DOS actually has a CP/M core deep deep inside, and therefore the amount of work needed to get a CP/M-86 program to run under MS-DOS was limited (not to a single byte, but manageable).

I had the pleasure to work a few years with CCP/M-86 which allowed multitasking very similar to what Linux in text mode (with virtual consoles) allow today. Unfortunately it never caught on. Oh, well, we have Linux :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文