This template is used with the following examples / utilities

; License:
; Name: mod97.template
; Description: Template to build multiple programs with the application of modulo97 ; This file isn't ment to assemble nor linked. ; ; Usage: First define the four constants and the macro with the modulo97 algorithm to use/ ; ; COMMAND: The commandname of the application as you should type it in a terminal - here it
; is the name of the .asm file without the .asm
; PURPOSE: What the program is used for. ; APPLICATIONTITLE: The title of the application. This string will be showed also in the usage text. ; NUMBERLENGTH: The length of the number to be checked, two digit modulo97 digits included ; NUMBERSTRING: same value of NUMBERLENGTH but between double quotes ; MODULO97CHECK: Definition of the modulo97 algorithm that must be applied. Some checks implies a
; subtraction from 97 to obtain the check digits, others doesn't.
; That's why I define it as a macro. ; RDI already contains the parsed number as hexadecimal. ; ; second include this template file in your asm program ; ; example: ; ---------------------------------------------------------- ; Name: bebankacc.asm ; Description: ; Modulo 97 check on Belgian Bankaccount Numbers ; %define COMMAND "bebankacc" ; %define PURPOSE "Belgian bank account number check" ; %define APPLICATIONTITLE "Belgian bank account number" ; %define NUMBERLENGTH 12 ; %define NUMBERSTRING "12" ; %macro MODULO97CHECK 0 ; call Modulo97.Check ; %endm ; [list -] ; %include "../template/mod97.template" ; [list +] ; ---------------------------------------------------------- ; ; A later use of such a template can be the creation of multi-language applications. bits 64 [list -] %include "" extern Modulo97.Calculate extern Modulo97.Check extern Modulo97.CheckLength extern Modulo97.ParseNumber [list +] section .data Message: .usage: db COMMAND, " - Copyright (C) 2012 - Agguro <>.", 10 db PURPOSE, 10 db "This is free software and you are free to redistribute under" db "<> conditions.", 10 db "usage: ",COMMAND," n (where n = ", NUMBERSTRING, " digit ", APPLICATIONTITLE, ".)", 10
.usagelength: equ $-Message.usage .illegalnumber: db "il" .legalnumber: db "legal number", 10 .legalnumberlength: equ $-Message.legalnumber .illegalnumberlength: equ Message.legalnumberlength + 2 section .text global _start _start: pop rax ; get argc cmp rax, 2 ; two arguments? jne .usage ; nope, show usage pop rax ; pointer to programname pop rsi ; pointer to number string mov rdi, NUMBERLENGTH call Modulo97.CheckLength jc .illegalnumber call Modulo97.ParseNumber jc .illegalnumber MODULO97CHECK jc .illegalnumber mov rsi, Message.legalnumber mov rdx, Message.legalnumberlength jmp .printmessage .illegalnumber: mov rsi, Message.illegalnumber mov rdx, Message.illegalnumberlength jmp .printmessage .usage: mov rsi, Message.usage mov rdx, Message.usagelength .printmessage: call Write syscall exit, 0 Write: syscall write, stdout ret