# Difference between revisions of "PDP-11"

Childishbeat (talk | contribs) m (Childishbeat moved page PDP-11 CPUs to PDP-11: Less verbose) |
|||

(6 intermediate revisions by one other user not shown) | |||

Line 6: | Line 6: | ||

=== Registers === | === Registers === | ||

− | The PDP-11 | + | The PDP-11's registers are ALL 16 bit. |

+ | |||

+ | '''R0, R1, R2, R3, R4 | ||

+ | R5 (Often Used to remember the return address during calls) | ||

+ | SP (R6), PC (R7) | ||

+ | ''' | ||

+ | If an Even register number (R0,R2,R4) is used for certain commands (for example MUL)- the register and it's following will be used as a 32 bit pair when the result is returned | ||

+ | |||

+ | Assignment direction is left (source) to right (dest). Default number mode for the PDP-11 is Octal mode (base-8), but there is possible to use other modes as well | ||

+ | |||

+ | <syntaxhighlight> | ||

+ | mov #777,r0 ; octal =default | ||

+ | mov #^b101,r0 ; binary | ||

+ | mov #^x0aa,r0 ; hexadecimal | ||

+ | mov #'A,r0 ; ascii | ||

+ | </syntaxhighlight> | ||

+ | |||

=== Instructions === | === Instructions === | ||

Here is a rough translation for some of the PDP-11 instructions: | Here is a rough translation for some of the PDP-11 instructions: | ||

− | * - | + | * MOV src,dest - move source int dest register |

+ | * CLR, CLRB - move zero into register | ||

+ | * INC/DEC , incb/decb - Increase/decrease register | ||

+ | * ADD/SUB - Add/Sub in 16 bits | ||

+ | * ADC/SBC - Add and Subtract in 32 bits | ||

+ | * MUL - 16 (odd register) or 32 bit (even register) multiplication | ||

+ | * DIV - 32 bit division | ||

+ | * ROL/ROR/ASR/ASL - Bit Rol and Shift instructions for 16 bit register | ||

+ | * ASH/ASHC - Shift 32bit register pair left and right (depending on argument) | ||

+ | * CALL/RETURN - Call subroutine, return to PC | ||

+ | * JSR/RTS<reg> - Jump subroutine / Return to address in register | ||

+ | * BIT - Bit test (can be used for AND) | ||

+ | * SWAB - Swap bytes in a 16bit register | ||

+ | * SXT - Sign extend a 16bit register into a 32bit pari | ||

+ | * COM - Complement register (flip all bit) | ||

+ | * NEG - Flip all bits and add 1 (negative) | ||

+ | * XOR - Exclusive OR | ||

+ | * BIS - Logical OR | ||

+ | * BIC - Inverse Logical OR (can be used as an AND instruction if performing a COM (bitflip) command first) | ||

+ | |||

+ | === Testing and Branching === | ||

+ | The PDP-11 has many branch conditions: | ||

+ | * TST - test register and update flags | ||

+ | * CMP - compare register | ||

+ | * BLT - branch if smaller (signed) | ||

+ | * BGT - branch if greater (signed) | ||

+ | * BLE - branch if smaller or equal (signed) | ||

+ | * BLO - branch if smaller (unsigned) | ||

+ | * BHI - branch if greater (unsigned) | ||

+ | * BLOS - branch if smaller or equal (unsigned) | ||

+ | * BHIS - branch if greater or equal (unsigned) | ||

+ | * BEQ - will branch if Z is set (Branch if EQual) | ||

+ | * BNE - will branch if Z is not set (Branch if Not Equal) | ||

+ | * BVS will branch if overflow is set | ||

+ | * BVC will branch if overflow is clear | ||

+ | * BMI will branch if the value is negative (minus - N set) | ||

+ | * BPL will branch if the value is positive (plus - N clear) | ||

+ | * BCS will Branch if Carry is Set | ||

+ | * BCC will Branch if Carry is Clear | ||

+ | * BR - this will ALWAYS branch | ||

=== Learning PDP-11 Assembler === | === Learning PDP-11 Assembler === | ||

There are a couple of PDP-11 tutorials available online, but most of them are in russian. Here is a basic one: | There are a couple of PDP-11 tutorials available online, but most of them are in russian. Here is a basic one: | ||

− | * | + | * https://www.chibiakumas.com/pdp11/ |

== Electronika BK-0010 == | == Electronika BK-0010 == | ||

Line 41: | Line 96: | ||

=== Small demos with documented source code === | === Small demos with documented source code === | ||

− | * | + | * Mona Lisa for the BK-0010/11m https://www.pouet.net/prod.php?which=86820 |

=== Additional Resources === | === Additional Resources === |

