计算农历的函数汇编原码(3)/zz/

;=============================
_GetLunarYearDays       proc    dwYear:dword
pushad
mov     edx,dwYear
cmp     edx,2050
ja      toerr
sub     dx,1900
jb      toerr


mov     bx,LunarInfo[edx*2]
&n103fbsp;   mov     ecx,12
xor     eax,eax
loc3:                   shl     bx,1
adc     eax,29
loop    loc3
or      bx,bx
jz      loc4
mov     cl,dl
and     cl,7
inc     cl
shr     edx,3
mov     dl,leapBigTab[edx]
shl     dl,cl
adc     eax,29
loc4:                   jmp     toRet
toerr:                  mov     eax,12*30
toRet:                  mov     [esp+1Ch],eax                   ;returnEAX
popad
ret
_GetLunarYearDays       endp
;=============================
_GetLunarMonthDays      proc    dwYear:dword,dwMonth:dword
pushad
mov     edx,dwYear
cmp     edx,2050
ja      toerr
103f                     sub     dx,1900
jb      toerr
mov     ecx,dwMonth
cmp     ecx,12
ja      toerr
cmp     cl,1
jb      toerr
movzx   ebx,LunarInfo[edx*2]
mov     esi,ebx
xor     eax,eax
shl     bx,cl
adc     eax,29
and     esi,0Fh
cmp     esi,ecx
jnz     toRet
mov     cl,dl
and     cl,7
inc     cl
shr     edx,3
mov     dl,leapBigTab[edx]
shl     dl,cl
adc     ah,29
jmp     toRet
toerr:     &103fnbsp;            mov     eax,30
toRet:                  mov     [esp+1Ch],eax                   ;returnEAX
popad
ret
_GetLunarMonthDays      endp
;=====================================
_GetLunarData           proc    _lpstLunarData:dword
assume esi:ptr LUNARDATA
local   AllDay:dword,ThisYear,ThisMonth,ThisDay,AllDays
mov     eax,-1
pushad
mov     esi,_lpstLunarData
lea     edi,[esi].dwLunarYear
mov     ecx,sizeof LUNARDATA-6
inc     eax
cld
rep     stosb
movzx   edx,[esi].dwYear
cmp     edx,1901
jb      OverErr
cmp     edx,2050
ja      OverErr
movzx   ebx,[esi].dwMonth
cmp     ebx,1
jb      OverErr
cmp     ebx,12
&nbs103fp;                     ja      OverErr
invoke  _GetMonthDays,edx,ebx
movzx   ecx,[esi].dwDay
cmp     ecx,1
jb      OverErr
cmp     ecx,31
ja      OverErr
invoke  _GetBetweenDays,edx,ebx,ecx,1901,1,1
mov     AllDays,eax
mov     ThisYear,1900
mov     ThisMonth,11
mov     ecx,eax
add     cl,11
mov     ThisDay,ecx
cmp     eax,19
jb      loc07
sub     eax,18
inc     ThisMonth
mov     ThisDay,eax
cmp     eax,31
jb      loc07
sub     eax,31
inc     103fThisYear
mov     ThisMonth,1
mov     ThisDay,1
mov     AllDay,eax
loc01:                  invoke  _GetLunarYearDays,ThisYear
cmp     AllDay,eax
jb      loc02
sub     AllDay,eax
inc     ThisYear
jmp     loc01
loc02:                  invoke  _GetLunarMonthDays,ThisYear,ThisMonth
movzx   edx,ah
mov     ah,0
cmp     AllDay,eax
jb      loc06
sub     AllDay,eax
cmp     AllDay,edx
jb      loc05
sub     AllDay,edx
loc04:                  inc     ThisMonth
jmp     loc02
loc05:                  mov     [esi].dbIsLeapMonth,1
loc06:                  mov     eax,AllDay
add     ThisDay,eax
loc07:              &nbs103fp;   mov     eax,ThisYear
mov     [esi].dwLunarYear,ax
mov     eax,ThisMonth
mov     [esi].dbLunarMonth,al
mov     eax, dword ptr ThisDay
mov     [esi].dbLunarDay,al
movzx   edx,[esi].dwYear
movzx   ebx,[esi].dwMonth
movzx   ecx,[esi].dwDay
invoke  _GetWeekDay,edx,ebx,ecx
mov     [esi].dbWeekDay,al
invoke  _GetHolDay,edx,ebx,ecx
mov     [esi].noLunarHolDay,al
mov     ecx,60
movzx   eax,[esi].dwLunarYear
add     eax,56
cdq
div     ecx
mov     [esi].noLunarYear,dl
movzx   eax,[esi].dwLunarYear
imul    eax,12
movzx   edx,[esi].dbLunarMonth
add     eax,edx
103f            add     eax,13
cdq
div     ecx
mov     [esi].noLunarMonth,dl
mov     eax,AllDays
add     eax,15
cdq
div     ecx
mov     [esi].noLunarDay,dl
mov     dword ptr [esp+1Ch],0           ;returnEAX
OverErr:                popad
ret
assume  esi:nothing
_GetLunarData           endp

发表评论

邮箱地址不会被公开。 必填项已用*标注