• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Code Puzzle

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Originally posted by AtW View Post
    I moved one register load outside of loop - so I'd say I gained performance and spent it wisely on making file size smaller
    Yes, but you can still gain even more performance at the cost of one byte: I'd say it's a no-brainer, given that that code is going to execute, what, 20 trillion times? Probably something like 16!, anyway

    Assuming we move on from an 8MHz 8086 to something where it's saving one cycle on a machine running at 5GHz, you'll save over an hour

    Comment


      Originally posted by NickFitz View Post
      Yes, but you can still gain even more performance at the cost of one byte: I'd say it's a no-brainer, given that that code is going to execute, what, 20 trillion times? Something like 16!, anyway

      Assuming we move on from an 8MHz 8086 to something where it's saving one cycle on a machine running at 5GHz, you'll save over an hour
      At that time I was optimising primarily for size, typically it's either speed or size, rarely both.

      As I said I took one constant assigned from the loop, so I improved speed of it, then I potentially (depending on CPU) sacrified it by changing to 2 dec's rather than 1 sub.

      Since this program is completely retarded in its function the main optimisation target should be size really, it's not like it's doing any useful time sensitive operation.

      Comment


        Frankly on old CPUs branch prediction was non existant, so excessive branching in this loop was probably the main performance killer anyway - that and writing directly into memory instead of calculating data in registers and then writing it once into memory.

        Comment


          Originally posted by Churchill View Post
          Ffs
          WTF are those requirements??!?!

          Anyone seen them in writing?!??!!

          Comment


            Nick, Churchy seems to have gone a bit quiet now AtW has submitted some code. Can you verify for those of us who can't tell, if it is a valid submission?
            Originally posted by MaryPoppins
            I'd still not breastfeed a nazi
            Originally posted by vetran
            Urine is quite nourishing

            Comment


              Code from debug disassembly:

              Code:
              0100 B800B8        MOV     AX,B800
              0103 CD10          INT     10
              0105 8ED8          MOV     DS,AX
              0107 8EC0          MOV     ES,AX
              0109 B83007        MOV     AX,0730
              010C 33FF          XOR     DI,DI
              010E B90A00        MOV     CX,000A
              0111 F3            REPZ
              0112 AB            STOSW
              0113 B230          MOV     DL,30
              0115 BF1200        MOV     DI,0012
              0118 8A05          MOV     AL,[DI]
              011A 40            INC     AX
              011B 3C3A          CMP     AL,3A
              011D 7404          JZ      0123
              011F 8805          MOV     [DI],AL
              0121 EBF2          JMP     0115
              0123 8815          MOV     [DI],DL
              0125 4F            DEC     DI
              0126 4F            DEC     DI
              0127 79EF          JNS     0118
              0129 C3            RET

              Comment


                I was slow with the test please delete thread. I'd like to register an early post here. To be fair I have no idea what this thread is about as I only write commercial code, but as I feel this is going to run and run , I would like to predict that atw wins the argument in 2056 when Churchill eventually gives up when corks it in the old peoples home at the age of 99. Atw will then have a heart attack as he realises that Churchill was right after all and andyws grandson posts the ten millionth reply to the guineas book of records most tedious bulletin board thread in three galaxies!
                What happens in General, stays in General.
                You know what they say about assumptions!

                Comment


                  Originally posted by d000hg View Post
                  Nick, Churchy seems to have gone a bit quiet now AtW has submitted some code. Can you verify for those of us who can't tell, if it is a valid submission?
                  Looks OK, but I haven't checked and I'm out at the mo - give me a few minutes to copy it into my notebook (a paper one...) and I'll hand-execute it to check

                  Comment


                    Originally posted by MarillionFan View Post
                    I only write commercial code
                    Code? You write code? I was pretty sure you were reporting monkey - shush from the thread when real programming languages are used!

                    Comment


                      Well, AtW's code seems fine, apart from the mode setting (line 2) which looks like a sneaky hack - I'd want some confirmation that it works reliably before putting that into production.

                      Apart from that, a very nice bit of work

                      Comment

                      Working...
                      X