資源描述:
《星期判別參考源程序》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、閏年判斷主要代碼Getrightdayprocnear;此子程序用來判斷年份是否為閏年pushbx;保存寄存器狀態(tài)pushcxpushdxmovsi,offsetwmovax,Yearmovcx,ax;把轉(zhuǎn)換后的年份的數(shù)值存入cxmovdx,0;計(jì)算年份是否為4的整數(shù)倍movbx,4divbxmovb,dx;把此刻的余數(shù)賦給b,便于后面天數(shù)計(jì)算cmpdx,0jnzlab1;不能被4整除,不為閏年movax,cx;接著判斷年份是否為100的倍數(shù)movbx,100divbxmovcc,dx;把此刻的余數(shù)賦給cc,便于后面天數(shù)計(jì)算cmpdx,0jnzlab2;不為100的倍數(shù)
2、,則為閏年movax,cx;再判斷是否為400的倍數(shù)movbx,400divbxmovd,dx;把此刻的余數(shù)賦給d,便于后面天數(shù)計(jì)算cmpdx,0jzlab2;為400的倍數(shù),則為閏年閏年判斷流程圖蔡勒(Zeller)公式主要代碼decyearmovax,yearmovcx,ax;year自減1再存入cxmovdx,0movbl,4divbxaddcx,ax;把[Y-1]/4的商加入cxxorax,axxorbx,bxmovax,yearmovdx,0movbl,100divbxsubcx,ax;用cx中的值減去[Y-1]/100的商xorax,axxorbx,bxxo
3、rdx,dxmovax,yearmovbx,400divbxaddcx,ax;把[Y-1]/400的商加入cxxorax,axmovdx,0movbx,0incmonthmoval,monthmovbl,13mulbl;月加1后乘以13xorbx,bxmovbl,5divbxaddcx,ax;把上面得到的月除以5取整加入cx蔡勒(Zeller)公式運(yùn)用流程圖說明:是只把前面得出的結(jié)果賦值給后者a的值和星期的對應(yīng)關(guān)系a的值0123456星期星期日星期一星期二星期三星期四星期五星期六五、程序源代碼stackSEGMENTstackDB200DUP(0)stackENDSda
4、tasegmentYeardw0Monthdb0Daydb0tempdb10dup(0)countdw?ErrMsgdb0dh,0ah,'Inputwrong!pleaseinputagain!','$'str1db0dh,0ah,'pleaseinputyearmonthday:'0dh,0ah,'$'str2db0dh,0ah,'WhetherornottocontinueinquiriesYes/No',0dh,0ah,'$'weekstr0db'TodayisSunday','$'weekstr1db'TodayisMonday','$'weekstr2db'T
5、odayisTuesday','$'weekstr3db'TodayisWednesday','$'weekstr4db'TodayisThursday','$'weekstr5db'TodayisFriday','$'weekstr6db'TodayisSaturday','$'adw?b????????dw?ccdw?ddw?wdb?dataends;定義了變量和信息codesegmentassumecs:code,ds:data,ss:stackstart:movax,datamovds,axleadx,str1;提醒你輸入年月日movah,9hint21h;顯示
6、字符串callGetYearMonthDay;調(diào)用子程序輸入正確的年月日calldisplay;調(diào)用子程序通過計(jì)算得出星期sel:leadx,str2;提醒你選擇退出程序還是繼續(xù)movah,9hint21hmovah,1;輸入你的選擇(鍵盤輸入并回顯)int21hcmpal,'Y'jestartcmpal,'y';輸入y或Y繼續(xù)程序jestartcmpal,'N'jeexitcmpal,'n';輸入n或N退出程序jeexitjmpselexit:movah,4chint21h;退出;********************************************
7、******主程序GetYearMonthDayprocnear;子程序輸入正確的年月日pushaxpushcxpushsipushdi;壓棧inputagain:movYear,0movMonth,0movDay,0movsi,0;把年月日重新歸零repeatY:movah,1;輸入年int21hcmpal,0dh;換行jeEndY;回車結(jié)束年的輸入cmpal,20h;判斷是否是是空格鍵SPjeEndY;空格結(jié)束年的輸入cmpal,1bh;判斷是否是退出ESCjeExitDos0;退出鍵則退出程序cmpal,30h;和0比較jbErr;