• 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

You want to challenge me to beat you?

You see? This is where you show your lack of English. It's a harmless bit of fun, not a competition.

If you think that you can optimise it in any way then by all means. Don't forget the constraints.

Please also explain how your version is "optimised".
 
Can you post it again? I''m bored....

Code:
A 100
mov ax,b800
mov ds,ax
mov ax,30
xor di,di
mov cx,10
ds:
mov [di],al
inc di
inc di
dec cx
cmp cx,0
jne 10e
mov di,20
mov cx,10
mov al,[di]
inc al
cmp al,3a
je 12A
mov [di],al
jmp 118
mov al,30
mov [di],al
dec di
dec di
cmp di,0
je 137
jmp 11E
mov ax,4c00
int 21

N test.COM
RCX
3C
W
Q

Have fun.
 
If you think that you can optimise it in any way then by all means.

Make jump labels sensible and I'll do it - I cba determining hex offsets - if you program assembly you need to be professional enough to use tools that remove some of the unnecessary pain when working with it.
 
Make jump labels sensible and I'll do it - I cba determining hex offsets - if you program assembly you need to be professional enough to use tools that remove some of the unnecessary pain when working with it.

If you use debug then you don't have to calculate the offsets - put in the destination address.

Simples - even for you.
Code:
0DFA:0100 B800B8        MOV     AX,B800
0DFA:0103 8ED8          MOV     DS,AX
0DFA:0105 B83000        MOV     AX,0030
0DFA:0108 31FF          XOR     DI,DI
0DFA:010A B91000        MOV     CX,0010
0DFA:010D 3E            DS:
0DFA:010E 8805          MOV     [DI],AL
0DFA:0110 47            INC     DI
0DFA:0111 47            INC     DI
0DFA:0112 49            DEC     CX
0DFA:0113 83F900        CMP     CX,+00
0DFA:0116 75F6          JNZ     010E
0DFA:0118 BF2000        MOV     DI,0020
0DFA:011B B91000        MOV     CX,0010
0DFA:011E 8A05          MOV     AL,[DI]
0DFA:0120 FEC0          INC     AL
0DFA:0122 3C3A          CMP     AL,3A
0DFA:0124 7404          JZ      012A
0DFA:0126 8805          MOV     [DI],AL
0DFA:0128 EBEE          JMP     0118
0DFA:012A B030          MOV     AL,30
0DFA:012C 8805          MOV     [DI],AL
0DFA:012E 4F            DEC     DI
0DFA:012F 4F            DEC     DI
0DFA:0130 83FF00        CMP     DI,+00
0DFA:0133 7402          JZ      0137
0DFA:0135 EBE7          JMP     011E
0DFA:0137 B8004C        MOV     AX,4C00
0DFA:013A CD21          INT     21

You know what the constraints are.

Stop looking for excuses, put up or shut up!
 
Last edited: 10:30
If you use debug then you don't have to calculate the offsets - put in the destination address.

You are a very poor competition organiser, I hope this asm code isn't your best version of it.

How long it is supposed to run - took forever on my i920 processor and had to abort as no end was in sight.

P.S. I'll give it a whack tonight - too much work in the office today.

P.P.S. 2 categories in this competition - speed (we need to agree test CPU - I say modern ones should be baseline - ie mine i920 2.66 Ghz) and size of executable.
 
Last edited: 10:38
You are a very poor competition organiser, I hope this asm code isn't your best version of it.

How long it is supposed to run - took forever on my i920 processor and had to abort as no end was in sight.

It's not a competition, it is a piece of fun.

Now, I'm assuming that because that you didn't realise that a "jmp" instruction entered via debug requires a destination and not an offset that you don't have the ability to contribute.

So, f**k off, there's nothing for you here.
 
When I wrote in asm I either use proper assembler like TASM or MASM, or did inline assembly in C code. Professionals don't waste their time with crap tools like debug - it wasn't in heavy use even back 20 years.

So, f**k off, there's nothing for you here.

Your software does not work - it does not display like you claimed above countdown, my compiled size is 60 bytes on 32 bit system.
 
When I wrote in asm I either use proper assembler like TASM or MASM, or did inline assembly in C code. Professionals don't waste their time with crap tools like debug - it wasn't in heavy use even back 20 years.



Your software does not work - it does not display like you claimed above countdown, my compiled size is 60 bytes on 32 bit system.

Follow the instructions as mentioned.

Use the tools as provided and prove that you're an engineer not a whinging tart.

Otherwise, f**k off, there's nothing for you here.
 

Advertisers

Back
Top