Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data
- msg: .string "If result is 1 Matrikelnummer is valid otherwise invalid. Result: %d\n"
- # number: abcdefg, valid if (a * 9 + b * 7 + c * 3 + d * 9 + e * 7 + f * 3) mod 10 = g
- .text
- .global main
- main:
- movl $1611813,%eax
- movl $10, %ebx
- movl $0, %ecx
- movl $0, %edx
- movl $0, %edi
- cdq
- idivl %ebx
- movl %edx, %edi # edi = g (1st digit)
- cdq
- idivl %ebx
- imull $3, %edx # f*3
- movl %edx, %ecx # ecx = f*3 (2nd digit)
- cdq
- idivl %ebx
- imull $7, %edx # e*7
- addl %edx, %ecx # ecx = f*3 + e*7 (3rd digit)
- cdq
- idivl %ebx
- imull $9, %edx # d*9
- addl %edx, %ecx # ecx = f*3 + e*7 + d*9 (4th digit)
- cdq
- idivl %ebx
- imull $3, %edx # c*3
- addl %edx, %ecx # ecx = f*3 + e*7 + d*9 + c*3 (5th digit)
- cdq
- idivl %ebx
- imull $7, %edx # b*7
- addl %edx, %ecx # ecx = f*3 + e*7 + d*9 + c*3 + b*7 (6th digit)
- cdq
- idivl %ebx
- imull $9, %edx # a*9
- addl %edx, %ecx # ecx = f*3 + e*7 + d*9 + c*3 + b*7 + a*9 (7th)
- movl %ecx, %eax
- cdq
- idivl %ebx
- cmpl %edi, %edx
- je .valid
- movl $0, %eax
- jmp .invalid
- .valid:
- movl $1, %eax
- .invalid:
- pushl %eax
- pushl $msg
- call printf
- movl $0, %eax
- int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement