PDP-11

Programming for the PDP-11 and UKNC
User avatar
aberrant
Posts: 14
Joined: Fri Apr 26, 2019 6:37 am

Re: PDP-11

Post by aberrant » Sat Mar 28, 2020 3:51 pm

I just enjoyed watching the very first tutorial in the PDP-11 series.
Excellent video :ThumbsUp
It is especially touching that people got interested in the series :Wow: and I'm looking forward to the new tutorials as well.

I'm anxious to add that in the Soviet Union, the PDP-11 compatible systems and microprocessors were very widely adopted.
The USSR produced many more of such computers than DEC itself.
Here is a nice list of such computers produced behind the iron curtain (which does not include military equipment and spacecrafts).
And of course, the very first "official" Soviet home computer - BK-0010 was based on a PDP-11 compatible microprocessor :D

User avatar
aberrant
Posts: 14
Joined: Fri Apr 26, 2019 6:37 am

Re: PDP-11

Post by aberrant » Sat Mar 28, 2020 4:26 pm

About the octal numbers. Sure, they look weird because "modern" bytes consists of 8-bits, and general microprocessors have 16, 32, or 64-bit words.
But for example, the very notable predecessor of the PDP-11, PDP-8, has 12-bits words.
As for the PDP-11, octal numbers pretty practical for a hacker.

I'll try to demonstrate how nicely machine codes can be split into octets, but first, it is worth to mention that PDP-11 has orthogonal instruction set

Base instruction set nicely falls into two patterns, here is a bitwise representation:
instructions with one operand:

Code: Select all

|15 |           |           |         6 | 5       3 | 2       0 |
|   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
|                                       |    MODE   |     Rn    |
|                                       |  **   | * |    ***    |
| OP CODE                               | DESTINATION FIELD     |
* Specifies direct or indirect address
** Specifies how register will be used
*** Specifies one of 8 general perpose registers
and instruction with two operands:

Code: Select all

| 15| 14      12| 11      9 | 8       6 | 5       3 | 2       0 |
| B |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
|               |    MODE   |     Rn    |    MODE   |     Rn    |
|               |  **   | * |    ***    |  **   | * |    ***    |
| OP CODE       | SOURCE FIELD          | DESTINATION FIELD     |
* Direct/deferred bit for source and destination address
** Specifies how selected registers are to be used
*** Specifies a general register
And to complete the picture, there is 8 addressing modes:

Code: Select all

| Code | Name                   | Example    | Description                                                    |
|------+------------------------+------------+----------------------------------------------------------------|
| 0n   | Register               | OPR Rn     | The operand is in Rn                                           |
| 1n   | Register deferred      | OPR (Rn)   | Rn contains the address of the operand                         |
| 2n   | Autoincrement          | OPR (Rn)+  | Rn contains the address of the operand, then increment Rn by 2 |
| 3n   | Autoincrement deferred | OPR @(Rn)+ | Rn contains the address of the operand, then increment Rn by 2 |
| 4n   | Autodecrement          | OPR -(Rn)  | Decrement Rn, then use it as the address                       |
| 5n   | Autodecrement deferred | OPR @-(Rn) | Decrement Rn by 2, then use it as the address of the address   |
| 6n   | Index                  | OPR X(Rn)  | Rn+X is the address of the operand                             |
| 7n   | Index deferred         | OPR @X(Rn) | Rn+X is the address of the address                             |
And there is 8 registers: R0-R7

Now, lets translate a command MOVB (R5)+,R0 into machine code:

Code: Select all

1 - byte operation
1 - MOV op code
2 - autoincrement addressing mode
5 - R5
0 - register addressing mode
0 - R0

MOVB (R5)+,R0 translates to 112500
It's not that hard to learn to read and write machine codes when you use octal numbers :D
People who programmed on assembler back in the days, still can write straight in machine codes.

User avatar
akuyou
Posts: 398
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: PDP-11

Post by akuyou » Sun Mar 29, 2020 11:09 pm

