From d51745da5779877aa282aab80de55c3b9eef430d Mon Sep 17 00:00:00 2001 From: Albom Date: Sun, 1 Jul 2012 17:14:40 +0000 Subject: [PATCH] LuhnA - yet another useless program. Just for fun :) git-svn-id: svn://kolibrios.org@2838 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/other/luhna/build.bat | 7 +++ programs/other/luhna/luhna.asm | 94 +++++++++++++++++++++++++++++++++ programs/other/luhna/readme.txt | 9 ++++ 3 files changed, 110 insertions(+) create mode 100644 programs/other/luhna/build.bat create mode 100644 programs/other/luhna/luhna.asm create mode 100644 programs/other/luhna/readme.txt diff --git a/programs/other/luhna/build.bat b/programs/other/luhna/build.bat new file mode 100644 index 0000000000..542c1a2ad0 --- /dev/null +++ b/programs/other/luhna/build.bat @@ -0,0 +1,7 @@ +@fasm luhna.asm luhna +@kpack luhna +@pause + + + + diff --git a/programs/other/luhna/luhna.asm b/programs/other/luhna/luhna.asm new file mode 100644 index 0000000000..68812df96e --- /dev/null +++ b/programs/other/luhna/luhna.asm @@ -0,0 +1,94 @@ +; LuhnA - Luhn algorithm +; by Albom + +use32 + org 0 + db 'MENUET01' + dd 1 + dd _start + dd _end + dd _memory + dd _stack + dd _param + dd 0 + +include '../../macros.inc' + + +align 4 +_start: + + mov al, [_param] + test al, al + jz exit + + call luhna + xor edx, edx + mov ecx, 10 + div ecx + + test edx, edx + jz valid + mov ebx, msg_not + jmp print +valid: + mov ebx, msg_valid + +print: + mov [notifyapp+2*4], ebx + mcall 70, notifyapp + + +exit: + mcall -1 + + + + +align 4 +luhna: + xor edx, edx + xor ecx, ecx + xor eax, eax + mov esi, _param +@@: + lodsb + test al, al + jz .exit + sub al, '0' + mov dl, [odd+eax] + add ecx, edx + lodsb + test al, al + jz .exit + sub al, '0' + add ecx, eax + jmp @b +.exit: + mov eax, ecx + ret + +align 4 +msg_not db 'NOT ' +msg_valid db 'VALID', 0 + +align 4 +odd: db 0, 2, 4, 6, 8, 1, 3, 5, 7, 9 + +align 4 +notifyapp: + dd 7 + dd 0 + dd 0 ;  ¤аҐб б®®ЎйҐ­Ёп + dd 0 + dd 0 + db '@notify', 0 + + +_end: +align 4 + rb 256 +_stack: +align 4 +_param rb 256 +_memory: diff --git a/programs/other/luhna/readme.txt b/programs/other/luhna/readme.txt new file mode 100644 index 0000000000..2f4ca6f9ca --- /dev/null +++ b/programs/other/luhna/readme.txt @@ -0,0 +1,9 @@ + +LuhnA - алгоритм Луна (Luhn algorithm) для проверки правильности номера банковской карты. + +Ещё одна бесполезная утилита. Написана в электричке на листе бумаги, для развлечения и разминки мозга. +http://ru.wikipedia.org/wiki/Алгоритм_Луна + +================ +Albom +01/07/2012