• 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

    #71
    Originally posted by Churchill View Post
    Good lad!
    Mind you, is it worth saving 237 years when we're so heavily bound by the cost of display RAM I/O?

    Comment


      #72
      Originally posted by NickFitz View Post
      Mind you, is it worth saving 237 years when we're so heavily bound by the cost of display RAM I/O?
      Well, considering that it's not really display memory that it's accessing if you run it under XP etc. wgas?

      Comment


        #73
        A couple of additional points: the second assignment of a value to cx is a waste of space, as the register is never used after that point; and it terminates with a display of all zeros rather than all nines.

        Comment


          #74
          Originally posted by Churchill View Post
          Good lad! However, it don't work... You've broked it. You've not got the 5 bytes on the front that set the display mode.
          I didn't bother with that as it was working for me in a command prompt window; however, it makes sense to add that back in, making 61 bytes.

          If you don't mind setting the character attributes as well (7 is the default value) then the whole of the first part (i.e. up to but not including mov di,1e) can be replaced with:

          Code:
          mov ax,b800
          mov ds,ax
          mov es, ax
          mov ax,0730
          xor di,di
          mov cx,10
          rep stosw

          Comment


            #75
            Originally posted by Churchill View Post
            Quoted
            And welched on
            I'd love to play but I only ever did Motorola assembly language (eee, now that were proper programming lad)
            +50 Xeno Geek Points
            Come back Toolpusher, scotspine, Voodooflux. Pogle
            As for the rest of you - DILLIGAF

            Purveyor of fine quality smut since 2005

            CUK Olympic University Challenge Champions 2010/2012

            Comment


              #76
              Originally posted by Churchill View Post
              Thanks Nick, modified as follows...

              Code:
              A 100
              mov ax,2
              int 10
              mov ax,b800
              mov ds,ax
              mov ax,30
              xor di,di
              mov cx,f
              ds:
              mov [di],al
              inc di
              dec cx
              inc di
              cmp cx,0
              jne 113
              mov di,1E
              mov cx,10
              mov al,[di]
              inc al
              cmp al,3a
              je 12F
              mov [di],al
              jmp 11D
              mov al,30
              mov [di],al
              dec di
              dec di
              cmp di,0
              je 13C
              jmp 123
              mov ax,4c00
              int 21
              
              N test.COM
              RCX
              41
              W
              Q
              This one is 65 bytes and it actually works.

              Comment


                #77
                Originally posted by Churchill View Post
                If you follow the instructions you will find it obvious that the code hasn't hung.

                Code:
                ;********* File: test.com *************
                ;
                    code     SEGMENT
                             ASSUME CS:code, DS:code
                             ORG 100h
                  
                    strt:
                
                	MOV	AX ,0002h
                	INT	10				; Video Function Call
                	MOV	AX ,B800h
                	MOV	DS,AX
                	MOV	AX ,0030h
                	XOR	DI,DI
                	MOV	CX ,0010h
                	MOV	DS:[DI],AL
                	INC	DI 
                	INC	DI 
                	DEC	CX 
                	CMP	CX,+00h
                	JNZ	J00113
                J0011D: MOV	DI ,0020h
                	MOV	CX ,0010h
                J00123: MOV	AL,[DI]
                	INC	AL
                	CMP	AL,3Ah
                	JZ	J0012F
                	MOV	[DI],AL
                	JMP	J0011D
                J0012F: MOV	AL ,30h
                	MOV	[DI],AL
                	DEC	DI 
                	DEC	DI 
                	CMP	DI,+00h
                	JZ	J0013C
                	JMP	J00123
                J0013C: MOV	AX ,4C00h
                	INT	21				; DOS Function Call
                
                    code     ENDS
                             END  strt
                ->>> JNZ J00113

                J00113 label isn't specified in your source code, did you compile it?

                I just had to spend an hour trying to locate decent assembler, had to settle on Turbo Assembler

                Comment


                  #78
                  Originally posted by AtW View Post
                  This one is 65 bytes and it actually works.
                  Sadly not: it still has the fail-to-do-the-last-digit problem, by my tests

                  Latest version of mine, which also fails to stop at 99...9, but cut down to do ten digits in order to avoid having to wait for the heat death of the Universe:

                  Code:
                  MOV     AX,0002
                  INT     10
                  MOV     AX,B800
                  MOV     DS,AX
                  MOV     ES,AX
                  MOV     AX,0730
                  XOR     DI,DI
                  MOV     CX,000A
                  REP STOSW
                  MOV     DI,0012
                  MOV     CX,000B
                  MOV     AL,[DI]
                  INC     AL
                  CMP     AL,3A
                  JZ      0128
                  MOV     [DI],AL
                  JMP     0116
                  MOV     AL,30
                  MOV     [DI],AL
                  SUB     DI,+02
                  JS      0133
                  JMP     011C
                  MOV     AX,4C00
                  INT     21
                  55 bytes. However, I've just noticed that it still has that redundant assignment to CX

                  Comment


                    #79
                    Originally posted by AtW View Post
                    ->>> JNZ J00113

                    J00113 label isn't specified in your source code, did you compile it?

                    I just had to spend an hour trying to locate decent assembler, had to settle on Turbo Assembler
                    Put up or shut up!

                    Comment


                      #80
                      Originally posted by AtW View Post
                      This one is 65 bytes and it actually works.
                      Code:
                      inc di
                      dec cx
                      inc di
                      cmp cx,0
                      jne 113
                      can be changed to

                      Code:
                      inc di
                      inc di
                      dec cx
                      jne 113
                      saving you three bytes (although as I mention above, you can use rep stosw to avoid having a loop there at all).

                      EDIT: of course, the two increments of DI can be changed to an ADD, saving you a few more cycles but costing a byte
                      Last edited by NickFitz; 4 March 2010, 20:42.

                      Comment

                      Working...
                      X