#IBM PC DOS, 8088 Assembly, 29 bytes ; Perform LUHN check ; Input: SI = card num string, CX = length ; Output: ZF=1 if valid, ZF=0 if not valid LUHN MACRO LOCAL DIGIT_LOOP, EVEN 33 D2 XOR DX, DX ; clear digit sum in DX 03 F1 ADD SI, CX ; start at end of string FD STD ; set LODSB direction to decrement DIGIT_LOOP: AC LODSB ; load last value into AL, decrement SI 2C 30 SUB AL, '0' ; convert ASCII char to binary value F6 C3 01 TEST BL, 1 ; test if digit is even or odd index 74 06 JZ EVEN ; if not odd index, do not double or sum digits D0 E0 SHL AL, 1 ; double the value D4 0A AAM ; BCD convert to split digits (ex: 18 = 12H --> 0108H) 02 C4 ADD AL, AH ; add AL = AL + AH EVEN: 32 E4 XOR AH, AH ; clear AH so AX can be added to DX 03 D0 ADD DX, AX ; add to running sum in DX 43 INC BX ; increment even/odd counter E2 EB LOOP DIGIT_LOOP D4 0A AAM ; BCD convert AX (set ZF=1 if low digit is 0) **Example output:** [![enter image description here][1]][1] [Download LUHN.COM][2] IBM PC DOS test program. [1]: https://i.sstatic.net/vOgkr.png [2]: https://stage.stonedrop.com/ppcg/LUHN.COM