@@ -10,28 +10,25 @@ main:
1010 mov ebx , 1900 ;year (to be increased soon)
1111 mov edi , 2 ;1901/01/01 was a Tuesday
1212 mov esi , 1 ;day in month counter
13- mov r8d , 4 ;for leap year divisions
14- xor r9d , r9d ;sum
13+ xor r8d , r8d ;sum
1514
1615nextyear:
1716 mov ecx , 1 ;set month to January
1817 inc ebx ;next year
1918 cmp ebx , 2001 ;check if we are finished
2019 je print ;if yes, print result
2120 mov dword [ dim + 8 ], 28 ;reset febuary
22- xor edx , edx ;reset remainder
23- mov eax , ebx ;year in eax
24- div r8d ;divide by 4
25- test edx , edx ;check remainder
26- jnz count ;if not zero go to count
21+ bsr eax , ebx ;year divisible by 4 when last two bits are 0
22+ cmp eax , 2 ;result 2?
23+ jne count ;if not, go to count
2724 mov dword [ dim + 8 ], 29 ;if zero, set febuary to 29 days
2825
2926count:
3027 cmp esi , 1 ;check if first of month
3128 jne continue ;if not, continue
3229 cmp edi , 7 ;check if it is Sunday
3330 jne continue ;if not, continue
34- inc r9d ;else increase count
31+ inc r8d ;else increase count
3532
3633continue:
3734 inc edi ;increase weekday
6158print: ;printing routine, differs slightly from OS to OS
6259 push rbp
6360 mov edi , msg
64- mov esi , r9d
61+ mov esi , r8d
6562 call printf
6663 pop rbp
6764
0 commit comments