Is there a way to get a compiler for the original B programming language?
I am learning about the original B programming language, but I don't have a compiler.
Is there an emulator for an old computer that can run an old operating system that have a compiler for the original B programming language?
history programming
New contributor
add a comment |
I am learning about the original B programming language, but I don't have a compiler.
Is there an emulator for an old computer that can run an old operating system that have a compiler for the original B programming language?
history programming
New contributor
add a comment |
I am learning about the original B programming language, but I don't have a compiler.
Is there an emulator for an old computer that can run an old operating system that have a compiler for the original B programming language?
history programming
New contributor
I am learning about the original B programming language, but I don't have a compiler.
Is there an emulator for an old computer that can run an old operating system that have a compiler for the original B programming language?
history programming
history programming
New contributor
New contributor
New contributor
asked 4 hours ago
user13493user13493
311
311
New contributor
New contributor
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
This question has already been asked on Stack Overflow and answered, however we cannot show duplicated across sites. I will link to the answer there:
https://stackoverflow.com/a/26247672/4370109
Which says:
Prompted by this question, there is now a B compiler available from here: https://github.com/Leushenko/ybc
Runs on Windows, Linux, and OSX (binaries provided; in the spirit of the question it is written in an obscure language), where it produces very poor quality x86-32 assembly. Should be GCC-compatible. It is reconstructed out of the available reference material on B, and almost certainly does not reflect the language as it really was in the 1960s. Notably, in the absence of type information (B is untyped), the
&a[b] == &*(a + b)
rule can not hold on x86, meaning that this task is effectively impossible (without resorting to an interpreter).
Apart from that, Pavel Minaev's comment is right: the language as described is extremely small, far smaller than C, and an experienced/competent compiler programmer could likely write one for you in an afternoon.
Unfortunately this is only a partial answer, as I couldn't tell you where to find a good B compiler.
ybc
can't compile contemporary programs, unfortunately.
– wizzwizz4♦
59 mins ago
add a comment |
I found an LLVM-based implementation of Ken Thompson's PDP-11 flavour of B on GitHub: https://github.com/dobyrch/dbc and also an x86-based implementation of the Honeywell flavour: https://github.com/aap/abc. abc
appears to have been reconstructed from documentation, and due to its x86 nature is a little hackish:
Since B was first implemented for machines with word addressing, some hacking was required to make it work on the byte addressed x86. Addresses filled in by the linker are always byte addresses, so pointers to these addresses are collectively stored at the end of the .data section and are then converted to word addresses at runtime, before main() is called.
The generated assembly is very inefficient, not even constant expressions are reduced at compile time. Also I/O is currently not buffered.
However, dbc
comes with its own issues:
- All operators and statements are implemented, although they haven't all been thoroughly tested. I suspect some edge cases with oddly placed labels may generate invalid LLVM IR.
- Every library function has been implemented, although
gtty()
andstty()
differ slightly from their descriptions in the manual: they both require a 4-word vector as a second argument. They are equivalent totcgetattr
andtcsetattr
, respectively, but use a vector instead ofstruct termios
to hold the four flag fields.
- The error diagnostics still need some work—several different errors may be printed for the same line, and the line number is not always correct.
- Indirectly assigning to a global variable will have strange results (e.g.
foo = 40
is fine, but*&foo = 40
will actually set foo to 5, not 40). This issue does not affect local variable assignment, nor does it affect assignment to array indices (i.e. iffoo
is a global vector,foo[3] = 40
works as expected). The problem stems from a kludge which is necessary to achieve correct pointer arithmetic semantics.
- A simple definition may contain at most one value in its initializer list. I have not yet found a reasonable way to implement the semantics described in section 7.1 of the manual; use a vector definition instead (e.g.
foo[5] 1, 2, 3, 4, 5;
instead offoo 1 2 3 4 5;
). Incidentally, this same restriction seemed to be present in the H6070 implementation of B.
- Global initializer lists may not contain strings or names of other globals (yet).
Unlike ybc
, these can both compile some original B programs.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "648"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
user13493 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f10870%2fis-there-a-way-to-get-a-compiler-for-the-original-b-programming-language%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This question has already been asked on Stack Overflow and answered, however we cannot show duplicated across sites. I will link to the answer there:
https://stackoverflow.com/a/26247672/4370109
Which says:
Prompted by this question, there is now a B compiler available from here: https://github.com/Leushenko/ybc
Runs on Windows, Linux, and OSX (binaries provided; in the spirit of the question it is written in an obscure language), where it produces very poor quality x86-32 assembly. Should be GCC-compatible. It is reconstructed out of the available reference material on B, and almost certainly does not reflect the language as it really was in the 1960s. Notably, in the absence of type information (B is untyped), the
&a[b] == &*(a + b)
rule can not hold on x86, meaning that this task is effectively impossible (without resorting to an interpreter).
Apart from that, Pavel Minaev's comment is right: the language as described is extremely small, far smaller than C, and an experienced/competent compiler programmer could likely write one for you in an afternoon.
Unfortunately this is only a partial answer, as I couldn't tell you where to find a good B compiler.
ybc
can't compile contemporary programs, unfortunately.
– wizzwizz4♦
59 mins ago
add a comment |
This question has already been asked on Stack Overflow and answered, however we cannot show duplicated across sites. I will link to the answer there:
https://stackoverflow.com/a/26247672/4370109
Which says:
Prompted by this question, there is now a B compiler available from here: https://github.com/Leushenko/ybc
Runs on Windows, Linux, and OSX (binaries provided; in the spirit of the question it is written in an obscure language), where it produces very poor quality x86-32 assembly. Should be GCC-compatible. It is reconstructed out of the available reference material on B, and almost certainly does not reflect the language as it really was in the 1960s. Notably, in the absence of type information (B is untyped), the
&a[b] == &*(a + b)
rule can not hold on x86, meaning that this task is effectively impossible (without resorting to an interpreter).
Apart from that, Pavel Minaev's comment is right: the language as described is extremely small, far smaller than C, and an experienced/competent compiler programmer could likely write one for you in an afternoon.
Unfortunately this is only a partial answer, as I couldn't tell you where to find a good B compiler.
ybc
can't compile contemporary programs, unfortunately.
– wizzwizz4♦
59 mins ago
add a comment |
This question has already been asked on Stack Overflow and answered, however we cannot show duplicated across sites. I will link to the answer there:
https://stackoverflow.com/a/26247672/4370109
Which says:
Prompted by this question, there is now a B compiler available from here: https://github.com/Leushenko/ybc
Runs on Windows, Linux, and OSX (binaries provided; in the spirit of the question it is written in an obscure language), where it produces very poor quality x86-32 assembly. Should be GCC-compatible. It is reconstructed out of the available reference material on B, and almost certainly does not reflect the language as it really was in the 1960s. Notably, in the absence of type information (B is untyped), the
&a[b] == &*(a + b)
rule can not hold on x86, meaning that this task is effectively impossible (without resorting to an interpreter).
Apart from that, Pavel Minaev's comment is right: the language as described is extremely small, far smaller than C, and an experienced/competent compiler programmer could likely write one for you in an afternoon.
Unfortunately this is only a partial answer, as I couldn't tell you where to find a good B compiler.
This question has already been asked on Stack Overflow and answered, however we cannot show duplicated across sites. I will link to the answer there:
https://stackoverflow.com/a/26247672/4370109
Which says:
Prompted by this question, there is now a B compiler available from here: https://github.com/Leushenko/ybc
Runs on Windows, Linux, and OSX (binaries provided; in the spirit of the question it is written in an obscure language), where it produces very poor quality x86-32 assembly. Should be GCC-compatible. It is reconstructed out of the available reference material on B, and almost certainly does not reflect the language as it really was in the 1960s. Notably, in the absence of type information (B is untyped), the
&a[b] == &*(a + b)
rule can not hold on x86, meaning that this task is effectively impossible (without resorting to an interpreter).
Apart from that, Pavel Minaev's comment is right: the language as described is extremely small, far smaller than C, and an experienced/competent compiler programmer could likely write one for you in an afternoon.
Unfortunately this is only a partial answer, as I couldn't tell you where to find a good B compiler.
edited 51 mins ago
Nisse Engström
23727
23727
answered 2 hours ago
Brian Tompsett - 汤莱恩Brian Tompsett - 汤莱恩
1,555521
1,555521
ybc
can't compile contemporary programs, unfortunately.
– wizzwizz4♦
59 mins ago
add a comment |
ybc
can't compile contemporary programs, unfortunately.
– wizzwizz4♦
59 mins ago
ybc
can't compile contemporary programs, unfortunately.– wizzwizz4♦
59 mins ago
ybc
can't compile contemporary programs, unfortunately.– wizzwizz4♦
59 mins ago
add a comment |
I found an LLVM-based implementation of Ken Thompson's PDP-11 flavour of B on GitHub: https://github.com/dobyrch/dbc and also an x86-based implementation of the Honeywell flavour: https://github.com/aap/abc. abc
appears to have been reconstructed from documentation, and due to its x86 nature is a little hackish:
Since B was first implemented for machines with word addressing, some hacking was required to make it work on the byte addressed x86. Addresses filled in by the linker are always byte addresses, so pointers to these addresses are collectively stored at the end of the .data section and are then converted to word addresses at runtime, before main() is called.
The generated assembly is very inefficient, not even constant expressions are reduced at compile time. Also I/O is currently not buffered.
However, dbc
comes with its own issues:
- All operators and statements are implemented, although they haven't all been thoroughly tested. I suspect some edge cases with oddly placed labels may generate invalid LLVM IR.
- Every library function has been implemented, although
gtty()
andstty()
differ slightly from their descriptions in the manual: they both require a 4-word vector as a second argument. They are equivalent totcgetattr
andtcsetattr
, respectively, but use a vector instead ofstruct termios
to hold the four flag fields.
- The error diagnostics still need some work—several different errors may be printed for the same line, and the line number is not always correct.
- Indirectly assigning to a global variable will have strange results (e.g.
foo = 40
is fine, but*&foo = 40
will actually set foo to 5, not 40). This issue does not affect local variable assignment, nor does it affect assignment to array indices (i.e. iffoo
is a global vector,foo[3] = 40
works as expected). The problem stems from a kludge which is necessary to achieve correct pointer arithmetic semantics.
- A simple definition may contain at most one value in its initializer list. I have not yet found a reasonable way to implement the semantics described in section 7.1 of the manual; use a vector definition instead (e.g.
foo[5] 1, 2, 3, 4, 5;
instead offoo 1 2 3 4 5;
). Incidentally, this same restriction seemed to be present in the H6070 implementation of B.
- Global initializer lists may not contain strings or names of other globals (yet).
Unlike ybc
, these can both compile some original B programs.
add a comment |
I found an LLVM-based implementation of Ken Thompson's PDP-11 flavour of B on GitHub: https://github.com/dobyrch/dbc and also an x86-based implementation of the Honeywell flavour: https://github.com/aap/abc. abc
appears to have been reconstructed from documentation, and due to its x86 nature is a little hackish:
Since B was first implemented for machines with word addressing, some hacking was required to make it work on the byte addressed x86. Addresses filled in by the linker are always byte addresses, so pointers to these addresses are collectively stored at the end of the .data section and are then converted to word addresses at runtime, before main() is called.
The generated assembly is very inefficient, not even constant expressions are reduced at compile time. Also I/O is currently not buffered.
However, dbc
comes with its own issues:
- All operators and statements are implemented, although they haven't all been thoroughly tested. I suspect some edge cases with oddly placed labels may generate invalid LLVM IR.
- Every library function has been implemented, although
gtty()
andstty()
differ slightly from their descriptions in the manual: they both require a 4-word vector as a second argument. They are equivalent totcgetattr
andtcsetattr
, respectively, but use a vector instead ofstruct termios
to hold the four flag fields.
- The error diagnostics still need some work—several different errors may be printed for the same line, and the line number is not always correct.
- Indirectly assigning to a global variable will have strange results (e.g.
foo = 40
is fine, but*&foo = 40
will actually set foo to 5, not 40). This issue does not affect local variable assignment, nor does it affect assignment to array indices (i.e. iffoo
is a global vector,foo[3] = 40
works as expected). The problem stems from a kludge which is necessary to achieve correct pointer arithmetic semantics.
- A simple definition may contain at most one value in its initializer list. I have not yet found a reasonable way to implement the semantics described in section 7.1 of the manual; use a vector definition instead (e.g.
foo[5] 1, 2, 3, 4, 5;
instead offoo 1 2 3 4 5;
). Incidentally, this same restriction seemed to be present in the H6070 implementation of B.
- Global initializer lists may not contain strings or names of other globals (yet).
Unlike ybc
, these can both compile some original B programs.
add a comment |
I found an LLVM-based implementation of Ken Thompson's PDP-11 flavour of B on GitHub: https://github.com/dobyrch/dbc and also an x86-based implementation of the Honeywell flavour: https://github.com/aap/abc. abc
appears to have been reconstructed from documentation, and due to its x86 nature is a little hackish:
Since B was first implemented for machines with word addressing, some hacking was required to make it work on the byte addressed x86. Addresses filled in by the linker are always byte addresses, so pointers to these addresses are collectively stored at the end of the .data section and are then converted to word addresses at runtime, before main() is called.
The generated assembly is very inefficient, not even constant expressions are reduced at compile time. Also I/O is currently not buffered.
However, dbc
comes with its own issues:
- All operators and statements are implemented, although they haven't all been thoroughly tested. I suspect some edge cases with oddly placed labels may generate invalid LLVM IR.
- Every library function has been implemented, although
gtty()
andstty()
differ slightly from their descriptions in the manual: they both require a 4-word vector as a second argument. They are equivalent totcgetattr
andtcsetattr
, respectively, but use a vector instead ofstruct termios
to hold the four flag fields.
- The error diagnostics still need some work—several different errors may be printed for the same line, and the line number is not always correct.
- Indirectly assigning to a global variable will have strange results (e.g.
foo = 40
is fine, but*&foo = 40
will actually set foo to 5, not 40). This issue does not affect local variable assignment, nor does it affect assignment to array indices (i.e. iffoo
is a global vector,foo[3] = 40
works as expected). The problem stems from a kludge which is necessary to achieve correct pointer arithmetic semantics.
- A simple definition may contain at most one value in its initializer list. I have not yet found a reasonable way to implement the semantics described in section 7.1 of the manual; use a vector definition instead (e.g.
foo[5] 1, 2, 3, 4, 5;
instead offoo 1 2 3 4 5;
). Incidentally, this same restriction seemed to be present in the H6070 implementation of B.
- Global initializer lists may not contain strings or names of other globals (yet).
Unlike ybc
, these can both compile some original B programs.
I found an LLVM-based implementation of Ken Thompson's PDP-11 flavour of B on GitHub: https://github.com/dobyrch/dbc and also an x86-based implementation of the Honeywell flavour: https://github.com/aap/abc. abc
appears to have been reconstructed from documentation, and due to its x86 nature is a little hackish:
Since B was first implemented for machines with word addressing, some hacking was required to make it work on the byte addressed x86. Addresses filled in by the linker are always byte addresses, so pointers to these addresses are collectively stored at the end of the .data section and are then converted to word addresses at runtime, before main() is called.
The generated assembly is very inefficient, not even constant expressions are reduced at compile time. Also I/O is currently not buffered.
However, dbc
comes with its own issues:
- All operators and statements are implemented, although they haven't all been thoroughly tested. I suspect some edge cases with oddly placed labels may generate invalid LLVM IR.
- Every library function has been implemented, although
gtty()
andstty()
differ slightly from their descriptions in the manual: they both require a 4-word vector as a second argument. They are equivalent totcgetattr
andtcsetattr
, respectively, but use a vector instead ofstruct termios
to hold the four flag fields.
- The error diagnostics still need some work—several different errors may be printed for the same line, and the line number is not always correct.
- Indirectly assigning to a global variable will have strange results (e.g.
foo = 40
is fine, but*&foo = 40
will actually set foo to 5, not 40). This issue does not affect local variable assignment, nor does it affect assignment to array indices (i.e. iffoo
is a global vector,foo[3] = 40
works as expected). The problem stems from a kludge which is necessary to achieve correct pointer arithmetic semantics.
- A simple definition may contain at most one value in its initializer list. I have not yet found a reasonable way to implement the semantics described in section 7.1 of the manual; use a vector definition instead (e.g.
foo[5] 1, 2, 3, 4, 5;
instead offoo 1 2 3 4 5;
). Incidentally, this same restriction seemed to be present in the H6070 implementation of B.
- Global initializer lists may not contain strings or names of other globals (yet).
Unlike ybc
, these can both compile some original B programs.
edited 1 hour ago
answered 1 hour ago
wizzwizz4♦wizzwizz4
8,855641109
8,855641109
add a comment |
add a comment |
user13493 is a new contributor. Be nice, and check out our Code of Conduct.
user13493 is a new contributor. Be nice, and check out our Code of Conduct.
user13493 is a new contributor. Be nice, and check out our Code of Conduct.
user13493 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Retrocomputing Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f10870%2fis-there-a-way-to-get-a-compiler-for-the-original-b-programming-language%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown