Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Clever Code
  4. ProjectEuler problem 24 solution - in PDP/8 assembly language

ProjectEuler problem 24 solution - in PDP/8 assembly language

Scheduled Pinned Locked Moved Clever Code
questioncsharppythonhelptutorial
7 Posts 5 Posters 29 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MrChug
    wrote on last edited by
    #1

    I solved this in PDP/8 assembly language PAL/8. It's a brute force loop unrolled for the /8. The answer is in octal so don't panic.

    .PAL E24,E24 E 20:31 / examine the answer
    20: 0002
    21: 0007
    22: 0010
    23: 0003
    24: 0011
    25: 0001
    26: 0005
    27: 0004
    30: 0006
    31: 0000
    sim> G 7600 / back to the monitor
    .

    Recent work for $(DAYJOB) has triggered memories of PDP/8, PAL/8, OS/8, FOTP, PIP, ODT, and the whole suite of stuff from the dark ages [1]. Here's my source code listing:

    .TYPE E24.LS

    / PROJECTEULER.NET PROBLEM 24 PAL8-V12B 02-NOV-77 PAGE 1

             / PROJECTEULER.NET PROBLEM 24
             /
             / A PERMUTATION IS AN ORDERED ARRANGEMENT OF OBJECTS.
             / FOR EXAMPLE, 3124 IS ONE POSSIBLE PERMUTATION OF
             / THE DIGITS 1, 2, 3 AND 4. IF ALL OF THE PERMUTATIONS
             / ARE LISTED NUMERICALLY OR ALPHABETICALLY,
             / WE CALL IT LEXICOGRAPHIC ORDER.
             / THE LEXICOGRAPHIC PERMUTATIONS OF 0, 1 AND 2 ARE:
             /
             /     012   021   102   120   201   210
             /
             / WHAT IS THE MILLIONTH LEXICOGRAPHIC PERMUTATION
             / OF THE DIGITS 0, 1, 2, 3, 4, 5, 6, 7, 8 AND 9?
             /
             / PAL/8 DIGITAL EQUIPMENT CORPORATION (DEC) PDP/8
             / ASSEMBLY LANGUAGE SOLUTION BY CHUCK ROLKE, 2-NOV-2011
             /
       0010          \*10
    

    00010 0000 CHKPTR, 0

       0020          \*20
                                             / SOLUTION IS CONSTRUCTED HERE
    

    00020 0000 D0, 0
    00021 0000 D1, 0
    00022 0000 D2, 0
    00023 0000 D3, 0
    00024 0000 D4, 0
    00025 0000 D5, 0
    00026 0000 D6, 0
    00027 0000 D7, 0
    00030 0000 D8, 0
    00031 0000 D9, 0
    / COUNTERS
    00032 0000 C0, 0
    00033 0000 C1, 0
    00034 0000 C2, 0
    00035 0000 C3, 0
    00036 0000 C4, 0
    00037 0000 C5, 0
    00040 0000 C6, 0
    00041 0000 C7, 0
    00042 0000 C8, 0
    00043 0000 C9, 0
    / SUBR POINTERS
    00044 0202 PTR0, S0
    00045 0215 PTR1, S1
    00046 0233 PTR2, S2
    00047 0251 PTR3, S3
    00050 0267 PTR4, S4
    00051 0305 PTR5, S5
    00052 0323 PTR6, S6
    00053 0341 PTR7, S7
    00054 0400 PTR8, S8
    00055 0416 PTR9, S9

    J L M 3 Replies Last reply
    0
    • M MrChug

      I solved this in PDP/8 assembly language PAL/8. It's a brute force loop unrolled for the /8. The answer is in octal so don't panic.

      .PAL E24,E24 E 20:31 / examine the answer
      20: 0002
      21: 0007
      22: 0010
      23: 0003
      24: 0011
      25: 0001
      26: 0005
      27: 0004
      30: 0006
      31: 0000
      sim> G 7600 / back to the monitor
      .

      Recent work for $(DAYJOB) has triggered memories of PDP/8, PAL/8, OS/8, FOTP, PIP, ODT, and the whole suite of stuff from the dark ages [1]. Here's my source code listing:

      .TYPE E24.LS

      / PROJECTEULER.NET PROBLEM 24 PAL8-V12B 02-NOV-77 PAGE 1

               / PROJECTEULER.NET PROBLEM 24
               /
               / A PERMUTATION IS AN ORDERED ARRANGEMENT OF OBJECTS.
               / FOR EXAMPLE, 3124 IS ONE POSSIBLE PERMUTATION OF
               / THE DIGITS 1, 2, 3 AND 4. IF ALL OF THE PERMUTATIONS
               / ARE LISTED NUMERICALLY OR ALPHABETICALLY,
               / WE CALL IT LEXICOGRAPHIC ORDER.
               / THE LEXICOGRAPHIC PERMUTATIONS OF 0, 1 AND 2 ARE:
               /
               /     012   021   102   120   201   210
               /
               / WHAT IS THE MILLIONTH LEXICOGRAPHIC PERMUTATION
               / OF THE DIGITS 0, 1, 2, 3, 4, 5, 6, 7, 8 AND 9?
               /
               / PAL/8 DIGITAL EQUIPMENT CORPORATION (DEC) PDP/8
               / ASSEMBLY LANGUAGE SOLUTION BY CHUCK ROLKE, 2-NOV-2011
               /
         0010          \*10
      

      00010 0000 CHKPTR, 0

         0020          \*20
                                               / SOLUTION IS CONSTRUCTED HERE
      

      00020 0000 D0, 0
      00021 0000 D1, 0
      00022 0000 D2, 0
      00023 0000 D3, 0
      00024 0000 D4, 0
      00025 0000 D5, 0
      00026 0000 D6, 0
      00027 0000 D7, 0
      00030 0000 D8, 0
      00031 0000 D9, 0
      / COUNTERS
      00032 0000 C0, 0
      00033 0000 C1, 0
      00034 0000 C2, 0
      00035 0000 C3, 0
      00036 0000 C4, 0
      00037 0000 C5, 0
      00040 0000 C6, 0
      00041 0000 C7, 0
      00042 0000 C8, 0
      00043 0000 C9, 0
      / SUBR POINTERS
      00044 0202 PTR0, S0
      00045 0215 PTR1, S1
      00046 0233 PTR2, S2
      00047 0251 PTR3, S3
      00050 0267 PTR4, S4
      00051 0305 PTR5, S5
      00052 0323 PTR6, S6
      00053 0341 PTR7, S7
      00054 0400 PTR8, S8
      00055 0416 PTR9, S9

      J Offline
      J Offline
      Julien Villers
      wrote on last edited by
      #2

      Any idea how much time this would take on a real PDP/8?

      'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail

      M 1 Reply Last reply
      0
      • J Julien Villers

        Any idea how much time this would take on a real PDP/8?

        'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail

        M Offline
        M Offline
        MrChug
        wrote on last edited by
        #3

        About 40 minutes. The simulator indicates 825,000,000 instructions. At, say, 0.33 mips it takes a while.

        They will never have seen anything like us them there. - M. Spirito

        1 Reply Last reply
        0
        • M MrChug

          I solved this in PDP/8 assembly language PAL/8. It's a brute force loop unrolled for the /8. The answer is in octal so don't panic.

          .PAL E24,E24 E 20:31 / examine the answer
          20: 0002
          21: 0007
          22: 0010
          23: 0003
          24: 0011
          25: 0001
          26: 0005
          27: 0004
          30: 0006
          31: 0000
          sim> G 7600 / back to the monitor
          .

          Recent work for $(DAYJOB) has triggered memories of PDP/8, PAL/8, OS/8, FOTP, PIP, ODT, and the whole suite of stuff from the dark ages [1]. Here's my source code listing:

          .TYPE E24.LS

          / PROJECTEULER.NET PROBLEM 24 PAL8-V12B 02-NOV-77 PAGE 1

                   / PROJECTEULER.NET PROBLEM 24
                   /
                   / A PERMUTATION IS AN ORDERED ARRANGEMENT OF OBJECTS.
                   / FOR EXAMPLE, 3124 IS ONE POSSIBLE PERMUTATION OF
                   / THE DIGITS 1, 2, 3 AND 4. IF ALL OF THE PERMUTATIONS
                   / ARE LISTED NUMERICALLY OR ALPHABETICALLY,
                   / WE CALL IT LEXICOGRAPHIC ORDER.
                   / THE LEXICOGRAPHIC PERMUTATIONS OF 0, 1 AND 2 ARE:
                   /
                   /     012   021   102   120   201   210
                   /
                   / WHAT IS THE MILLIONTH LEXICOGRAPHIC PERMUTATION
                   / OF THE DIGITS 0, 1, 2, 3, 4, 5, 6, 7, 8 AND 9?
                   /
                   / PAL/8 DIGITAL EQUIPMENT CORPORATION (DEC) PDP/8
                   / ASSEMBLY LANGUAGE SOLUTION BY CHUCK ROLKE, 2-NOV-2011
                   /
             0010          \*10
          

          00010 0000 CHKPTR, 0

             0020          \*20
                                                   / SOLUTION IS CONSTRUCTED HERE
          

          00020 0000 D0, 0
          00021 0000 D1, 0
          00022 0000 D2, 0
          00023 0000 D3, 0
          00024 0000 D4, 0
          00025 0000 D5, 0
          00026 0000 D6, 0
          00027 0000 D7, 0
          00030 0000 D8, 0
          00031 0000 D9, 0
          / COUNTERS
          00032 0000 C0, 0
          00033 0000 C1, 0
          00034 0000 C2, 0
          00035 0000 C3, 0
          00036 0000 C4, 0
          00037 0000 C5, 0
          00040 0000 C6, 0
          00041 0000 C7, 0
          00042 0000 C8, 0
          00043 0000 C9, 0
          / SUBR POINTERS
          00044 0202 PTR0, S0
          00045 0215 PTR1, S1
          00046 0233 PTR2, S2
          00047 0251 PTR3, S3
          00050 0267 PTR4, S4
          00051 0305 PTR5, S5
          00052 0323 PTR6, S6
          00053 0341 PTR7, S7
          00054 0400 PTR8, S8
          00055 0416 PTR9, S9

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Nice. I created some PDP assembly code around the same time, some was PDP/8, the majority was PDP/11. Two remarks though: 1. there are more clever ways to do this, they are faster and smarter than simple brute force. 2. Project Euler asks its visitors not to discuss nor disclose a solution, except within the group of members that already solved the particular problem. :)

          Luc Pattyn [My Articles] Nil Volentibus Arduum

          J 1 Reply Last reply
          0
          • L Luc Pattyn

            Nice. I created some PDP assembly code around the same time, some was PDP/8, the majority was PDP/11. Two remarks though: 1. there are more clever ways to do this, they are faster and smarter than simple brute force. 2. Project Euler asks its visitors not to discuss nor disclose a solution, except within the group of members that already solved the particular problem. :)

            Luc Pattyn [My Articles] Nil Volentibus Arduum

            J Offline
            J Offline
            Julien Villers
            wrote on last edited by
            #5

            Luc Pattyn wrote:

            2. Project Euler asks its visitors not to discuss nor disclose a solution, except within the group of members that already solved the particular problem.

            Well, a brute force, however optimized, 40 minutes run on an obscure* platform isn't quite a 'solution' to a Project Euler problem, is it? ;) * sorry for actual PDP programmers (aka 'old timers' ;p), it's now quite obscure.

            'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail

            B 1 Reply Last reply
            0
            • M MrChug

              I solved this in PDP/8 assembly language PAL/8. It's a brute force loop unrolled for the /8. The answer is in octal so don't panic.

              .PAL E24,E24 E 20:31 / examine the answer
              20: 0002
              21: 0007
              22: 0010
              23: 0003
              24: 0011
              25: 0001
              26: 0005
              27: 0004
              30: 0006
              31: 0000
              sim> G 7600 / back to the monitor
              .

              Recent work for $(DAYJOB) has triggered memories of PDP/8, PAL/8, OS/8, FOTP, PIP, ODT, and the whole suite of stuff from the dark ages [1]. Here's my source code listing:

              .TYPE E24.LS

              / PROJECTEULER.NET PROBLEM 24 PAL8-V12B 02-NOV-77 PAGE 1

                       / PROJECTEULER.NET PROBLEM 24
                       /
                       / A PERMUTATION IS AN ORDERED ARRANGEMENT OF OBJECTS.
                       / FOR EXAMPLE, 3124 IS ONE POSSIBLE PERMUTATION OF
                       / THE DIGITS 1, 2, 3 AND 4. IF ALL OF THE PERMUTATIONS
                       / ARE LISTED NUMERICALLY OR ALPHABETICALLY,
                       / WE CALL IT LEXICOGRAPHIC ORDER.
                       / THE LEXICOGRAPHIC PERMUTATIONS OF 0, 1 AND 2 ARE:
                       /
                       /     012   021   102   120   201   210
                       /
                       / WHAT IS THE MILLIONTH LEXICOGRAPHIC PERMUTATION
                       / OF THE DIGITS 0, 1, 2, 3, 4, 5, 6, 7, 8 AND 9?
                       /
                       / PAL/8 DIGITAL EQUIPMENT CORPORATION (DEC) PDP/8
                       / ASSEMBLY LANGUAGE SOLUTION BY CHUCK ROLKE, 2-NOV-2011
                       /
                 0010          \*10
              

              00010 0000 CHKPTR, 0

                 0020          \*20
                                                       / SOLUTION IS CONSTRUCTED HERE
              

              00020 0000 D0, 0
              00021 0000 D1, 0
              00022 0000 D2, 0
              00023 0000 D3, 0
              00024 0000 D4, 0
              00025 0000 D5, 0
              00026 0000 D6, 0
              00027 0000 D7, 0
              00030 0000 D8, 0
              00031 0000 D9, 0
              / COUNTERS
              00032 0000 C0, 0
              00033 0000 C1, 0
              00034 0000 C2, 0
              00035 0000 C3, 0
              00036 0000 C4, 0
              00037 0000 C5, 0
              00040 0000 C6, 0
              00041 0000 C7, 0
              00042 0000 C8, 0
              00043 0000 C9, 0
              / SUBR POINTERS
              00044 0202 PTR0, S0
              00045 0215 PTR1, S1
              00046 0233 PTR2, S2
              00047 0251 PTR3, S3
              00050 0267 PTR4, S4
              00051 0305 PTR5, S5
              00052 0323 PTR6, S6
              00053 0341 PTR7, S7
              00054 0400 PTR8, S8
              00055 0416 PTR9, S9

              M Offline
              M Offline
              Michael Kingsford Gray
              wrote on last edited by
              #6

              You just put me in "The Wayback Machine" & selected 1976! When programmers were REAL programmers. No keyboards. Just bit-switch panels. And graphics rendered on oscilloscopes!

              1 Reply Last reply
              0
              • J Julien Villers

                Luc Pattyn wrote:

                2. Project Euler asks its visitors not to discuss nor disclose a solution, except within the group of members that already solved the particular problem.

                Well, a brute force, however optimized, 40 minutes run on an obscure* platform isn't quite a 'solution' to a Project Euler problem, is it? ;) * sorry for actual PDP programmers (aka 'old timers' ;p), it's now quite obscure.

                'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail

                B Offline
                B Offline
                Bill_Hallahan
                wrote on last edited by
                #7

                Julien Villers wrote:

                Well, a brute force, however optimized, 40 minutes run on an obscure* platform isn't quite a 'solution' to a Project Euler problem, is it? ;)

                If the code solves the problem on the obscure platform, then it is a solution to the problem.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups