# Is there (was there ever?) serious programming being done in machine code?

**URL:** <https://boards.straightdope.com/t/is-there-was-there-ever-serious-programming-being-done-in-machine-code/937343>\
**Category:** Factual Questions\
**Created:** [March 6, 2021, 6:19pm UTC](https://boards.straightdope.com/t/is-there-was-there-ever-serious-programming-being-done-in-machine-code/937343 "2021-03-06T18:19:50Z")\
**Posts on this page:** 12\
**Page:** 13

<div class="post-metadata">

**Author:** ![Crane](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/crane/32/3495_2.png) [@Crane](https://boards.straightdope.com/u/Crane)\
**Post date:** [April 1, 2021, 10:04pm UTC](https://boards.straightdope.com/t/is-there-was-there-ever-serious-programming-being-done-in-machine-code/937343/242 "2021-04-01T22:04:20Z")

</div>

Oh yes, the systems were supported by assemblers at IBM, but they were not commonly used by the customers where i was resident.

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [April 1, 2021, 11:02pm UTC](https://boards.straightdope.com/t/is-there-was-there-ever-serious-programming-being-done-in-machine-code/937343/243 "2021-04-01T23:02:33Z")

</div>

> [@Voyager](#):
>
> Not that C is perfect. At one point I wanted to compute a call to one of an array of functions. (Or something like that.) I had no idea of the syntax to use, so I looked up several possibilities in the BNF. They were all legal. I finally looked at the source code of an internal emacs which did this and found out something that worked.

By far the best (and only decent) discussion I have ever seen of C declarations, I found in the VAX C programming manual. It gave a full step-by-step procedure for building any arbitrarily complex declaration you want, and a separate procedure for comprehending any existing declaration written by someone else. If you wanted to declare a pointer to an array of pointers to functions returning float, you could. Or an array of pointers to arrays of functions returning pointers to a struct. Or whatever.

I made a copy, which I still have around somewhere. I’ll post some examples if I find it.

> [@Francis\_Vaughan](#):
>
> On the way did a lot in VAX Pascal. That was a very different language to base Pascal. It had all the proper additions as well, and provided full systems access, there were bindings for all the system calls and libraries, bit twiddling capability and so on. I wrote some serious stuff in that.

See, everywhere students learned Pascal as a “teaching language”, they came out as fully-indoctrinated Pascal fanatics who thought Pascal was God’s gift to the world and any other language was just the shitz. So instead of graduating from Pascal to a Real Programming Language, they insisted on bringing Pascal with them wherever they went. Then you got different implementations of Pascal everywhere, all of them with system-specific extensions, often including their ways of doing input/output, and none of them are portable any more. Same thing that happened with Algol.

> [@Voyager](#):
>
> By the way, he started the lecture by saying his name could be pronounced two ways - Virth, call by name, Worth, call by value.

This must have been a standard joke Wirth always told everywhere he went. Ed Post (author of Real Programmers Don’t Use Pascal, cited several posts above) quoted it also.

---

<div class="post-metadata">

**Author:** ![Francis\_Vaughan](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/francis_vaughan/32/3093_2.png) [@Francis\_Vaughan](https://boards.straightdope.com/u/Francis_Vaughan)\
**Post date:** [April 1, 2021, 11:07pm UTC](https://boards.straightdope.com/t/is-there-was-there-ever-serious-programming-being-done-in-machine-code/937343/244 "2021-04-01T23:07:45Z")

</div>

> [@Senegoid](#):
>
> By far the best (and only decent) discussion I have ever seen of C declarations, I found in the VAX C programming manual.

Gosh, yes. I had a copy of that too. It really was a godsend. DEC had some fabulously well written documentation. Especially compared to the dearth of anything useful from modern zillion dollar companies.

_cdecl_ was pretty useful to check with, but didn’t give any clues about how to actually craft the declaration.

> [@Senegoid](#):
>
> This must have been a standard joke Wirth always told everywhere he went. Ed Post (author of Real Programmers Don’t Use Pascal, cited several posts above) quoted it also.

Yup. I have heard him make the same joke.

---

<div class="post-metadata">

**Author:** ![Terminus\_Est](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/terminus_est/32/3087_2.png) [@Terminus\_Est](https://boards.straightdope.com/u/Terminus_Est)\
**Post date:** [April 2, 2021, 2:28am UTC](https://boards.straightdope.com/t/is-there-was-there-ever-serious-programming-being-done-in-machine-code/937343/245 "2021-04-02T02:28:35Z")

</div>

Three backticks ``` allows formatting of multiline blocks of code, e.g.,

```auto
function AuxInChar(Port: word): char;
    inline (
            $5A/
            $B4/$02/
            $CD/$14);

```

Not including the disassembled x86 instructions as comments seems like bad programming practice.

And the forum software is Dis **course**. Dis **cord** is for group chat.

---

<div class="post-metadata">

**Author:** ![Melbourne](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Melbourne](https://boards.straightdope.com/u/Melbourne)\
**Post date:** [April 2, 2021, 4:00am UTC](https://boards.straightdope.com/t/is-there-was-there-ever-serious-programming-being-done-in-machine-code/937343/246 "2021-04-02T04:00:48Z")

</div>

Well, I can tell you that $5A is a POP (to get Port off the stack), and $CD $14 is (interrupt 14). Dunno what $B4 $02 is, but given the context (just before $CD $14), it’s MOV immediate: MOV AX 2 or MOV AH 2. My DOS book isn’t on the shelf here anymore.

TP3 and DOS says 1980’s, but that snip is actually from a TP7 program: somewhere along the line it was updated without re-writing. If it was native TP7 it wouldn’t even be ASM, it would be an INTR declaration.

---

<div class="post-metadata">

**Author:** ![Terminus\_Est](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/terminus_est/32/3087_2.png) [@Terminus\_Est](https://boards.straightdope.com/u/Terminus_Est)\
**Post date:** [April 2, 2021, 5:07am UTC](https://boards.straightdope.com/t/is-there-was-there-ever-serious-programming-being-done-in-machine-code/937343/247 "2021-04-02T05:07:43Z")

</div>

I got bothered enough to disassemble the machine code myself.

```
0: 5a pop edx
1: b4 02 mov ah,0x2
3: cd 14 int 0x14

```

`int 14` with `AH=2` is a DOS call to read from AUX (i.e., COM1), so at least the function name reflects what’s going on in the code.

Turbo Pascal could already `Read()` and `Write()` from/to AUX so I’m not sure what was to be gained by writing inline code to do the same thing.

Oh! DX lets you set the port number so this allows you to read from other than COM1. I’m fairly sure there’s also a way to do that, but I’ve wasted enough time on this already.

---

<div class="post-metadata">

**Author:** ![Crane](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/crane/32/3495_2.png) [@Crane](https://boards.straightdope.com/u/Crane)\
**Post date:** [April 2, 2021, 1:41pm UTC](https://boards.straightdope.com/t/is-there-was-there-ever-serious-programming-being-done-in-machine-code/937343/248 "2021-04-02T13:41:07Z")

</div>

With DOS you could access the parallel port directly with the port addresses 03BC, 0378 and 0278.

---

<div class="post-metadata">

**Author:** ![Melbourne](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Melbourne](https://boards.straightdope.com/u/Melbourne)\
**Post date:** [April 2, 2021, 10:26pm UTC](https://boards.straightdope.com/t/is-there-was-there-ever-serious-programming-being-done-in-machine-code/937343/249 "2021-04-02T22:26:07Z")

</div>

> [@Terminus\_Est](#):
>
> Turbo Pascal could already `Read()` and `Write()` from/to AUX so I’m not sure what was to be gained by writing inline code to do the same thing.

This was the normal way to do it. What TP did was provide the hooks so that Read and Write could be hooked into things that aren’t DOS text files or DOS random access files or DOS logical devices (AUX). The code that uses this ‘file driver’ just uses PASCAL ‘read’ and ‘write’.

What’s notable is that the other part of the code for this test machine doesn’t use ‘read’ and ‘write’ at all – it uses direct hardware access. _Including serial I/O (using a different protocol) through a digital I/O card_.

The chipset for PC serial I/O was well known and no more complex than the digital I/O card: this serial I/O part could have been written the same way as the other (using port addresses), avoiding ‘read’ and ‘write’ and the DOS serial I/O API. Or the other serial I/O could have been written this way: as a ‘file driver’ hiding the digital I/O card behind ‘read’ and ‘write’. The two sections were written by different people…

---

<div class="post-metadata">

**Author:** ![Voyager](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/voyager/32/133_2.png) [@Voyager](https://boards.straightdope.com/u/Voyager)\
**Post date:** [April 3, 2021, 1:58am UTC](https://boards.straightdope.com/t/is-there-was-there-ever-serious-programming-being-done-in-machine-code/937343/250 "2021-04-03T01:58:25Z")

</div>

> [@Senegoid](#):
>
> This must have been a standard joke Wirth always told everywhere he went. Ed Post (author of Real Programmers Don’t Use Pascal, cited several posts above) quoted it also.

Yeah, I got the impression it was standard (and he used his last name only) but I heard it with my own ears, so my post is my cite. 😛

---

<div class="post-metadata">

**Author:** ![Melbourne](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Melbourne](https://boards.straightdope.com/u/Melbourne)\
**Post date:** [April 5, 2021, 5:35am UTC](https://boards.straightdope.com/t/is-there-was-there-ever-serious-programming-being-done-in-machine-code/937343/251 "2021-04-05T05:35:01Z")

</div>

> [@Saint\_Cad](#):
>
> This just hit me. The Apollo programming was woven in as core-rope memory and as such wasn’t the programming done as machine code?

An example of the assembly language:  
[1969 Apollo 11 used these 30 lines of assembly language code to calculate transcendental functions for navigation | Tech News | Startups News (techstartups.com)](https://techstartups.com/2020/06/01/1969-apollo-11-used-30-lines-assembly-language-code-calculate-transcendental-functions-navigation/)

The navigation was handled in an interpreted language, with the interpreter running as a native program, so the code example may be from the interpreter.

This was Apollo 11 (first moon landing). I haven’t seen information about earlier iterations.

---

<div class="post-metadata">

**Author:** ![Melbourne](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Melbourne](https://boards.straightdope.com/u/Melbourne)\
**Post date:** [September 19, 2021, 11:03pm UTC](https://boards.straightdope.com/t/is-there-was-there-ever-serious-programming-being-done-in-machine-code/937343/252 "2021-09-19T23:03:08Z")

</div>

Not ‘serious’ programming, but Linus Torvalds talking about his Sinclair QL and writing his assembler in machine code, so that he could place it in ROM:  
[Linus Torvalds interviewed by Jeremy Allison - YouTube](https://www.youtube.com/watch?v=05pgVwzAZ6k&t=574s)

---

<div class="post-metadata">

**Author:** ![Voyager](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/voyager/32/133_2.png) [@Voyager](https://boards.straightdope.com/u/Voyager)\
**Post date:** [September 20, 2021, 12:32am UTC](https://boards.straightdope.com/t/is-there-was-there-ever-serious-programming-being-done-in-machine-code/937343/253 "2021-09-20T00:32:52Z")

</div>

As I probably said upthread (I’m not about to check) I wrote my first assembler in machine code since I had nothing else to write it in. It’s not all that hard if you grok the instruction set.

[Previous page](https://boards.straightdope.com/t/is-there-was-there-ever-serious-programming-being-done-in-machine-code/937343.md?page=12)