## Latest revision as of 10:42, 8 April 2022

## Contents

## Introduction

Wanting to start sizecoding on a PDP-11 platforms like the BK-0010 and BK-0011m in this day and age can be tough, especially if you have not grown up with such a machine.

So here is a bit of help to get you started:

### Registers

The PDP-11's registers are ALL 16 bit.

**R0, R1, R2, R3, R4**
R5 (Often Used to remember the return address during calls)
SP (R6), PC (R7)
If an Even register number (R0,R2,R4) is used for certain commands (for example MUL)- the register and it's following will be used as a 32 bit pair when the result is returned

Assignment direction is left (source) to right (dest). Default number mode for the PDP-11 is Octal mode (base-8), but there is possible to use other modes as well

```
mov #777,r0 ; octal =default
mov #^b101,r0 ; binary
mov #^x0aa,r0 ; hexadecimal
mov #'A,r0 ; ascii
```

### Instructions

Here is a rough translation for some of the PDP-11 instructions:

- MOV src,dest - move source int dest register
- CLR, CLRB - move zero into register
- INC/DEC , incb/decb - Increase/decrease register
- ADD/SUB - Add/Sub in 16 bits
- ADC/SBC - Add and Subtract in 32 bits
- MUL - 16 (odd register) or 32 bit (even register) multiplication
- DIV - 32 bit division
- ROL/ROR/ASR/ASL - Bit Rol and Shift instructions for 16 bit register
- ASH/ASHC - Shift 32bit register pair left and right (depending on argument)
- CALL/RETURN - Call subroutine, return to PC
- JSR/RTS<reg> - Jump subroutine / Return to address in register
- BIT - Bit test (can be used for AND)
- SWAB - Swap bytes in a 16bit register
- SXT - Sign extend a 16bit register into a 32bit pari
- COM - Complement register (flip all bit)
- NEG - Flip all bits and add 1 (negative)
- XOR - Exclusive OR
- BIS - Logical OR
- BIC - Inverse Logical OR (can be used as an AND instruction if performing a COM (bitflip) command first)

### Testing and Branching

The PDP-11 has many branch conditions:

- TST - test register and update flags
- CMP - compare register
- BLT - branch if smaller (signed)
- BGT - branch if greater (signed)
- BLE - branch if smaller or equal (signed)
- BLO - branch if smaller (unsigned)
- BHI - branch if greater (unsigned)
- BLOS - branch if smaller or equal (unsigned)
- BHIS - branch if greater or equal (unsigned)
- BEQ - will branch if Z is set (Branch if EQual)
- BNE - will branch if Z is not set (Branch if Not Equal)
- BVS will branch if overflow is set
- BVC will branch if overflow is clear
- BMI will branch if the value is negative (minus - N set)
- BPL will branch if the value is positive (plus - N clear)
- BCS will Branch if Carry is Set
- BCC will Branch if Carry is Clear
- BR - this will ALWAYS branch

### Learning PDP-11 Assembler

There are a couple of PDP-11 tutorials available online, but most of them are in russian. Here is a basic one:

## Electronika BK-0010

The Electronika BK-0010 is a 16-bit PDP-11-compatible fanless Soviet home computers developed under the Electronika brand by NPO Scientific Center, the leading Soviet microcomputer design team at the time. It was also the predecessor of the more powerful UKNC and DVK micros.

### Setting up

Setting up your development platform for the BK-0010/BK-0011m machine works as follows:

- Assembler: https://github.com/imachug/PDPy11
- Emulator: http://sandro.pdp-11.ru

### Video display

Video display

### Memory Map

To be added.

#### Getting something on screen

Now to get something on screen, lets fill our colorram with a simple AND pattern, like so:

```
to be added
```

### Sound

To be added.

### Small demos with documented source code

- Mona Lisa for the BK-0010/11m https://www.pouet.net/prod.php?which=86820

### Additional Resources

I found resources on BK-0010 sizecoding in english to be sparse.

- Good book to start BK-0010 programming http://www.translatetheweb.com/?from=&to=en&ref=TVert&dl=en&rr=DC&a=http%3a%2f%2fgid.pdp-11.ru%2fbooks%2fprogramming_BK10.html
- BK0010 ROM, system, etc http://www.translatetheweb.com/?from=&to=en&ref=TVert&dl=en&rr=DC&a=http%3a%2f%2fgid.pdp-11.ru%2fbooks%2f00001-01.32.03.html
- BK-0011M Information https://www.translatetheweb.com/?ref=TVert&from=&to=en&a=http%3A%2F%2Fgid.pdp-11.ru%2Fbooks%2F00015-01.32.01.html
- List of PDP-11 resources (Russian) http://gid.pdp-11.ru/doclist.html