• 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

    #81
    Originally posted by AtW View Post
    I just had to spend an hour trying to locate decent assembler, had to settle on Turbo Assembler
    I'm using debug and Notepad in a virtual machine on my Mac

    Comment


      #82
      Originally posted by NickFitz View Post
      I'm using debug and Notepad in a virtual machine on my Mac
      I am NOT ****ing using debug!

      The ****ing program is buggy as heck - instead of killing zombies in L4D 2 I am doing this tulip now

      Comment


        #83
        Tidied up, redundant line removed; 53 bytes, sets the screen mode at the start, completes the most significant digit, still stops having rolled over to zero rather than at 999..9, still doing only ten digits (change lines 7 and 9 for more or less):

        Code:
        mov ax,2
        int 10
        mov ax,b800
        mov ds,ax
        mov es,ax
        mov ax,0730
        xor di,di
        mov cx,0a
        rep stosw
        mov di,12
        mov al,[di]
        inc al
        cmp al,3a
        je 125
        mov [di],al
        jmp 116
        mov al,30
        mov [di],al
        sub di,2
        js 130
        jmp 119
        mov ax,4c00
        int 21

        Comment


          #84
          Originally posted by AtW View Post
          I am NOT ****ing using debug!

          The ****ing program is buggy as heck - instead of killing zombies in L4D 2 I am doing this tulip now
          More excuses - remember the constraints!

          Comment


            #85
            Originally posted by NickFitz View Post
            Tidied up, redundant line removed; 53 bytes, sets the screen mode at the start, completes the most significant digit, still stops having rolled over to zero rather than at 999..9, still doing only ten digits (change lines 7 and 9 for more or less):

            Code:
            mov ax,2
            int 10
            mov ax,b800
            mov ds,ax
            mov es,ax
            mov ax,0730
            xor di,di
            mov cx,0a
            rep stosw
            mov di,12
            mov al,[di]
            inc al
            cmp al,3a
            je 125
            mov [di],al
            jmp 116
            mov al,30
            mov [di],al
            sub di,2
            js 130
            jmp 119
            mov ax,4c00
            int 21
            Well done. If you remember the original constraints you'll shave 5 bytes off the code. Use debug to set the mode for you.

            Nick, respect.

            Alexei, you blow goats!

            Comment


              #86
              ---------------------------
              MOV AX, 4C00h
              INT 21h ; DOS Function Call
              ---------------------------

              RET

              will work so long as stack is not buggered, this should be like what 6 bytes reduction?

              Comment


                #87
                Originally posted by AtW View Post
                ---------------------------
                MOV AX, 4C00h
                INT 21h ; DOS Function Call
                ---------------------------

                RET

                will work so long as stack is not buggered, this should be like what 6 bytes reduction?
                Alexei you've done f**k al apart from bitch about the tools, insult me and crib from Nick. You still blow goats.

                If you had any ability you'd have risen to the challenge last night instead of gobbing off like a twat.

                Do you seriously think that I don't have an optimised version of that code?

                Nick, well done!

                AtW you've shown yourself up!

                Comment


                  #88
                  Originally posted by AtW View Post
                  ---------------------------
                  MOV AX, 4C00h
                  INT 21h ; DOS Function Call
                  ---------------------------

                  RET

                  will work so long as stack is not buggered, this should be like what 6 bytes reduction?
                  Well, the DOS call takes care of some houskeeping that might be required by certain execution contexts, such as DOS shells that mimic task switching and so forth (like Win3.1):
                  - restores the terminate, ~Ctrl-Break~, and critical error exit addresses, flushes all buffers, frees memory and returns to DOS via the termination handler address.

                  - http://www.htl-steyr.ac.at/~morg/pci...s/inte835c.htm

                  Also, AL contains the return code, which would be useful if this was being run from a batch file which wanted to take some special action in the event of abnormal termination.

                  Comment


                    #89
                    Nick, don't forget that debug sets the correct display mode as a side effect so you can shave the first 5 bytes and still be safe. That was in the constraints

                    Comment


                      #90
                      Originally posted by NickFitz View Post
                      Well, the DOS call takes care of some houskeeping that might be required by certain execution contexts, such as DOS shells that mimic task switching and so forth (like Win3.1):
                      - restores the terminate, ~Ctrl-Break~, and critical error exit addresses, flushes all buffers, frees memory and returns to DOS via the termination handler address.

                      - http://www.htl-steyr.ac.at/~morg/pci...s/inte835c.htm

                      Also, AL contains the return code, which would be useful if this was being run from a batch file which wanted to take some special action in the event of abnormal termination.
                      It's valid optimisation - the program did what was required and terminated, return error codes are not required in the original spec and looking at what it does also does not require such return code.

                      Stand by for me posting version of working code that is only 42 bytes long

                      Comment

                      Working...
                      X