Skip to main content
+1 legalize function call with RET; added 1 character in body; added 6 characters in body
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61

#x86 machine code, 9 7 bytes

x86 machine code, 9 8 bytes

D1 E9 SHR CX, 1 ; divide length in half  L1: AD LODSW ; load next two chars into AH/AL 3A E0 CMP AH, AL ; compare AH and AL E1 FB LOOPE -5L1 ; if equal, continue loop C3 RET ; return to caller 

Callable function. Input string in SI, input string length in CX. Output ZF if is double speak.

###Or 14 bytes as a complete PC DOS executable:###

Or 14 bytes as a complete PC DOS executable:

###Original 24 bytes complete PC DOS executable:###

Original 24 bytes complete PC DOS executable:

###Credits:###

Credits:

#x86 machine code, 9 7 bytes

D1 E9 SHR CX, 1 ; divide length in half AD LODSW ; load next two chars into AH/AL 3A E0 CMP AH, AL ; compare AH and AL E1 FB LOOPE -5 ; if equal, continue loop 

Input string in SI, input string length in CX. Output ZF if is double speak.

###Or 14 bytes as a complete PC DOS executable:###

###Original 24 bytes complete PC DOS executable:###

###Credits:###

x86 machine code, 9 8 bytes

D1 E9 SHR CX, 1 ; divide length in half  L1: AD LODSW ; load next two chars into AH/AL 3A E0 CMP AH, AL ; compare AH and AL E1 FB LOOPE L1 ; if equal, continue loop C3 RET ; return to caller 

Callable function. Input string in SI, input string length in CX. Output ZF if is double speak.

Or 14 bytes as a complete PC DOS executable:

Original 24 bytes complete PC DOS executable:

Credits:

added 6 characters in body
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61
B4 01 MOV AH, 01H ; DOS read char from STDIN (with echo) CD 21 INT 21H ; read secondfirst char into AL 92 XCHG DX, AX ; put first char into DL B4 08 MOV AH, 08H ; DOS read char from STDIN (no echo) CD 21 INT 21H ; read second char into AL 3A C2 CMP AL, DL ; compare first and second char 74 F3 JE -13 ; if the same, continue loop C3 RET ; otherwise exit to DOS 
B4 01 MOV AH, 01H ; DOS read char from STDIN (with echo) CD 21 INT 21H ; read second char into AL 92 XCHG DX, AX ; put first char into DL B4 08 MOV AH, 08H ; DOS read char from STDIN (no echo) CD 21 INT 21H ; read char into AL 3A C2 CMP AL, DL ; compare first and second char 74 F3 JE -13 ; if the same, continue loop C3 RET ; otherwise exit to DOS 
B4 01 MOV AH, 01H ; DOS read char from STDIN (with echo) CD 21 INT 21H ; read first char into AL 92 XCHG DX, AX ; put first char into DL B4 08 MOV AH, 08H ; DOS read char from STDIN (no echo) CD 21 INT 21H ; read second char into AL 3A C2 CMP AL, DL ; compare first and second char 74 F3 JE -13 ; if the same, continue loop C3 RET ; otherwise exit to DOS 
add 14 byte executable answer
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61

###Or -2 bytes thx to @ErikF!14 bytes

Or 9 bytes as a complete PC DOS executable:###

D1B4 E901 SHRMOV CXAH, 101H ; DOS ;read dividechar lengthfrom inSTDIN half(with echo)  8BCD FE21 MOVINT DI,21H SI  ; stringread pointersecond tochar DIinto AL 4792 INCXCHG DX, DIAX ; put first char ;into offsetDL B4 DI08 by 1 byte A6  MOV AH, 08H CMPSB ; DOS read char from STDIN (no echo)  CD 21 ; advance SI and DIINT (ignore comparison) A621H CMPSB ; read char into AL 3A C2  CMP AL, DL ; compare [SI]first and [DI]second char  E174 FCF3 LOOPEJE  -413 ; if equalthe same, continue loop  C3 RET ; otherwise exit to DOS 

Unfortunately can't useInput is via REPE CMPSBSTDIN since it, either pipe or interactive. Will echo the "de-doubled" input until a non-doubled character is detected, at which point will only advanceexit SI(maybe bending I/O rules a little bit, but this is just a bonus answer).

enter image description here

Build and test ISDBL2.COM using DIxxd -r by one byte on each iteration.:

00000000: b401 cd21 92b4 08cd 213a c274 f3c3 ...!....!:.t.. 

Or###Original 26 24 bytes as a24 bytes complete PC DOS executable:###

(will re-do screenshot with new program size when I have more time)

Build and test ISDBL.COM using xxd -r:

###Credits:###

  • -2 bytes thx to @ErikF!

-2 bytes thx to @ErikF!

Or 9 bytes:

D1 E9 SHR CX, 1 ; divide length in half 8B FE MOV DI, SI ; string pointer to DI 47 INC DI ; offset DI by 1 byte A6 CMPSB ; advance SI and DI (ignore comparison) A6 CMPSB ; compare [SI] and [DI] E1 FC LOOPE -4 ; if equal, continue loop 

Unfortunately can't use REPE CMPSB since it will only advance SI and DI by one byte on each iteration.

Or 26 24 bytes as a complete DOS executable:

(will re-do screenshot with new program size when I have more time)

Build and test ISDBL.COM using xxd -r:

###Or 14 bytes as a complete PC DOS executable:###

B4 01 MOV AH, 01H ; DOS read char from STDIN (with echo)  CD 21 INT 21H   ; read second char into AL 92 XCHG DX, AX ; put first char into DL B4 08   MOV AH, 08H ; DOS read char from STDIN (no echo)  CD 21 INT 21H  ; read char into AL 3A C2  CMP AL, DL ; compare first and second char  74 F3 JE  -13 ; if the same, continue loop  C3 RET ; otherwise exit to DOS 

Input is via STDIN, either pipe or interactive. Will echo the "de-doubled" input until a non-doubled character is detected, at which point will exit (maybe bending I/O rules a little bit, but this is just a bonus answer).

enter image description here

Build and test ISDBL2.COM using xxd -r:

00000000: b401 cd21 92b4 08cd 213a c274 f3c3 ...!....!:.t.. 

###Original 24 bytes complete PC DOS executable:###

Build and test ISDBL.COM using xxd -r:

###Credits:###

  • -2 bytes thx to @ErikF!
another (not quite as good) way to go
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61
Loading
-2 bytes thx to ErikF
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61
Loading
Source Link
640KB
  • 12.4k
  • 2
  • 38
  • 61
Loading