Thanks for providing this excellent description, it's far better than I could have done
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

User avatar
aberrant
Posts: 14
Joined: Fri Apr 26, 2019 6:37 am

Re: PDP-11

Post by aberrant » Mon Mar 30, 2020 9:22 pm

I had those figures in my notes for a while, and yeah, they are pretty concise. I believe that I took them from one of the DEC manuals, but I don't remember from which one.

I'll be happy to help if you need some information to continue the tutorials.

Recently I added a keyboard scan-codes table, with some notes explaining Russian markings.
And I'll continue to translate the technical description of the machine.

Code: Select all

 | code |   key   | note     | code |  key  |  note     |
 |   05 | ,       | NumPad   | 0106 | АЛФ   | Alphabet  |
 |   06 | АР2     | Esc      | 0107 | ФИКС  | Lock      |
 |   07 | ; / +   |          | 0110 | Ч / ^ |           |
 |  010 | К1 / К6 | F1 / F6  | 0111 | С / S |           |
 |  011 | К2 / К7 | F2 / F7  | 0112 | М / M |           |
 |  012 | КЗ / К8 | F3 / F8  | 0113 | SPACE |           |
 |  013 | 4 / ¤   |          | 0114 | Т / T |           |
 |  014 | К4 / К9 | F4 / F9  | 0115 | Ь / X |           |
 |  015 | К5 / К10| F5 / F10 | 0116 | ←     |           |
 |  016 | 7 / '   |          | 0117 | , / < |           |
 |  017 | 8 / (   |          | 0125 | 7     | NumPad    |
 |  025 | -       | NumPad   | 0126 | 0     | NumPad    |
 |  026 | ТАБ     | Tab      | 0127 | 1     | NumPad    |
 |  027 | Й / J   |          | 0130 | 4     | NumPad    |
 |  028 | 1 / !   |          | 0131 | +     | NumPad    |
 |  031 | 2 / "   |          | 0132 | ЗБ    | Backspace |
 |  032 | 3 / #   |          | 0133 | →     |           |
 |  033 | Е / E   |          | 0134 | ↓     |           |
 |  034 | 5 / %   |          | 0135 | . / > |           |
 |  035 | 6 / &   |          | 0136 | Э / \ |           |
 |  036 | Ш / [   |          | 0137 | Ж / V |           |
 |  037 | Щ / ]   |          | 0145 | 8     | NumPad    |
 |  046 | УПР     | Ctrl     | 0146 | .     | NumPad    |
 |  047 | Ф / F   |          | 0147 | 2     | NumPad    |
 |  050 | Ц / C   |          | 0150 | 5     | NumPad    |
 |  051 | У / U   |          | 0151 | ИСП   | Execute   |
 |  052 | К / K   |          | 0152 | УСТ   | Settings  |
 |  053 | П / P   |          | 0153 | ВВОД  | Enter     |
 |  054 | H / N   |          | 0154 | ↑     |           |
 |  055 | Г / G   |          | 0155 | : / * |           |
 |  056 | Л / L   |          | 0156 | Х / H |           |
 |  057 | Д / D   |          | 0157 | З / Z |           |
 |  066 | ГРАФ    | Graph    | 0165 | 9     | NumPad    |
 |  067 | Я / Q   |          | 0166 | ВВОД  | NumPad    |
 |  070 | Ы / Y   |          | 0167 | 3     | NumPad    |
 |  071 | В / W   |          | 0170 | 7     | NumPad    |
 |  072 | А / A   |          | 0171 | СБРОС | Reset     |
 |  073 | И / I   |          | 0172 | ПОМ   | Help      |
 |  074 | Р / R   |          | 0173 | / / ? |           |
 |  075 | О / O   |          | 0174 | Ъ / } |           |
 |  076 | Б / B   |          | 0175 | - / = |           |
 |  077 | Ю / @   |          | 0176 | О / } |           |
 | 0105 | HP      | Shift    | 0177 | 9 / ) |           |

Post Reply

Return to “PDP-11 Assembly Programming”