Jump to content

User:RastaKins/sandbox2: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 1: Line 1:
==Instruction Set==
{| class="infobox" style="font-size:88%;width:38em;"
The LGP-30 has 16 instructions. Each instruction occupies a 31-bit word though about half the bits are unused and set to zero. An instruction consists of an "order" such as the letter b for "bring from memory" and an address part such as the number 2000 to designate a memory location. All instructions have a similar appearance in an LGP-30 word. The order bits occupy positions 12 through 15 of the word and the address bits occupy positions 18 through 29 of the word. The address bits are further divided by track and sector. Although all instructions have an address, some do not use the address. It is customary to enter an address of 0000 in these instructions.<ref>{{cite book |title=Royal Precision Electronic Computer LGP - 30 Programming Manual |date=April 1957 |publisher=Royal Precision |location=Port Chester, New York |url=https://ed-thelen.org/comp-hist/lgp-30-man.html |access-date=19 November 2023}}</ref>

{|style="text-align:center;"
|style="width:15px;"|00
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|11
|style="width:15px;"|12
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|15
|style="width:15px;"|16
|style="width:15px;"|17
|style="width:15px;"|18
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|23
|style="width:15px;"|24
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|
|style="width:15px;"|29
|style="width:15px;"|30
|-
|-
|colspan="12" style="background-color:#CCC;"|000000000000
|+ Atmel AVR registers
|colspan="4" style="background-color:#99F;"|Order
|colspan="2" style="background-color:#CCC;"|00
|colspan="6" style="background-color:#9F9;"|Track
|colspan="6" style="background-color:#9C9;"|Sector
|colspan="1" style="background-color:#CCC;"|0
|}

{|class="wikitable"
!Example || Order || Operation
|-
|-
!b 2000
|
|0001 || <code>Bring from Memory:</code> Replace the contents of the accumulator with the contents of memory location 2000. The contents of memory location 2000 is unaffected.
{| style="font-size:88%;"
|-
|-
!h 2000
| style="width:10px; text-align:center;"| <sup>2</sup><sub>1</sub>
|1100 || <code>Hold and Store:</code> Replace the contents of memory location 2000 with the contents of the accumulator. The contents of the accumulator is unaffected.
| style="width:10px; text-align:center;"| <sup>2</sup><sub>0</sub>
| style="width:10px; text-align:center;"| <sup>1</sup><sub>9</sub>
| style="width:10px; text-align:center;"| <sup>1</sup><sub>8</sub>
| style="width:10px; text-align:center;"| <sup>1</sup><sub>7</sub>
| style="width:10px; text-align:center;"| <sup>1</sup><sub>6</sub>
| style="width:10px; text-align:center;"| <sup>1</sup><sub>5</sub>
| style="width:10px; text-align:center;"| <sup>1</sup><sub>4</sub>
| style="width:10px; text-align:center;"| <sup>1</sup><sub>3</sub>
| style="width:10px; text-align:center;"| <sup>1</sup><sub>2</sub>
| style="width:10px; text-align:center;"| <sup>1</sup><sub>1</sub>
| style="width:10px; text-align:center;"| <sup>1</sup><sub>0</sub>
| style="width:10px; text-align:center;"| <sup>0</sup><sub>9</sub>
| style="width:10px; text-align:center;"| <sup>0</sup><sub>8</sub>
| style="width:10px; text-align:center;"| <sup>0</sup><sub>7</sub>
| style="width:10px; text-align:center;"| <sup>0</sup><sub>6</sub>
| style="width:10px; text-align:center;"| <sup>0</sup><sub>5</sub>
| style="width:10px; text-align:center;"| <sup>0</sup><sub>4</sub>
| style="width:10px; text-align:center;"| <sup>0</sup><sub>3</sub>
| style="width:10px; text-align:center;"| <sup>0</sup><sub>2</sub>
| style="width:10px; text-align:center;"| <sup>0</sup><sub>1</sub>
| style="width:10px; text-align:center;"| <sup>0</sup><sub>0</sub>
| style="width:auto; background:white; color:black" | ''(bit position)''
|-
|-
!c 2000
|colspan="21" | '''Main registers''' <br />
|1101 || <code>Clear and Store:</code> Replace the contents of memory location 2000 with the contents of the accumulator and replace the contents of the accumulator with zero.
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R1
| style="text-align:center;" colspan="8"| R0
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R3
| style="text-align:center;" colspan="8"| R2
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R5
| style="text-align:center;" colspan="8"| R4
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R7
| style="text-align:center;" colspan="8"| R6
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R9
| style="text-align:center;" colspan="8"| R8
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R11
| style="text-align:center;" colspan="8"| R10
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R13
| style="text-align:center;" colspan="8"| R12
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R15
| style="text-align:center;" colspan="8"| R14
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R17
| style="text-align:center;" colspan="8"| R16
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R19
| style="text-align:center;" colspan="8"| R18
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R21
| style="text-align:center;" colspan="8"| R20
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R23
| style="text-align:center;" colspan="8"| R22
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R25
| style="text-align:center;" colspan="8"| R24
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R27
| style="text-align:center;" colspan="8"| R26
| style="background:white; color:black;"| '''X''' (pointer)
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R29
| style="text-align:center;" colspan="8"| R28
| style="background:white; color:black;"| '''Y''' (pointer)
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| R31
| style="text-align:center;" colspan="8"| R30
| style="background:white; color:black;"| '''Z''' (pointer)
|-
|colspan="21" | '''Stack pointer''' <br />
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="6"| &nbsp;
| style="text-align:center;" colspan="8"| SPH
| style="text-align:center;" colspan="8"| SPL
| style="background:white; color:black;"| [[Call stack|'''S'''tack '''P'''ointer]]
|-
|-
!y 2000
|colspan="21" | '''Program counter''' <br />
|0010 || <code>Store Address:</code> Replace the contents of the address portion of the word in memory location 2000 with the contents of the address portion of the word in the accumulator. The contents of the accumulator is unaffected. THE LGB-30 has no index register. Y can be used to index an array.
|- style="background:silver;color:black"
| style="text-align:center;" colspan="22"| PC
| style="background:white; color:black;"| [[Program counter|'''P'''rogram '''C'''counter]]
|-
|-
!u 2000
|colspan="21" | '''Extended memory''' <br />
|1010 || <code>Unconditional transfer:</code> Replace the number in the (program) counter register with the contents of the address portion of the unconditional transfer instruction.
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="14"| &nbsp;
| style="text-align:center;" colspan="8"| RAMPZ
| style="background:white; color:black;"| Extended Z
|- style="background:silver;color:black"
| style="text-align:center; background:white" colspan="14"| &nbsp;
| style="text-align:center;" colspan="8"| EIND
| style="background:white; color:black;"| Extended indirect
|-
|-
!r 2000

|0011 || <code>Return address:</code> Add one to the contents of the counter register and replace the address portion of memory location 2000 with the contents of the counter register. This instruction is used to patch an "unconditional transfer" instruction at the end of a subroutine to force it to return to the caller.

|-
|colspan="21" | '''Status register'''
!t 2000
|- style="background:silver;color:black"
|1011 || <code>Test:</code> (Conditional transfer) If a one is in the sign bit of the word in the accumulator, the test instruction has the effect of an unconditional transfer. If a zero is in the sign bit of the word in the accumulator, the next following instruction in normal sequence is executed.
| style="text-align:center; background:white" colspan="14"| &nbsp;
|-
| style="text-align:center;"| [[Interrupt flag|I]]
!z 0000
| style="text-align:center;"| T
|0000 || <code>Stop:</code> Stop computation. If computation is to stop, the address portion of the stop instruction is usually of no significance. However, the stop order has a special characteristic. If there is a one in the third bit from the right hand end of the track portion of a stop instruction, computation does not stop if break point switch 4 on the console of the computer is depressed. Four break point switches are supported by the Z instruction.
| style="text-align:center;"| [[Half-carry flag|H]]
|-
| style="text-align:center;"| [[Sign flag|S]]
!p 2000
| style="text-align:center;"| [[Overflow flag|V]]
|1000 || <code>Print:</code> Execute the typewriter keyboard function indicated by the 6 track bits. The print order has no effect on the contents of any memory location, the accumulator, or the counter register. For example, p 2000 has 010100 in the track bits which is the code for a back space on the typewriter. The execution of p 2000 results in the typewriter back spacing.
| style="text-align:center;"| [[Sign flag|N]]
|-
| style="text-align:center;"| [[Zero flag|Z]]
!i 0000
| style="text-align:center;"| [[Carry flag|C]]
|0100 || <code>Input:</code> The address portion of the instruction constructed from this order is always 0000. It is always preceded by the instruction p 0000. After a p 0000 instruction starts the tape reader, an i 0000 instruction transfers into the last 4 bit positions of the accumulator the first 4 bits of the typewriter code for the first character read on the tape. When the second character is read, the bits representing the first character are shifted left into the next to last four bit positions of the accumulator and the first four bits of the typewriter code of the second character on tape are placed in the last four bit positions of the accumulator. This process continues up to eight times to fill the entire accumulator until a stop code (100000) appears on the tape. The stop code stops the tape reader and sends a start signal to the computer so that the instruction following i 0000 in memory is executed. Often this next instruction is a h or c instruction so that the characters read into the accumulator can be stored in some memory location.
| style="background:white; color:black" | SREG
|-

!a 2000
|}
|1110 || <code>Add:</code> Add the contents of memory location 2000 to the contents of the accumulator and place the result in the accumulator. The contents of memory location 2000 is unaffected.
|-
!s 2000
|1111 || <code>Subtract:</code> Add the contents of memory location 2000 to the contents of the accumulator and place the result in the accumulator. The contents of memory location 2000 is unaffected.
|-
!m 2000
|0111 || <code>Multiply upper:</code> Multiply the number in the accumulator by the number in memory location 2000 and place the most significant thirty bits of the product in the accumulator. The contents of memory location 2000 is unaffected.
|-
!n 2000
|0110 || <code>Multiply lower:</code> Multiply the number in the accumulator by the number in memory location 2000 and place the least significant thirty-one magnitude bits of the product in the sign bit and thirty magnitude bits of the accumulator. The contents of memory location 2000 is unaffected.
|-
!d 2000
|0101 || <code>Divide:</code> Divide the number in the accumulator by the number in memory location 2000 and place the quotient rounded to thirty bits in the accumulator. The contents of memory location 2000 is unaffected.
|-
!e 2000
|1001 || <code>Extract:</code> Place zeroes in the word in the accumulator wherever there are zeroes in location 2000 but otherwise leave the word in the accumulator unchanged. The contents of location 2000 is unaffected. This is the equivalent of an [[bitwise and|AND]] instruction on most computers.
|}
|}

Revision as of 18:15, 19 November 2023

Instruction Set

The LGP-30 has 16 instructions. Each instruction occupies a 31-bit word though about half the bits are unused and set to zero. An instruction consists of an "order" such as the letter b for "bring from memory" and an address part such as the number 2000 to designate a memory location. All instructions have a similar appearance in an LGP-30 word. The order bits occupy positions 12 through 15 of the word and the address bits occupy positions 18 through 29 of the word. The address bits are further divided by track and sector. Although all instructions have an address, some do not use the address. It is customary to enter an address of 0000 in these instructions.[1]

00 11 12 15 16 17 18 23 24 29 30
000000000000 Order 00 Track Sector 0
Example Order Operation
b 2000 0001 Bring from Memory: Replace the contents of the accumulator with the contents of memory location 2000. The contents of memory location 2000 is unaffected.
h 2000 1100 Hold and Store: Replace the contents of memory location 2000 with the contents of the accumulator. The contents of the accumulator is unaffected.
c 2000 1101 Clear and Store: Replace the contents of memory location 2000 with the contents of the accumulator and replace the contents of the accumulator with zero.
y 2000 0010 Store Address: Replace the contents of the address portion of the word in memory location 2000 with the contents of the address portion of the word in the accumulator. The contents of the accumulator is unaffected. THE LGB-30 has no index register. Y can be used to index an array.
u 2000 1010 Unconditional transfer: Replace the number in the (program) counter register with the contents of the address portion of the unconditional transfer instruction.
r 2000 0011 Return address: Add one to the contents of the counter register and replace the address portion of memory location 2000 with the contents of the counter register. This instruction is used to patch an "unconditional transfer" instruction at the end of a subroutine to force it to return to the caller.
t 2000 1011 Test: (Conditional transfer) If a one is in the sign bit of the word in the accumulator, the test instruction has the effect of an unconditional transfer. If a zero is in the sign bit of the word in the accumulator, the next following instruction in normal sequence is executed.
z 0000 0000 Stop: Stop computation. If computation is to stop, the address portion of the stop instruction is usually of no significance. However, the stop order has a special characteristic. If there is a one in the third bit from the right hand end of the track portion of a stop instruction, computation does not stop if break point switch 4 on the console of the computer is depressed. Four break point switches are supported by the Z instruction.
p 2000 1000 Print: Execute the typewriter keyboard function indicated by the 6 track bits. The print order has no effect on the contents of any memory location, the accumulator, or the counter register. For example, p 2000 has 010100 in the track bits which is the code for a back space on the typewriter. The execution of p 2000 results in the typewriter back spacing.
i 0000 0100 Input: The address portion of the instruction constructed from this order is always 0000. It is always preceded by the instruction p 0000. After a p 0000 instruction starts the tape reader, an i 0000 instruction transfers into the last 4 bit positions of the accumulator the first 4 bits of the typewriter code for the first character read on the tape. When the second character is read, the bits representing the first character are shifted left into the next to last four bit positions of the accumulator and the first four bits of the typewriter code of the second character on tape are placed in the last four bit positions of the accumulator. This process continues up to eight times to fill the entire accumulator until a stop code (100000) appears on the tape. The stop code stops the tape reader and sends a start signal to the computer so that the instruction following i 0000 in memory is executed. Often this next instruction is a h or c instruction so that the characters read into the accumulator can be stored in some memory location.
a 2000 1110 Add: Add the contents of memory location 2000 to the contents of the accumulator and place the result in the accumulator. The contents of memory location 2000 is unaffected.
s 2000 1111 Subtract: Add the contents of memory location 2000 to the contents of the accumulator and place the result in the accumulator. The contents of memory location 2000 is unaffected.
m 2000 0111 Multiply upper: Multiply the number in the accumulator by the number in memory location 2000 and place the most significant thirty bits of the product in the accumulator. The contents of memory location 2000 is unaffected.
n 2000 0110 Multiply lower: Multiply the number in the accumulator by the number in memory location 2000 and place the least significant thirty-one magnitude bits of the product in the sign bit and thirty magnitude bits of the accumulator. The contents of memory location 2000 is unaffected.
d 2000 0101 Divide: Divide the number in the accumulator by the number in memory location 2000 and place the quotient rounded to thirty bits in the accumulator. The contents of memory location 2000 is unaffected.
e 2000 1001 Extract: Place zeroes in the word in the accumulator wherever there are zeroes in location 2000 but otherwise leave the word in the accumulator unchanged. The contents of location 2000 is unaffected. This is the equivalent of an AND instruction on most computers.
  1. ^ Royal Precision Electronic Computer LGP - 30 Programming Manual. Port Chester, New York: Royal Precision. April 1957. Retrieved 19 November 2023.