Upload original 计算机组成原理课程实践 学分×2 陈媛媛 course files (part 13)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 ADC using an AD1674 sdcc/8051 ADC using an AD1674.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 ADC using an AD1674/AD1674 & 80C51.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 DAC using a DAC1230/DAC1230_8051.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 DC Motor Controller/8051 DC Motor Controller.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 LCD Driver/LCDDEMO.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 Memory/ExtMem.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 Stepper Motor Controller/Stepper.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 Timer with LCD/8051 Timer.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 with ERM19264 GLCD 3xKS0108B/ERM19264.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 with LCD1602 LCD controller/LCD1602.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 with Memory Mapped LCD1602/8051 with Memory Mapped LCD1602.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 with a DS18B20 Temperture Sensor/DS18B20.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/BASIC-52.LST
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/BASIC-52.PDF
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/BASIC-52.SDI
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/Basic-52.asm
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/Basic-52.hex+422-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/FP-52.HEX+97-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/FP-52.LST+2277-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/FP-52.SDI+1610-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/Fp-52.asm+1610-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/basic-52.DSN
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/basic-52.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/ASEM51 Calculator/CALC.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/ASEM51_Stepper/Stepper.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/C51 Calculator/calc.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/C8051F38x/C8051F380 7-seg LED.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/C8051F38x/C8051F380 Blinking LED.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/C8051F38x/C8051F380 Input.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/C8051F38x/C8051F380 Output.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/C8051F38x/C8051F380 UARTs Two.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/GNUCHESS.pdsprj
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/Makefile.in+511-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/config.sub+1492-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/configure.ac+62-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/doc/Chess Engine Protocol.htm+1367-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/doc/README+512-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/gnuchess.Opt+74-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/gnuchess.Uv2+153-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/gnuchess.lnp+1-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/gnuchess.map
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/atak.c+535-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/book.c+682-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/book.h+46-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/cmd.c+994-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/common.h+864-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/config.h+173-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/debug.c+73-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/eeprom.c+106-3
- Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/eeprom.h+37-3
123version https://git-lfs.github.com/spec/v1oid sha256:2f9f5d569466534da00551258390c51478c7f5f5accdca9dd0d3711f6a2281ecsize 18832123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422:02000000618716:1000030020312DC0D0024003C0D0202E1002400B5F:1000130020122BC0D0024013C0D0021F7802190354:10002300C0D0201F1C024023C0D002402B02193D28:10003300202608C29630B2FDD29632022040D21654:1000430032022050178512150FE60FDC049506D0F7:1000530006B7069D139E131D11A2173F13FC171A13:10006300148A1476147F139313CD13D913DD13D38A:1000730013C813B71381135F13871488115F11C259:100083001163127F139F131911D212B213A813B065:10009300147113E3149B170F171F0FE21641172751:1000A30014AB14AF14B314B914BF14C514C914CDCD:1000B30014D114D714DB0F4C164E14E215AC108C6C:1000C3000D6E0ED60EDE07890806010F0E0A080A0A:1000D300080305040C0606060606060F0F0F0F0F8E:1000E3000F0F0F0F0F0F0F0F0F53544F5022545278:1000F3005920414741494E22524541445922202D1E:1001030020494E204C494E4520220806103A0B1038:100113000654183F04611771177D0536045A097692:1001230006870A7E0AB216840C31192C19310A8506:100133000C350E6C0D6A060416F719190C33085C9E:100143000E5F140B0B160F0E0BD60F050B67140166:100153000CF40DFE0BEB0EF50B180A8E0B350A444F:100163000B040B091785185C0FEE0FF2050C07BC87:10017300804C455481434C454152825055534883EA:10018300474F544F8450574D855048302E8655491C:1001930087554F88504F50895052494E5489502E9D:1001A300893F8A43414C4C8B44494D8C53545249AB:1001B3004E478D424155448E434C4F434B8F5048DD:1001C300312E9053544F50914F4E54494D45924FB9:1001D3004E455831935245544994444F9552455393:1001E300544F52459652454D974E455854984F4E4D:1001F300455252994F4E9A494E5055549B52454140:10020300449C444154419D52455455524E9E494647:100213009F474F535542A0464F52A15748494C451B:10022300A2554E54494CA3454E44A4544142A554AF:1002330048454EA6544FA753544550A8454C5345E3:10024300A9535043AA4352AB49444C45AC53544081:10025300AD4C4440AE50474DAF52524F4DE028E1B4:100263002A2AE22AE32BE42FE52DE62E584F522EBD:10027300E72E414E442EE82E4F522EEA3DEB3E3DF3:10028300EC3C3DED3C3EEE3CEF3EB0414253B149C8:100293004E54B253474EB34E4F54B4434F53B554D9:1002A300414EB653494EB7535152B8434259B945DB:1002B3005850BA41544EBB4C4F47BC444259BD58A9:1002C3004259BE5049BF524E44C0474554C146529D:1002D3004545C24C454EC35854414CC44D544F50F0:1002E300C64945C74950C854494D455230C9544978:1002F3004D455231CA54494D455232C554494D4575:10030300CB5432434F4ECC54434F4ECD544D4F44B8:10031300CE5243415032CF504F525431D050434FBD:100323004ED141534328D25553494E4728D2552ED7:1003330028D343485228F052554EF14C495354F2B6:100343004E554C4CF34E4557F4434F4E54F55052D3:100353004F47F658464552F752414DF8524F4DF923:100363004650524F47FF45585452412049474E4F3C:1003730052454422412D535441434B22432D535460:1003830041434B2275985A75891075885475C83442:10039300902001E493B4AA0312209078FFE4F6D8E6:1003A300FD753E4D853E8175138075141190800057:1003B300E0C39431F545C2E2FFA3B1B2120889A3A9:1003C300B1B290005FE0900000B4A508E545C2E03B:1003D30064046029BF02028003BF0304D175801146:1003E300AB83A982A3745AF0E0B45A05E4F0BBE0EE:1003F300EFBB0300408E90010AB1FBD154D16712C9:100403001649E545B40503124039500D30E02590F7:100413008010E0B4551E020806E4FBF9780420B00E:10042300FDD8FE121581780230B0F620B0FD30B051:10043300FD120889901FD3D1A502177D7F007E018D:100443007A7F78FF91980EE5CB9198E5CA7E037980:10045300097B019198803790012AD233800590015E:1004630028C233B17AC295120EEA70D07CFED21D37:10047300B153121855ECF41214A31219A1B116D1E9:100483009DA80EAA0F74550EBE00010F919BD29525:10049300A13A8BA0E31215687D01FC91D691F0205F:1004A300330C6C702012163970E853D0E7226C704D:1004B3000FEC91D691E091E091E0DDF891F080E2CC:1004C3000DECBD19D5D29575D000302FE0901F9A51:1004D30002189088808AA0B105C293F580000000BD:1004E300000000B105C294B127308FFD22D294B130:1004F3000530B2FD7580FFC2B7B105E580D2B7D232:100503009322750F0CD50FFD22C29575D0189195C6:10051300D29522B182A3AB13A914C3E58299FEE558:10052300839BFF22B126C28E85408D85418BC28F6E:10053300D28E22C217B13D02107E120F3EAC005084:10054300027C01B153BC0011A3858313858214225D:10055300908010E0B45509DC0122A3B1A4A380F379:10056300101DF6901FC981D3E0FAA3E0F822CBC592:1005730083CBC9C582C922E0F540A3E0F54122D26D:1005830029120EA4120AAC6012A320290AB1C4B125:10059300BAE0202A064004B1D680E9C2292290029B:1005A30000D22980DFE0C0E0A3E0F582D08322E01F:1005B300FBA3E0F922B1BAC5827002158314C58288:1005C30022C22AE0B5030AA3E0B1BAB50103B3B26C:1005D3002AB3222582F5825002058322D192B1A14A:1005E3007406B1D6B171900108B1FDB1B290012288:1005F300B1A8120A0A900104B1FDEBF0A3E9F0A33C:1006030022120E8E900122B1FD0E8E3FC15C90012D:1006130004B1A8B1B8E06020A3B5070FE0B5060B9D:10062300E5829402F8E5839400FA22E582C39409F3:10063300F58250E1158380DD120DF8C3D123E894D0:1006430006F9EA9400FB900106B1FDB1C44032D330:10065300229002007401F0C215B1DF90010AB1B219:10066300B1A1D1759000FEE4F07511FE7509FEC2CB:100673001722A3E4F0E07009EBB583F6E9B582F243:10068300220215A7120EEA50D0120EE0B449D5305B:100693001202C2AA53222032D19D7D0DF1097D0A97:1006A300E109D19DE493C2E7B4220122D234FDF1E2:1006B30009A38004B1717C0D1034E9E06003B50433:1006C3000122B40DE9021886B40416D19D75A00069:1006D3007807F189FDB408F0B807187D07F10980A0:1006E300F1F2B40D02C19DB4200040F108B856EDFB:1006F3001880E8187D08F109F1077D0880DF7E0086:10070300005067417D20C0E0C083C082303504F1D2:100713008580F9ED302C05122040E15E301C051276:100723004030E15E30270830190512403CE15E306D:100733001B22900124B17AC297B127EDD37D09130F:10074300308FFD9297B127DDF6308FFDB127308FC3:10075300FDFD80073099FDC2998D99BD0D03751676:1007630000BD0A0BE51560077D00F1091470F9BDA2:1007730008021516BD200040020516D082D083D092:10078300E022F1C450323032051220608011301E55:100793000512403380093098FDE599C298C2E7B449:1007A3001302D235B41102C235B403043030262209:1007B300C228B41702D228D322D21DB13D101D4343:1007C30022303203022068301E03024036A29822F0:1007D300901969D1A7C235120C39D19D1028F13077:1007E3002F7FA13AE548A949B548F9C9954CE99540:1007F3004B22F1E74040D214C210A211922B900178:1008030026803C12065A71D851AC604AD1C1F12CF2:100813009144C22F853E81202F06850A42850843D5:10082300120785202F24B0185006900100F0D2182B:100833002014172010BC30161120110E9001207CBB:1008430002713DD21112056B61003100F12050C4D9:10085300302F0302179B021785F120850A42850872:1008630043D2179000ECD2200218AEB4C8058B8C8B:10087300898A22B4C9058B8D898B22B4CA058BCD95:1008830089CC22B4CE05BBFF04B9FF01228BCB89EF:10089300CA2231DDB4CB0389C822B4C60389A82296:1008A300B4C70389B822B4CC03898822B4CD0389A1:1008B3008922B4CF2F899022F50FD1E031D0E50FF3:1008C300B4C30302164ED199E50FB4C40990010ACB:1008D3001205FD02065CB4C592A2AFC2AF8B488974:1008E3004992AF22B4D056898722B4D1CBD1D4B4A4:1008F300244B5126B1B61214A631E52129D1D630A5:100903002D0EB420005009122070D1E0540F8051F5:10091300B4C30050D530E75BB4BC0631E131DDF739:1009230022B4BD0631E18BA0F322B4AB004009B47D:10093300B000500924F9801DB4A4004003021886B6:10094300302F12B49000400DB4A0028008B4970277:100953008003B496E8D1E0900121B48002809E54D4:100963003F232582F582E493C0E0A3E493D083F58B:1009730082E473D1C84050C2151205717FEA91EE2B:10098300D1D6B42211AF3FD1E0D1EA60B0F0B422A6:1009930026740DF0C1E0C083C082D1C8409FD0004F:1009A300D002AF3F121588B40D0122DF05740DF29A:1009B300C15712156880EDDF063194D157C1F5A3F5:1009C30080C5901829811631CEE1DCF10AC002C03E:1009D300007FEAF14AD001D00322BB00E522D1E037:1009E30091E831D0121493EEBF00D722D19E31DDAE:1009F30009E960CE900104853FF0511890010A1275:100A030015A2853F821583C3E99582F9EB9583FB94:100A1300492275F0061205A8E9A42582F9E5F03507:100A230083FB2231EFC003C0017F2C91EED197E904:100A3300B53F00508D19D0E029F9D00350010B8147:100A4300EC31CEC003C001F1DC7FA6F14AD1D6B4AC:100A5300A706D1E0F14C800312143574EF71B9711C:100A6300C57B00A900F1DCF1DCD1ABA8017141D059:100A730008D00A7C017141D1C10117F14CD1CF508B:100A8300FA22F10AF1DAD1CF50F82251CFF9D1D6B7:100A9300B4A502D1E0B9000B7FA8D1F760ECD1E097:100AA300B4A8F5F13E50562100E01420E72E225160:100AB300FAD1C110250830150312065A0115101476:100AC300055322BD0117A22B92110117F14C1212EB:100AD30041600274FF22D1A4E0FFDF05901FB581BE:100AE3001620E7F8A3E0B50208A31FE0B50002A3B0:100AF30022EF1205D680E1F13951D9E12051D941D4:100B0300B451CFF4800251CF7C03FD800CF13988BE:100B1300150159D2257C027D557153E2F58308E214:100B2300F58208E0B401020159ED60858811F47083:100B3300802251FA7C02713D417A74FD71B975A02E:100B430000E508F218E50AF218ECF222740371B911:100B5300A81175A000E2B5040208226069B401EC93:100B630071B780EC7C017153880F790BE2F70908A8:100B7300B90FF9B16E5004AA0BA80CEAB50B47E8FC:100B8300B50C43F1E6740E250FF87A008AA0E2084B:100B9300C0E0F1E6C00012173F12141EAB0BA90C04:100BA300F1DC7A00D000F1E6121997D0E06001B3CE:100BB30072D5401774112511B461004009C5111491:100BC300F822F12050FB90037F8116850D0A850ED4:100BD30008011771DED1A4D1C1F12CC50AC512C514:100BE3000AC508C510C5082271DED1CF4016F14CE5:100BF300D1D6B42C028002F12071DEF10AF1DAD1F0:100C0300CF50E522B49C04D1E080E3B4010871DE47:100C1300901F81021890D1F5F12040F280CCD1D6FB:100C2300B42304D21BC1D4B440D9D219C1D4D2360F:100C3300D237912191405323F553263F22D1EA40E5:100C43000702069DD1CF40F9D1B250F8B4A408D120:100C53009E951640EF8005B4A90AD19E60E612075F:100C6300071480F8B4D314D1D4B42406121002D1DB:100C7300998004D19791ECAD018007B4AA09D1E022:100C83007D0D12070980BDB4D253D1D4B446167575:100C930017F0D1D4D1E0540F6007B40300500274AD:100CA300034217802AB43007751700D1E08020B4BF:100CB300231D91D68F17B42E11D1D491D6EF2517BA:100CC30024F750022140EFC44217E517C4F51791EA:100CD300EC81477F00B4230C0FD1D480F8D1EC50C2:100CE30003B4A834227FE0F14A7F29D1DEB507D4CB:100CF30022D197D1DEB48304B106417AB49FC5B142:100D0300066137B90006F139D1F541FC7F2CD1F7E3:100D1300B42CB119D1E080EBD1C840051206B781DC:100D230047F14C7448B51600500291443037141201:100D330011F4400F1213817007D1991219A9814739:100D43001213931219A17401815FD1D4121FED40C4:100D53000CB45F0122B441004004B45B00B3223001:100D6300D53E90175F8116D2D58002C2D5D1D6B1B8:100D730058500420D5EC22FFE4FDFEB14D4007CFCF:100D83002DCF7D1A80F4C215B4E02F4306801206DE:100D930011C002C00050C820D528790A7B00B1D504:100DA300D1A0BB00BDD082D083E0149940B412051A:100DB300B85115C9C8C9CBCACB2220D5A512061173:100DC300C322D1A0BB009BD000D002B1D5D1CF505C:100DD300962209E9608CFC9001085115AF83AE821D:100DE3009001061215A29001081205FD88828A83DC:100DF300ECF01205B8EFF0A3EEF022D1B2D1CF5050:100E03000791447D3F120709D2221206D0C22275F0:100E13000F00750E07D1C8400DB1B6AB0FA90E3147:100E2300A5D1CF50DE2212184E1219557018121880:100E330055F10AF1DA12184ED1CF4013E0B42C0663:100E4300A312185580CF9000F11206A5021845E0B1:100E5300B40D01229003691206A58144D18E8B4BF8:100E6300894C900126D210A1F8F139BA000AE82082:100E7300E70628904100F582317453D0E722D197D9:100E83001216798B4089417F2C91EEF14C7F2CF126:100E93004A021493F14C121215E922D1E091E88031:100EA300F585138385148222850A8385088222D1DE:100EB300D6B42273D1ABA37C221206BBA3C3858312:100EC3000A85820822D1D6B4245D21EFD1D6B42C71:100ED30056D1E0D2D38AA0E2C2D322D1D6D2D3084C:100EE300B800010AC2D322D1D6B40D02E422B43A27:100EF30036227F0DD1EA50F9B5070122D1E080F403:100F0300D1E0D1EA70FA22B16E802D71C57C0371F4:100F13003D0117B43A02C1E0B4A86DF105D1D6B4CE:100F23000DF1D1D4B40102D322C5082403C508109E:100F3300D70122050A22F13E404E22D1AB1219A558:100F4300D1C18A8388822291EE7ACDC002C224E580:100F530081240C500302188DE509943850030212C2:100F63000C202413B16E500DF1F8500BD1D6B4E020:100F73000674CE8055F1E6D1D6B4E000500EB4B07D:100F830000503BD0022024BEC3021888541F2024E3:100F930005B4053C740924CEFA90000093FCD0E01C:100FA300FD93B50404B40C9ED3509BC005C002D17D:100FB300E0F14ED0E090005724323164E152D1E0A9:100FC300242E2024C3B4EC0050EBC0E091E880E36E:100FD300B403B5D1E0E152B1B61212410214647AFE:100FE3000178131211FDD224021464D19780EAD13F:100FF30097B1B680EED1D6B4D114D1D4B4240612AD:101003000A260213B21214A3120EE0020CEC120E03:10101300AB121955B4FF02D3227006C3D224020EB9:10102300C1540B60F390174F30E00390180530E183:1010330003901F89021890120C2171BD120F3EE418:10104300FBF94014121855120EDEB4E50751411294:101053000F3991A6AB0FA90E120584601E1121A3AF:10106300D14431FA401512078531FD120EAB118FB1:1010730011211180A3E0D5E0E45141E185900007FF:101083001206B9120EAB02069D1205717B00790799:10109300A3112112056B1219A3120EABA3B90D00F4:1010A3004022A3E0FE20E724B420005003B40D1C2B:1010B300B4220931133115B422FB80E1B43A09316A:1010C30011EE3113311180D5311780D11121A22DA9:1010D30092D590017330D503122078E493A3B4FF23:1010E3000510D5EEE185B506F2B4B000500231111A:1010F300E49320E70760053113A380F4120EABEEEF:1011030064967004311580FC50933111808F7420E4:10111300C136A3E0B40DF9C1227E00572266287FB1:1011230001375716167F00149690427F0140962888:1011330075800064626510800199882014800051D5:10114300359919800145313333810000000010FFC8:101153008100000000207C00000004133184F13F73:10116300917131A7E54654016245911E318431FAEC:1011730040049171F11A71819016CC318D31CC21DB:10118300EE9171901153912561FC911C31A2913A1A:101193009125914131A29125F13FE493B4FFF312DC:1011A30019990124915E71FC7181F545911C5115CA:1011B300C0038946715FF11A914831A2D00322918D:1011C3001E3163914C315F61FC51457B0161737149:1011D30081F5455145247F922A5002516E90111C8E:1011E300318D302A0671933184F13FE545601961F1:1011F30093911E71BD914C02199774FA2509B4326B:10120300004006F509F97B01229003770137912508:1012130031A2E4FBF9A80975A001E2C39481FC188B:10122300E2705640190CE89405F808E2C41219A7B5:101233004047DC028008E21219A7403DDCEC74064B:101243008001E4A8097A018AA02840BDF509E222B9:10125300913531A7BB0022915E5141913A9135E519:1012630046700EE54560E890011EF09135914C61A2:10127300FC1546914131A280E60209C5718170F9DE:10128300915E913A7819E260242480500503547FDB:101293008007F40403547FF4042480F291489141BD:1012A30071FC9141F13F3186710E30D5EF8141716F:1012B3008170C6F54608E260C0B48100922A4002FC:1012C300516E911E913531FA501D51452485500EB2:1012D30091227401254640A1F54631A280E490177E:1012E300ED9125740B80ED915E9135F11A91489142:1012F30035F13F71FC9016A7318DA3912531A2E5FD:101303004691A3F11A31CC302A74229141914C9128:101313001E913A0219979122914C515390011FE06B:1013230060E8914891415145600251B231A2912246:10133300914C51537546009135911E913A91483124:10134300A20546E54691A371FC911E9141F13F71BF:101353000E30D5E95141914131A221A251459481E9:10136300500751419004E0812594075010F404FB89:101373001818E254F0F2DB0122E4F2DBF422719359:101383007019F222514160DC18E2FF9135EF600BD6:101393005145186006E26401F264012251151205F9:1013A30071E49381A351151209DDE781A351158BD4:1013B300A0E381A331FA72D540AA9013C281258597:1013C300000050536531FAB380EE31FAA2D580F7AD:1013D30031FAB2D580F631FA80DE31FA72D580E780:1013E30090010C1205B2E9C313F874061329C83B24:1013F300FA1582911691A671BD12199B0124120F41:1014030039D213900102800B120F39D21243A884F0:10141300900120EAF0A3E8F022911E514580239029:1014230017F331FD8BA07B06E493F3A319DBF9D209:1014330024229016F081257B017919020FDC78199B:101443007A01020FE6781F80F751457406FA28F9EE:10145300E2FBE3F2EBF31918DAF62251457B01794B:101463001F7C068AA0E28BA0F3B17DDCF6229017E5:10147300FF81259193EB5FFAE95E80269193EB4F11:10148300FAE94E801D71BD9193EB6FFAE96E8012FC:101493005115AF03AE014115900100E0101801E4AE:1014A3007A00F8D2240219ABE5A880F4E5B880F0FD:1014B300AA8CA88A80EDAA8DA88B80E7AACDA8CC98:1014C30080E1E5C880DAE58880D6E58980D2AACBB9:1014D300A8CA80CFE59080C8E58780C4020566E589:1014E30013B402F81205A1AC82AD83AB0FA90E129F:1014F30005847012E50DB4040122B19AAA05A8046B:10150300B1587401A18BFF121855E50D4009B404BD:1015130001E49F6036401FFFE50DB4040122EFB1E3:101523009A12184EB18F120DB6A904AB050EBE0068:10153300010FB1738015F4041205D6B18FA982ABE4:1015430083AA0FA80E6002B15FB105AA0FA80EE52A:101553000DB4040122E47904FBAE0DFFB188B16838:10156300D13970F82208B800010A09B900010B2229:10157300B188B17DD13970F8002218B8FF011A196A:10158300B9FFF51B228BA0E38AA0F222ECC395825C:10159300FEED9583FF4E222CF9E43DFB90010412EE:1015A30005C440F29018170137F16A120F3E121862:1015B3005592D59000059116A8087907C224900189:1015C300738805E493FFE2FBB461004007B47B003A:1015D3005002C2E5FAF2A3E493B502030880E720C0:1015E300E72F602DA3E49320E70370F8A3A805B4C5:1015F300FFCFBA20030880C4302D0A202407D22449:10160300122078A1C4D121B422B2D121B422FB800B:10161300ABEFD136B496A5EBD122D12180FCE2B455:101623000D10D000D000F3097401F3E99404F50D13:10163300790408F309221EBEFF011FEF4E22900119:101643000A12056B81A69017E79125911C911E90B4:101653000701D177900128F10C9017F9D177900108:101663002AF10C9011595111E9F404F54A7B0179DF:1016730013020FDC5111E9F4240FF9EBF43400FBEE:1016830022120E81D179C292C28E8B8D898BC28F29:10169300D28ED139308FFD719ED292120529308FAF:1016A300FD70E3228000713713197F00766437944D:1016B30080000722751780005235932880007191AE:1016C3008586FF81005158022377004490051679DF:1016D30001082105257B00197355277D01701284AC:1016E300197E0033333383800167666616810000F9:1016F300000010FF120FE2120F4C740C91A331A2E1:1017030071FC5115D1799001240205FDD1411205D7:10171300A1A882AA8391A61219950124120516AADB:1017230007EE81A5A2AFC2AFC047AA48E54992AF71:1017330091A5D0E091A374C891A371FC12199301F0:10174300244241442053594E544158228A44495615:10175300494445204259205A45524F224152524151:10176300592053495A4522750A0075080722120564:10177300167A027800B15F12065CC2177513027500:101783001400120C39C22DE490200293B45A0312B0:1017930020489000FB1206A5D22F853E811189C2F5:1017A3001890005EE0643470030208067D3E120761:1017B300091206D0B1AC20D50F91E21205DF201536:1017C300DED21512065C80D7F16A120EEA60C99068:1017D300010DB4F000400A120EE0540F12096480A8:1017E300B702081788000092051185004241875906:1017F3008100182818277C00000075838100265972:1018030041319E41524954482E20554E444552463B:101813004C4F57224D454D4F525920414C4C4F434D:101823004154494F4E22A842414420415247554D0D:10183300454E5422492D535441434B22901FA63009:10184300174B85420A854308020813850F83850ECB:10185300822285830F85820E22202F27C2964387FB:101863000120160B1021083010F41207E740EFD2C5:101873009622A3202F2330132090010112066BA37D:10188300020848A22F9017448004901837C3853E5E:1018930081120C39E49310E7D911554003120667FE:1018A30012069B901FF81206A7114E1206A7302F9F:1018B30005C2200217859001011206A7120EA4E4A7:1018C30011551205D611FC40066004E0B401F11174:1018D3004E11FCE9240AF545A312164431A1202038:1018E300D012069B114E12108F1210807D2D319055:1018F300D545F97D58319001B4AB0AA908020A0A0B:10190300854A8CC54704B4C808E40549B5490205AE:1019130048C547D0D0323136C2A9C22E500A5389A6:10192300F0D22E43A882D28C223136921E22313637:10193300921C22120EDE9431B32220D4FC20D3F960:1019430010E70690004702096420E050603F9019B9:101953009173319D504631A57036C083C08231AB3F:10196300D082D083E422D7D2C9D454C5CE20C2D9E1:1019730020CACFC8CEA04BC1D4C1D553CBD92C20BC:1019830049CED4C5CCA0C3CFD2D02E2031B938355F:011993002231:0319900002070942:101F7800201A0302401B0220884E4F20444154413E:101F8800229441524954482E204F564552464C4FB0:101F9800572250524F4752414D4D494E47224341D7:101FA8004E275420434F4E54494E554522494E56CC:101FB800414C4944204C494E45204E554D424552CE:101FC8002250524F4D204D4F4445222A4D43532D08:101FD800353128746D292042415349432056312E0A:031FE800312A2279:081FF8004552524F523A2022DB:00000001FF
123version https://git-lfs.github.com/spec/v1oid sha256:45d58e161c8f18bc6f8b3bb32dacea49fa370149681c1d41a69b084635874faasize 430512345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697:1019930021B721AD416A419A41CF819681CFA18779:1019A300E104C1ABC1E0E14C81C375A001A80918F2:1019B300E2B2E0F29177EF600DBE0012916B7F0609:1019C300E2F31819DFFAE5092406F509E4229E8FEC:1019D300308C2F50098E308B2FF404C8C9C8FFC236:1019E30023BD0002D2239188BF0B0040027F0A75FA:1019F3002A0071C87F04792E749EC39CD4CC7001D5:101A0300FCB45000302318B351195008052A7F0144:101A130071C8717F6170E237D4F71819DFF822E2D9:101A2300FEE43499972ED4F71819DFF34011B278F6:101A3300792E7F04749A972400D4F719B3DFF578CD:101A43002B7F00E670080F0F08B82FF761B8B410AA:101A53000050010FE530C39F600B4009F530910240:101A6300752A00617061B29177E509240CF509EEDE:101A7300C2D59F600A4003EB8001EC6001B322BD35:101A830000F57F04181818191919E2FEE39E70EA8D:101A93000809DFF6D2D5229175BE000261B88D2FF9:101AA300EF60F92E20E70510D70661B2500261A15D:101AB3009481FE718B7B04AC018C01E3FA9138EACB:101AC300C491381CDBF38E308D2F613091778D2FCD:101AD300BF000671A1E4D2E322EE60C09F20E704B9:101AE300500461B250C82481F53091887A34AB0038:101AF300752A007DFFD38B00792E7F045017E2FEF9:101B0300E434999E27D4F71819DFF30D40E8E794DE:101B130001F7B380E1511977008A00A6050A7F0116:101B23009100BA3ECED5300261B2752A007834E610:101B3300FE6003717F18087408F928F8B6050040A1:101B430013D3E41836D4D630E409D9F518760171E5:101B53007F800619E9C3C898F8792BE6C408D642F2:101B630006F70809B92FF4EE7003753000916B89FD:101B7300097830E6F31819B82AF9E4220530E5307C:101B830070F9D0E0D0E061A1C0017932E2540FF7DF:101B9300E2C4540F19F71819B92AF1D00122782E8B:101BA3007499F618B82AFB7530FF7170D2E122716F:101BB300B8E4D2E02271BF7170D2E222E4783DF63C:101BC30018B829FB227C00C3EF60229402501FC087:101BD30000C001792E782DECD7C4FCE7D6C4F718E2:101BE30019B92AF7E7C4540FF7D001D00022FFE454:101BF300C52AC52BC52CC52DC52EFC80CB7C00C3A7:101C0300EF60229402501FC000C001782A792BE6AE:101C1300C4F6E7C4D6F70809B82EF7ECC4D654F0D7:101C2300FCD001D00022FFE4CCC52EC52DC52CC5A8:101C33002BC52A80CB540FFF783C7932E4F5331857:101C430026D430E403180608D68FF0E7A475F00A0B:101C530084C5F026D430E40205F008D618E5F0195F:101C6300B92ADC2533D4F62275A001A80974062805:101C7300F92271BF916BE2FFE3FE1819E2FCE3FB6B:101C83006CFD181922C000782EE3F61918B82AF94A:101C9300D00022B16CC083C082E0F1ED401291B656:101CA300400EC2E5B44803D38001C3D082D083225F:101CB300A380E6C2E5B44700400122B44100B32249:101CC3007B007958F104740DF390005871BFB16C27:101CD300B172927878347E7FD2D5F1EB5007540FEE:101CE300B145A380F5B42E0C205163D251B834F220:101CF300D25280EE20D557B465028003B44533B188:101D03006BB1729250F1EB5045540FFDA3F1EB50C0:101D13000D540FCD75F00AA42DFD50F07DFFED306D:101D23005009C39EF40440097401222E5003740227:101D330022CE8E30B8340271BFE509C3940CF50985:101D43006130C2D5700BB83408305204DE0274FF20:101D530022205302C2522052F32051010E2053F08D:101D6300B83D02D253F60822A3E0B4201680F9B49A:101D7300E302800EB42B028009B4E5028003B42D84:101D830002D3A322917731C9EFFE718B782BE5172C:101D9300FB6049B4F0005073EE70027E80EBC454D4:101DA3000FFAD174CAC39AFF50067D3FD1A9A1DFB0:101DB300BA00071FD196D1A38006D196EAFFD15866:101DC300EB540FFA60BDD19FD17DB50203EAC18DFB:101DD30050FBCAC39ACAD18DEAFFC158EE7004D131:101DE300A7C1A37BF074772E402194F7401DD198AF:101DF300D174B40802C158D158D16A6057D19F7FBA:101E030001D158704FD16A604B80F4D1987F01D1D2:101E130058D19FEB540F6006FF1FD1588002D102A7:101E2300D1A77D45D1A9EE600414B48005D1A7E400:101E3300800C40067D2BD1A98004D19BF404C2E71A:101E4300F87A0079587B00F1047858E2FDD1A908AB:101E5300E8B501F722EF600EE64430081FFDD1A973:101E6300E4B833F1745522A900E7700409B933F9D2:101E730022EEC394805001E4FF22C374809E50017C:101E8300E422EF60FCD1A71F80F8FFEF60F3D1A33A:101E93001F80F8D185EC600C7D2D800A7D2E800695:101EA3007D3080027D20219091969223F1EBB34007:101EB300287B0079008015A389008B02F1EB400C8D:101EC30030231691B64003A3800F240975F00A301E:101ED300230375F010D1E350DEE492E12275F00A9A:101EE300C0E0C0F0E9A4F9EBABF0D0F0A4A2D29229:101EF300D52BFBD0E072D54007540F29F9E43BFB07:101F030022E4902710F1219003E8F121900064F17D:101F13002190000AF121900001F1216020227EFF2F:101F23000ECAB58300CA4012C89582C8CA9583CA2F:101F330050EEC82582C8CA3583CA4E60E074302E7D:101F43008BA0F309B900010B22D1A7A2369223EB90:101F5300F16FEBF170C223E9F16FE9F1707D48C1D4:101F6300A9C2232490D43440D4FD80F3C4540F7009:051F7300F03023ED2217:0D1FEB00B16CB43A00400122B43000B322C2:00000001FF
123version https://git-lfs.github.com/spec/v1oid sha256:10ede0840641e30c1bd30db7f1d0e4826caee781ee1185ec3f0a323f18dd36cesize 80326123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277ASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 1MCS-51 Family Cross Assembler A S E M - 5 1 V 1.2=====================================================Source File: FP-52.ASMObject File: FP-52.HEXList File: FP-52.LSTLine I Addr Code Source1: ;************************************************************2: ;3: ; This is a complete BCD floating point package for the 8051 micro-4: ; controller. It provides 8 digits of accuracy with exponents that5: ; range from +127 to -127. The mantissa is in packed BCD, while the6: ; exponent is expressed in pseudo-twos complement. A ZERO exponent7: ; is used to express the number ZERO. An exponent value of 80H or8: ; greater than means the exponent is positive, i.e. 80H = E 0,9: ; 81H = E+1, 82H = E+2 and so on. If the exponent is 7FH or less,10: ; the exponent is negative, 7FH = E-1, 7EH = E-2, and so on.11: ; ALL NUMBERS ARE ASSUMED TO BE NORMALIZED and all results are12: ; normalized after calculation. A normalized mantissa is >=.10 and13: ; <=.99999999.14: ;15: ; The numbers in memory assumed to be stored as follows:16: ;17: ; EXPONENT OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE18: ; SIGN OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE-119: ; DIGIT 78 OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE-220: ; DIGIT 56 OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE-321: ; DIGIT 34 OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE-422: ; DIGIT 12 OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE-523: ;24: ; EXPONENT OF ARGUMENT 1 = VALUE OF ARG_STACK25: ; SIGN OF ARGUMENT 1 = VALUE OF ARG_STACK-126: ; DIGIT 78 OF ARGUMENT 1 = VALUE OF ARG_STACK-227: ; DIGIT 56 OF ARGUMENT 1 = VALUE OF ARG_STACK-328: ; DIGIT 34 OF ARGUMENT 1 = VALUE OF ARG_STACK-429: ; DIGIT 12 OF ARGUMENT 1 = VALUE OF ARG_STACK-530: ;31: ; The operations are performed thusly:32: ;33: ; ARG_STACK+FP_NUMBER_SIZE = ARG_STACK+FP_NUMBER_SIZE # ARG_STACK34: ;35: ; Which is ARGUMENT 2 = ARGUMENT 2 # ARGUMENT 136: ;37: ; Where # can be ADD, SUBTRACT, MULTIPLY OR DIVIDE.38: ;39: ; Note that the stack gets popped after an operation.40: ;41: ; The FP_COMP instruction POPS the ARG_STACK TWICE and returns status.42: ;43: ;**********************************************************************ASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 2Line I Addr Code Source44: ;45: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 3Line I Addr Code Source46: ;**********************************************************************47: ;48: ; STATUS ON RETURN - After performing an operation (+, -, *, /)49: ; the accumulator contains the following status50: ;51: ; ACCUMULATOR - BIT 0 - FLOATING POINT UNDERFLOW OCCURED52: ;53: ; - BIT 1 - FLOATING POINT OVERFLOW OCCURED54: ;55: ; - BIT 2 - RESULT WAS ZER056: ;57: ; - BIT 3 - DIVIDE BY ZERO ATTEMPTED58: ;59: ; - BIT 4 - NOT USED, 0 RETURNED60: ;61: ; - BIT 5 - NOT USED, 0 RETURNED62: ;63: ; - BIT 6 - NOT USED, 0 RETURNED64: ;65: ; - BIT 7 - NOT USED, 0 RETURNED66: ;67: ; NOTE: When underflow occures, a ZERO result is returned.68: ; When overflow or divide by zero occures, a result of69: ; .99999999 E+127 is returned and it is up to the user70: ; to handle these conditions as needed in the program.71: ;72: ; NOTE: The Compare instruction returns F0 = 0 if ARG 1 = ARG 273: ; and returns a CARRY FLAG = 1 if ARG 1 is > ARG 274: ;75: ;***********************************************************************76: ;77: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 4Line I Addr Code Source78: ;***********************************************************************79: ;80: ; The following values MUST be provided by the user81: ;82: ;***********************************************************************83: ;84: N 0009 ARG_STACK EQU 9 ;ARGUMENT STACK POINTER85: N 0001 ARG_STACK_PAGE EQU 186: N 0017 FORMAT EQU 23 ;LOCATION OF OUTPUT FORMAT BYTE87: N 1990 OUTPUT EQU 1990H ;CALL LOCATION TO OUTPUT A CHARACTER88: N 0058 CONVT EQU 58H ;LOCATION TO CONVERT NUMBERS89: N 19 INTGRC BIT 25 ;BIT SET IF INTGER ERROR90: N 36 ZSURP BIT 54 ;ZERO SUPRESSION FOR HEX PRINT91: ;92: ;***********************************************************************93: ;94: ; The following equates are used internally95: ;96: ;***********************************************************************97: ;98: N 0006 FP_NUMBER_SIZE EQU 699: N 0004 DIGIT EQU FP_NUMBER_SIZE-2100: N 0000 R0B0 EQU 0101: N 0001 R1B0 EQU 1102: N 0000 UNDERFLOW EQU 0103: N 0001 OVERFLOW EQU 1104: N 0002 ZERO EQU 2105: N 0003 ZERO_DIVIDE EQU 3106: ;107: ;***********************************************************************108: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 5Line I Addr Code Source109: ;**************************************************************110: ;111: ; The following internal locations are used by the math pack112: ; ordering is important and the FP_DIGITS must be bit113: ; addressable114: ;115: ;***************************************************************116: ;117: N 0028 FP_STATUS EQU 28H ;NOT USED118: N 0029 FP_TEMP EQU FP_STATUS+1 ;NOT USED119: N 002A FP_CARRY EQU FP_STATUS+2 ;USED FOR BITS120: N 23 ADD_IN BIT 35 ;DCMPXZ IN BASIC BACKAGE121: B 50 XSIGN BIT FP_CARRY.0122: B 51 FOUND_RADIX BIT FP_CARRY.1123: B 52 FIRST_RADIX BIT FP_CARRY.2124: B 53 DONE_LOAD BIT FP_CARRY.3125: N 002B FP_DIG12 EQU FP_CARRY+1126: N 002C FP_DIG34 EQU FP_CARRY+2127: N 002D FP_DIG56 EQU FP_CARRY+3128: N 002E FP_DIG78 EQU FP_CARRY+4129: N 002F FP_SIGN EQU FP_CARRY+5130: B 78 MSIGN BIT FP_SIGN.0131: N 0030 FP_EXP EQU FP_CARRY+6132: N 002B FP_NIB1 EQU FP_DIG12133: N 002C FP_NIB2 EQU FP_NIB1+1134: N 002D FP_NIB3 EQU FP_NIB1+2135: N 002E FP_NIB4 EQU FP_NIB1+3136: N 002F FP_NIB5 EQU FP_NIB1+4137: N 0030 FP_NIB6 EQU FP_NIB1+5138: N 0031 FP_NIB7 EQU FP_NIB1+6139: N 0032 FP_NIB8 EQU FP_NIB1+7140: N 0033 FP_ACCX EQU FP_NIB1+8141: N 0034 FP_ACCC EQU FP_NIB1+9142: N 0035 FP_ACC1 EQU FP_NIB1+10143: N 0036 FP_ACC2 EQU FP_NIB1+11144: N 0037 FP_ACC3 EQU FP_NIB1+12145: N 0038 FP_ACC4 EQU FP_NIB1+13146: N 0039 FP_ACC5 EQU FP_NIB1+14147: N 003A FP_ACC6 EQU FP_NIB1+15148: N 003B FP_ACC7 EQU FP_NIB1+16149: N 003C FP_ACC8 EQU FP_NIB1+17150: N 003D FP_ACCS EQU FP_NIB1+18151: ;152: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 6Line I Addr Code Source153: N 1993 ORG 1993H154: ;155: ;**************************************************************156: ;157: ; The floating point entry points and jump table158: ;159: ;**************************************************************160: ;161: 1993 21 B7 AJMP FLOATING_ADD162: 1995 21 AD AJMP FLOATING_SUB163: 1997 41 6A AJMP FLOATING_COMP164: 1999 41 9A AJMP FLOATING_MUL165: 199B 41 CF AJMP FLOATING_DIV166: 199D 81 96 AJMP HEXSCAN167: 199F 81 CF AJMP FLOATING_POINT_INPUT168: 19A1 A1 87 AJMP FLOATING_POINT_OUTPUT169: 19A3 E1 04 AJMP CONVERT_BINARY_TO_ASCII_STRING170: 19A5 C1 AB AJMP CONVERT_ASCII_STRING_TO_BINARY171: 19A7 C1 E0 AJMP MULNUM10172: 19A9 E1 4C AJMP HEXOUT173: 19AB 81 C3 AJMP PUSHR2R0174: ;175: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 7Line I Addr Code Source176: ;177: 19AD FLOATING_SUB:178: ;179: 19AD 75 A0 01 MOV P2,#ARG_STACK_PAGE180: 19B0 A8 09 MOV R0,ARG_STACK181: 19B2 18 DEC R0 ;POINT TO SIGN182: 19B3 E2 MOVX A,@R0 ;READ SIGN183: 19B4 B2 E0 CPL ACC.0184: 19B6 F2 MOVX @R0,A185: ;186: ;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA187: ;188: 19B7 FLOATING_ADD:189: ;190: ;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA191: ;192: ;193: 19B7 91 77 ACALL MDES1 ;R7=TOS EXP, R6=TOS-1 EXP, R4=TOS SIGN194: ;R3=TOS-1 SIGN, OPERATION IS R1 # R0195: ;196: 19B9 EF MOV A,R7 ;GET TOS EXPONENT197: 19BA 60 0D JZ POP_AND_EXIT ;IF TOS=0 THEN POP AND EXIT198: 19BC BE 00 12 CJNE R6,#0,LOAD1 ;CLEAR CARRY EXIT IF ZERO199: ;200: ;**************************************************************201: ;202: 19BF SWAP_AND_EXIT: ; Swap external args and return203: ;204: ;**************************************************************205: ;206: 19BF 91 6B ACALL LOAD_POINTERS207: 19C1 7F 06 MOV R7,#FP_NUMBER_SIZE208: ;209: 19C3 E2 SE1: MOVX A,@R0 ;SWAP THE ARGUMENTS210: 19C4 F3 MOVX @R1,A211: 19C5 18 DEC R0212: 19C6 19 DEC R1213: 19C7 DF FA DJNZ R7,SE1214: ;215: 19C9 POP_AND_EXIT:216: ;217: 19C9 E5 09 MOV A,ARG_STACK ;POP THE STACK218: 19CB 24 06 ADD A,#FP_NUMBER_SIZE219: 19CD F5 09 MOV ARG_STACK,A220: 19CF E4 CLR A221: 19D0 22 RET222: ;223: ;224: 19D1 9E LOAD1: SUBB A,R6 ;A = ARG 1 EXP - ARG 2 EXP225: 19D2 8F 30 MOV FP_EXP,R7 ;SAVE EXPONENT AND SIGN226: 19D4 8C 2F MOV FP_SIGN,R4227: 19D6 50 09 JNC LOAD2 ;ARG1 EXPONENT IS LARGER OR SAME228: 19D8 8E 30 MOV FP_EXP,R6229: 19DA 8B 2F MOV FP_SIGN,R3230: 19DC F4 CPL A231: 19DD 04 INC A ;COMPENSATE FOR EXP DELTAASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 8Line I Addr Code Source232: 19DE C8 XCH A,R0 ;FORCE R0 TO POINT AT THE LARGEST233: 19DF C9 XCH A,R1 ;EXPONENT234: 19E0 C8 XCH A,R0235: ;236: 19E1 FF LOAD2: MOV R7,A ;SAVE THE EXPONENT DELTA IN R7237: 19E2 C2 23 CLR ADD_IN238: 19E4 BD 00 02 CJNE R5,#0,$+5239: 19E7 D2 23 SETB ADD_IN240: ;241: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 9Line I Addr Code Source242: ; Load the R1 mantissa243: ;244: 19E9 91 88 ACALL LOADR1_MANTISSA ;LOAD THE SMALLEST NUMBER245: ;246: ; Now align the number to the delta exponent247: ; R4 points to the string of the last digits lost248: ;249: 19EB BF 0B 00 CJNE R7,#DIGIT+DIGIT+3,$+3250: 19EE 40 02 JC $+4251: 19F0 7F 0A MOV R7,#DIGIT+DIGIT+2252: ;253: 19F2 75 2A 00 MOV FP_CARRY,#00 ;CLEAR THE CARRY254: 19F5 71 C8 ACALL RIGHT ;SHIFT THE NUMBER255: ;256: ; Set up for addition and subtraction257: ;258: 19F7 7F 04 MOV R7,#DIGIT ;LOOP COUNT259: 19F9 79 2E MOV R1,#FP_DIG78260: 19FB 74 9E MOV A,#9EH261: 19FD C3 CLR C262: 19FE 9C SUBB A,R4263: 19FF D4 DA A264: 1A00 CC XCH A,R4265: 1A01 70 01 JNZ $+3266: 1A03 FC MOV R4,A267: 1A04 B4 50 00 CJNE A,#50H,$+3 ;TEST FOR SUBTRACTION268: 1A07 30 23 18 JNB ADD_IN,SUBLP ;DO SUBTRACTION IF NO ADD_IN269: 1A0A B3 CPL C ;FLIP CARRY FOR ADDITION270: 1A0B 51 19 ACALL ADDLP ;DO ADDITION271: ;272: 1A0D 50 08 JNC ADD_R273: 1A0F 05 2A INC FP_CARRY274: 1A11 7F 01 MOV R7,#1275: 1A13 71 C8 ACALL RIGHT276: 1A15 71 7F ACALL INC_FP_EXP ;SHIFT AND BUMP EXPONENT277: ;278: 1A17 61 70 ADD_R: AJMP STORE_ALIGN_TEST_AND_EXIT279: ;280: 1A19 E2 ADDLP: MOVX A,@R0281: 1A1A 37 ADDC A,@R1282: 1A1B D4 DA A283: 1A1C F7 MOV @R1,A284: 1A1D 18 DEC R0285: 1A1E 19 DEC R1286: 1A1F DF F8 DJNZ R7,ADDLP ;LOOP UNTIL DONE287: 1A21 22 RET288: ;289: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 10Line I Addr Code Source290: ;291: 1A22 E2 SUBLP: MOVX A,@R0 ;NOW DO SUBTRACTION292: 1A23 FE MOV R6,A293: 1A24 E4 CLR A294: 1A25 34 99 ADDC A,#99H295: 1A27 97 SUBB A,@R1296: 1A28 2E ADD A,R6297: 1A29 D4 DA A298: 1A2A F7 MOV @R1,A299: 1A2B 18 DEC R0300: 1A2C 19 DEC R1301: 1A2D DF F3 DJNZ R7,SUBLP302: 1A2F 40 11 JC FSUB6303: ;304: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 11Line I Addr Code Source305: ;306: ; Need to complement the result and sign because the floating307: ; point accumulator mantissa was larger than the external308: ; memory and their signs were equal.309: ;310: 1A31 B2 78 CPL FP_SIGN.0311: 1A33 79 2E MOV R1,#FP_DIG78312: 1A35 7F 04 MOV R7,#DIGIT ;LOOP COUNT313: ;314: 1A37 74 9A FSUB5: MOV A,#9AH315: 1A39 97 SUBB A,@R1316: 1A3A 24 00 ADD A,#0317: 1A3C D4 DA A318: 1A3D F7 MOV @R1,A319: 1A3E 19 DEC R1320: 1A3F B3 CPL C321: 1A40 DF F5 DJNZ R7,FSUB5 ;LOOP322: ;323: ; Now see how many zeros their are324: ;325: 1A42 78 2B FSUB6: MOV R0,#FP_DIG12326: 1A44 7F 00 MOV R7,#0327: ;328: 1A46 E6 FSUB7: MOV A,@R0329: 1A47 70 08 JNZ FSUB8330: 1A49 0F INC R7331: 1A4A 0F INC R7332: 1A4B 08 INC R0333: 1A4C B8 2F F7 CJNE R0,#FP_SIGN,FSUB7334: 1A4F 61 B8 AJMP ZERO_AND_EXIT335: ;336: 1A51 B4 10 00 FSUB8: CJNE A,#10H,$+3337: 1A54 50 01 JNC FSUB9338: 1A56 0F INC R7339: ;340: ; Now R7 has the number of leading zeros in the FP ACC341: ;342: 1A57 E5 30 FSUB9: MOV A,FP_EXP ;GET THE OLD EXPONENT343: 1A59 C3 CLR C344: 1A5A 9F SUBB A,R7 ;SUBTRACT FROM THE NUMBER OF ZEROS345: 1A5B 60 0B JZ FSUB10346: 1A5D 40 09 JC FSUB10347: ;348: 1A5F F5 30 MOV FP_EXP,A ;SAVE THE NEW EXPONENT349: ;350: 1A61 91 02 ACALL LEFT1 ;SHIFT THE FP ACC351: 1A63 75 2A 00 MOV FP_CARRY,#0352: 1A66 61 70 AJMP STORE_ALIGN_TEST_AND_EXIT353: ;354: 1A68 61 B2 FSUB10: AJMP UNDERFLOW_AND_EXIT355: ;356: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 12Line I Addr Code Source357: ;***************************************************************358: ;359: 1A6A FLOATING_COMP: ; Compare two floating point numbers360: ; used for relational operations and is faster361: ; than subtraction. ON RETURN, The carry is set362: ; if ARG1 is > ARG2, else carry is not set363: ; if ARG1 = ARG2, F0 gets set364: ;365: ;***************************************************************366: ;367: 1A6A 91 77 ACALL MDES1 ;SET UP THE REGISTERS368: 1A6C E5 09 MOV A,ARG_STACK369: 1A6E 24 0C ADD A,#FP_NUMBER_SIZE+FP_NUMBER_SIZE370: 1A70 F5 09 MOV ARG_STACK,A ;POP THE STACK TWICE, CLEAR THE CARRY371: 1A72 EE MOV A,R6 ;CHECK OUT EXPONENTS372: 1A73 C2 D5 CLR F0373: 1A75 9F SUBB A,R7374: 1A76 60 0A JZ EXPONENTS_EQUAL375: 1A78 40 03 JC ARG1_EXP_IS_LARGER376: ;377: ; Now the ARG2 EXPONENT is > ARG1 EXPONENT378: ;379: 1A7A SIGNS_DIFFERENT:380: ;381: 1A7A EB MOV A,R3 ;SEE IF SIGN OF ARG2 IS POSITIVE382: 1A7B 80 01 SJMP $+3383: ;384: 1A7D ARG1_EXP_IS_LARGER:385: ;386: 1A7D EC MOV A,R4 ;GET THE SIGN OF ARG1 EXPONENT387: 1A7E 60 01 JZ $+3388: 1A80 B3 CPL C389: 1A81 22 RET390: ;391: 1A82 EXPONENTS_EQUAL:392: ;393: ; First, test the sign, then the mantissa394: ;395: 1A82 BD 00 F5 CJNE R5,#0,SIGNS_DIFFERENT396: ;397: 1A85 BOTH_PLUS:398: ;399: 1A85 7F 04 MOV R7,#DIGIT ;POINT AT MS DIGIT400: 1A87 18 DEC R0401: 1A88 18 DEC R0402: 1A89 18 DEC R0403: 1A8A 19 DEC R1404: 1A8B 19 DEC R1405: 1A8C 19 DEC R1406: ;407: ; Now do the compare408: ;409: 1A8D E2 CLOOP: MOVX A,@R0410: 1A8E FE MOV R6,A411: 1A8F E3 MOVX A,@R1412: 1A90 9E SUBB A,R6ASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 13Line I Addr Code Source413: 1A91 70 EA JNZ ARG1_EXP_IS_LARGER414: 1A93 08 INC R0415: 1A94 09 INC R1416: 1A95 DF F6 DJNZ R7,CLOOP417: ;418: ; If here, the numbers are the same, the carry is cleared419: ;420: 1A97 D2 D5 SETB F0421: 1A99 22 RET ;EXIT WITH EQUAL422: ;423: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 14Line I Addr Code Source424: ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM425: ;426: 1A9A FLOATING_MUL: ; Floating point multiply427: ;428: ;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM429: ;430: 1A9A 91 75 ACALL MUL_DIV_EXP_AND_SIGN431: ;432: ; check for zero exponents433: ;434: 1A9C BE 00 02 CJNE R6,#00,$+5 ;ARG 2 EXP ZERO?435: 1A9F 61 B8 AJMP ZERO_AND_EXIT436: ;437: ; calculate the exponent438: ;439: 1AA1 8D 2F FMUL1: MOV FP_SIGN,R5 ;SAVE THE SIGN, IN CASE OF FAILURE440: ;441: 1AA3 EF MOV A,R7442: 1AA4 60 F9 JZ FMUL1-2443: 1AA6 2E ADD A,R6 ;ADD THE EXPONENTS444: 1AA7 20 E7 05 JB ACC.7,FMUL_OVER445: 1AAA 10 D7 06 JBC CY,FMUL2 ;SEE IF CARRY IS SET446: ;447: 1AAD 61 B2 AJMP UNDERFLOW_AND_EXIT448: ;449: 1AAF FMUL_OVER:450: ;451: 1AAF 50 02 JNC FMUL2 ;OK IF SET452: ;453: 1AB1 61 A1 FOV: AJMP OVERFLOW_AND_EXIT454: ;455: 1AB3 94 81 FMUL2: SUBB A,#129 ;SUBTRACT THE EXPONENT BIAS456: 1AB5 FE MOV R6,A ;SAVE IT FOR LATER457: ;458: ; Unpack and load R0459: ;460: 1AB6 71 8B ACALL UNPACK_R0461: ;462: ; Now set up for loop multiply463: ;464: 1AB8 7B 04 MOV R3,#DIGIT465: 1ABA AC 01 MOV R4,R1B0466: ;467: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 15Line I Addr Code Source468: ;469: ; Now, do the multiply and accumulate the product470: ;471: 1ABC 8C 01 FMUL3: MOV R1B0,R4472: 1ABE E3 MOVX A,@R1473: 1ABF FA MOV R2,A474: 1AC0 91 38 ACALL MUL_NIBBLE475: ;476: 1AC2 EA MOV A,R2477: 1AC3 C4 SWAP A478: 1AC4 91 38 ACALL MUL_NIBBLE479: 1AC6 1C DEC R4480: 1AC7 DB F3 DJNZ R3,FMUL3481: ;482: ; Now, pack and restore the sign483: ;484: 1AC9 8E 30 MOV FP_EXP,R6485: 1ACB 8D 2F MOV FP_SIGN,R5486: 1ACD 61 30 AJMP PACK ;FINISH IT OFF487: ;488: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 16Line I Addr Code Source489: ;DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD490: ;491: 1ACF FLOATING_DIV:492: ;493: ;DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD494: ;495: 1ACF 91 77 ACALL MDES1496: ;497: ; Check the exponents498: ;499: 1AD1 8D 2F MOV FP_SIGN,R5 ;SAVE THE SIGN500: 1AD3 BF 00 06 CJNE R7,#0,DIV0 ;CLEARS THE CARRY501: 1AD6 71 A1 ACALL OVERFLOW_AND_EXIT502: 1AD8 E4 CLR A503: 1AD9 D2 E3 SETB ACC.ZERO_DIVIDE504: 1ADB 22 RET505: ;506: 1ADC EE DIV0: MOV A,R6 ;GET EXPONENT507: 1ADD 60 C0 JZ FMUL1-2 ;EXIT IF ZERO508: 1ADF 9F SUBB A,R7 ;DELTA EXPONENT509: 1AE0 20 E7 04 JB ACC.7,D_UNDER510: 1AE3 50 04 JNC DIV3511: 1AE5 61 B2 AJMP UNDERFLOW_AND_EXIT512: ;513: 1AE7 50 C8 D_UNDER:JNC FOV514: ;515: 1AE9 24 81 DIV3: ADD A,#129 ;CORRECTLY BIAS THE EXPONENT516: 1AEB F5 30 MOV FP_EXP,A ;SAVE THE EXPONENT517: 1AED 91 88 ACALL LOADR1_MANTISSA ;LOAD THE DIVIDED518: ;519: 1AEF 7A 34 MOV R2,#FP_ACCC ;SAVE LOCATION520: 1AF1 AB 00 MOV R3,R0B0 ;SAVE POINTER IN R3521: 1AF3 75 2A 00 MOV FP_CARRY,#0 ;ZERO CARRY BYTE522: ;523: 1AF6 7D FF DIV4: MOV R5,#0FFH ;LOOP COUNT524: 1AF8 D3 SETB C525: ;526: 1AF9 8B 00 DIV5: MOV R0B0,R3 ;RESTORE THE EXTERNAL POINTER527: 1AFB 79 2E MOV R1,#FP_DIG78 ;SET UP INTERNAL POINTER528: 1AFD 7F 04 MOV R7,#DIGIT ;LOOP COUNT529: 1AFF 50 17 JNC DIV7 ;EXIT IF NO CARRY530: ;531: 1B01 E2 DIV6: MOVX A,@R0 ;DO ACCUMLATION532: 1B02 FE MOV R6,A533: 1B03 E4 CLR A534: 1B04 34 99 ADDC A,#99H535: 1B06 9E SUBB A,R6536: 1B07 27 ADD A,@R1537: 1B08 D4 DA A538: 1B09 F7 MOV @R1,A539: 1B0A 18 DEC R0540: 1B0B 19 DEC R1541: 1B0C DF F3 DJNZ R7,DIV6 ;LOOP542: ;543: 1B0E 0D INC R5 ;SUBTRACT COUNTER544: 1B0F 40 E8 JC DIV5 ;KEEP LOOPING IF CARRYASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 17Line I Addr Code Source545: 1B11 E7 MOV A,@R1 ;GET CARRY546: 1B12 94 01 SUBB A,#1 ;CARRY IS CLEARED547: 1B14 F7 MOV @R1,A ;SAVE CARRY DIGIT548: 1B15 B3 CPL C549: 1B16 80 E1 SJMP DIV5 ;LOOP550: ;551: ; Restore the result if carry was found552: ;553: 1B18 51 19 DIV7: ACALL ADDLP ;ADD NUMBER BACK554: 1B1A 77 00 MOV @R1,#0 ;CLEAR CARRY555: 1B1C 8A 00 MOV R0B0,R2 ;GET SAVE COUNTER556: 1B1E A6 05 MOV @R0,5 ;SAVE COUNT BYTE557: ;558: 1B20 0A INC R2 ;ADJUST SAVE COUNTER559: 1B21 7F 01 MOV R7,#1 ;BUMP DIVIDEND560: 1B23 91 00 ACALL LEFT561: 1B25 BA 3E CE CJNE R2,#FP_ACC8+2,DIV4562: ;563: 1B28 D5 30 02 DJNZ FP_EXP,DIV8564: 1B2B 61 B2 AJMP UNDERFLOW_AND_EXIT565: ;566: 1B2D 75 2A 00 DIV8: MOV FP_CARRY,#0567: ;568: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 18Line I Addr Code Source569: ;***************************************************************570: ;571: 1B30 PACK: ; Pack the mantissa572: ;573: ;***************************************************************574: ;575: ; First, set up the pointers576: ;577: 1B30 78 34 MOV R0,#FP_ACCC578: 1B32 E6 MOV A,@R0 ;GET FP_ACCC579: 1B33 FE MOV R6,A ;SAVE FOR ZERO COUNT580: 1B34 60 03 JZ PACK0 ;JUMP OVER IF ZERO581: 1B36 71 7F ACALL INC_FP_EXP ;BUMP THE EXPONENT582: 1B38 18 DEC R0583: ;584: 1B39 08 PACK0: INC R0 ;POINT AT FP_ACC1585: ;586: 1B3A 74 08 PACK1: MOV A,#8 ;ADJUST NIBBLE POINTER587: 1B3C F9 MOV R1,A588: 1B3D 28 ADD A,R0589: 1B3E F8 MOV R0,A590: 1B3F B6 05 00 CJNE @R0,#5,$+3 ;SEE IF ADJUSTING NEEDED591: 1B42 40 13 JC PACK3+1592: ;593: 1B44 D3 PACK2: SETB C594: 1B45 E4 CLR A595: 1B46 18 DEC R0596: 1B47 36 ADDC A,@R0597: 1B48 D4 DA A598: 1B49 D6 XCHD A,@R0 ;SAVE THE VALUE599: 1B4A 30 E4 09 JNB ACC.4,PACK3600: 1B4D D9 F5 DJNZ R1,PACK2601: ;602: 1B4F 18 DEC R0603: 1B50 76 01 MOV @R0,#1604: 1B52 71 7F ACALL INC_FP_EXP605: 1B54 80 06 SJMP PACK4606: ;607: 1B56 19 PACK3: DEC R1608: 1B57 E9 MOV A,R1609: 1B58 C3 CLR C610: 1B59 C8 XCH A,R0611: 1B5A 98 SUBB A,R0612: 1B5B F8 MOV R0,A613: ;614: 1B5C 79 2B PACK4: MOV R1,#FP_DIG12615: ;616: ; Now, pack617: ;618: 1B5E E6 PLOOP: MOV A,@R0619: 1B5F C4 SWAP A ;FLIP THE DIGITS620: 1B60 08 INC R0621: 1B61 D6 XCHD A,@R0622: 1B62 42 06 ORL 6,A ;ACCUMULATE THE OR'ED DIGITS623: 1B64 F7 MOV @R1,A624: 1B65 08 INC R0ASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 19Line I Addr Code Source625: 1B66 09 INC R1626: 1B67 B9 2F F4 CJNE R1,#FP_SIGN,PLOOP627: 1B6A EE MOV A,R6628: 1B6B 70 03 JNZ STORE_ALIGN_TEST_AND_EXIT629: 1B6D 75 30 00 MOV FP_EXP,#0 ;ZERO EXPONENT630: ;631: ;**************************************************************632: ;633: 1B70 STORE_ALIGN_TEST_AND_EXIT: ;Save the number align carry and exit634: ;635: ;**************************************************************636: ;637: 1B70 91 6B ACALL LOAD_POINTERS638: 1B72 89 09 MOV ARG_STACK,R1 ;SET UP THE NEW STACK639: 1B74 78 30 MOV R0,#FP_EXP640: ;641: ; Now load the numbers642: ;643: 1B76 E6 STORE2: MOV A,@R0644: 1B77 F3 MOVX @R1,A ;SAVE THE NUMBER645: 1B78 18 DEC R0646: 1B79 19 DEC R1647: 1B7A B8 2A F9 CJNE R0,#FP_CARRY,STORE2648: ;649: 1B7D E4 CLR A ;NO ERRORS650: ;651: 1B7E 22 PRET: RET ;EXIT652: ;653: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 20Line I Addr Code Source654: 1B7F INC_FP_EXP:655: ;656: 1B7F 05 30 INC FP_EXP657: 1B81 E5 30 MOV A,FP_EXP658: 1B83 70 F9 JNZ PRET ;EXIT IF NOT ZERO659: 1B85 D0 E0 POP ACC ;WASTE THE CALLING STACK660: 1B87 D0 E0 POP ACC661: 1B89 61 A1 AJMP OVERFLOW_AND_EXIT662: ;663: ;***********************************************************************664: ;665: 1B8B UNPACK_R0: ; Unpack BCD digits and load into nibble locations666: ;667: ;***********************************************************************668: ;669: 1B8B C0 01 PUSH R1B0670: 1B8D 79 32 MOV R1,#FP_NIB8671: ;672: 1B8F E2 ULOOP: MOVX A,@R0673: 1B90 54 0F ANL A,#0FH674: 1B92 F7 MOV @R1,A ;SAVE THE NIBBLE675: 1B93 E2 MOVX A,@R0676: 1B94 C4 SWAP A677: 1B95 54 0F ANL A,#0FH678: 1B97 19 DEC R1679: 1B98 F7 MOV @R1,A ;SAVE THE NIBBLE AGAIN680: 1B99 18 DEC R0681: 1B9A 19 DEC R1682: 1B9B B9 2A F1 CJNE R1,#FP_NIB1-1,ULOOP683: ;684: 1B9E D0 01 POP R1B0685: ;686: 1BA0 22 LOAD7: RET687: ;688: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 21Line I Addr Code Source689: ;**************************************************************690: ;691: 1BA1 OVERFLOW_AND_EXIT: ;LOAD 99999999 E+127, SET OV BIT, AND EXIT692: ;693: ;**************************************************************694: ;695: 1BA1 78 2E MOV R0,#FP_DIG78696: 1BA3 74 99 MOV A,#99H697: ;698: 1BA5 F6 OVE1: MOV @R0,A699: 1BA6 18 DEC R0700: 1BA7 B8 2A FB CJNE R0,#FP_CARRY,OVE1701: ;702: 1BAA 75 30 FF MOV FP_EXP,#0FFH703: 1BAD 71 70 ACALL STORE_ALIGN_TEST_AND_EXIT704: ;705: 1BAF D2 E1 SETB ACC.OVERFLOW706: 1BB1 22 RET707: ;708: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 22Line I Addr Code Source709: ;**************************************************************710: ;711: 1BB2 UNDERFLOW_AND_EXIT: ;LOAD 0, SET UF BIT, AND EXIT712: ;713: ;**************************************************************714: ;715: 1BB2 71 B8 ACALL ZERO_AND_EXIT716: 1BB4 E4 CLR A717: 1BB5 D2 E0 SETB ACC.UNDERFLOW718: 1BB7 22 RET719: ;720: ;**************************************************************721: ;722: 1BB8 ZERO_AND_EXIT: ;LOAD 0, SET ZERO BIT, AND EXIT723: ;724: ;**************************************************************725: ;726: 1BB8 71 BF ACALL FP_CLEAR727: 1BBA 71 70 ACALL STORE_ALIGN_TEST_AND_EXIT728: 1BBC D2 E2 SETB ACC.ZERO729: 1BBE 22 RET ;EXIT730: ;731: ;**************************************************************732: ;733: 1BBF FP_CLEAR:734: ;735: ; Clear internal storage736: ;737: ;**************************************************************738: ;739: 1BBF E4 CLR A740: 1BC0 78 3D MOV R0,#FP_ACC8+1741: ;742: 1BC2 F6 FPC1: MOV @R0,A743: 1BC3 18 DEC R0744: 1BC4 B8 29 FB CJNE R0,#FP_TEMP,FPC1745: 1BC7 22 RET746: ;747: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 23Line I Addr Code Source748: ;**************************************************************749: ;750: 1BC8 RIGHT: ; Shift ACCUMULATOR RIGHT the number of nibbles in R7751: ; Save the shifted values in R4 if SAVE_ROUND is set752: ;753: ;**************************************************************754: ;755: 1BC8 7C 00 MOV R4,#0 ;IN CASE OF NO SHIFT756: ;757: 1BCA C3 RIGHT1: CLR C758: 1BCB EF MOV A,R7 ;GET THE DIGITS TO SHIFT759: 1BCC 60 22 JZ RIGHT5-1 ;EXIT IF ZERO760: 1BCE 94 02 SUBB A,#2 ;TWO TO DO?761: 1BD0 50 1F JNC RIGHT5 ;SHIFT TWO NIBBLES762: ;763: ; Swap one nibble then exit764: ;765: 1BD2 C0 00 RIGHT3: PUSH R0B0 ;SAVE POINTER REGISTER766: 1BD4 C0 01 PUSH R1B0767: ;768: 1BD6 79 2E MOV R1,#FP_DIG78 ;LOAD THE POINTERS769: 1BD8 78 2D MOV R0,#FP_DIG56770: 1BDA EC MOV A,R4 ;GET THE OVERFLOW REGISTER771: 1BDB D7 XCHD A,@R1 ;GET DIGIT 8772: 1BDC C4 SWAP A ;FLIP FOR LOAD773: 1BDD FC MOV R4,A774: ;775: 1BDE E7 RIGHTL: MOV A,@R1 ;GET THE LOW ORDER BYTE776: 1BDF D6 XCHD A,@R0 ;SWAP NIBBLES777: 1BE0 C4 SWAP A ;FLIP FOR STORE778: 1BE1 F7 MOV @R1,A ;SAVE THE DIGITS779: 1BE2 18 DEC R0 ;BUMP THE POINTERS780: 1BE3 19 DEC R1781: 1BE4 B9 2A F7 CJNE R1,#FP_DIG12-1,RIGHTL ;LOOP782: ;783: 1BE7 E7 MOV A,@R1 ;ACC = CH8784: 1BE8 C4 SWAP A ;ACC = 8CH785: 1BE9 54 0F ANL A,#0FH ;ACC = 0CH786: 1BEB F7 MOV @R1,A ;CARRY DONE787: 1BEC D0 01 POP R1B0 ;EXIT788: 1BEE D0 00 POP R0B0 ;RESTORE REGISTER789: 1BF0 22 RET790: ;791: 1BF1 FF RIGHT5: MOV R7,A ;SAVE THE NEW SHIFT NUMBER792: 1BF2 E4 CLR A793: 1BF3 C5 2A XCH A,FP_CARRY ;SWAP THE NIBBLES794: 1BF5 C5 2B XCH A,FP_DIG12795: 1BF7 C5 2C XCH A,FP_DIG34796: 1BF9 C5 2D XCH A,FP_DIG56797: 1BFB C5 2E XCH A,FP_DIG78798: 1BFD FC MOV R4,A ;SAVE THE LAST DIGIT SHIFTED799: 1BFE 80 CB SJMP RIGHT1+1800: ;801: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 24Line I Addr Code Source802: ;***************************************************************803: ;804: 1C00 LEFT: ; Shift ACCUMULATOR LEFT the number of nibbles in R7805: ;806: ;***************************************************************807: ;808: 1C00 7C 00 MOV R4,#00H ;CLEAR FOR SOME ENTRYS809: ;810: 1C02 C3 LEFT1: CLR C811: 1C03 EF MOV A,R7 ;GET SHIFT VALUE812: 1C04 60 22 JZ LEFT5-1 ;EXIT IF ZERO813: 1C06 94 02 SUBB A,#2 ;SEE HOW MANY BYTES TO SHIFT814: 1C08 50 1F JNC LEFT5815: ;816: 1C0A C0 00 LEFT3: PUSH R0B0 ;SAVE POINTER817: 1C0C C0 01 PUSH R1B0818: 1C0E 78 2A MOV R0,#FP_CARRY819: 1C10 79 2B MOV R1,#FP_DIG12820: ;821: 1C12 E6 MOV A,@R0 ;ACC=CHCL822: 1C13 C4 SWAP A ;ACC = CLCH823: 1C14 F6 MOV @R0,A ;ACC = CLCH, @R0 = CLCH824: ;825: 1C15 E7 LEFTL: MOV A,@R1 ;DIG 12826: 1C16 C4 SWAP A ;DIG 21827: 1C17 D6 XCHD A,@R0828: 1C18 F7 MOV @R1,A ;SAVE IT829: 1C19 08 INC R0 ;BUMP POINTERS830: 1C1A 09 INC R1831: 1C1B B8 2E F7 CJNE R0,#FP_DIG78,LEFTL832: ;833: 1C1E EC MOV A,R4834: 1C1F C4 SWAP A835: 1C20 D6 XCHD A,@R0836: 1C21 54 F0 ANL A,#0F0H837: 1C23 FC MOV R4,A838: ;839: 1C24 D0 01 POP R1B0840: 1C26 D0 00 POP R0B0 ;RESTORE841: 1C28 22 RET ;DONE842: ;843: 1C29 FF LEFT5: MOV R7,A ;RESTORE COUNT844: 1C2A E4 CLR A845: 1C2B CC XCH A,R4 ;GET THE RESTORATION BYTE846: 1C2C C5 2E XCH A,FP_DIG78 ;DO THE SWAP847: 1C2E C5 2D XCH A,FP_DIG56848: 1C30 C5 2C XCH A,FP_DIG34849: 1C32 C5 2B XCH A,FP_DIG12850: 1C34 C5 2A XCH A,FP_CARRY851: 1C36 80 CB SJMP LEFT1+1852: ;853: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 25Line I Addr Code Source854: 1C38 MUL_NIBBLE:855: ;856: ; Multiply the nibble in R7 by the FP_NIB locations857: ; accumulate the product in FP_ACC858: ;859: ; Set up the pointers for multiplication860: ;861: 1C38 54 0F ANL A,#0FH ;STRIP OFF MS NIBBLE862: 1C3A FF MOV R7,A863: 1C3B 78 3C MOV R0,#FP_ACC8864: 1C3D 79 32 MOV R1,#FP_NIB8865: 1C3F E4 CLR A866: 1C40 F5 33 MOV FP_ACCX,A867: ;868: 1C42 18 MNLOOP: DEC R0 ;BUMP POINTER TO PROPAGATE CARRY869: 1C43 26 ADD A,@R0 ;ATTEMPT TO FORCE CARRY870: 1C44 D4 DA A ;BCD ADJUST871: 1C45 30 E4 03 JNB ACC.4,MNL0 ;DON'T ADJUST IF NO NEED872: 1C48 18 DEC R0 ;PROPAGATE CARRY TO THE NEXT DIGIT873: 1C49 06 INC @R0 ;DO THE ADJUSTING874: 1C4A 08 INC R0 ;RESTORE R0875: ;876: 1C4B D6 MNL0: XCHD A,@R0 ;RESTORE INITIAL NUMBER877: 1C4C 8F F0 MOV B,R7 ;GET THE NUBBLE TO MULTIPLY878: 1C4E E7 MOV A,@R1 ;GET THE OTHER NIBBLE879: 1C4F A4 MUL AB ;DO THE MULTIPLY880: 1C50 75 F0 0A MOV B,#10 ;NOW BCD ADJUST881: 1C53 84 DIV AB882: 1C54 C5 F0 XCH A,B ;GET THE REMAINDER883: 1C56 26 ADD A,@R0 ;PROPAGATE THE PARTIAL PRODUCTS884: 1C57 D4 DA A ;BCD ADJUST885: 1C58 30 E4 02 JNB ACC.4,MNL1 ;PROPAGATE PARTIAL PRODUCT CARRY886: 1C5B 05 F0 INC B887: ;888: 1C5D 08 MNL1: INC R0889: 1C5E D6 XCHD A,@R0 ;SAVE THE NEW PRODUCT890: 1C5F 18 DEC R0891: 1C60 E5 F0 MOV A,B ;GET BACK THE QUOTIENT892: 1C62 19 DEC R1893: 1C63 B9 2A DC CJNE R1,#FP_NIB1-1,MNLOOP894: ;895: 1C66 25 33 ADD A,FP_ACCX ;GET THE OVERFLOW896: 1C68 D4 DA A ;ADJUST897: 1C69 F6 MOV @R0,A ;SAVE IT898: 1C6A 22 RET ;EXIT899: ;900: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 26Line I Addr Code Source901: ;***************************************************************902: ;903: 1C6B LOAD_POINTERS: ; Load the ARG_STACK into R0 and bump R1904: ;905: ;***************************************************************906: ;907: 1C6B 75 A0 01 MOV P2,#ARG_STACK_PAGE908: 1C6E A8 09 MOV R0,ARG_STACK909: 1C70 74 06 MOV A,#FP_NUMBER_SIZE910: 1C72 28 ADD A,R0911: 1C73 F9 MOV R1,A912: 1C74 22 RET913: ;914: ;***************************************************************915: ;916: 1C75 MUL_DIV_EXP_AND_SIGN:917: ;918: ; Load the sign into R7, R6. R5 gets the sign for919: ; multiply and divide.920: ;921: ;***************************************************************922: ;923: 1C75 71 BF ACALL FP_CLEAR ;CLEAR INTERNAL MEMORY924: ;925: 1C77 91 6B MDES1: ACALL LOAD_POINTERS ;LOAD REGISTERS926: 1C79 E2 MOVX A,@R0 ;ARG 1 EXP927: 1C7A FF MOV R7,A ;SAVED IN R7928: 1C7B E3 MOVX A,@R1 ;ARG 2 EXP929: 1C7C FE MOV R6,A ;SAVED IN R6930: 1C7D 18 DEC R0 ;BUMP POINTERS TO SIGN931: 1C7E 19 DEC R1932: 1C7F E2 MOVX A,@R0 ;GET THE SIGN933: 1C80 FC MOV R4,A ;SIGN OF ARG1934: 1C81 E3 MOVX A,@R1 ;GET SIGN OF NEXT ARG935: 1C82 FB MOV R3,A ;SIGN OF ARG2936: 1C83 6C XRL A,R4 ;ACC GETS THE NEW SIGN937: 1C84 FD MOV R5,A ;R5 GETS THE NEW SIGN938: ;939: ; Bump the pointers to point at the LS digit940: ;941: 1C85 18 DEC R0942: 1C86 19 DEC R1943: ;944: 1C87 22 RET945: ;946: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 27Line I Addr Code Source947: ;***************************************************************948: ;949: 1C88 LOADR1_MANTISSA:950: ;951: ; Load the mantissa of R0 into FP_Digits952: ;953: ;***************************************************************954: ;955: 1C88 C0 00 PUSH R0B0 ;SAVE REGISTER 1956: 1C8A 78 2E MOV R0,#FP_DIG78 ;SET UP THE POINTER957: ;958: 1C8C E3 LOADR1: MOVX A,@R1959: 1C8D F6 MOV @R0,A960: 1C8E 19 DEC R1961: 1C8F 18 DEC R0962: 1C90 B8 2A F9 CJNE R0,#FP_CARRY,LOADR1963: ;964: 1C93 D0 00 POP R0B0965: 1C95 22 RET966: ;967: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 28Line I Addr Code Source968: ;***************************************************************969: ;970: 1C96 HEXSCAN: ; Scan a string to determine if it is a hex number971: ; set carry if hex, else carry = 0972: ;973: ;***************************************************************974: ;975: 1C96 B1 6C ACALL GET_DPTR_CHARACTER976: 1C98 C0 83 PUSH DPH977: 1C9A C0 82 PUSH DPL ;SAVE THE POINTER978: ;979: 1C9C E0 HEXSC1: MOVX A,@DPTR ;GET THE CHARACTER980: 1C9D F1 ED ACALL DIGIT_CHECK ;SEE IF A DIGIT981: 1C9F 40 12 JC HS1 ;CONTINUE IF A DIGIT982: 1CA1 91 B6 ACALL HEX_CHECK ;SEE IF HEX983: 1CA3 40 0E JC HS1984: ;985: 1CA5 C2 E5 CLR ACC.5 ;NO LOWER CASE986: 1CA7 B4 48 03 CJNE A,#'H',HEXDON987: 1CAA D3 SETB C988: 1CAB 80 01 SJMP HEXDO1 ;NUMBER IS VALID HEX, MAYBE989: ;990: 1CAD C3 HEXDON: CLR C991: ;992: 1CAE D0 82 HEXDO1: POP DPL ;RESTORE POINTER993: 1CB0 D0 83 POP DPH994: 1CB2 22 RET995: ;996: 1CB3 A3 HS1: INC DPTR ;BUMP TO NEXT CHARACTER997: 1CB4 80 E6 SJMP HEXSC1 ;LOOP998: ;999: 1CB6 HEX_CHECK: ;CHECK FOR A VALID ASCII HEX, SET CARRY IF FOUND1000: ;1001: 1CB6 C2 E5 CLR ACC.5 ;WASTE LOWER CASE1002: 1CB8 B4 47 00 CJNE A,#'F'+1,$+3 ;SEE IF F OR LESS1003: 1CBB 40 01 JC HC11004: 1CBD 22 RET1005: ;1006: 1CBE B4 41 00 HC1: CJNE A,#'A',$+3 ;SEE IF A OR GREATER1007: 1CC1 B3 CPL C1008: 1CC2 22 RET1009: ;1010: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 29Line I Addr Code Source1011: ;1012: 1CC3 PUSHR2R0:1013: ;1014: 1CC3 7B 00 MOV R3,#HIGH CONVT ;CONVERSION LOCATION1015: 1CC5 79 58 MOV R1,#LOW CONVT1016: 1CC7 F1 04 ACALL CONVERT_BINARY_TO_ASCII_STRING1017: 1CC9 74 0D MOV A,#0DH ;A CR TO TERMINATE1018: 1CCB F3 MOVX @R1,A ;SAVE THE CR1019: 1CCC 90 00 58 MOV DPTR,#CONVT1020: ;1021: ; Falls thru to FLOATING INPUT1022: ;1023: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 30Line I Addr Code Source1024: ;***************************************************************1025: ;1026: 1CCF FLOATING_POINT_INPUT: ; Input a floating point number pointed to by1027: ; the DPTR1028: ;1029: ;***************************************************************1030: ;1031: 1CCF 71 BF ACALL FP_CLEAR ;CLEAR EVERYTHING1032: 1CD1 B1 6C ACALL GET_DPTR_CHARACTER1033: 1CD3 B1 72 ACALL PLUS_MINUS_TEST1034: 1CD5 92 78 MOV MSIGN,C ;SAVE THE MANTISSA SIGN1035: ;1036: ; Now, set up for input loop1037: ;1038: 1CD7 78 34 MOV R0,#FP_ACCC1039: 1CD9 7E 7F MOV R6,#7FH ;BASE EXPONENT1040: 1CDB D2 D5 SETB F0 ;SET INITIAL FLAG1041: ;1042: 1CDD F1 EB INLOOP: ACALL GET_DIGIT_CHECK1043: 1CDF 50 07 JNC GTEST ;IF NOT A CHARACTER, WHAT IS IT?1044: 1CE1 54 0F ANL A,#0FH ;STRIP ASCII1045: 1CE3 B1 45 ACALL STDIG ;STORE THE DIGITS1046: ;1047: 1CE5 A3 INLPIK: INC DPTR ;BUMP POINTER FOR LOOP1048: 1CE6 80 F5 SJMP INLOOP ;LOOP FOR INPUT1049: ;1050: 1CE8 B4 2E 0C GTEST: CJNE A,#'.',GT1 ;SEE IF A RADIX1051: 1CEB 20 51 63 JB FOUND_RADIX,INERR1052: 1CEE D2 51 SETB FOUND_RADIX1053: 1CF0 B8 34 F2 CJNE R0,#FP_ACCC,INLPIK1054: 1CF3 D2 52 SETB FIRST_RADIX ;SET IF FIRST RADIX1055: 1CF5 80 EE SJMP INLPIK ;GET ADDITIONAL DIGITS1056: ;1057: 1CF7 20 D5 57 GT1: JB F0,INERR ;ERROR IF NOT CLEARED1058: 1CFA B4 65 02 CJNE A,#'e',$+5 ;CHECK FOR LOWER CASE1059: 1CFD 80 03 SJMP $+51060: 1CFF B4 45 33 CJNE A,#'E',FINISH_UP1061: 1D02 B1 6B ACALL INC_AND_GET_DPTR_CHARACTER1062: 1D04 B1 72 ACALL PLUS_MINUS_TEST1063: 1D06 92 50 MOV XSIGN,C ;SAVE SIGN STATUS1064: 1D08 F1 EB ACALL GET_DIGIT_CHECK1065: 1D0A 50 45 JNC INERR1066: ;1067: 1D0C 54 0F ANL A,#0FH ;STRIP ASCII BIAS OFF THE CHARACTER1068: 1D0E FD MOV R5,A ;SAVE THE CHARACTER IN R51069: ;1070: 1D0F A3 GT2: INC DPTR1071: 1D10 F1 EB ACALL GET_DIGIT_CHECK1072: 1D12 50 0D JNC FINISH11073: 1D14 54 0F ANL A,#0FH ;STRIP OFF BIAS1074: 1D16 CD XCH A,R5 ;GET THE LAST DIGIT1075: 1D17 75 F0 0A MOV B,#10 ;MULTIPLY BY TEN1076: 1D1A A4 MUL AB1077: 1D1B 2D ADD A,R5 ;ADD TO ORIGINAL VALUE1078: 1D1C FD MOV R5,A ;SAVE IN R51079: 1D1D 50 F0 JNC GT2 ;LOOP IF NO CARRYASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 31Line I Addr Code Source1080: 1D1F 7D FF MOV R5,#0FFH ;FORCE AN ERROR1081: ;1082: 1D21 ED FINISH1:MOV A,R5 ;GET THE SIGN1083: 1D22 30 50 09 JNB XSIGN,POSNUM ;SEE IF EXPONENT IS POS OR NEG1084: 1D25 C3 CLR C1085: 1D26 9E SUBB A,R61086: 1D27 F4 CPL A1087: 1D28 04 INC A1088: 1D29 40 09 JC FINISH21089: 1D2B 74 01 MOV A,#01H1090: 1D2D 22 RET1091: ;1092: 1D2E 2E POSNUM: ADD A,R6 ;ADD TO EXPONENT1093: 1D2F 50 03 JNC FINISH21094: ;1095: 1D31 74 02 POSNM1: MOV A,#02H1096: 1D33 22 RET1097: ;1098: 1D34 CE FINISH2:XCH A,R6 ;SAVE THE EXPONENT1099: ;1100: 1D35 FINISH_UP:1101: ;1102: 1D35 8E 30 MOV FP_EXP,R6 ;SAVE EXPONENT1103: 1D37 B8 34 02 CJNE R0,#FP_ACCC,$+51104: 1D3A 71 BF ACALL FP_CLEAR ;CLEAR THE MEMORY IF 01105: 1D3C E5 09 MOV A,ARG_STACK ;GET THE ARG STACK1106: 1D3E C3 CLR C1107: 1D3F 94 0C SUBB A,#FP_NUMBER_SIZE+FP_NUMBER_SIZE1108: 1D41 F5 09 MOV ARG_STACK,A ;ADJUST FOR STORE1109: 1D43 61 30 AJMP PACK1110: ;1111: 1D45 C2 D5 STDIG: CLR F0 ;CLEAR INITIAL DESIGNATOR1112: 1D47 70 0B JNZ STDIG1 ;CONTINUE IF NOT ZERO1113: 1D49 B8 34 08 CJNE R0,#FP_ACCC,STDIG11114: 1D4C 30 52 04 JNB FIRST_RADIX,RET_X1115: ;1116: 1D4F DE 02 DECX: DJNZ R6,RET_X1117: ;1118: 1D51 74 FF INERR: MOV A,#0FFH1119: ;1120: 1D53 22 RET_X: RET1121: ;1122: 1D54 20 53 02 STDIG1: JB DONE_LOAD,FRTEST1123: 1D57 C2 52 CLR FIRST_RADIX1124: ;1125: 1D59 20 52 F3 FRTEST: JB FIRST_RADIX,DECX1126: ;1127: 1D5C 20 51 01 FDTEST: JB FOUND_RADIX,FDT11128: 1D5F 0E INC R61129: ;1130: 1D60 20 53 F0 FDT1: JB DONE_LOAD,RET_X1131: 1D63 B8 3D 02 CJNE R0,#FP_ACC8+1,FDT21132: 1D66 D2 53 SETB DONE_LOAD1133: ;1134: 1D68 F6 FDT2: MOV @R0,A ;SAVE THE STRIPPED ACCUMULATOR1135: 1D69 08 INC R0 ;BUMP THE POINTERASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 32Line I Addr Code Source1136: 1D6A 22 RET ;EXIT1137: ;1138: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 33Line I Addr Code Source1139: ;***************************************************************1140: ;1141: ; I/O utilities1142: ;1143: ;***************************************************************1144: ;1145: 1D6B INC_AND_GET_DPTR_CHARACTER:1146: ;1147: 1D6B A3 INC DPTR1148: ;1149: 1D6C GET_DPTR_CHARACTER:1150: ;1151: 1D6C E0 MOVX A,@DPTR ;GET THE CHARACTER1152: 1D6D B4 20 16 CJNE A,#' ',PMT1 ;SEE IF A SPACE1153: ;1154: ; Kill spaces1155: ;1156: 1D70 80 F9 SJMP INC_AND_GET_DPTR_CHARACTER1157: ;1158: 1D72 PLUS_MINUS_TEST:1159: ;1160: 1D72 B4 E3 02 CJNE A,#0E3H,$+5 ;SEE IF A PLUS, PLUS TOKEN FROM BASIC1161: 1D75 80 0E SJMP PMT31162: 1D77 B4 2B 02 CJNE A,#'+',$+51163: 1D7A 80 09 SJMP PMT31164: 1D7C B4 E5 02 CJNE A,#0E5H,$+5 ;SEE IF MINUS, MINUS TOKEN FROM BASIC1165: 1D7F 80 03 SJMP PMT21166: 1D81 B4 2D 02 CJNE A,#'-',PMT11167: ;1168: 1D84 D3 PMT2: SETB C1169: ;1170: 1D85 A3 PMT3: INC DPTR1171: ;1172: 1D86 22 PMT1: RET1173: ;1174: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 34Line I Addr Code Source1175: ;***************************************************************1176: ;1177: 1D87 FLOATING_POINT_OUTPUT: ; Output the number, format is in location 231178: ;1179: ; IF FORMAT = 00 - FREE FLOATING1180: ; = FX - EXPONENTIAL (X IS THE NUMBER OF SIG DIGITS)1181: ; = NX - N = NUM BEFORE RADIX, X = NUM AFTER RADIX1182: ; N + X = 8 MAX1183: ;1184: ;***************************************************************1185: ;1186: 1D87 91 77 ACALL MDES1 ;GET THE NUMBER TO OUTPUT, R0 IS POINTER1187: 1D89 31 C9 ACALL POP_AND_EXIT ;OUTPUT POPS THE STACK1188: 1D8B EF MOV A,R71189: 1D8C FE MOV R6,A ;PUT THE EXPONENT IN R61190: 1D8D 71 8B ACALL UNPACK_R0 ;UNPACK THE NUMBER1191: 1D8F 78 2B MOV R0,#FP_NIB1 ;POINT AT THE NUMBER1192: 1D91 E5 17 MOV A,FORMAT ;GET THE FORMAT1193: 1D93 FB MOV R3,A ;SAVE IN CASE OF EXP FORMAT1194: 1D94 60 49 JZ FREE ;FREE FLOATING?1195: 1D96 B4 F0 00 CJNE A,#0F0H,$+3 ;SEE IF EXPONENTIAL1196: 1D99 50 73 JNC EXPOUT1197: ;1198: ; If here, must be integer USING format1199: ;1200: 1D9B EE MOV A,R6 ;GET THE EXPONENT1201: 1D9C 70 02 JNZ $+41202: 1D9E 7E 80 MOV R6,#80H1203: 1DA0 EB MOV A,R3 ;GET THE FORMAT1204: 1DA1 C4 SWAP A ;SPLIT INTEGER AND FRACTION1205: 1DA2 54 0F ANL A,#0FH1206: 1DA4 FA MOV R2,A ;SAVE INTEGER1207: 1DA5 D1 74 ACALL NUM_LT ;GET THE NUMBER OF INTEGERS1208: 1DA7 CA XCH A,R2 ;FLIP FOR SUBB1209: 1DA8 C3 CLR C1210: 1DA9 9A SUBB A,R21211: 1DAA FF MOV R7,A1212: 1DAB 50 06 JNC $+81213: 1DAD 7D 3F MOV R5,#'?' ;OUTPUT A QUESTION MARK1214: 1DAF D1 A9 ACALL SOUT1 ;NUMBER IS TOO LARGE FOR FORMAT1215: 1DB1 A1 DF AJMP FREE1216: 1DB3 BA 00 07 CJNE R2,#00,USING0 ;SEE IF ZERO1217: 1DB6 1F DEC R71218: 1DB7 D1 96 ACALL SS71219: 1DB9 D1 A3 ACALL ZOUT ;OUTPUT A ZERO1220: 1DBB 80 06 SJMP USING11221: ;1222: 1DBD D1 96 USING0: ACALL SS7 ;OUTPUT SPACES, IF NEED TO1223: 1DBF EA MOV A,R2 ;OUTPUT DIGITS1224: 1DC0 FF MOV R7,A1225: 1DC1 D1 58 ACALL OUTR01226: ;1227: 1DC3 EB USING1: MOV A,R31228: 1DC4 54 0F ANL A,#0FH ;GET THE NUMBER RIGHT OF DP1229: 1DC6 FA MOV R2,A ;SAVE IT1230: 1DC7 60 BD JZ PMT1 ;EXIT IF ZEROASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 35Line I Addr Code Source1231: 1DC9 D1 9F ACALL ROUT ;OUTPUT DP1232: 1DCB D1 7D ACALL NUM_RT1233: 1DCD B5 02 03 CJNE A,2,USINGX ;COMPARE A TO R21234: ;1235: 1DD0 EA USINGY: MOV A,R21236: 1DD1 C1 8D AJMP Z7R71237: ;1238: 1DD3 50 FB USINGX: JNC USINGY1239: ;1240: 1DD5 CA USING2: XCH A,R21241: 1DD6 C3 CLR C1242: 1DD7 9A SUBB A,R21243: 1DD8 CA XCH A,R21244: 1DD9 D1 8D ACALL Z7R7 ;OUTPUT ZEROS IF NEED TO1245: 1DDB EA MOV A,R21246: 1DDC FF MOV R7,A1247: 1DDD C1 58 AJMP OUTR01248: ;1249: ; First, force exponential output, if need to1250: ;1251: 1DDF EE FREE: MOV A,R6 ;GET THE EXPONENT1252: 1DE0 70 04 JNZ FREE1 ;IF ZERO, PRINT IT1253: 1DE2 D1 A7 ACALL SOUT1254: 1DE4 C1 A3 AJMP ZOUT1255: ;1256: 1DE6 7B F0 FREE1: MOV R3,#0F0H ;IN CASE EXP NEEDED1257: 1DE8 74 77 MOV A,#80H-DIGIT-DIGIT-11258: 1DEA 2E ADD A,R61259: 1DEB 40 21 JC EXPOUT1260: 1DED 94 F7 SUBB A,#0F7H1261: 1DEF 40 1D JC EXPOUT1262: ;1263: ; Now, just print the number1264: ;1265: 1DF1 D1 98 ACALL SINOUT ;PRINT THE SIGN OF THE NUMBER1266: 1DF3 D1 74 ACALL NUM_LT ;GET THE NUMBER LEFT OF DP1267: 1DF5 B4 08 02 CJNE A,#8,FREE41268: 1DF8 C1 58 AJMP OUTR01269: ;1270: 1DFA D1 58 FREE4: ACALL OUTR01271: 1DFC D1 6A ACALL ZTEST ;TEST FOR TRAILING ZEROS1272: 1DFE 60 57 JZ U_RET ;DONE IF ALL TRAILING ZEROS1273: 1E00 D1 9F ACALL ROUT ;OUTPUT RADIX1274: ;1275: 1E02 7F 01 FREE2: MOV R7,#1 ;OUTPUT ONE DIGIT1276: 1E04 D1 58 ACALL OUTR01277: 1E06 70 4F JNZ U_RET1278: 1E08 D1 6A ACALL ZTEST1279: 1E0A 60 4B JZ U_RET1280: 1E0C 80 F4 SJMP FREE2 ;LOOP1281: ;1282: 1E0E D1 98 EXPOUT: ACALL SINOUT ;PRINT THE SIGN1283: 1E10 7F 01 MOV R7,#1 ;OUTPUT ONE CHARACTER1284: 1E12 D1 58 ACALL OUTR01285: 1E14 D1 9F ACALL ROUT ;OUTPUT RADIX1286: 1E16 EB MOV A,R3 ;GET FORMATASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 36Line I Addr Code Source1287: 1E17 54 0F ANL A,#0FH ;STRIP INDICATOR1288: 1E19 60 06 JZ EXPOTX1289: ;1290: 1E1B FF MOV R7,A ;OUTPUT THE NUMBER OF DIGITS1291: 1E1C 1F DEC R7 ;ADJUST BECAUSE ONE CHAR ALREADY OUT1292: 1E1D D1 58 ACALL OUTR01293: 1E1F 80 02 SJMP EXPOT41294: ;1295: 1E21 D1 02 EXPOTX: ACALL FREE2 ;OUTPUT UNTIL TRAILING ZEROS1296: ;1297: 1E23 D1 A7 EXPOT4: ACALL SOUT ;OUTPUT A SPACE1298: 1E25 7D 45 MOV R5,#'E'1299: 1E27 D1 A9 ACALL SOUT1 ;OUTPUT AN E1300: 1E29 EE MOV A,R6 ;GET THE EXPONENT1301: 1E2A 60 04 JZ XOUT0 ;EXIT IF ZERO1302: 1E2C 14 DEC A ;ADJUST FOR THE DIGIT ALREADY OUTPUT1303: 1E2D B4 80 05 CJNE A,#80H,XOUT2 ;SEE WHAT IT IS1304: ;1305: 1E30 D1 A7 XOUT0: ACALL SOUT1306: 1E32 E4 CLR A1307: 1E33 80 0C SJMP XOUT41308: ;1309: 1E35 40 06 XOUT2: JC XOUT3 ;NEGATIVE EXPONENT1310: 1E37 7D 2B MOV R5,#'+' ;OUTPUT A PLUS SIGN1311: 1E39 D1 A9 ACALL SOUT11312: 1E3B 80 04 SJMP XOUT41313: ;1314: 1E3D D1 9B XOUT3: ACALL MOUT1315: 1E3F F4 CPL A ;FLIP BITS1316: 1E40 04 INC A ;BUMP1317: ;1318: 1E41 C2 E7 XOUT4: CLR ACC.71319: 1E43 F8 MOV R0,A1320: 1E44 7A 00 MOV R2,#01321: 1E46 79 58 MOV R1,#LOW CONVT ;CONVERSION LOCATION1322: 1E48 7B 00 MOV R3,#HIGH CONVT1323: 1E4A F1 04 ACALL CONVERT_BINARY_TO_ASCII_STRING1324: 1E4C 78 58 MOV R0,#LOW CONVT ;NOW, OUTPUT EXPONENT1325: ;1326: 1E4E E2 EXPOT5: MOVX A,@R0 ;GET THE CHARACTER1327: 1E4F FD MOV R5,A ;OUTPUT IT1328: 1E50 D1 A9 ACALL SOUT11329: 1E52 08 INC R0 ;BUMP THE POINTER1330: 1E53 E8 MOV A,R0 ;GET THE POINTER1331: 1E54 B5 01 F7 CJNE A,R1B0,EXPOT5 ;LOOP1332: ;1333: 1E57 22 U_RET: RET ;EXIT1334: ;1335: 1E58 OUTR0: ; Output the characters pointed to by R0, also bias ascii1336: ;1337: 1E58 EF MOV A,R7 ;GET THE COUNTER1338: 1E59 60 0E JZ OUTR ;EXIT IF DONE1339: 1E5B E6 MOV A,@R0 ;GET THE NUMBER1340: 1E5C 44 30 ORL A,#30H ;ASCII BIAS1341: 1E5E 08 INC R0 ;BUMP POINTER AND COUNTER1342: 1E5F 1F DEC R7ASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 37Line I Addr Code Source1343: 1E60 FD MOV R5,A ;PUT CHARACTER IN OUTPUT REGISTER1344: 1E61 D1 A9 ACALL SOUT1 ;OUTPUT THE CHARACTER1345: 1E63 E4 CLR A ;JUST FOR TEST1346: 1E64 B8 33 F1 CJNE R0,#FP_NIB8+1,OUTR01347: 1E67 74 55 MOV A,#55H ;KNOW WHERE EXIT OCCURED1348: ;1349: 1E69 22 OUTR: RET1350: ;1351: 1E6A A9 00 ZTEST: MOV R1,R0B0 ;GET POINTER REGISTER1352: ;1353: 1E6C E7 ZT0: MOV A,@R1 ;GET THE VALUE1354: 1E6D 70 04 JNZ ZT11355: 1E6F 09 INC R1 ;BUMP POINTER1356: 1E70 B9 33 F9 CJNE R1,#FP_NIB8+1,ZT01357: ;1358: 1E73 22 ZT1: RET1359: ;1360: 1E74 EE NUM_LT: MOV A,R6 ;GET EXPONENT1361: 1E75 C3 CLR C ;GET READY FOR SUBB1362: 1E76 94 80 SUBB A,#80H ;SUB EXPONENT BIAS1363: 1E78 50 01 JNC NL1 ;OK IF NO CARRY1364: 1E7A E4 CLR A ;NO DIGITS LEFT1365: ;1366: 1E7B FF NL1: MOV R7,A ;SAVE THE COUNT1367: 1E7C 22 RET1368: ;1369: 1E7D C3 NUM_RT: CLR C ;SUBB AGAIN1370: 1E7E 74 80 MOV A,#80H ;EXPONENT BIAS1371: 1E80 9E SUBB A,R6 ;GET THE BIASED EXPONENT1372: 1E81 50 01 JNC NR11373: 1E83 E4 CLR A1374: ;1375: 1E84 22 NR1: RET ;EXIT1376: ;1377: 1E85 EF SPACE7: MOV A,R7 ;GET THE NUMBER OF SPACES1378: 1E86 60 FC JZ NR1 ;EXIT IF ZERO1379: 1E88 D1 A7 ACALL SOUT ;OUTPUT A SPACE1380: 1E8A 1F DEC R7 ;BUMP COUNTER1381: 1E8B 80 F8 SJMP SPACE7 ;LOOP1382: ;1383: 1E8D FF Z7R7: MOV R7,A1384: ;1385: 1E8E EF ZERO7: MOV A,R7 ;GET COUNTER1386: 1E8F 60 F3 JZ NR1 ;EXIT IF ZERO1387: 1E91 D1 A3 ACALL ZOUT ;OUTPUT A ZERO1388: 1E93 1F DEC R7 ;BUMP COUNTER1389: 1E94 80 F8 SJMP ZERO7 ;LOOP1390: ;1391: 1E96 D1 85 SS7: ACALL SPACE71392: ;1393: 1E98 EC SINOUT: MOV A,R4 ;GET THE SIGN1394: 1E99 60 0C JZ SOUT ;OUTPUT A SPACE IF ZERO1395: ;1396: 1E9B 7D 2D MOUT: MOV R5,#'-'1397: 1E9D 80 0A SJMP SOUT1 ;OUTPUT A MINUS IF NOT1398: ;ASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 38Line I Addr Code Source1399: 1E9F 7D 2E ROUT: MOV R5,#'.' ;OUTPUT A RADIX1400: 1EA1 80 06 SJMP SOUT11401: ;1402: 1EA3 7D 30 ZOUT: MOV R5,#'0' ;OUTPUT A ZERO1403: 1EA5 80 02 SJMP SOUT11404: ;1405: 1EA7 7D 20 SOUT: MOV R5,#' ' ;OUTPUT A SPACE1406: ;1407: 1EA9 21 90 SOUT1: AJMP OUTPUT1408: ;1409: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 39Line I Addr Code Source1410: ;***************************************************************1411: ;1412: 1EAB CONVERT_ASCII_STRING_TO_BINARY:1413: ;1414: ;DPTR POINTS TO ASCII STRING1415: ;PUT THE BINARY NUMBER IN R2:R0, ERROR IF >64K1416: ;1417: ;***************************************************************1418: ;1419: 1EAB 91 96 CASB: ACALL HEXSCAN ;SEE IF HEX NUMBER1420: 1EAD 92 23 MOV ADD_IN,C ;IF ADD_IN IS SET, THE NUMBER IS HEX1421: 1EAF F1 EB ACALL GET_DIGIT_CHECK1422: 1EB1 B3 CPL C ;FLIP FOR EXIT1423: 1EB2 40 28 JC RCASB1424: 1EB4 7B 00 MOV R3,#00H ;ZERO R3:R1 FOR LOOP1425: 1EB6 79 00 MOV R1,#00H1426: 1EB8 80 15 SJMP CASB51427: ;1428: 1EBA A3 CASB2: INC DPTR1429: 1EBB 89 00 MOV R0B0,R1 ;SAVE THE PRESENT CONVERTED VALUE1430: 1EBD 8B 02 MOV R0B0+2,R3 ;IN R2:R01431: 1EBF F1 EB ACALL GET_DIGIT_CHECK1432: 1EC1 40 0C JC CASB51433: 1EC3 30 23 16 JNB ADD_IN,RCASB ;CONVERSION COMPLETE1434: 1EC6 91 B6 ACALL HEX_CHECK ;SEE IF HEX NUMBER1435: 1EC8 40 03 JC CASB4 ;PROCEED IF GOOD1436: 1ECA A3 INC DPTR ;BUMP PAST H1437: 1ECB 80 0F SJMP RCASB1438: ;1439: 1ECD 24 09 CASB4: ADD A,#9 ;ADJUST HEX ASCII BIAS1440: ;1441: 1ECF 75 F0 0A CASB5: MOV B,#101442: 1ED2 30 23 03 JNB ADD_IN,CASB61443: 1ED5 75 F0 10 MOV B,#16 ;HEX MODE1444: ;1445: 1ED8 D1 E3 CASB6: ACALL MULNUM ;ACCUMULATE THE DIGITS1446: 1EDA 50 DE JNC CASB2 ;LOOP IF NO CARRY1447: ;1448: 1EDC E4 RCASB: CLR A ;RESET ACC1449: 1EDD 92 E1 MOV ACC.OVERFLOW,C ;IF OVERFLOW, SAY SO1450: 1EDF 22 RET ;EXIT1451: ;1452: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 40Line I Addr Code Source1453: ;1454: 1EE0 75 F0 0A MULNUM10:MOV B,#101455: ;1456: ;***************************************************************1457: ;1458: 1EE3 MULNUM: ; Take the next digit in the acc (masked to 0FH)1459: ; accumulate in R3:R11460: ;1461: ;***************************************************************1462: ;1463: 1EE3 C0 E0 PUSH ACC ;SAVE ACC1464: 1EE5 C0 F0 PUSH B ;SAVE MULTIPLIER1465: 1EE7 E9 MOV A,R1 ;PUT LOW ORDER BITS IN ACC1466: 1EE8 A4 MUL AB ;DO THE MULTIPLY1467: 1EE9 F9 MOV R1,A ;PUT THE RESULT BACK1468: 1EEA EB MOV A,R3 ;GET THE HIGH ORDER BYTE1469: 1EEB AB F0 MOV R3,B ;SAVE THE OVERFLOW1470: 1EED D0 F0 POP B ;GET THE MULTIPLIER1471: 1EEF A4 MUL AB ;DO IT1472: 1EF0 A2 D2 MOV C,OV ;SAVE OVERFLOW IN F01473: 1EF2 92 D5 MOV F0,C1474: 1EF4 2B ADD A,R3 ;ADD OVERFLOW TO HIGH RESULT1475: 1EF5 FB MOV R3,A ;PUT IT BACK1476: 1EF6 D0 E0 POP ACC ;GET THE ORIGINAL ACC BACK1477: 1EF8 72 D5 ORL C,F0 ;OR CARRY AND OVERFLOW1478: 1EFA 40 07 JC MULX ;NO GOOD IF THE CARRY IS SET1479: ;1480: 1EFC 54 0F MUL11: ANL A,#0FH ;MASK OFF HIGH ORDER BITS1481: 1EFE 29 ADD A,R1 ;NOW ADD THE ACC1482: 1EFF F9 MOV R1,A ;PUT IT BACK1483: 1F00 E4 CLR A ;PROPAGATE THE CARRY1484: 1F01 3B ADDC A,R31485: 1F02 FB MOV R3,A ;PUT IT BACK1486: ;1487: 1F03 22 MULX: RET ;EXIT WITH OR WITHOUT CARRY1488: ;1489: ;***************************************************************1490: ;1491: 1F04 CONVERT_BINARY_TO_ASCII_STRING:1492: ;1493: ;R3:R1 contains the address of the string1494: ;R2:R0 contains the value to convert1495: ;DPTR, R7, R6, and ACC gets clobbered1496: ;1497: ;***************************************************************1498: ;1499: 1F04 E4 CLR A ;NO LEADING ZEROS1500: 1F05 90 27 10 MOV DPTR,#10000 ;SUBTRACT 100001501: 1F08 F1 21 ACALL RSUB ;DO THE SUBTRACTION1502: 1F0A 90 03 E8 MOV DPTR,#1000 ;NOW 10001503: 1F0D F1 21 ACALL RSUB1504: 1F0F 90 00 64 MOV DPTR,#100 ;NOW 1001505: 1F12 F1 21 ACALL RSUB1506: 1F14 90 00 0A MOV DPTR,#10 ;NOW 101507: 1F17 F1 21 ACALL RSUB1508: 1F19 90 00 01 MOV DPTR,#1 ;NOW 1ASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 41Line I Addr Code Source1509: 1F1C F1 21 ACALL RSUB1510: 1F1E 60 20 JZ RSUB2 ;JUMP OVER RET1511: ;1512: 1F20 22 RSUB_R: RET1513: ;1514: 1F21 7E FF RSUB: MOV R6,#-1 ;SET UP THE COUNTER1515: ;1516: 1F23 0E RSUB1: INC R6 ;BUMP THE COUNTER1517: 1F24 CA XCH A,R2 ;DO A FAST COMPARE1518: 1F25 B5 83 00 CJNE A,DPH,$+31519: 1F28 CA XCH A,R21520: 1F29 40 12 JC FAST_DONE1521: 1F2B C8 XCH A,R0 ;GET LOW BYTE1522: 1F2C 95 82 SUBB A,DPL ;SUBTRACT, CARRY IS CLEARED1523: 1F2E C8 XCH A,R0 ;PUT IT BACK1524: 1F2F CA XCH A,R2 ;GET THE HIGH BYTE1525: 1F30 95 83 SUBB A,DPH ;ADD THE HIGH BYTE1526: 1F32 CA XCH A,R2 ;PUT IT BACK1527: 1F33 50 EE JNC RSUB1 ;LOOP UNTIL CARRY1528: ;1529: 1F35 C8 XCH A,R01530: 1F36 25 82 ADD A,DPL ;RESTORE R2:R01531: 1F38 C8 XCH A,R01532: 1F39 CA XCH A,R21533: 1F3A 35 83 ADDC A,DPH1534: 1F3C CA XCH A,R21535: ;1536: 1F3D FAST_DONE:1537: ;1538: 1F3D 4E ORL A,R6 ;OR THE COUNT VALUE1539: 1F3E 60 E0 JZ RSUB_R ;RETURN IF ZERO1540: ;1541: 1F40 74 30 RSUB2: MOV A,#'0' ;GET THE ASCII BIAS1542: 1F42 2E ADD A,R6 ;ADD THE COUNT1543: ;1544: 1F43 8B A0 RSUB4: MOV P2,R3 ;SET UP P21545: 1F45 F3 MOVX @R1,A ;PLACE THE VALUE IN MEMORY1546: 1F46 09 INC R11547: 1F47 B9 00 01 CJNE R1,#00H,RSUB3 ;SEE IF RAPPED AROUND1548: 1F4A 0B INC R3 ;BUMP HIGH BYTE1549: ;1550: 1F4B 22 RSUB3: RET ;EXIT1551: ;1552: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 42Line I Addr Code Source1553: ;***************************************************************1554: ;1555: 1F4C HEXOUT: ; Output the hex number in R3:R1, supress leading zeros, if set1556: ;1557: ;***************************************************************1558: ;1559: 1F4C D1 A7 ACALL SOUT ;OUTPUT A SPACE1560: 1F4E A2 36 MOV C,ZSURP ;GET ZERO SUPPRESSION BIT1561: 1F50 92 23 MOV ADD_IN,C1562: 1F52 EB MOV A,R3 ;GET HIGH NIBBLE AND PRINT IT1563: 1F53 F1 6F ACALL HOUTHI1564: 1F55 EB MOV A,R31565: 1F56 F1 70 ACALL HOUTLO1566: ;1567: 1F58 C2 23 HEX2X: CLR ADD_IN ;DON'T SUPPRESS ZEROS1568: 1F5A E9 MOV A,R1 ;GET LOW NIBBLE AND PRINT IT1569: 1F5B F1 6F ACALL HOUTHI1570: 1F5D E9 MOV A,R11571: 1F5E F1 70 ACALL HOUTLO1572: 1F60 7D 48 MOV R5,#'H' ;OUTPUT H TO INDICATE HEX MODE1573: ;1574: 1F62 C1 A9 SOUT_1: AJMP SOUT11575: ;1576: 1F64 C2 23 HOUT1: CLR ADD_IN ;PRINTED SOMETHING, SO CLEAR ADD_IN1577: 1F66 24 90 ADD A,#90H ;CONVERT TO ASCII1578: 1F68 D4 DA A1579: 1F69 34 40 ADDC A,#40H1580: 1F6B D4 DA A ;GOT IT HERE1581: 1F6C FD MOV R5,A ;OUTPUT THE BYTE1582: 1F6D 80 F3 SJMP SOUT_11583: ;1584: 1F6F C4 HOUTHI: SWAP A ;SWAP TO OUTPUT HIGH NIBBLE1585: ;1586: 1F70 54 0F HOUTLO: ANL A,#0FH ;STRIP1587: 1F72 70 F0 JNZ HOUT1 ;PRINT IF NOT ZERO1588: 1F74 30 23 ED JNB ADD_IN,HOUT1 ;OUTPUT A ZERO IF NOT SUPRESSED1589: 1F77 22 RET1590: ;1591: $EJECTASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 43Line I Addr Code Source1592: N 1FEB ORG 1FEBH ;FOR LINK COMPATABILITY1593: ;1594: ;1595: 1FEB GET_DIGIT_CHECK: ; Get a character, then check for digit1596: ;1597: 1FEB B1 6C ACALL GET_DPTR_CHARACTER1598: ;1599: 1FED DIGIT_CHECK: ;CHECK FOR A VALID ASCII DIGIT, SET CARRY IF FOUND1600: ;1601: 1FED B4 3A 00 CJNE A,#'9'+1,$+3 ;SEE IF ASCII 9 OR LESS1602: 1FF0 40 01 JC DC11603: 1FF2 22 RET1604: ;1605: 1FF3 B4 30 00 DC1: CJNE A,#'0',$+3 ;SEE IF ASCII 0 OR GREATER1606: 1FF6 B3 CPL C1607: 1FF7 22 RET1608: ;1609:1610: ENDregister banks used: ---no errorsASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 44L I S T O F S Y M B O L S=============================SYMBOL TYPE VALUE LINE------------------------------------------------------------AC BIT D6ACC DATA E0ADDLP CODE 1A19 280ADD_IN BIT 23 120ADD_R CODE 1A17 278ARG1_EXP_IS_LARGER CODE 1A7D 384ARG_STACK NUMBER 0009 84ARG_STACK_PAGE NUMBER 0001 85B DATA F0BOTH_PLUS CODE 1A85 397CASB CODE 1EAB 1419CASB2 CODE 1EBA 1428CASB4 CODE 1ECD 1439CASB5 CODE 1ECF 1441CASB6 CODE 1ED8 1445CLOOP CODE 1A8D 409CONVERT_ASCII_STRING_TO_BINARY CODE 1EAB 1412CONVERT_BINARY_TO_ASCII_STRING CODE 1F04 1491CONVT NUMBER 0058 88CY BIT D7DC1 CODE 1FF3 1605DECX CODE 1D4F 1116DIGIT NUMBER 0004 99DIGIT_CHECK CODE 1FED 1599DIV0 CODE 1ADC 506DIV3 CODE 1AE9 515DIV4 CODE 1AF6 523DIV5 CODE 1AF9 526DIV6 CODE 1B01 531DIV7 CODE 1B18 553DIV8 CODE 1B2D 566DONE_LOAD BIT 53 124DPH DATA 83DPL DATA 82D_UNDER CODE 1AE7 513EA BIT AFES BIT ACET0 BIT A9ET1 BIT ABEX0 BIT A8EX1 BIT AAEXPONENTS_EQUAL CODE 1A82 391EXPOT4 CODE 1E23 1297EXPOT5 CODE 1E4E 1326EXPOTX CODE 1E21 1295EXPOUT CODE 1E0E 1282EXTI0 CODE 0003EXTI1 CODE 0013F0 BIT D5FAST_DONE CODE 1F3D 1536ASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 45SYMBOL TYPE VALUE LINE------------------------------------------------------------FDT1 CODE 1D60 1130FDT2 CODE 1D68 1134FDTEST CODE 1D5C 1127FINISH1 CODE 1D21 1082FINISH2 CODE 1D34 1098FINISH_UP CODE 1D35 1100FIRST_RADIX BIT 52 123FLOATING_ADD CODE 19B7 188FLOATING_COMP CODE 1A6A 359FLOATING_DIV CODE 1ACF 491FLOATING_MUL CODE 1A9A 426FLOATING_POINT_INPUT CODE 1CCF 1026FLOATING_POINT_OUTPUT CODE 1D87 1177FLOATING_SUB CODE 19AD 177FMUL1 CODE 1AA1 439FMUL2 CODE 1AB3 455FMUL3 CODE 1ABC 471FMUL_OVER CODE 1AAF 449FORMAT NUMBER 0017 86FOUND_RADIX BIT 51 122FOV CODE 1AB1 453FPC1 CODE 1BC2 742FP_ACC1 NUMBER 0035 142FP_ACC2 NUMBER 0036 143FP_ACC3 NUMBER 0037 144FP_ACC4 NUMBER 0038 145FP_ACC5 NUMBER 0039 146FP_ACC6 NUMBER 003A 147FP_ACC7 NUMBER 003B 148FP_ACC8 NUMBER 003C 149FP_ACCC NUMBER 0034 141FP_ACCS NUMBER 003D 150FP_ACCX NUMBER 0033 140FP_CARRY NUMBER 002A 119FP_CLEAR CODE 1BBF 733FP_DIG12 NUMBER 002B 125FP_DIG34 NUMBER 002C 126FP_DIG56 NUMBER 002D 127FP_DIG78 NUMBER 002E 128FP_EXP NUMBER 0030 131FP_NIB1 NUMBER 002B 132FP_NIB2 NUMBER 002C 133FP_NIB3 NUMBER 002D 134FP_NIB4 NUMBER 002E 135FP_NIB5 NUMBER 002F 136FP_NIB6 NUMBER 0030 137FP_NIB7 NUMBER 0031 138FP_NIB8 NUMBER 0032 139FP_NUMBER_SIZE NUMBER 0006 98FP_SIGN NUMBER 002F 129FP_STATUS NUMBER 0028 117FP_TEMP NUMBER 0029 118FREE CODE 1DDF 1251FREE1 CODE 1DE6 1256FREE2 CODE 1E02 1275FREE4 CODE 1DFA 1270ASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 46SYMBOL TYPE VALUE LINE------------------------------------------------------------FRTEST CODE 1D59 1125FSUB10 CODE 1A68 354FSUB5 CODE 1A37 314FSUB6 CODE 1A42 325FSUB7 CODE 1A46 328FSUB8 CODE 1A51 336FSUB9 CODE 1A57 342GET_DIGIT_CHECK CODE 1FEB 1595GET_DPTR_CHARACTER CODE 1D6C 1149GT1 CODE 1CF7 1057GT2 CODE 1D0F 1070GTEST CODE 1CE8 1050HC1 CODE 1CBE 1006HEX2X CODE 1F58 1567HEXDO1 CODE 1CAE 992HEXDON CODE 1CAD 990HEXOUT CODE 1F4C 1555HEXSC1 CODE 1C9C 979HEXSCAN CODE 1C96 970HEX_CHECK CODE 1CB6 999HOUT1 CODE 1F64 1576HOUTHI CODE 1F6F 1584HOUTLO CODE 1F70 1586HS1 CODE 1CB3 996IE DATA A8IE0 BIT 89IE1 BIT 8BINC_AND_GET_DPTR_CHARACTER CODE 1D6B 1145INC_FP_EXP CODE 1B7F 654INERR CODE 1D51 1118INLOOP CODE 1CDD 1042INLPIK CODE 1CE5 1047INT0 BIT B2INT1 BIT B3INTGRC BIT 19 89IP DATA B8IT0 BIT 88IT1 BIT 8ALEFT CODE 1C00 804LEFT1 CODE 1C02 810LEFT3 CODE 1C0A 816LEFT5 CODE 1C29 843LEFTL CODE 1C15 825LOAD1 CODE 19D1 224LOAD2 CODE 19E1 236LOAD7 CODE 1BA0 686LOADR1 CODE 1C8C 958LOADR1_MANTISSA CODE 1C88 949LOAD_POINTERS CODE 1C6B 903MDES1 CODE 1C77 925MNL0 CODE 1C4B 876MNL1 CODE 1C5D 888MNLOOP CODE 1C42 868MOUT CODE 1E9B 1396MSIGN BIT 78 130MUL11 CODE 1EFC 1480ASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 47SYMBOL TYPE VALUE LINE------------------------------------------------------------MULNUM CODE 1EE3 1458MULNUM10 CODE 1EE0 1454MULX CODE 1F03 1487MUL_DIV_EXP_AND_SIGN CODE 1C75 916MUL_NIBBLE CODE 1C38 854NL1 CODE 1E7B 1366NR1 CODE 1E84 1375NUM_LT CODE 1E74 1360NUM_RT CODE 1E7D 1369OUTPUT NUMBER 1990 87OUTR CODE 1E69 1349OUTR0 CODE 1E58 1335OV BIT D2OVE1 CODE 1BA5 698OVERFLOW NUMBER 0001 103OVERFLOW_AND_EXIT CODE 1BA1 691P BIT D0P0 DATA 80P1 DATA 90P2 DATA A0P3 DATA B0PACK CODE 1B30 571PACK0 CODE 1B39 584PACK1 CODE 1B3A 586PACK2 CODE 1B44 593PACK3 CODE 1B56 607PACK4 CODE 1B5C 614PCON DATA 87PLOOP CODE 1B5E 618PLUS_MINUS_TEST CODE 1D72 1158PMT1 CODE 1D86 1172PMT2 CODE 1D84 1168PMT3 CODE 1D85 1170POP_AND_EXIT CODE 19C9 215POSNM1 CODE 1D31 1095POSNUM CODE 1D2E 1092PRET CODE 1B7E 651PS BIT BCPSW DATA D0PT0 BIT B9PT1 BIT BBPUSHR2R0 CODE 1CC3 1012PX0 BIT B8PX1 BIT BAR0B0 NUMBER 0000 100R1B0 NUMBER 0001 101RB8 BIT 9ARCASB CODE 1EDC 1448RD BIT B7REN BIT 9CRESET CODE 0000RET_X CODE 1D53 1120RI BIT 98RIGHT CODE 1BC8 750RIGHT1 CODE 1BCA 757RIGHT3 CODE 1BD2 765ASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 48SYMBOL TYPE VALUE LINE------------------------------------------------------------RIGHT5 CODE 1BF1 791RIGHTL CODE 1BDE 775ROUT CODE 1E9F 1399RS0 BIT D3RS1 BIT D4RSUB CODE 1F21 1514RSUB1 CODE 1F23 1516RSUB2 CODE 1F40 1541RSUB3 CODE 1F4B 1550RSUB4 CODE 1F43 1544RSUB_R CODE 1F20 1512RXD BIT B0SBUF DATA 99SCON DATA 98SE1 CODE 19C3 209SIGNS_DIFFERENT CODE 1A7A 379SINOUT CODE 1E98 1393SINT CODE 0023SM0 BIT 9FSM1 BIT 9ESM2 BIT 9DSOUT CODE 1EA7 1405SOUT1 CODE 1EA9 1407SOUT_1 CODE 1F62 1574SP DATA 81SPACE7 CODE 1E85 1377SS7 CODE 1E96 1391STDIG CODE 1D45 1111STDIG1 CODE 1D54 1122STORE2 CODE 1B76 643STORE_ALIGN_TEST_AND_EXIT CODE 1B70 633SUBLP CODE 1A22 291SWAP_AND_EXIT CODE 19BF 202T0 BIT B4T1 BIT B5TB8 BIT 9BTCON DATA 88TF0 BIT 8DTF1 BIT 8FTH0 DATA 8CTH1 DATA 8DTI BIT 99TIMER0 CODE 000BTIMER1 CODE 001BTL0 DATA 8ATL1 DATA 8BTMOD DATA 89TR0 BIT 8CTR1 BIT 8ETXD BIT B1ULOOP CODE 1B8F 672UNDERFLOW NUMBER 0000 102UNDERFLOW_AND_EXIT CODE 1BB2 711UNPACK_R0 CODE 1B8B 665USING0 CODE 1DBD 1222USING1 CODE 1DC3 1227ASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 49SYMBOL TYPE VALUE LINE------------------------------------------------------------USING2 CODE 1DD5 1240USINGX CODE 1DD3 1238USINGY CODE 1DD0 1235U_RET CODE 1E57 1333WR BIT B6XOUT0 CODE 1E30 1305XOUT2 CODE 1E35 1309XOUT3 CODE 1E3D 1314XOUT4 CODE 1E41 1318XSIGN BIT 50 121Z7R7 CODE 1E8D 1383ZERO NUMBER 0002 104ZERO7 CODE 1E8E 1385ZERO_AND_EXIT CODE 1BB8 722ZERO_DIVIDE NUMBER 0003 105ZOUT CODE 1EA3 1402ZSURP BIT 36 90ZT0 CODE 1E6C 1353ZT1 CODE 1E73 1358ZTEST CODE 1E6A 1351
123version https://git-lfs.github.com/spec/v1oid sha256:04e943c8f4fc1b61b3ca247de93a9c0d5877f92a9ead4eee8abde08f7f49168bsize 6576312345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610,,,;************************************************************,,,;,,,; This is a complete BCD floating point package for the 8051 micro-,,,; controller. It provides 8 digits of accuracy with exponents that,,,; range from +127 to -127. The mantissa is in packed BCD, while the,,,; exponent is expressed in pseudo-twos complement. A ZERO exponent,,,; is used to express the number ZERO. An exponent value of 80H or,,,; greater than means the exponent is positive, i.e. 80H = E 0,,,,; 81H = E+1, 82H = E+2 and so on. If the exponent is 7FH or less,,,,; the exponent is negative, 7FH = E-1, 7EH = E-2, and so on.,,,; ALL NUMBERS ARE ASSUMED TO BE NORMALIZED and all results are,,,; normalized after calculation. A normalized mantissa is >=.10 and,,,; <=.99999999.,,,;,,,; The numbers in memory assumed to be stored as follows:,,,;,,,; EXPONENT OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE,,,; SIGN OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE-1,,,; DIGIT 78 OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE-2,,,; DIGIT 56 OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE-3,,,; DIGIT 34 OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE-4,,,; DIGIT 12 OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE-5,,,;,,,; EXPONENT OF ARGUMENT 1 = VALUE OF ARG_STACK,,,; SIGN OF ARGUMENT 1 = VALUE OF ARG_STACK-1,,,; DIGIT 78 OF ARGUMENT 1 = VALUE OF ARG_STACK-2,,,; DIGIT 56 OF ARGUMENT 1 = VALUE OF ARG_STACK-3,,,; DIGIT 34 OF ARGUMENT 1 = VALUE OF ARG_STACK-4,,,; DIGIT 12 OF ARGUMENT 1 = VALUE OF ARG_STACK-5,,,;,,,; The operations are performed thusly:,,,;,,,; ARG_STACK+FP_NUMBER_SIZE = ARG_STACK+FP_NUMBER_SIZE # ARG_STACK,,,;,,,; Which is ARGUMENT 2 = ARGUMENT 2 # ARGUMENT 1,,,;,,,; Where # can be ADD, SUBTRACT, MULTIPLY OR DIVIDE.,,,;,,,; Note that the stack gets popped after an operation.,,,;,,,; The FP_COMP instruction POPS the ARG_STACK TWICE and returns status.,,,;,,,;**********************************************************************,,,;,,,$EJECT,,,;**********************************************************************,,,;,,,; STATUS ON RETURN - After performing an operation (+, -, *, /),,,; the accumulator contains the following status,,,;,,,; ACCUMULATOR - BIT 0 - FLOATING POINT UNDERFLOW OCCURED,,,;,,,; - BIT 1 - FLOATING POINT OVERFLOW OCCURED,,,;,,,; - BIT 2 - RESULT WAS ZER0,,,;,,,; - BIT 3 - DIVIDE BY ZERO ATTEMPTED,,,;,,,; - BIT 4 - NOT USED, 0 RETURNED,,,;,,,; - BIT 5 - NOT USED, 0 RETURNED,,,;,,,; - BIT 6 - NOT USED, 0 RETURNED,,,;,,,; - BIT 7 - NOT USED, 0 RETURNED,,,;,,,; NOTE: When underflow occures, a ZERO result is returned.,,,; When overflow or divide by zero occures, a result of,,,; .99999999 E+127 is returned and it is up to the user,,,; to handle these conditions as needed in the program.,,,;,,,; NOTE: The Compare instruction returns F0 = 0 if ARG 1 = ARG 2,,,; and returns a CARRY FLAG = 1 if ARG 1 is > ARG 2,,,;,,,;***********************************************************************,,,;,,,$EJECT,,,;***********************************************************************,,,;,,,; The following values MUST be provided by the user,,,;,,,;***********************************************************************,,,;,,,ARG_STACK EQU 9 ;ARGUMENT STACK POINTER,,,ARG_STACK_PAGE EQU 1,,,FORMAT EQU 23 ;LOCATION OF OUTPUT FORMAT BYTE,,,OUTPUT EQU 1990H ;CALL LOCATION TO OUTPUT A CHARACTER,,,CONVT EQU 58H ;LOCATION TO CONVERT NUMBERS,,,INTGRC BIT 25 ;BIT SET IF INTGER ERROR,,,ZSURP BIT 54 ;ZERO SUPRESSION FOR HEX PRINT,,,;,,,;***********************************************************************,,,;,,,; The following equates are used internally,,,;,,,;***********************************************************************,,,;,,,FP_NUMBER_SIZE EQU 6,,,DIGIT EQU FP_NUMBER_SIZE-2,,,R0B0 EQU 0,,,R1B0 EQU 1,,,UNDERFLOW EQU 0,,,OVERFLOW EQU 1,,,ZERO EQU 2,,,ZERO_DIVIDE EQU 3,,,;,,,;***********************************************************************,,,$EJECT,,, ;**************************************************************,,, ;,,, ; The following internal locations are used by the math pack,,, ; ordering is important and the FP_DIGITS must be bit,,, ; addressable,,, ;,,, ;***************************************************************,,, ;,,,FP_STATUS EQU 28H ;NOT USED,,,FP_TEMP EQU FP_STATUS+1 ;NOT USED,,,FP_CARRY EQU FP_STATUS+2 ;USED FOR BITS,,,ADD_IN BIT 35 ;DCMPXZ IN BASIC BACKAGE000B,,,XSIGN BIT FP_CARRY.0000B,,,FOUND_RADIX BIT FP_CARRY.1000B,,,FIRST_RADIX BIT FP_CARRY.2000B,,,DONE_LOAD BIT FP_CARRY.3,,,FP_DIG12 EQU FP_CARRY+1,,,FP_DIG34 EQU FP_CARRY+2,,,FP_DIG56 EQU FP_CARRY+3,,,FP_DIG78 EQU FP_CARRY+4,,,FP_SIGN EQU FP_CARRY+5000B,,,MSIGN BIT FP_SIGN.0,,,FP_EXP EQU FP_CARRY+6,,,FP_NIB1 EQU FP_DIG12,,,FP_NIB2 EQU FP_NIB1+1,,,FP_NIB3 EQU FP_NIB1+2,,,FP_NIB4 EQU FP_NIB1+3,,,FP_NIB5 EQU FP_NIB1+4,,,FP_NIB6 EQU FP_NIB1+5,,,FP_NIB7 EQU FP_NIB1+6,,,FP_NIB8 EQU FP_NIB1+7,,,FP_ACCX EQU FP_NIB1+8,,,FP_ACCC EQU FP_NIB1+9,,,FP_ACC1 EQU FP_NIB1+10,,,FP_ACC2 EQU FP_NIB1+11,,,FP_ACC3 EQU FP_NIB1+12,,,FP_ACC4 EQU FP_NIB1+13,,,FP_ACC5 EQU FP_NIB1+14,,,FP_ACC6 EQU FP_NIB1+15,,,FP_ACC7 EQU FP_NIB1+16,,,FP_ACC8 EQU FP_NIB1+17,,,FP_ACCS EQU FP_NIB1+18,,, ;,,,$EJECT,,, ORG 1993H,,, ;,,, ;**************************************************************,,, ;,,, ; The floating point entry points and jump table,,, ;,,, ;**************************************************************,,, ;1993,21 B7,, AJMP FLOATING_ADD1995,21 AD,, AJMP FLOATING_SUB1997,41 6A,, AJMP FLOATING_COMP1999,41 9A,, AJMP FLOATING_MUL199B,41 CF,, AJMP FLOATING_DIV199D,81 96,, AJMP HEXSCAN199F,81 CF,, AJMP FLOATING_POINT_INPUT19A1,A1 87,, AJMP FLOATING_POINT_OUTPUT19A3,E1 04,, AJMP CONVERT_BINARY_TO_ASCII_STRING19A5,C1 AB,, AJMP CONVERT_ASCII_STRING_TO_BINARY19A7,C1 E0,, AJMP MULNUM1019A9,E1 4C,, AJMP HEXOUT19AB,81 C3,, AJMP PUSHR2R0,,, ;,,,$EJECT,,, ;19AD,,FLOATING_SUB,FLOATING_SUB:,,, ;19AD,75 A0 01,, MOV P2,#ARG_STACK_PAGE19B0,A8 09,, MOV R0,ARG_STACK19B2,18,, DEC R0 ;POINT TO SIGN19B3,E2,, MOVX A,@R0 ;READ SIGN19B4,B2 E0,, CPL ACC.019B6,F2,, MOVX @R0,A,,, ;,,, ;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,,, ;19B7,,FLOATING_ADD,FLOATING_ADD:,,, ;,,, ;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,,, ;,,, ;19B7,91 77,, ACALL MDES1 ;R7=TOS EXP, R6=TOS-1 EXP, R4=TOS SIGN,,, ;R3=TOS-1 SIGN, OPERATION IS R1 # R0,,, ;19B9,EF,, MOV A,R7 ;GET TOS EXPONENT19BA,60 0D,, JZ POP_AND_EXIT ;IF TOS=0 THEN POP AND EXIT19BC,BE 00 12,, CJNE R6,#0,LOAD1 ;CLEAR CARRY EXIT IF ZERO,,, ;,,, ;**************************************************************,,, ;19BF,,SWAP_AND_EXIT,SWAP_AND_EXIT: ; Swap external args and return,,, ;,,, ;**************************************************************,,, ;19BF,91 6B,, ACALL LOAD_POINTERS19C1,7F 06,, MOV R7,#FP_NUMBER_SIZE,,, ;19C3,E2,SE1,SE1: MOVX A,@R0 ;SWAP THE ARGUMENTS19C4,F3,, MOVX @R1,A19C5,18,, DEC R019C6,19,, DEC R119C7,DF FA,, DJNZ R7,SE1,,, ;19C9,,POP_AND_EXIT,POP_AND_EXIT:,,, ;19C9,E5 09,, MOV A,ARG_STACK ;POP THE STACK19CB,24 06,, ADD A,#FP_NUMBER_SIZE19CD,F5 09,, MOV ARG_STACK,A19CF,E4,, CLR A19D0,22,, RET,,, ;,,, ;19D1,9E,LOAD1,LOAD1: SUBB A,R6 ;A = ARG 1 EXP - ARG 2 EXP19D2,8F 30,, MOV FP_EXP,R7 ;SAVE EXPONENT AND SIGN19D4,8C 2F,, MOV FP_SIGN,R419D6,50 09,, JNC LOAD2 ;ARG1 EXPONENT IS LARGER OR SAME19D8,8E 30,, MOV FP_EXP,R619DA,8B 2F,, MOV FP_SIGN,R319DC,F4,, CPL A19DD,04,, INC A ;COMPENSATE FOR EXP DELTA19DE,C8,, XCH A,R0 ;FORCE R0 TO POINT AT THE LARGEST19DF,C9,, XCH A,R1 ;EXPONENT19E0,C8,, XCH A,R0,,, ;19E1,FF,LOAD2,LOAD2: MOV R7,A ;SAVE THE EXPONENT DELTA IN R719E2,C2 23,, CLR ADD_IN19E4,BD 00 02,, CJNE R5,#0,$+519E7,D2 23,, SETB ADD_IN,,, ;,,,$EJECT,,, ; Load the R1 mantissa,,, ;19E9,91 88,, ACALL LOADR1_MANTISSA ;LOAD THE SMALLEST NUMBER,,, ;,,, ; Now align the number to the delta exponent,,, ; R4 points to the string of the last digits lost,,, ;19EB,BF 0B 00,, CJNE R7,#DIGIT+DIGIT+3,$+319EE,40 02,, JC $+419F0,7F 0A,, MOV R7,#DIGIT+DIGIT+2,,, ;19F2,75 2A 00,, MOV FP_CARRY,#00 ;CLEAR THE CARRY19F5,71 C8,, ACALL RIGHT ;SHIFT THE NUMBER,,, ;,,, ; Set up for addition and subtraction,,, ;19F7,7F 04,, MOV R7,#DIGIT ;LOOP COUNT19F9,79 2E,, MOV R1,#FP_DIG7819FB,74 9E,, MOV A,#9EH19FD,C3,, CLR C19FE,9C,, SUBB A,R419FF,D4,, DA A1A00,CC,, XCH A,R41A01,70 01,, JNZ $+31A03,FC,, MOV R4,A1A04,B4 50 00,, CJNE A,#50H,$+3 ;TEST FOR SUBTRACTION1A07,30 23 18,, JNB ADD_IN,SUBLP ;DO SUBTRACTION IF NO ADD_IN1A0A,B3,, CPL C ;FLIP CARRY FOR ADDITION1A0B,51 19,, ACALL ADDLP ;DO ADDITION,,, ;1A0D,50 08,, JNC ADD_R1A0F,05 2A,, INC FP_CARRY1A11,7F 01,, MOV R7,#11A13,71 C8,, ACALL RIGHT1A15,71 7F,, ACALL INC_FP_EXP ;SHIFT AND BUMP EXPONENT,,, ;1A17,61 70,ADD_R,ADD_R: AJMP STORE_ALIGN_TEST_AND_EXIT,,, ;1A19,E2,ADDLP,ADDLP: MOVX A,@R01A1A,37,, ADDC A,@R11A1B,D4,, DA A1A1C,F7,, MOV @R1,A1A1D,18,, DEC R01A1E,19,, DEC R11A1F,DF F8,, DJNZ R7,ADDLP ;LOOP UNTIL DONE1A21,22,, RET,,, ;,,,$EJECT,,, ;1A22,E2,SUBLP,SUBLP: MOVX A,@R0 ;NOW DO SUBTRACTION1A23,FE,, MOV R6,A1A24,E4,, CLR A1A25,34 99,, ADDC A,#99H1A27,97,, SUBB A,@R11A28,2E,, ADD A,R61A29,D4,, DA A1A2A,F7,, MOV @R1,A1A2B,18,, DEC R01A2C,19,, DEC R11A2D,DF F3,, DJNZ R7,SUBLP1A2F,40 11,, JC FSUB6,,, ;,,,$EJECT,,, ;,,, ; Need to complement the result and sign because the floating,,, ; point accumulator mantissa was larger than the external,,, ; memory and their signs were equal.,,, ;1A31,B2 78,, CPL FP_SIGN.01A33,79 2E,, MOV R1,#FP_DIG781A35,7F 04,, MOV R7,#DIGIT ;LOOP COUNT,,, ;1A37,74 9A,FSUB5,FSUB5: MOV A,#9AH1A39,97,, SUBB A,@R11A3A,24 00,, ADD A,#01A3C,D4,, DA A1A3D,F7,, MOV @R1,A1A3E,19,, DEC R11A3F,B3,, CPL C1A40,DF F5,, DJNZ R7,FSUB5 ;LOOP,,, ;,,, ; Now see how many zeros their are,,, ;1A42,78 2B,FSUB6,FSUB6: MOV R0,#FP_DIG121A44,7F 00,, MOV R7,#0,,, ;1A46,E6,FSUB7,FSUB7: MOV A,@R01A47,70 08,, JNZ FSUB81A49,0F,, INC R71A4A,0F,, INC R71A4B,08,, INC R01A4C,B8 2F F7,, CJNE R0,#FP_SIGN,FSUB71A4F,61 B8,, AJMP ZERO_AND_EXIT,,, ;1A51,B4 10 00,FSUB8,FSUB8: CJNE A,#10H,$+31A54,50 01,, JNC FSUB91A56,0F,, INC R7,,, ;,,, ; Now R7 has the number of leading zeros in the FP ACC,,, ;1A57,E5 30,FSUB9,FSUB9: MOV A,FP_EXP ;GET THE OLD EXPONENT1A59,C3,, CLR C1A5A,9F,, SUBB A,R7 ;SUBTRACT FROM THE NUMBER OF ZEROS1A5B,60 0B,, JZ FSUB101A5D,40 09,, JC FSUB10,,, ;1A5F,F5 30,, MOV FP_EXP,A ;SAVE THE NEW EXPONENT,,, ;1A61,91 02,, ACALL LEFT1 ;SHIFT THE FP ACC1A63,75 2A 00,, MOV FP_CARRY,#01A66,61 70,, AJMP STORE_ALIGN_TEST_AND_EXIT,,, ;1A68,61 B2,FSUB10,FSUB10: AJMP UNDERFLOW_AND_EXIT,,, ;,,,$EJECT,,, ;***************************************************************,,, ;1A6A,,FLOATING_COMP,FLOATING_COMP: ; Compare two floating point numbers,,, ; used for relational operations and is faster,,, ; than subtraction. ON RETURN, The carry is set,,, ; if ARG1 is > ARG2, else carry is not set,,, ; if ARG1 = ARG2, F0 gets set,,, ;,,, ;***************************************************************,,, ;1A6A,91 77,, ACALL MDES1 ;SET UP THE REGISTERS1A6C,E5 09,, MOV A,ARG_STACK1A6E,24 0C,, ADD A,#FP_NUMBER_SIZE+FP_NUMBER_SIZE1A70,F5 09,, MOV ARG_STACK,A ;POP THE STACK TWICE, CLEAR THE CARRY1A72,EE,, MOV A,R6 ;CHECK OUT EXPONENTS1A73,C2 D5,, CLR F01A75,9F,, SUBB A,R71A76,60 0A,, JZ EXPONENTS_EQUAL1A78,40 03,, JC ARG1_EXP_IS_LARGER,,, ;,,, ; Now the ARG2 EXPONENT is > ARG1 EXPONENT,,, ;1A7A,,SIGNS_DIFFERENT,SIGNS_DIFFERENT:,,, ;1A7A,EB,, MOV A,R3 ;SEE IF SIGN OF ARG2 IS POSITIVE1A7B,80 01,, SJMP $+3,,, ;1A7D,,ARG1_EXP_IS_LARGER,ARG1_EXP_IS_LARGER:,,, ;1A7D,EC,, MOV A,R4 ;GET THE SIGN OF ARG1 EXPONENT1A7E,60 01,, JZ $+31A80,B3,, CPL C1A81,22,, RET,,, ;1A82,,EXPONENTS_EQUAL,EXPONENTS_EQUAL:,,, ;,,, ; First, test the sign, then the mantissa,,, ;1A82,BD 00 F5,, CJNE R5,#0,SIGNS_DIFFERENT,,, ;1A85,,BOTH_PLUS,BOTH_PLUS:,,, ;1A85,7F 04,, MOV R7,#DIGIT ;POINT AT MS DIGIT1A87,18,, DEC R01A88,18,, DEC R01A89,18,, DEC R01A8A,19,, DEC R11A8B,19,, DEC R11A8C,19,, DEC R1,,, ;,,, ; Now do the compare,,, ;1A8D,E2,CLOOP,CLOOP: MOVX A,@R01A8E,FE,, MOV R6,A1A8F,E3,, MOVX A,@R11A90,9E,, SUBB A,R61A91,70 EA,, JNZ ARG1_EXP_IS_LARGER1A93,08,, INC R01A94,09,, INC R11A95,DF F6,, DJNZ R7,CLOOP,,, ;,,, ; If here, the numbers are the same, the carry is cleared,,, ;1A97,D2 D5,, SETB F01A99,22,, RET ;EXIT WITH EQUAL,,, ;,,,$EJECT,,,;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM,,,;1A9A,,FLOATING_MUL,FLOATING_MUL: ; Floating point multiply,,,;,,,;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM,,,;1A9A,91 75,, ACALL MUL_DIV_EXP_AND_SIGN,,, ;,,, ; check for zero exponents,,, ;1A9C,BE 00 02,, CJNE R6,#00,$+5 ;ARG 2 EXP ZERO?1A9F,61 B8,, AJMP ZERO_AND_EXIT,,, ;,,, ; calculate the exponent,,, ;1AA1,8D 2F,FMUL1,FMUL1: MOV FP_SIGN,R5 ;SAVE THE SIGN, IN CASE OF FAILURE,,, ;1AA3,EF,, MOV A,R71AA4,60 F9,, JZ FMUL1-21AA6,2E,, ADD A,R6 ;ADD THE EXPONENTS1AA7,20 E7 05,, JB ACC.7,FMUL_OVER1AAA,10 D7 06,, JBC CY,FMUL2 ;SEE IF CARRY IS SET,,, ;1AAD,61 B2,, AJMP UNDERFLOW_AND_EXIT,,, ;1AAF,,FMUL_OVER,FMUL_OVER:,,, ;1AAF,50 02,, JNC FMUL2 ;OK IF SET,,, ;1AB1,61 A1,FOV,FOV: AJMP OVERFLOW_AND_EXIT,,, ;1AB3,94 81,FMUL2,FMUL2: SUBB A,#129 ;SUBTRACT THE EXPONENT BIAS1AB5,FE,, MOV R6,A ;SAVE IT FOR LATER,,, ;,,, ; Unpack and load R0,,, ;1AB6,71 8B,, ACALL UNPACK_R0,,, ;,,, ; Now set up for loop multiply,,, ;1AB8,7B 04,, MOV R3,#DIGIT1ABA,AC 01,, MOV R4,R1B0,,, ;,,,$EJECT,,, ;,,, ; Now, do the multiply and accumulate the product,,, ;1ABC,8C 01,FMUL3,FMUL3: MOV R1B0,R41ABE,E3,, MOVX A,@R11ABF,FA,, MOV R2,A1AC0,91 38,, ACALL MUL_NIBBLE,,, ;1AC2,EA,, MOV A,R21AC3,C4,, SWAP A1AC4,91 38,, ACALL MUL_NIBBLE1AC6,1C,, DEC R41AC7,DB F3,, DJNZ R3,FMUL3,,, ;,,, ; Now, pack and restore the sign,,, ;1AC9,8E 30,, MOV FP_EXP,R61ACB,8D 2F,, MOV FP_SIGN,R51ACD,61 30,, AJMP PACK ;FINISH IT OFF,,, ;,,,$EJECT,,, ;DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD,,, ;1ACF,,FLOATING_DIV,FLOATING_DIV:,,, ;,,, ;DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD,,, ;1ACF,91 77,, ACALL MDES1,,, ;,,, ; Check the exponents,,, ;1AD1,8D 2F,, MOV FP_SIGN,R5 ;SAVE THE SIGN1AD3,BF 00 06,, CJNE R7,#0,DIV0 ;CLEARS THE CARRY1AD6,71 A1,, ACALL OVERFLOW_AND_EXIT1AD8,E4,, CLR A1AD9,D2 E3,, SETB ACC.ZERO_DIVIDE1ADB,22,, RET,,, ;1ADC,EE,DIV0,DIV0: MOV A,R6 ;GET EXPONENT1ADD,60 C0,, JZ FMUL1-2 ;EXIT IF ZERO1ADF,9F,, SUBB A,R7 ;DELTA EXPONENT1AE0,20 E7 04,, JB ACC.7,D_UNDER1AE3,50 04,, JNC DIV31AE5,61 B2,, AJMP UNDERFLOW_AND_EXIT,,, ;1AE7,50 C8,D_UNDER,D_UNDER:JNC FOV,,, ;1AE9,24 81,DIV3,DIV3: ADD A,#129 ;CORRECTLY BIAS THE EXPONENT1AEB,F5 30,, MOV FP_EXP,A ;SAVE THE EXPONENT1AED,91 88,, ACALL LOADR1_MANTISSA ;LOAD THE DIVIDED,,, ;1AEF,7A 34,, MOV R2,#FP_ACCC ;SAVE LOCATION1AF1,AB 00,, MOV R3,R0B0 ;SAVE POINTER IN R31AF3,75 2A 00,, MOV FP_CARRY,#0 ;ZERO CARRY BYTE,,, ;1AF6,7D FF,DIV4,DIV4: MOV R5,#0FFH ;LOOP COUNT1AF8,D3,, SETB C,,, ;1AF9,8B 00,DIV5,DIV5: MOV R0B0,R3 ;RESTORE THE EXTERNAL POINTER1AFB,79 2E,, MOV R1,#FP_DIG78 ;SET UP INTERNAL POINTER1AFD,7F 04,, MOV R7,#DIGIT ;LOOP COUNT1AFF,50 17,, JNC DIV7 ;EXIT IF NO CARRY,,, ;1B01,E2,DIV6,DIV6: MOVX A,@R0 ;DO ACCUMLATION1B02,FE,, MOV R6,A1B03,E4,, CLR A1B04,34 99,, ADDC A,#99H1B06,9E,, SUBB A,R61B07,27,, ADD A,@R11B08,D4,, DA A1B09,F7,, MOV @R1,A1B0A,18,, DEC R01B0B,19,, DEC R11B0C,DF F3,, DJNZ R7,DIV6 ;LOOP,,, ;1B0E,0D,, INC R5 ;SUBTRACT COUNTER1B0F,40 E8,, JC DIV5 ;KEEP LOOPING IF CARRY1B11,E7,, MOV A,@R1 ;GET CARRY1B12,94 01,, SUBB A,#1 ;CARRY IS CLEARED1B14,F7,, MOV @R1,A ;SAVE CARRY DIGIT1B15,B3,, CPL C1B16,80 E1,, SJMP DIV5 ;LOOP,,, ;,,, ; Restore the result if carry was found,,, ;1B18,51 19,DIV7,DIV7: ACALL ADDLP ;ADD NUMBER BACK1B1A,77 00,, MOV @R1,#0 ;CLEAR CARRY1B1C,8A 00,, MOV R0B0,R2 ;GET SAVE COUNTER1B1E,A6 05,, MOV @R0,5 ;SAVE COUNT BYTE,,, ;1B20,0A,, INC R2 ;ADJUST SAVE COUNTER1B21,7F 01,, MOV R7,#1 ;BUMP DIVIDEND1B23,91 00,, ACALL LEFT1B25,BA 3E CE,, CJNE R2,#FP_ACC8+2,DIV4,,, ;1B28,D5 30 02,, DJNZ FP_EXP,DIV81B2B,61 B2,, AJMP UNDERFLOW_AND_EXIT,,, ;1B2D,75 2A 00,DIV8,DIV8: MOV FP_CARRY,#0,,, ;,,,$EJECT,,, ;***************************************************************,,, ;1B30,,PACK,PACK: ; Pack the mantissa,,, ;,,, ;***************************************************************,,, ;,,, ; First, set up the pointers,,, ;1B30,78 34,, MOV R0,#FP_ACCC1B32,E6,, MOV A,@R0 ;GET FP_ACCC1B33,FE,, MOV R6,A ;SAVE FOR ZERO COUNT1B34,60 03,, JZ PACK0 ;JUMP OVER IF ZERO1B36,71 7F,, ACALL INC_FP_EXP ;BUMP THE EXPONENT1B38,18,, DEC R0,,, ;1B39,08,PACK0,PACK0: INC R0 ;POINT AT FP_ACC1,,, ;1B3A,74 08,PACK1,PACK1: MOV A,#8 ;ADJUST NIBBLE POINTER1B3C,F9,, MOV R1,A1B3D,28,, ADD A,R01B3E,F8,, MOV R0,A1B3F,B6 05 00,, CJNE @R0,#5,$+3 ;SEE IF ADJUSTING NEEDED1B42,40 13,, JC PACK3+1,,, ;1B44,D3,PACK2,PACK2: SETB C1B45,E4,, CLR A1B46,18,, DEC R01B47,36,, ADDC A,@R01B48,D4,, DA A1B49,D6,, XCHD A,@R0 ;SAVE THE VALUE1B4A,30 E4 09,, JNB ACC.4,PACK31B4D,D9 F5,, DJNZ R1,PACK2,,, ;1B4F,18,, DEC R01B50,76 01,, MOV @R0,#11B52,71 7F,, ACALL INC_FP_EXP1B54,80 06,, SJMP PACK4,,, ;1B56,19,PACK3,PACK3: DEC R11B57,E9,, MOV A,R11B58,C3,, CLR C1B59,C8,, XCH A,R01B5A,98,, SUBB A,R01B5B,F8,, MOV R0,A,,, ;1B5C,79 2B,PACK4,PACK4: MOV R1,#FP_DIG12,,, ;,,, ; Now, pack,,, ;1B5E,E6,PLOOP,PLOOP: MOV A,@R01B5F,C4,, SWAP A ;FLIP THE DIGITS1B60,08,, INC R01B61,D6,, XCHD A,@R01B62,42 06,, ORL 6,A ;ACCUMULATE THE OR'ED DIGITS1B64,F7,, MOV @R1,A1B65,08,, INC R01B66,09,, INC R11B67,B9 2F F4,, CJNE R1,#FP_SIGN,PLOOP1B6A,EE,, MOV A,R61B6B,70 03,, JNZ STORE_ALIGN_TEST_AND_EXIT1B6D,75 30 00,, MOV FP_EXP,#0 ;ZERO EXPONENT,,, ;,,, ;**************************************************************,,, ;1B70,,STORE_ALIGN_TEST_AND_EXIT,STORE_ALIGN_TEST_AND_EXIT: ;Save the number align carry and exit,,, ;,,, ;**************************************************************,,, ;1B70,91 6B,, ACALL LOAD_POINTERS1B72,89 09,, MOV ARG_STACK,R1 ;SET UP THE NEW STACK1B74,78 30,, MOV R0,#FP_EXP,,, ;,,, ; Now load the numbers,,, ;1B76,E6,STORE2,STORE2: MOV A,@R01B77,F3,, MOVX @R1,A ;SAVE THE NUMBER1B78,18,, DEC R01B79,19,, DEC R11B7A,B8 2A F9,, CJNE R0,#FP_CARRY,STORE2,,, ;1B7D,E4,, CLR A ;NO ERRORS,,, ;1B7E,22,PRET,PRET: RET ;EXIT,,, ;,,,$EJECT1B7F,,INC_FP_EXP,INC_FP_EXP:,,, ;1B7F,05 30,, INC FP_EXP1B81,E5 30,, MOV A,FP_EXP1B83,70 F9,, JNZ PRET ;EXIT IF NOT ZERO1B85,D0 E0,, POP ACC ;WASTE THE CALLING STACK1B87,D0 E0,, POP ACC1B89,61 A1,, AJMP OVERFLOW_AND_EXIT,,, ;,,,;***********************************************************************,,,;1B8B,,UNPACK_R0,UNPACK_R0: ; Unpack BCD digits and load into nibble locations,,,;,,,;***********************************************************************,,, ;1B8B,C0 01,, PUSH R1B01B8D,79 32,, MOV R1,#FP_NIB8,,, ;1B8F,E2,ULOOP,ULOOP: MOVX A,@R01B90,54 0F,, ANL A,#0FH1B92,F7,, MOV @R1,A ;SAVE THE NIBBLE1B93,E2,, MOVX A,@R01B94,C4,, SWAP A1B95,54 0F,, ANL A,#0FH1B97,19,, DEC R11B98,F7,, MOV @R1,A ;SAVE THE NIBBLE AGAIN1B99,18,, DEC R01B9A,19,, DEC R11B9B,B9 2A F1,, CJNE R1,#FP_NIB1-1,ULOOP,,, ;1B9E,D0 01,, POP R1B0,,, ;1BA0,22,LOAD7,LOAD7: RET,,, ;,,,$EJECT,,, ;**************************************************************,,, ;1BA1,,OVERFLOW_AND_EXIT,OVERFLOW_AND_EXIT: ;LOAD 99999999 E+127, SET OV BIT, AND EXIT,,, ;,,, ;**************************************************************,,, ;1BA1,78 2E,, MOV R0,#FP_DIG781BA3,74 99,, MOV A,#99H,,, ;1BA5,F6,OVE1,OVE1: MOV @R0,A1BA6,18,, DEC R01BA7,B8 2A FB,, CJNE R0,#FP_CARRY,OVE1,,, ;1BAA,75 30 FF,, MOV FP_EXP,#0FFH1BAD,71 70,, ACALL STORE_ALIGN_TEST_AND_EXIT,,, ;1BAF,D2 E1,, SETB ACC.OVERFLOW1BB1,22,, RET,,, ;,,,$EJECT,,, ;**************************************************************,,, ;1BB2,,UNDERFLOW_AND_EXIT,UNDERFLOW_AND_EXIT: ;LOAD 0, SET UF BIT, AND EXIT,,, ;,,, ;**************************************************************,,, ;1BB2,71 B8,, ACALL ZERO_AND_EXIT1BB4,E4,, CLR A1BB5,D2 E0,, SETB ACC.UNDERFLOW1BB7,22,, RET,,, ;,,, ;**************************************************************,,, ;1BB8,,ZERO_AND_EXIT,ZERO_AND_EXIT: ;LOAD 0, SET ZERO BIT, AND EXIT,,, ;,,, ;**************************************************************,,, ;1BB8,71 BF,, ACALL FP_CLEAR1BBA,71 70,, ACALL STORE_ALIGN_TEST_AND_EXIT1BBC,D2 E2,, SETB ACC.ZERO1BBE,22,, RET ;EXIT,,, ;,,, ;**************************************************************,,, ;1BBF,,FP_CLEAR,FP_CLEAR:,,, ;,,, ; Clear internal storage,,, ;,,, ;**************************************************************,,, ;1BBF,E4,, CLR A1BC0,78 3D,, MOV R0,#FP_ACC8+1,,, ;1BC2,F6,FPC1,FPC1: MOV @R0,A1BC3,18,, DEC R01BC4,B8 29 FB,, CJNE R0,#FP_TEMP,FPC11BC7,22,, RET,,, ;,,,$EJECT,,, ;**************************************************************,,, ;1BC8,,RIGHT,RIGHT: ; Shift ACCUMULATOR RIGHT the number of nibbles in R7,,, ; Save the shifted values in R4 if SAVE_ROUND is set,,, ;,,, ;**************************************************************,,, ;1BC8,7C 00,, MOV R4,#0 ;IN CASE OF NO SHIFT,,, ;1BCA,C3,RIGHT1,RIGHT1: CLR C1BCB,EF,, MOV A,R7 ;GET THE DIGITS TO SHIFT1BCC,60 22,, JZ RIGHT5-1 ;EXIT IF ZERO1BCE,94 02,, SUBB A,#2 ;TWO TO DO?1BD0,50 1F,, JNC RIGHT5 ;SHIFT TWO NIBBLES,,, ;,,, ; Swap one nibble then exit,,, ;1BD2,C0 00,RIGHT3,RIGHT3: PUSH R0B0 ;SAVE POINTER REGISTER1BD4,C0 01,, PUSH R1B0,,, ;1BD6,79 2E,, MOV R1,#FP_DIG78 ;LOAD THE POINTERS1BD8,78 2D,, MOV R0,#FP_DIG561BDA,EC,, MOV A,R4 ;GET THE OVERFLOW REGISTER1BDB,D7,, XCHD A,@R1 ;GET DIGIT 81BDC,C4,, SWAP A ;FLIP FOR LOAD1BDD,FC,, MOV R4,A,,, ;1BDE,E7,RIGHTL,RIGHTL: MOV A,@R1 ;GET THE LOW ORDER BYTE1BDF,D6,, XCHD A,@R0 ;SWAP NIBBLES1BE0,C4,, SWAP A ;FLIP FOR STORE1BE1,F7,, MOV @R1,A ;SAVE THE DIGITS1BE2,18,, DEC R0 ;BUMP THE POINTERS1BE3,19,, DEC R11BE4,B9 2A F7,, CJNE R1,#FP_DIG12-1,RIGHTL ;LOOP,,, ;1BE7,E7,, MOV A,@R1 ;ACC = CH81BE8,C4,, SWAP A ;ACC = 8CH1BE9,54 0F,, ANL A,#0FH ;ACC = 0CH1BEB,F7,, MOV @R1,A ;CARRY DONE1BEC,D0 01,, POP R1B0 ;EXIT1BEE,D0 00,, POP R0B0 ;RESTORE REGISTER1BF0,22,, RET,,, ;1BF1,FF,RIGHT5,RIGHT5: MOV R7,A ;SAVE THE NEW SHIFT NUMBER1BF2,E4,, CLR A1BF3,C5 2A,, XCH A,FP_CARRY ;SWAP THE NIBBLES1BF5,C5 2B,, XCH A,FP_DIG121BF7,C5 2C,, XCH A,FP_DIG341BF9,C5 2D,, XCH A,FP_DIG561BFB,C5 2E,, XCH A,FP_DIG781BFD,FC,, MOV R4,A ;SAVE THE LAST DIGIT SHIFTED1BFE,80 CB,, SJMP RIGHT1+1,,, ;,,,$EJECT,,, ;***************************************************************,,, ;1C00,,LEFT,LEFT: ; Shift ACCUMULATOR LEFT the number of nibbles in R7,,, ;,,, ;***************************************************************,,, ;1C00,7C 00,, MOV R4,#00H ;CLEAR FOR SOME ENTRYS,,, ;1C02,C3,LEFT1,LEFT1: CLR C1C03,EF,, MOV A,R7 ;GET SHIFT VALUE1C04,60 22,, JZ LEFT5-1 ;EXIT IF ZERO1C06,94 02,, SUBB A,#2 ;SEE HOW MANY BYTES TO SHIFT1C08,50 1F,, JNC LEFT5,,, ;1C0A,C0 00,LEFT3,LEFT3: PUSH R0B0 ;SAVE POINTER1C0C,C0 01,, PUSH R1B01C0E,78 2A,, MOV R0,#FP_CARRY1C10,79 2B,, MOV R1,#FP_DIG12,,, ;1C12,E6,, MOV A,@R0 ;ACC=CHCL1C13,C4,, SWAP A ;ACC = CLCH1C14,F6,, MOV @R0,A ;ACC = CLCH, @R0 = CLCH,,, ;1C15,E7,LEFTL,LEFTL: MOV A,@R1 ;DIG 121C16,C4,, SWAP A ;DIG 211C17,D6,, XCHD A,@R01C18,F7,, MOV @R1,A ;SAVE IT1C19,08,, INC R0 ;BUMP POINTERS1C1A,09,, INC R11C1B,B8 2E F7,, CJNE R0,#FP_DIG78,LEFTL,,, ;1C1E,EC,, MOV A,R41C1F,C4,, SWAP A1C20,D6,, XCHD A,@R01C21,54 F0,, ANL A,#0F0H1C23,FC,, MOV R4,A,,, ;1C24,D0 01,, POP R1B01C26,D0 00,, POP R0B0 ;RESTORE1C28,22,, RET ;DONE,,, ;1C29,FF,LEFT5,LEFT5: MOV R7,A ;RESTORE COUNT1C2A,E4,, CLR A1C2B,CC,, XCH A,R4 ;GET THE RESTORATION BYTE1C2C,C5 2E,, XCH A,FP_DIG78 ;DO THE SWAP1C2E,C5 2D,, XCH A,FP_DIG561C30,C5 2C,, XCH A,FP_DIG341C32,C5 2B,, XCH A,FP_DIG121C34,C5 2A,, XCH A,FP_CARRY1C36,80 CB,, SJMP LEFT1+1,,, ;,,,$EJECT1C38,,MUL_NIBBLE,MUL_NIBBLE:,,, ;,,, ; Multiply the nibble in R7 by the FP_NIB locations,,, ; accumulate the product in FP_ACC,,, ;,,, ; Set up the pointers for multiplication,,, ;1C38,54 0F,, ANL A,#0FH ;STRIP OFF MS NIBBLE1C3A,FF,, MOV R7,A1C3B,78 3C,, MOV R0,#FP_ACC81C3D,79 32,, MOV R1,#FP_NIB81C3F,E4,, CLR A1C40,F5 33,, MOV FP_ACCX,A,,, ;1C42,18,MNLOOP,MNLOOP: DEC R0 ;BUMP POINTER TO PROPAGATE CARRY1C43,26,, ADD A,@R0 ;ATTEMPT TO FORCE CARRY1C44,D4,, DA A ;BCD ADJUST1C45,30 E4 03,, JNB ACC.4,MNL0 ;DON'T ADJUST IF NO NEED1C48,18,, DEC R0 ;PROPAGATE CARRY TO THE NEXT DIGIT1C49,06,, INC @R0 ;DO THE ADJUSTING1C4A,08,, INC R0 ;RESTORE R0,,, ;1C4B,D6,MNL0,MNL0: XCHD A,@R0 ;RESTORE INITIAL NUMBER1C4C,8F F0,, MOV B,R7 ;GET THE NUBBLE TO MULTIPLY1C4E,E7,, MOV A,@R1 ;GET THE OTHER NIBBLE1C4F,A4,, MUL AB ;DO THE MULTIPLY1C50,75 F0 0A,, MOV B,#10 ;NOW BCD ADJUST1C53,84,, DIV AB1C54,C5 F0,, XCH A,B ;GET THE REMAINDER1C56,26,, ADD A,@R0 ;PROPAGATE THE PARTIAL PRODUCTS1C57,D4,, DA A ;BCD ADJUST1C58,30 E4 02,, JNB ACC.4,MNL1 ;PROPAGATE PARTIAL PRODUCT CARRY1C5B,05 F0,, INC B,,, ;1C5D,08,MNL1,MNL1: INC R01C5E,D6,, XCHD A,@R0 ;SAVE THE NEW PRODUCT1C5F,18,, DEC R01C60,E5 F0,, MOV A,B ;GET BACK THE QUOTIENT1C62,19,, DEC R11C63,B9 2A DC,, CJNE R1,#FP_NIB1-1,MNLOOP,,, ;1C66,25 33,, ADD A,FP_ACCX ;GET THE OVERFLOW1C68,D4,, DA A ;ADJUST1C69,F6,, MOV @R0,A ;SAVE IT1C6A,22,, RET ;EXIT,,, ;,,,$EJECT,,, ;***************************************************************,,, ;1C6B,,LOAD_POINTERS,LOAD_POINTERS: ; Load the ARG_STACK into R0 and bump R1,,, ;,,, ;***************************************************************,,, ;1C6B,75 A0 01,, MOV P2,#ARG_STACK_PAGE1C6E,A8 09,, MOV R0,ARG_STACK1C70,74 06,, MOV A,#FP_NUMBER_SIZE1C72,28,, ADD A,R01C73,F9,, MOV R1,A1C74,22,, RET,,, ;,,, ;***************************************************************,,, ;1C75,,MUL_DIV_EXP_AND_SIGN,MUL_DIV_EXP_AND_SIGN:,,, ;,,, ; Load the sign into R7, R6. R5 gets the sign for,,, ; multiply and divide.,,, ;,,, ;***************************************************************,,, ;1C75,71 BF,, ACALL FP_CLEAR ;CLEAR INTERNAL MEMORY,,, ;1C77,91 6B,MDES1,MDES1: ACALL LOAD_POINTERS ;LOAD REGISTERS1C79,E2,, MOVX A,@R0 ;ARG 1 EXP1C7A,FF,, MOV R7,A ;SAVED IN R71C7B,E3,, MOVX A,@R1 ;ARG 2 EXP1C7C,FE,, MOV R6,A ;SAVED IN R61C7D,18,, DEC R0 ;BUMP POINTERS TO SIGN1C7E,19,, DEC R11C7F,E2,, MOVX A,@R0 ;GET THE SIGN1C80,FC,, MOV R4,A ;SIGN OF ARG11C81,E3,, MOVX A,@R1 ;GET SIGN OF NEXT ARG1C82,FB,, MOV R3,A ;SIGN OF ARG21C83,6C,, XRL A,R4 ;ACC GETS THE NEW SIGN1C84,FD,, MOV R5,A ;R5 GETS THE NEW SIGN,,, ;,,, ; Bump the pointers to point at the LS digit,,, ;1C85,18,, DEC R01C86,19,, DEC R1,,, ;1C87,22,, RET,,, ;,,,$EJECT,,, ;***************************************************************,,, ;1C88,,LOADR1_MANTISSA,LOADR1_MANTISSA:,,, ;,,, ; Load the mantissa of R0 into FP_Digits,,, ;,,, ;***************************************************************,,, ;1C88,C0 00,, PUSH R0B0 ;SAVE REGISTER 11C8A,78 2E,, MOV R0,#FP_DIG78 ;SET UP THE POINTER,,, ;1C8C,E3,LOADR1,LOADR1: MOVX A,@R11C8D,F6,, MOV @R0,A1C8E,19,, DEC R11C8F,18,, DEC R01C90,B8 2A F9,, CJNE R0,#FP_CARRY,LOADR1,,, ;1C93,D0 00,, POP R0B01C95,22,, RET,,, ;,,,$EJECT,,, ;***************************************************************,,, ;1C96,,HEXSCAN,HEXSCAN: ; Scan a string to determine if it is a hex number,,, ; set carry if hex, else carry = 0,,, ;,,, ;***************************************************************,,, ;1C96,B1 6C,, ACALL GET_DPTR_CHARACTER1C98,C0 83,, PUSH DPH1C9A,C0 82,, PUSH DPL ;SAVE THE POINTER,,, ;1C9C,E0,HEXSC1,HEXSC1: MOVX A,@DPTR ;GET THE CHARACTER1C9D,F1 ED,, ACALL DIGIT_CHECK ;SEE IF A DIGIT1C9F,40 12,, JC HS1 ;CONTINUE IF A DIGIT1CA1,91 B6,, ACALL HEX_CHECK ;SEE IF HEX1CA3,40 0E,, JC HS1,,, ;1CA5,C2 E5,, CLR ACC.5 ;NO LOWER CASE1CA7,B4 48 03,, CJNE A,#'H',HEXDON1CAA,D3,, SETB C1CAB,80 01,, SJMP HEXDO1 ;NUMBER IS VALID HEX, MAYBE,,, ;1CAD,C3,HEXDON,HEXDON: CLR C,,, ;1CAE,D0 82,HEXDO1,HEXDO1: POP DPL ;RESTORE POINTER1CB0,D0 83,, POP DPH1CB2,22,, RET,,, ;1CB3,A3,HS1,HS1: INC DPTR ;BUMP TO NEXT CHARACTER1CB4,80 E6,, SJMP HEXSC1 ;LOOP,,, ;1CB6,,HEX_CHECK,HEX_CHECK: ;CHECK FOR A VALID ASCII HEX, SET CARRY IF FOUND,,, ;1CB6,C2 E5,, CLR ACC.5 ;WASTE LOWER CASE1CB8,B4 47 00,, CJNE A,#'F'+1,$+3 ;SEE IF F OR LESS1CBB,40 01,, JC HC11CBD,22,, RET,,, ;1CBE,B4 41 00,HC1,HC1: CJNE A,#'A',$+3 ;SEE IF A OR GREATER1CC1,B3,, CPL C1CC2,22,, RET,,, ;,,,$EJECT,,, ;1CC3,,PUSHR2R0,PUSHR2R0:,,, ;1CC3,7B 00,, MOV R3,#HIGH CONVT ;CONVERSION LOCATION1CC5,79 58,, MOV R1,#LOW CONVT1CC7,F1 04,, ACALL CONVERT_BINARY_TO_ASCII_STRING1CC9,74 0D,, MOV A,#0DH ;A CR TO TERMINATE1CCB,F3,, MOVX @R1,A ;SAVE THE CR1CCC,90 00 58,, MOV DPTR,#CONVT,,, ;,,, ; Falls thru to FLOATING INPUT,,, ;,,,$EJECT,,, ;***************************************************************,,, ;1CCF,,FLOATING_POINT_INPUT,FLOATING_POINT_INPUT: ; Input a floating point number pointed to by,,, ; the DPTR,,, ;,,, ;***************************************************************,,, ;1CCF,71 BF,, ACALL FP_CLEAR ;CLEAR EVERYTHING1CD1,B1 6C,, ACALL GET_DPTR_CHARACTER1CD3,B1 72,, ACALL PLUS_MINUS_TEST1CD5,92 78,, MOV MSIGN,C ;SAVE THE MANTISSA SIGN,,, ;,,, ; Now, set up for input loop,,, ;1CD7,78 34,, MOV R0,#FP_ACCC1CD9,7E 7F,, MOV R6,#7FH ;BASE EXPONENT1CDB,D2 D5,, SETB F0 ;SET INITIAL FLAG,,, ;1CDD,F1 EB,INLOOP,INLOOP: ACALL GET_DIGIT_CHECK1CDF,50 07,, JNC GTEST ;IF NOT A CHARACTER, WHAT IS IT?1CE1,54 0F,, ANL A,#0FH ;STRIP ASCII1CE3,B1 45,, ACALL STDIG ;STORE THE DIGITS,,, ;1CE5,A3,INLPIK,INLPIK: INC DPTR ;BUMP POINTER FOR LOOP1CE6,80 F5,, SJMP INLOOP ;LOOP FOR INPUT,,, ;1CE8,B4 2E 0C,GTEST,GTEST: CJNE A,#'.',GT1 ;SEE IF A RADIX1CEB,20 51 63,, JB FOUND_RADIX,INERR1CEE,D2 51,, SETB FOUND_RADIX1CF0,B8 34 F2,, CJNE R0,#FP_ACCC,INLPIK1CF3,D2 52,, SETB FIRST_RADIX ;SET IF FIRST RADIX1CF5,80 EE,, SJMP INLPIK ;GET ADDITIONAL DIGITS,,, ;1CF7,20 D5 57,GT1,GT1: JB F0,INERR ;ERROR IF NOT CLEARED1CFA,B4 65 02,, CJNE A,#'e',$+5 ;CHECK FOR LOWER CASE1CFD,80 03,, SJMP $+51CFF,B4 45 33,, CJNE A,#'E',FINISH_UP1D02,B1 6B,, ACALL INC_AND_GET_DPTR_CHARACTER1D04,B1 72,, ACALL PLUS_MINUS_TEST1D06,92 50,, MOV XSIGN,C ;SAVE SIGN STATUS1D08,F1 EB,, ACALL GET_DIGIT_CHECK1D0A,50 45,, JNC INERR,,, ;1D0C,54 0F,, ANL A,#0FH ;STRIP ASCII BIAS OFF THE CHARACTER1D0E,FD,, MOV R5,A ;SAVE THE CHARACTER IN R5,,, ;1D0F,A3,GT2,GT2: INC DPTR1D10,F1 EB,, ACALL GET_DIGIT_CHECK1D12,50 0D,, JNC FINISH11D14,54 0F,, ANL A,#0FH ;STRIP OFF BIAS1D16,CD,, XCH A,R5 ;GET THE LAST DIGIT1D17,75 F0 0A,, MOV B,#10 ;MULTIPLY BY TEN1D1A,A4,, MUL AB1D1B,2D,, ADD A,R5 ;ADD TO ORIGINAL VALUE1D1C,FD,, MOV R5,A ;SAVE IN R51D1D,50 F0,, JNC GT2 ;LOOP IF NO CARRY1D1F,7D FF,, MOV R5,#0FFH ;FORCE AN ERROR,,, ;1D21,ED,FINISH1,FINISH1:MOV A,R5 ;GET THE SIGN1D22,30 50 09,, JNB XSIGN,POSNUM ;SEE IF EXPONENT IS POS OR NEG1D25,C3,, CLR C1D26,9E,, SUBB A,R61D27,F4,, CPL A1D28,04,, INC A1D29,40 09,, JC FINISH21D2B,74 01,, MOV A,#01H1D2D,22,, RET,,, ;1D2E,2E,POSNUM,POSNUM: ADD A,R6 ;ADD TO EXPONENT1D2F,50 03,, JNC FINISH2,,, ;1D31,74 02,POSNM1,POSNM1: MOV A,#02H1D33,22,, RET,,, ;1D34,CE,FINISH2,FINISH2:XCH A,R6 ;SAVE THE EXPONENT,,, ;1D35,,FINISH_UP,FINISH_UP:,,, ;1D35,8E 30,, MOV FP_EXP,R6 ;SAVE EXPONENT1D37,B8 34 02,, CJNE R0,#FP_ACCC,$+51D3A,71 BF,, ACALL FP_CLEAR ;CLEAR THE MEMORY IF 01D3C,E5 09,, MOV A,ARG_STACK ;GET THE ARG STACK1D3E,C3,, CLR C1D3F,94 0C,, SUBB A,#FP_NUMBER_SIZE+FP_NUMBER_SIZE1D41,F5 09,, MOV ARG_STACK,A ;ADJUST FOR STORE1D43,61 30,, AJMP PACK,,, ;1D45,C2 D5,STDIG,STDIG: CLR F0 ;CLEAR INITIAL DESIGNATOR1D47,70 0B,, JNZ STDIG1 ;CONTINUE IF NOT ZERO1D49,B8 34 08,, CJNE R0,#FP_ACCC,STDIG11D4C,30 52 04,, JNB FIRST_RADIX,RET_X,,, ;1D4F,DE 02,DECX,DECX: DJNZ R6,RET_X,,, ;1D51,74 FF,INERR,INERR: MOV A,#0FFH,,, ;1D53,22,RET_X,RET_X: RET,,, ;1D54,20 53 02,STDIG1,STDIG1: JB DONE_LOAD,FRTEST1D57,C2 52,, CLR FIRST_RADIX,,, ;1D59,20 52 F3,FRTEST,FRTEST: JB FIRST_RADIX,DECX,,, ;1D5C,20 51 01,FDTEST,FDTEST: JB FOUND_RADIX,FDT11D5F,0E,, INC R6,,, ;1D60,20 53 F0,FDT1,FDT1: JB DONE_LOAD,RET_X1D63,B8 3D 02,, CJNE R0,#FP_ACC8+1,FDT21D66,D2 53,, SETB DONE_LOAD,,, ;1D68,F6,FDT2,FDT2: MOV @R0,A ;SAVE THE STRIPPED ACCUMULATOR1D69,08,, INC R0 ;BUMP THE POINTER1D6A,22,, RET ;EXIT,,, ;,,,$EJECT,,, ;***************************************************************,,, ;,,, ; I/O utilities,,, ;,,, ;***************************************************************,,, ;1D6B,,INC_AND_GET_DPTR_CHARACTER,INC_AND_GET_DPTR_CHARACTER:,,, ;1D6B,A3,, INC DPTR,,, ;1D6C,,GET_DPTR_CHARACTER,GET_DPTR_CHARACTER:,,, ;1D6C,E0,, MOVX A,@DPTR ;GET THE CHARACTER1D6D,B4 20 16,, CJNE A,#' ',PMT1 ;SEE IF A SPACE,,, ;,,, ; Kill spaces,,, ;1D70,80 F9,, SJMP INC_AND_GET_DPTR_CHARACTER,,, ;1D72,,PLUS_MINUS_TEST,PLUS_MINUS_TEST:,,, ;1D72,B4 E3 02,, CJNE A,#0E3H,$+5 ;SEE IF A PLUS, PLUS TOKEN FROM BASIC1D75,80 0E,, SJMP PMT31D77,B4 2B 02,, CJNE A,#'+',$+51D7A,80 09,, SJMP PMT31D7C,B4 E5 02,, CJNE A,#0E5H,$+5 ;SEE IF MINUS, MINUS TOKEN FROM BASIC1D7F,80 03,, SJMP PMT21D81,B4 2D 02,, CJNE A,#'-',PMT1,,, ;1D84,D3,PMT2,PMT2: SETB C,,, ;1D85,A3,PMT3,PMT3: INC DPTR,,, ;1D86,22,PMT1,PMT1: RET,,, ;,,,$EJECT,,, ;***************************************************************,,, ;1D87,,FLOATING_POINT_OUTPUT,FLOATING_POINT_OUTPUT: ; Output the number, format is in location 23,,, ;,,, ; IF FORMAT = 00 - FREE FLOATING,,, ; = FX - EXPONENTIAL (X IS THE NUMBER OF SIG DIGITS),,, ; = NX - N = NUM BEFORE RADIX, X = NUM AFTER RADIX,,, ; N + X = 8 MAX,,, ;,,, ;***************************************************************,,, ;1D87,91 77,, ACALL MDES1 ;GET THE NUMBER TO OUTPUT, R0 IS POINTER1D89,31 C9,, ACALL POP_AND_EXIT ;OUTPUT POPS THE STACK1D8B,EF,, MOV A,R71D8C,FE,, MOV R6,A ;PUT THE EXPONENT IN R61D8D,71 8B,, ACALL UNPACK_R0 ;UNPACK THE NUMBER1D8F,78 2B,, MOV R0,#FP_NIB1 ;POINT AT THE NUMBER1D91,E5 17,, MOV A,FORMAT ;GET THE FORMAT1D93,FB,, MOV R3,A ;SAVE IN CASE OF EXP FORMAT1D94,60 49,, JZ FREE ;FREE FLOATING?1D96,B4 F0 00,, CJNE A,#0F0H,$+3 ;SEE IF EXPONENTIAL1D99,50 73,, JNC EXPOUT,,, ;,,, ; If here, must be integer USING format,,, ;1D9B,EE,, MOV A,R6 ;GET THE EXPONENT1D9C,70 02,, JNZ $+41D9E,7E 80,, MOV R6,#80H1DA0,EB,, MOV A,R3 ;GET THE FORMAT1DA1,C4,, SWAP A ;SPLIT INTEGER AND FRACTION1DA2,54 0F,, ANL A,#0FH1DA4,FA,, MOV R2,A ;SAVE INTEGER1DA5,D1 74,, ACALL NUM_LT ;GET THE NUMBER OF INTEGERS1DA7,CA,, XCH A,R2 ;FLIP FOR SUBB1DA8,C3,, CLR C1DA9,9A,, SUBB A,R21DAA,FF,, MOV R7,A1DAB,50 06,, JNC $+81DAD,7D 3F,, MOV R5,#'?' ;OUTPUT A QUESTION MARK1DAF,D1 A9,, ACALL SOUT1 ;NUMBER IS TOO LARGE FOR FORMAT1DB1,A1 DF,, AJMP FREE1DB3,BA 00 07,, CJNE R2,#00,USING0 ;SEE IF ZERO1DB6,1F,, DEC R71DB7,D1 96,, ACALL SS71DB9,D1 A3,, ACALL ZOUT ;OUTPUT A ZERO1DBB,80 06,, SJMP USING1,,, ;1DBD,D1 96,USING0,USING0: ACALL SS7 ;OUTPUT SPACES, IF NEED TO1DBF,EA,, MOV A,R2 ;OUTPUT DIGITS1DC0,FF,, MOV R7,A1DC1,D1 58,, ACALL OUTR0,,, ;1DC3,EB,USING1,USING1: MOV A,R31DC4,54 0F,, ANL A,#0FH ;GET THE NUMBER RIGHT OF DP1DC6,FA,, MOV R2,A ;SAVE IT1DC7,60 BD,, JZ PMT1 ;EXIT IF ZERO1DC9,D1 9F,, ACALL ROUT ;OUTPUT DP1DCB,D1 7D,, ACALL NUM_RT1DCD,B5 02 03,, CJNE A,2,USINGX ;COMPARE A TO R2,,, ;1DD0,EA,USINGY,USINGY: MOV A,R21DD1,C1 8D,, AJMP Z7R7,,, ;1DD3,50 FB,USINGX,USINGX: JNC USINGY,,, ;1DD5,CA,USING2,USING2: XCH A,R21DD6,C3,, CLR C1DD7,9A,, SUBB A,R21DD8,CA,, XCH A,R21DD9,D1 8D,, ACALL Z7R7 ;OUTPUT ZEROS IF NEED TO1DDB,EA,, MOV A,R21DDC,FF,, MOV R7,A1DDD,C1 58,, AJMP OUTR0,,, ;,,, ; First, force exponential output, if need to,,, ;1DDF,EE,FREE,FREE: MOV A,R6 ;GET THE EXPONENT1DE0,70 04,, JNZ FREE1 ;IF ZERO, PRINT IT1DE2,D1 A7,, ACALL SOUT1DE4,C1 A3,, AJMP ZOUT,,, ;1DE6,7B F0,FREE1,FREE1: MOV R3,#0F0H ;IN CASE EXP NEEDED1DE8,74 77,, MOV A,#80H-DIGIT-DIGIT-11DEA,2E,, ADD A,R61DEB,40 21,, JC EXPOUT1DED,94 F7,, SUBB A,#0F7H1DEF,40 1D,, JC EXPOUT,,, ;,,, ; Now, just print the number,,, ;1DF1,D1 98,, ACALL SINOUT ;PRINT THE SIGN OF THE NUMBER1DF3,D1 74,, ACALL NUM_LT ;GET THE NUMBER LEFT OF DP1DF5,B4 08 02,, CJNE A,#8,FREE41DF8,C1 58,, AJMP OUTR0,,, ;1DFA,D1 58,FREE4,FREE4: ACALL OUTR01DFC,D1 6A,, ACALL ZTEST ;TEST FOR TRAILING ZEROS1DFE,60 57,, JZ U_RET ;DONE IF ALL TRAILING ZEROS1E00,D1 9F,, ACALL ROUT ;OUTPUT RADIX,,, ;1E02,7F 01,FREE2,FREE2: MOV R7,#1 ;OUTPUT ONE DIGIT1E04,D1 58,, ACALL OUTR01E06,70 4F,, JNZ U_RET1E08,D1 6A,, ACALL ZTEST1E0A,60 4B,, JZ U_RET1E0C,80 F4,, SJMP FREE2 ;LOOP,,, ;1E0E,D1 98,EXPOUT,EXPOUT: ACALL SINOUT ;PRINT THE SIGN1E10,7F 01,, MOV R7,#1 ;OUTPUT ONE CHARACTER1E12,D1 58,, ACALL OUTR01E14,D1 9F,, ACALL ROUT ;OUTPUT RADIX1E16,EB,, MOV A,R3 ;GET FORMAT1E17,54 0F,, ANL A,#0FH ;STRIP INDICATOR1E19,60 06,, JZ EXPOTX,,, ;1E1B,FF,, MOV R7,A ;OUTPUT THE NUMBER OF DIGITS1E1C,1F,, DEC R7 ;ADJUST BECAUSE ONE CHAR ALREADY OUT1E1D,D1 58,, ACALL OUTR01E1F,80 02,, SJMP EXPOT4,,, ;1E21,D1 02,EXPOTX,EXPOTX: ACALL FREE2 ;OUTPUT UNTIL TRAILING ZEROS,,, ;1E23,D1 A7,EXPOT4,EXPOT4: ACALL SOUT ;OUTPUT A SPACE1E25,7D 45,, MOV R5,#'E'1E27,D1 A9,, ACALL SOUT1 ;OUTPUT AN E1E29,EE,, MOV A,R6 ;GET THE EXPONENT1E2A,60 04,, JZ XOUT0 ;EXIT IF ZERO1E2C,14,, DEC A ;ADJUST FOR THE DIGIT ALREADY OUTPUT1E2D,B4 80 05,, CJNE A,#80H,XOUT2 ;SEE WHAT IT IS,,, ;1E30,D1 A7,XOUT0,XOUT0: ACALL SOUT1E32,E4,, CLR A1E33,80 0C,, SJMP XOUT4,,, ;1E35,40 06,XOUT2,XOUT2: JC XOUT3 ;NEGATIVE EXPONENT1E37,7D 2B,, MOV R5,#'+' ;OUTPUT A PLUS SIGN1E39,D1 A9,, ACALL SOUT11E3B,80 04,, SJMP XOUT4,,, ;1E3D,D1 9B,XOUT3,XOUT3: ACALL MOUT1E3F,F4,, CPL A ;FLIP BITS1E40,04,, INC A ;BUMP,,, ;1E41,C2 E7,XOUT4,XOUT4: CLR ACC.71E43,F8,, MOV R0,A1E44,7A 00,, MOV R2,#01E46,79 58,, MOV R1,#LOW CONVT ;CONVERSION LOCATION1E48,7B 00,, MOV R3,#HIGH CONVT1E4A,F1 04,, ACALL CONVERT_BINARY_TO_ASCII_STRING1E4C,78 58,, MOV R0,#LOW CONVT ;NOW, OUTPUT EXPONENT,,, ;1E4E,E2,EXPOT5,EXPOT5: MOVX A,@R0 ;GET THE CHARACTER1E4F,FD,, MOV R5,A ;OUTPUT IT1E50,D1 A9,, ACALL SOUT11E52,08,, INC R0 ;BUMP THE POINTER1E53,E8,, MOV A,R0 ;GET THE POINTER1E54,B5 01 F7,, CJNE A,R1B0,EXPOT5 ;LOOP,,, ;1E57,22,U_RET,U_RET: RET ;EXIT,,, ;1E58,,OUTR0,OUTR0: ; Output the characters pointed to by R0, also bias ascii,,, ;1E58,EF,, MOV A,R7 ;GET THE COUNTER1E59,60 0E,, JZ OUTR ;EXIT IF DONE1E5B,E6,, MOV A,@R0 ;GET THE NUMBER1E5C,44 30,, ORL A,#30H ;ASCII BIAS1E5E,08,, INC R0 ;BUMP POINTER AND COUNTER1E5F,1F,, DEC R71E60,FD,, MOV R5,A ;PUT CHARACTER IN OUTPUT REGISTER1E61,D1 A9,, ACALL SOUT1 ;OUTPUT THE CHARACTER1E63,E4,, CLR A ;JUST FOR TEST1E64,B8 33 F1,, CJNE R0,#FP_NIB8+1,OUTR01E67,74 55,, MOV A,#55H ;KNOW WHERE EXIT OCCURED,,, ;1E69,22,OUTR,OUTR: RET,,, ;1E6A,A9 00,ZTEST,ZTEST: MOV R1,R0B0 ;GET POINTER REGISTER,,, ;1E6C,E7,ZT0,ZT0: MOV A,@R1 ;GET THE VALUE1E6D,70 04,, JNZ ZT11E6F,09,, INC R1 ;BUMP POINTER1E70,B9 33 F9,, CJNE R1,#FP_NIB8+1,ZT0,,, ;1E73,22,ZT1,ZT1: RET,,, ;1E74,EE,NUM_LT,NUM_LT: MOV A,R6 ;GET EXPONENT1E75,C3,, CLR C ;GET READY FOR SUBB1E76,94 80,, SUBB A,#80H ;SUB EXPONENT BIAS1E78,50 01,, JNC NL1 ;OK IF NO CARRY1E7A,E4,, CLR A ;NO DIGITS LEFT,,, ;1E7B,FF,NL1,NL1: MOV R7,A ;SAVE THE COUNT1E7C,22,, RET,,, ;1E7D,C3,NUM_RT,NUM_RT: CLR C ;SUBB AGAIN1E7E,74 80,, MOV A,#80H ;EXPONENT BIAS1E80,9E,, SUBB A,R6 ;GET THE BIASED EXPONENT1E81,50 01,, JNC NR11E83,E4,, CLR A,,, ;1E84,22,NR1,NR1: RET ;EXIT,,, ;1E85,EF,SPACE7,SPACE7: MOV A,R7 ;GET THE NUMBER OF SPACES1E86,60 FC,, JZ NR1 ;EXIT IF ZERO1E88,D1 A7,, ACALL SOUT ;OUTPUT A SPACE1E8A,1F,, DEC R7 ;BUMP COUNTER1E8B,80 F8,, SJMP SPACE7 ;LOOP,,, ;1E8D,FF,Z7R7,Z7R7: MOV R7,A,,, ;1E8E,EF,ZERO7,ZERO7: MOV A,R7 ;GET COUNTER1E8F,60 F3,, JZ NR1 ;EXIT IF ZERO1E91,D1 A3,, ACALL ZOUT ;OUTPUT A ZERO1E93,1F,, DEC R7 ;BUMP COUNTER1E94,80 F8,, SJMP ZERO7 ;LOOP,,, ;1E96,D1 85,SS7,SS7: ACALL SPACE7,,, ;1E98,EC,SINOUT,SINOUT: MOV A,R4 ;GET THE SIGN1E99,60 0C,, JZ SOUT ;OUTPUT A SPACE IF ZERO,,, ;1E9B,7D 2D,MOUT,MOUT: MOV R5,#'-'1E9D,80 0A,, SJMP SOUT1 ;OUTPUT A MINUS IF NOT,,, ;1E9F,7D 2E,ROUT,ROUT: MOV R5,#'.' ;OUTPUT A RADIX1EA1,80 06,, SJMP SOUT1,,, ;1EA3,7D 30,ZOUT,ZOUT: MOV R5,#'0' ;OUTPUT A ZERO1EA5,80 02,, SJMP SOUT1,,, ;1EA7,7D 20,SOUT,SOUT: MOV R5,#' ' ;OUTPUT A SPACE,,, ;1EA9,21 90,SOUT1,SOUT1: AJMP OUTPUT,,, ;,,,$EJECT,,, ;***************************************************************,,, ;1EAB,,CONVERT_ASCII_STRING_TO_BINARY,CONVERT_ASCII_STRING_TO_BINARY:,,, ;,,, ;DPTR POINTS TO ASCII STRING,,, ;PUT THE BINARY NUMBER IN R2:R0, ERROR IF >64K,,, ;,,, ;***************************************************************,,, ;1EAB,91 96,CASB,CASB: ACALL HEXSCAN ;SEE IF HEX NUMBER1EAD,92 23,, MOV ADD_IN,C ;IF ADD_IN IS SET, THE NUMBER IS HEX1EAF,F1 EB,, ACALL GET_DIGIT_CHECK1EB1,B3,, CPL C ;FLIP FOR EXIT1EB2,40 28,, JC RCASB1EB4,7B 00,, MOV R3,#00H ;ZERO R3:R1 FOR LOOP1EB6,79 00,, MOV R1,#00H1EB8,80 15,, SJMP CASB5,,, ;1EBA,A3,CASB2,CASB2: INC DPTR1EBB,89 00,, MOV R0B0,R1 ;SAVE THE PRESENT CONVERTED VALUE1EBD,8B 02,, MOV R0B0+2,R3 ;IN R2:R01EBF,F1 EB,, ACALL GET_DIGIT_CHECK1EC1,40 0C,, JC CASB51EC3,30 23 16,, JNB ADD_IN,RCASB ;CONVERSION COMPLETE1EC6,91 B6,, ACALL HEX_CHECK ;SEE IF HEX NUMBER1EC8,40 03,, JC CASB4 ;PROCEED IF GOOD1ECA,A3,, INC DPTR ;BUMP PAST H1ECB,80 0F,, SJMP RCASB,,, ;1ECD,24 09,CASB4,CASB4: ADD A,#9 ;ADJUST HEX ASCII BIAS,,, ;1ECF,75 F0 0A,CASB5,CASB5: MOV B,#101ED2,30 23 03,, JNB ADD_IN,CASB61ED5,75 F0 10,, MOV B,#16 ;HEX MODE,,, ;1ED8,D1 E3,CASB6,CASB6: ACALL MULNUM ;ACCUMULATE THE DIGITS1EDA,50 DE,, JNC CASB2 ;LOOP IF NO CARRY,,, ;1EDC,E4,RCASB,RCASB: CLR A ;RESET ACC1EDD,92 E1,, MOV ACC.OVERFLOW,C ;IF OVERFLOW, SAY SO1EDF,22,, RET ;EXIT,,, ;,,,$EJECT,,, ;1EE0,75 F0 0A,MULNUM10,MULNUM10:MOV B,#10,,, ;,,, ;***************************************************************,,, ;1EE3,,MULNUM,MULNUM: ; Take the next digit in the acc (masked to 0FH),,, ; accumulate in R3:R1,,, ;,,, ;***************************************************************,,, ;1EE3,C0 E0,, PUSH ACC ;SAVE ACC1EE5,C0 F0,, PUSH B ;SAVE MULTIPLIER1EE7,E9,, MOV A,R1 ;PUT LOW ORDER BITS IN ACC1EE8,A4,, MUL AB ;DO THE MULTIPLY1EE9,F9,, MOV R1,A ;PUT THE RESULT BACK1EEA,EB,, MOV A,R3 ;GET THE HIGH ORDER BYTE1EEB,AB F0,, MOV R3,B ;SAVE THE OVERFLOW1EED,D0 F0,, POP B ;GET THE MULTIPLIER1EEF,A4,, MUL AB ;DO IT1EF0,A2 D2,, MOV C,OV ;SAVE OVERFLOW IN F01EF2,92 D5,, MOV F0,C1EF4,2B,, ADD A,R3 ;ADD OVERFLOW TO HIGH RESULT1EF5,FB,, MOV R3,A ;PUT IT BACK1EF6,D0 E0,, POP ACC ;GET THE ORIGINAL ACC BACK1EF8,72 D5,, ORL C,F0 ;OR CARRY AND OVERFLOW1EFA,40 07,, JC MULX ;NO GOOD IF THE CARRY IS SET,,, ;1EFC,54 0F,MUL11,MUL11: ANL A,#0FH ;MASK OFF HIGH ORDER BITS1EFE,29,, ADD A,R1 ;NOW ADD THE ACC1EFF,F9,, MOV R1,A ;PUT IT BACK1F00,E4,, CLR A ;PROPAGATE THE CARRY1F01,3B,, ADDC A,R31F02,FB,, MOV R3,A ;PUT IT BACK,,, ;1F03,22,MULX,MULX: RET ;EXIT WITH OR WITHOUT CARRY,,, ;,,, ;***************************************************************,,, ;1F04,,CONVERT_BINARY_TO_ASCII_STRING,CONVERT_BINARY_TO_ASCII_STRING:,,, ;,,, ;R3:R1 contains the address of the string,,, ;R2:R0 contains the value to convert,,, ;DPTR, R7, R6, and ACC gets clobbered,,, ;,,, ;***************************************************************,,, ;1F04,E4,, CLR A ;NO LEADING ZEROS1F05,90 27 10,, MOV DPTR,#10000 ;SUBTRACT 100001F08,F1 21,, ACALL RSUB ;DO THE SUBTRACTION1F0A,90 03 E8,, MOV DPTR,#1000 ;NOW 10001F0D,F1 21,, ACALL RSUB1F0F,90 00 64,, MOV DPTR,#100 ;NOW 1001F12,F1 21,, ACALL RSUB1F14,90 00 0A,, MOV DPTR,#10 ;NOW 101F17,F1 21,, ACALL RSUB1F19,90 00 01,, MOV DPTR,#1 ;NOW 11F1C,F1 21,, ACALL RSUB1F1E,60 20,, JZ RSUB2 ;JUMP OVER RET,,, ;1F20,22,RSUB_R,RSUB_R: RET,,, ;1F21,7E FF,RSUB,RSUB: MOV R6,#-1 ;SET UP THE COUNTER,,, ;1F23,0E,RSUB1,RSUB1: INC R6 ;BUMP THE COUNTER1F24,CA,, XCH A,R2 ;DO A FAST COMPARE1F25,B5 83 00,, CJNE A,DPH,$+31F28,CA,, XCH A,R21F29,40 12,, JC FAST_DONE1F2B,C8,, XCH A,R0 ;GET LOW BYTE1F2C,95 82,, SUBB A,DPL ;SUBTRACT, CARRY IS CLEARED1F2E,C8,, XCH A,R0 ;PUT IT BACK1F2F,CA,, XCH A,R2 ;GET THE HIGH BYTE1F30,95 83,, SUBB A,DPH ;ADD THE HIGH BYTE1F32,CA,, XCH A,R2 ;PUT IT BACK1F33,50 EE,, JNC RSUB1 ;LOOP UNTIL CARRY,,, ;1F35,C8,, XCH A,R01F36,25 82,, ADD A,DPL ;RESTORE R2:R01F38,C8,, XCH A,R01F39,CA,, XCH A,R21F3A,35 83,, ADDC A,DPH1F3C,CA,, XCH A,R2,,, ;1F3D,,FAST_DONE,FAST_DONE:,,, ;1F3D,4E,, ORL A,R6 ;OR THE COUNT VALUE1F3E,60 E0,, JZ RSUB_R ;RETURN IF ZERO,,, ;1F40,74 30,RSUB2,RSUB2: MOV A,#'0' ;GET THE ASCII BIAS1F42,2E,, ADD A,R6 ;ADD THE COUNT,,, ;1F43,8B A0,RSUB4,RSUB4: MOV P2,R3 ;SET UP P21F45,F3,, MOVX @R1,A ;PLACE THE VALUE IN MEMORY1F46,09,, INC R11F47,B9 00 01,, CJNE R1,#00H,RSUB3 ;SEE IF RAPPED AROUND1F4A,0B,, INC R3 ;BUMP HIGH BYTE,,, ;1F4B,22,RSUB3,RSUB3: RET ;EXIT,,, ;,,,$EJECT,,, ;***************************************************************,,, ;1F4C,,HEXOUT,HEXOUT: ; Output the hex number in R3:R1, supress leading zeros, if set,,, ;,,, ;***************************************************************,,, ;1F4C,D1 A7,, ACALL SOUT ;OUTPUT A SPACE1F4E,A2 36,, MOV C,ZSURP ;GET ZERO SUPPRESSION BIT1F50,92 23,, MOV ADD_IN,C1F52,EB,, MOV A,R3 ;GET HIGH NIBBLE AND PRINT IT1F53,F1 6F,, ACALL HOUTHI1F55,EB,, MOV A,R31F56,F1 70,, ACALL HOUTLO,,, ;1F58,C2 23,HEX2X,HEX2X: CLR ADD_IN ;DON'T SUPPRESS ZEROS1F5A,E9,, MOV A,R1 ;GET LOW NIBBLE AND PRINT IT1F5B,F1 6F,, ACALL HOUTHI1F5D,E9,, MOV A,R11F5E,F1 70,, ACALL HOUTLO1F60,7D 48,, MOV R5,#'H' ;OUTPUT H TO INDICATE HEX MODE,,, ;1F62,C1 A9,SOUT_1,SOUT_1: AJMP SOUT1,,, ;1F64,C2 23,HOUT1,HOUT1: CLR ADD_IN ;PRINTED SOMETHING, SO CLEAR ADD_IN1F66,24 90,, ADD A,#90H ;CONVERT TO ASCII1F68,D4,, DA A1F69,34 40,, ADDC A,#40H1F6B,D4,, DA A ;GOT IT HERE1F6C,FD,, MOV R5,A ;OUTPUT THE BYTE1F6D,80 F3,, SJMP SOUT_1,,, ;1F6F,C4,HOUTHI,HOUTHI: SWAP A ;SWAP TO OUTPUT HIGH NIBBLE,,, ;1F70,54 0F,HOUTLO,HOUTLO: ANL A,#0FH ;STRIP1F72,70 F0,, JNZ HOUT1 ;PRINT IF NOT ZERO1F74,30 23 ED,, JNB ADD_IN,HOUT1 ;OUTPUT A ZERO IF NOT SUPRESSED1F77,22,, RET,,, ;,,,$EJECT,,, ORG 1FEBH ;FOR LINK COMPATABILITY,,, ;,,, ;1FEB,,GET_DIGIT_CHECK,GET_DIGIT_CHECK: ; Get a character, then check for digit,,, ;1FEB,B1 6C,, ACALL GET_DPTR_CHARACTER,,, ;1FED,,DIGIT_CHECK,DIGIT_CHECK: ;CHECK FOR A VALID ASCII DIGIT, SET CARRY IF FOUND,,, ;1FED,B4 3A 00,, CJNE A,#'9'+1,$+3 ;SEE IF ASCII 9 OR LESS1FF0,40 01,, JC DC11FF2,22,, RET,,, ;1FF3,B4 30 00,DC1,DC1: CJNE A,#'0',$+3 ;SEE IF ASCII 0 OR GREATER1FF6,B3,, CPL C1FF7,22,, RET,,, ;,,,000E,,, END
123version https://git-lfs.github.com/spec/v1oid sha256:dac888526e8d4f26bafa73c88321b44cadac566959cc2c26a2868243afcbd823size 3569612345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610;************************************************************;; This is a complete BCD floating point package for the 8051 micro-; controller. It provides 8 digits of accuracy with exponents that; range from +127 to -127. The mantissa is in packed BCD, while the; exponent is expressed in pseudo-twos complement. A ZERO exponent; is used to express the number ZERO. An exponent value of 80H or; greater than means the exponent is positive, i.e. 80H = E 0,; 81H = E+1, 82H = E+2 and so on. If the exponent is 7FH or less,; the exponent is negative, 7FH = E-1, 7EH = E-2, and so on.; ALL NUMBERS ARE ASSUMED TO BE NORMALIZED and all results are; normalized after calculation. A normalized mantissa is >=.10 and; <=.99999999.;; The numbers in memory assumed to be stored as follows:;; EXPONENT OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE; SIGN OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE-1; DIGIT 78 OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE-2; DIGIT 56 OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE-3; DIGIT 34 OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE-4; DIGIT 12 OF ARGUMENT 2 = VALUE OF ARG_STACK+FP_NUMBER_SIZE-5;; EXPONENT OF ARGUMENT 1 = VALUE OF ARG_STACK; SIGN OF ARGUMENT 1 = VALUE OF ARG_STACK-1; DIGIT 78 OF ARGUMENT 1 = VALUE OF ARG_STACK-2; DIGIT 56 OF ARGUMENT 1 = VALUE OF ARG_STACK-3; DIGIT 34 OF ARGUMENT 1 = VALUE OF ARG_STACK-4; DIGIT 12 OF ARGUMENT 1 = VALUE OF ARG_STACK-5;; The operations are performed thusly:;; ARG_STACK+FP_NUMBER_SIZE = ARG_STACK+FP_NUMBER_SIZE # ARG_STACK;; Which is ARGUMENT 2 = ARGUMENT 2 # ARGUMENT 1;; Where # can be ADD, SUBTRACT, MULTIPLY OR DIVIDE.;; Note that the stack gets popped after an operation.;; The FP_COMP instruction POPS the ARG_STACK TWICE and returns status.;;**********************************************************************;$EJECT;**********************************************************************;; STATUS ON RETURN - After performing an operation (+, -, *, /); the accumulator contains the following status;; ACCUMULATOR - BIT 0 - FLOATING POINT UNDERFLOW OCCURED;; - BIT 1 - FLOATING POINT OVERFLOW OCCURED;; - BIT 2 - RESULT WAS ZER0;; - BIT 3 - DIVIDE BY ZERO ATTEMPTED;; - BIT 4 - NOT USED, 0 RETURNED;; - BIT 5 - NOT USED, 0 RETURNED;; - BIT 6 - NOT USED, 0 RETURNED;; - BIT 7 - NOT USED, 0 RETURNED;; NOTE: When underflow occures, a ZERO result is returned.; When overflow or divide by zero occures, a result of; .99999999 E+127 is returned and it is up to the user; to handle these conditions as needed in the program.;; NOTE: The Compare instruction returns F0 = 0 if ARG 1 = ARG 2; and returns a CARRY FLAG = 1 if ARG 1 is > ARG 2;;***********************************************************************;$EJECT;***********************************************************************;; The following values MUST be provided by the user;;***********************************************************************;ARG_STACK EQU 9 ;ARGUMENT STACK POINTERARG_STACK_PAGE EQU 1FORMAT EQU 23 ;LOCATION OF OUTPUT FORMAT BYTEOUTPUT EQU 1990H ;CALL LOCATION TO OUTPUT A CHARACTERCONVT EQU 58H ;LOCATION TO CONVERT NUMBERSINTGRC BIT 25 ;BIT SET IF INTGER ERRORZSURP BIT 54 ;ZERO SUPRESSION FOR HEX PRINT;;***********************************************************************;; The following equates are used internally;;***********************************************************************;FP_NUMBER_SIZE EQU 6DIGIT EQU FP_NUMBER_SIZE-2R0B0 EQU 0R1B0 EQU 1UNDERFLOW EQU 0OVERFLOW EQU 1ZERO EQU 2ZERO_DIVIDE EQU 3;;***********************************************************************$EJECT;**************************************************************;; The following internal locations are used by the math pack; ordering is important and the FP_DIGITS must be bit; addressable;;***************************************************************;FP_STATUS EQU 28H ;NOT USEDFP_TEMP EQU FP_STATUS+1 ;NOT USEDFP_CARRY EQU FP_STATUS+2 ;USED FOR BITSADD_IN BIT 35 ;DCMPXZ IN BASIC BACKAGEXSIGN BIT FP_CARRY.0FOUND_RADIX BIT FP_CARRY.1FIRST_RADIX BIT FP_CARRY.2DONE_LOAD BIT FP_CARRY.3FP_DIG12 EQU FP_CARRY+1FP_DIG34 EQU FP_CARRY+2FP_DIG56 EQU FP_CARRY+3FP_DIG78 EQU FP_CARRY+4FP_SIGN EQU FP_CARRY+5MSIGN BIT FP_SIGN.0FP_EXP EQU FP_CARRY+6FP_NIB1 EQU FP_DIG12FP_NIB2 EQU FP_NIB1+1FP_NIB3 EQU FP_NIB1+2FP_NIB4 EQU FP_NIB1+3FP_NIB5 EQU FP_NIB1+4FP_NIB6 EQU FP_NIB1+5FP_NIB7 EQU FP_NIB1+6FP_NIB8 EQU FP_NIB1+7FP_ACCX EQU FP_NIB1+8FP_ACCC EQU FP_NIB1+9FP_ACC1 EQU FP_NIB1+10FP_ACC2 EQU FP_NIB1+11FP_ACC3 EQU FP_NIB1+12FP_ACC4 EQU FP_NIB1+13FP_ACC5 EQU FP_NIB1+14FP_ACC6 EQU FP_NIB1+15FP_ACC7 EQU FP_NIB1+16FP_ACC8 EQU FP_NIB1+17FP_ACCS EQU FP_NIB1+18;$EJECTORG 1993H;;**************************************************************;; The floating point entry points and jump table;;**************************************************************;AJMP FLOATING_ADDAJMP FLOATING_SUBAJMP FLOATING_COMPAJMP FLOATING_MULAJMP FLOATING_DIVAJMP HEXSCANAJMP FLOATING_POINT_INPUTAJMP FLOATING_POINT_OUTPUTAJMP CONVERT_BINARY_TO_ASCII_STRINGAJMP CONVERT_ASCII_STRING_TO_BINARYAJMP MULNUM10AJMP HEXOUTAJMP PUSHR2R0;$EJECT;FLOATING_SUB:;MOV P2,#ARG_STACK_PAGEMOV R0,ARG_STACKDEC R0 ;POINT TO SIGNMOVX A,@R0 ;READ SIGNCPL ACC.0MOVX @R0,A;;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;FLOATING_ADD:;;AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;;ACALL MDES1 ;R7=TOS EXP, R6=TOS-1 EXP, R4=TOS SIGN;R3=TOS-1 SIGN, OPERATION IS R1 # R0;MOV A,R7 ;GET TOS EXPONENTJZ POP_AND_EXIT ;IF TOS=0 THEN POP AND EXITCJNE R6,#0,LOAD1 ;CLEAR CARRY EXIT IF ZERO;;**************************************************************;SWAP_AND_EXIT: ; Swap external args and return;;**************************************************************;ACALL LOAD_POINTERSMOV R7,#FP_NUMBER_SIZE;SE1: MOVX A,@R0 ;SWAP THE ARGUMENTSMOVX @R1,ADEC R0DEC R1DJNZ R7,SE1;POP_AND_EXIT:;MOV A,ARG_STACK ;POP THE STACKADD A,#FP_NUMBER_SIZEMOV ARG_STACK,ACLR ARET;;LOAD1: SUBB A,R6 ;A = ARG 1 EXP - ARG 2 EXPMOV FP_EXP,R7 ;SAVE EXPONENT AND SIGNMOV FP_SIGN,R4JNC LOAD2 ;ARG1 EXPONENT IS LARGER OR SAMEMOV FP_EXP,R6MOV FP_SIGN,R3CPL AINC A ;COMPENSATE FOR EXP DELTAXCH A,R0 ;FORCE R0 TO POINT AT THE LARGESTXCH A,R1 ;EXPONENTXCH A,R0;LOAD2: MOV R7,A ;SAVE THE EXPONENT DELTA IN R7CLR ADD_INCJNE R5,#0,$+5SETB ADD_IN;$EJECT; Load the R1 mantissa;ACALL LOADR1_MANTISSA ;LOAD THE SMALLEST NUMBER;; Now align the number to the delta exponent; R4 points to the string of the last digits lost;CJNE R7,#DIGIT+DIGIT+3,$+3JC $+4MOV R7,#DIGIT+DIGIT+2;MOV FP_CARRY,#00 ;CLEAR THE CARRYACALL RIGHT ;SHIFT THE NUMBER;; Set up for addition and subtraction;MOV R7,#DIGIT ;LOOP COUNTMOV R1,#FP_DIG78MOV A,#9EHCLR CSUBB A,R4DA AXCH A,R4JNZ $+3MOV R4,ACJNE A,#50H,$+3 ;TEST FOR SUBTRACTIONJNB ADD_IN,SUBLP ;DO SUBTRACTION IF NO ADD_INCPL C ;FLIP CARRY FOR ADDITIONACALL ADDLP ;DO ADDITION;JNC ADD_RINC FP_CARRYMOV R7,#1ACALL RIGHTACALL INC_FP_EXP ;SHIFT AND BUMP EXPONENT;ADD_R: AJMP STORE_ALIGN_TEST_AND_EXIT;ADDLP: MOVX A,@R0ADDC A,@R1DA AMOV @R1,ADEC R0DEC R1DJNZ R7,ADDLP ;LOOP UNTIL DONERET;$EJECT;SUBLP: MOVX A,@R0 ;NOW DO SUBTRACTIONMOV R6,ACLR AADDC A,#99HSUBB A,@R1ADD A,R6DA AMOV @R1,ADEC R0DEC R1DJNZ R7,SUBLPJC FSUB6;$EJECT;; Need to complement the result and sign because the floating; point accumulator mantissa was larger than the external; memory and their signs were equal.;CPL FP_SIGN.0MOV R1,#FP_DIG78MOV R7,#DIGIT ;LOOP COUNT;FSUB5: MOV A,#9AHSUBB A,@R1ADD A,#0DA AMOV @R1,ADEC R1CPL CDJNZ R7,FSUB5 ;LOOP;; Now see how many zeros their are;FSUB6: MOV R0,#FP_DIG12MOV R7,#0;FSUB7: MOV A,@R0JNZ FSUB8INC R7INC R7INC R0CJNE R0,#FP_SIGN,FSUB7AJMP ZERO_AND_EXIT;FSUB8: CJNE A,#10H,$+3JNC FSUB9INC R7;; Now R7 has the number of leading zeros in the FP ACC;FSUB9: MOV A,FP_EXP ;GET THE OLD EXPONENTCLR CSUBB A,R7 ;SUBTRACT FROM THE NUMBER OF ZEROSJZ FSUB10JC FSUB10;MOV FP_EXP,A ;SAVE THE NEW EXPONENT;ACALL LEFT1 ;SHIFT THE FP ACCMOV FP_CARRY,#0AJMP STORE_ALIGN_TEST_AND_EXIT;FSUB10: AJMP UNDERFLOW_AND_EXIT;$EJECT;***************************************************************;FLOATING_COMP: ; Compare two floating point numbers; used for relational operations and is faster; than subtraction. ON RETURN, The carry is set; if ARG1 is > ARG2, else carry is not set; if ARG1 = ARG2, F0 gets set;;***************************************************************;ACALL MDES1 ;SET UP THE REGISTERSMOV A,ARG_STACKADD A,#FP_NUMBER_SIZE+FP_NUMBER_SIZEMOV ARG_STACK,A ;POP THE STACK TWICE, CLEAR THE CARRYMOV A,R6 ;CHECK OUT EXPONENTSCLR F0SUBB A,R7JZ EXPONENTS_EQUALJC ARG1_EXP_IS_LARGER;; Now the ARG2 EXPONENT is > ARG1 EXPONENT;SIGNS_DIFFERENT:;MOV A,R3 ;SEE IF SIGN OF ARG2 IS POSITIVESJMP $+3;ARG1_EXP_IS_LARGER:;MOV A,R4 ;GET THE SIGN OF ARG1 EXPONENTJZ $+3CPL CRET;EXPONENTS_EQUAL:;; First, test the sign, then the mantissa;CJNE R5,#0,SIGNS_DIFFERENT;BOTH_PLUS:;MOV R7,#DIGIT ;POINT AT MS DIGITDEC R0DEC R0DEC R0DEC R1DEC R1DEC R1;; Now do the compare;CLOOP: MOVX A,@R0MOV R6,AMOVX A,@R1SUBB A,R6JNZ ARG1_EXP_IS_LARGERINC R0INC R1DJNZ R7,CLOOP;; If here, the numbers are the same, the carry is cleared;SETB F0RET ;EXIT WITH EQUAL;$EJECT;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM;FLOATING_MUL: ; Floating point multiply;;MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM;ACALL MUL_DIV_EXP_AND_SIGN;; check for zero exponents;CJNE R6,#00,$+5 ;ARG 2 EXP ZERO?AJMP ZERO_AND_EXIT;; calculate the exponent;FMUL1: MOV FP_SIGN,R5 ;SAVE THE SIGN, IN CASE OF FAILURE;MOV A,R7JZ FMUL1-2ADD A,R6 ;ADD THE EXPONENTSJB ACC.7,FMUL_OVERJBC CY,FMUL2 ;SEE IF CARRY IS SET;AJMP UNDERFLOW_AND_EXIT;FMUL_OVER:;JNC FMUL2 ;OK IF SET;FOV: AJMP OVERFLOW_AND_EXIT;FMUL2: SUBB A,#129 ;SUBTRACT THE EXPONENT BIASMOV R6,A ;SAVE IT FOR LATER;; Unpack and load R0;ACALL UNPACK_R0;; Now set up for loop multiply;MOV R3,#DIGITMOV R4,R1B0;$EJECT;; Now, do the multiply and accumulate the product;FMUL3: MOV R1B0,R4MOVX A,@R1MOV R2,AACALL MUL_NIBBLE;MOV A,R2SWAP AACALL MUL_NIBBLEDEC R4DJNZ R3,FMUL3;; Now, pack and restore the sign;MOV FP_EXP,R6MOV FP_SIGN,R5AJMP PACK ;FINISH IT OFF;$EJECT;DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD;FLOATING_DIV:;;DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD;ACALL MDES1;; Check the exponents;MOV FP_SIGN,R5 ;SAVE THE SIGNCJNE R7,#0,DIV0 ;CLEARS THE CARRYACALL OVERFLOW_AND_EXITCLR ASETB ACC.ZERO_DIVIDERET;DIV0: MOV A,R6 ;GET EXPONENTJZ FMUL1-2 ;EXIT IF ZEROSUBB A,R7 ;DELTA EXPONENTJB ACC.7,D_UNDERJNC DIV3AJMP UNDERFLOW_AND_EXIT;D_UNDER:JNC FOV;DIV3: ADD A,#129 ;CORRECTLY BIAS THE EXPONENTMOV FP_EXP,A ;SAVE THE EXPONENTACALL LOADR1_MANTISSA ;LOAD THE DIVIDED;MOV R2,#FP_ACCC ;SAVE LOCATIONMOV R3,R0B0 ;SAVE POINTER IN R3MOV FP_CARRY,#0 ;ZERO CARRY BYTE;DIV4: MOV R5,#0FFH ;LOOP COUNTSETB C;DIV5: MOV R0B0,R3 ;RESTORE THE EXTERNAL POINTERMOV R1,#FP_DIG78 ;SET UP INTERNAL POINTERMOV R7,#DIGIT ;LOOP COUNTJNC DIV7 ;EXIT IF NO CARRY;DIV6: MOVX A,@R0 ;DO ACCUMLATIONMOV R6,ACLR AADDC A,#99HSUBB A,R6ADD A,@R1DA AMOV @R1,ADEC R0DEC R1DJNZ R7,DIV6 ;LOOP;INC R5 ;SUBTRACT COUNTERJC DIV5 ;KEEP LOOPING IF CARRYMOV A,@R1 ;GET CARRYSUBB A,#1 ;CARRY IS CLEAREDMOV @R1,A ;SAVE CARRY DIGITCPL CSJMP DIV5 ;LOOP;; Restore the result if carry was found;DIV7: ACALL ADDLP ;ADD NUMBER BACKMOV @R1,#0 ;CLEAR CARRYMOV R0B0,R2 ;GET SAVE COUNTERMOV @R0,5 ;SAVE COUNT BYTE;INC R2 ;ADJUST SAVE COUNTERMOV R7,#1 ;BUMP DIVIDENDACALL LEFTCJNE R2,#FP_ACC8+2,DIV4;DJNZ FP_EXP,DIV8AJMP UNDERFLOW_AND_EXIT;DIV8: MOV FP_CARRY,#0;$EJECT;***************************************************************;PACK: ; Pack the mantissa;;***************************************************************;; First, set up the pointers;MOV R0,#FP_ACCCMOV A,@R0 ;GET FP_ACCCMOV R6,A ;SAVE FOR ZERO COUNTJZ PACK0 ;JUMP OVER IF ZEROACALL INC_FP_EXP ;BUMP THE EXPONENTDEC R0;PACK0: INC R0 ;POINT AT FP_ACC1;PACK1: MOV A,#8 ;ADJUST NIBBLE POINTERMOV R1,AADD A,R0MOV R0,ACJNE @R0,#5,$+3 ;SEE IF ADJUSTING NEEDEDJC PACK3+1;PACK2: SETB CCLR ADEC R0ADDC A,@R0DA AXCHD A,@R0 ;SAVE THE VALUEJNB ACC.4,PACK3DJNZ R1,PACK2;DEC R0MOV @R0,#1ACALL INC_FP_EXPSJMP PACK4;PACK3: DEC R1MOV A,R1CLR CXCH A,R0SUBB A,R0MOV R0,A;PACK4: MOV R1,#FP_DIG12;; Now, pack;PLOOP: MOV A,@R0SWAP A ;FLIP THE DIGITSINC R0XCHD A,@R0ORL 6,A ;ACCUMULATE THE OR'ED DIGITSMOV @R1,AINC R0INC R1CJNE R1,#FP_SIGN,PLOOPMOV A,R6JNZ STORE_ALIGN_TEST_AND_EXITMOV FP_EXP,#0 ;ZERO EXPONENT;;**************************************************************;STORE_ALIGN_TEST_AND_EXIT: ;Save the number align carry and exit;;**************************************************************;ACALL LOAD_POINTERSMOV ARG_STACK,R1 ;SET UP THE NEW STACKMOV R0,#FP_EXP;; Now load the numbers;STORE2: MOV A,@R0MOVX @R1,A ;SAVE THE NUMBERDEC R0DEC R1CJNE R0,#FP_CARRY,STORE2;CLR A ;NO ERRORS;PRET: RET ;EXIT;$EJECTINC_FP_EXP:;INC FP_EXPMOV A,FP_EXPJNZ PRET ;EXIT IF NOT ZEROPOP ACC ;WASTE THE CALLING STACKPOP ACCAJMP OVERFLOW_AND_EXIT;;***********************************************************************;UNPACK_R0: ; Unpack BCD digits and load into nibble locations;;***********************************************************************;PUSH R1B0MOV R1,#FP_NIB8;ULOOP: MOVX A,@R0ANL A,#0FHMOV @R1,A ;SAVE THE NIBBLEMOVX A,@R0SWAP AANL A,#0FHDEC R1MOV @R1,A ;SAVE THE NIBBLE AGAINDEC R0DEC R1CJNE R1,#FP_NIB1-1,ULOOP;POP R1B0;LOAD7: RET;$EJECT;**************************************************************;OVERFLOW_AND_EXIT: ;LOAD 99999999 E+127, SET OV BIT, AND EXIT;;**************************************************************;MOV R0,#FP_DIG78MOV A,#99H;OVE1: MOV @R0,ADEC R0CJNE R0,#FP_CARRY,OVE1;MOV FP_EXP,#0FFHACALL STORE_ALIGN_TEST_AND_EXIT;SETB ACC.OVERFLOWRET;$EJECT;**************************************************************;UNDERFLOW_AND_EXIT: ;LOAD 0, SET UF BIT, AND EXIT;;**************************************************************;ACALL ZERO_AND_EXITCLR ASETB ACC.UNDERFLOWRET;;**************************************************************;ZERO_AND_EXIT: ;LOAD 0, SET ZERO BIT, AND EXIT;;**************************************************************;ACALL FP_CLEARACALL STORE_ALIGN_TEST_AND_EXITSETB ACC.ZERORET ;EXIT;;**************************************************************;FP_CLEAR:;; Clear internal storage;;**************************************************************;CLR AMOV R0,#FP_ACC8+1;FPC1: MOV @R0,ADEC R0CJNE R0,#FP_TEMP,FPC1RET;$EJECT;**************************************************************;RIGHT: ; Shift ACCUMULATOR RIGHT the number of nibbles in R7; Save the shifted values in R4 if SAVE_ROUND is set;;**************************************************************;MOV R4,#0 ;IN CASE OF NO SHIFT;RIGHT1: CLR CMOV A,R7 ;GET THE DIGITS TO SHIFTJZ RIGHT5-1 ;EXIT IF ZEROSUBB A,#2 ;TWO TO DO?JNC RIGHT5 ;SHIFT TWO NIBBLES;; Swap one nibble then exit;RIGHT3: PUSH R0B0 ;SAVE POINTER REGISTERPUSH R1B0;MOV R1,#FP_DIG78 ;LOAD THE POINTERSMOV R0,#FP_DIG56MOV A,R4 ;GET THE OVERFLOW REGISTERXCHD A,@R1 ;GET DIGIT 8SWAP A ;FLIP FOR LOADMOV R4,A;RIGHTL: MOV A,@R1 ;GET THE LOW ORDER BYTEXCHD A,@R0 ;SWAP NIBBLESSWAP A ;FLIP FOR STOREMOV @R1,A ;SAVE THE DIGITSDEC R0 ;BUMP THE POINTERSDEC R1CJNE R1,#FP_DIG12-1,RIGHTL ;LOOP;MOV A,@R1 ;ACC = CH8SWAP A ;ACC = 8CHANL A,#0FH ;ACC = 0CHMOV @R1,A ;CARRY DONEPOP R1B0 ;EXITPOP R0B0 ;RESTORE REGISTERRET;RIGHT5: MOV R7,A ;SAVE THE NEW SHIFT NUMBERCLR AXCH A,FP_CARRY ;SWAP THE NIBBLESXCH A,FP_DIG12XCH A,FP_DIG34XCH A,FP_DIG56XCH A,FP_DIG78MOV R4,A ;SAVE THE LAST DIGIT SHIFTEDSJMP RIGHT1+1;$EJECT;***************************************************************;LEFT: ; Shift ACCUMULATOR LEFT the number of nibbles in R7;;***************************************************************;MOV R4,#00H ;CLEAR FOR SOME ENTRYS;LEFT1: CLR CMOV A,R7 ;GET SHIFT VALUEJZ LEFT5-1 ;EXIT IF ZEROSUBB A,#2 ;SEE HOW MANY BYTES TO SHIFTJNC LEFT5;LEFT3: PUSH R0B0 ;SAVE POINTERPUSH R1B0MOV R0,#FP_CARRYMOV R1,#FP_DIG12;MOV A,@R0 ;ACC=CHCLSWAP A ;ACC = CLCHMOV @R0,A ;ACC = CLCH, @R0 = CLCH;LEFTL: MOV A,@R1 ;DIG 12SWAP A ;DIG 21XCHD A,@R0MOV @R1,A ;SAVE ITINC R0 ;BUMP POINTERSINC R1CJNE R0,#FP_DIG78,LEFTL;MOV A,R4SWAP AXCHD A,@R0ANL A,#0F0HMOV R4,A;POP R1B0POP R0B0 ;RESTORERET ;DONE;LEFT5: MOV R7,A ;RESTORE COUNTCLR AXCH A,R4 ;GET THE RESTORATION BYTEXCH A,FP_DIG78 ;DO THE SWAPXCH A,FP_DIG56XCH A,FP_DIG34XCH A,FP_DIG12XCH A,FP_CARRYSJMP LEFT1+1;$EJECTMUL_NIBBLE:;; Multiply the nibble in R7 by the FP_NIB locations; accumulate the product in FP_ACC;; Set up the pointers for multiplication;ANL A,#0FH ;STRIP OFF MS NIBBLEMOV R7,AMOV R0,#FP_ACC8MOV R1,#FP_NIB8CLR AMOV FP_ACCX,A;MNLOOP: DEC R0 ;BUMP POINTER TO PROPAGATE CARRYADD A,@R0 ;ATTEMPT TO FORCE CARRYDA A ;BCD ADJUSTJNB ACC.4,MNL0 ;DON'T ADJUST IF NO NEEDDEC R0 ;PROPAGATE CARRY TO THE NEXT DIGITINC @R0 ;DO THE ADJUSTINGINC R0 ;RESTORE R0;MNL0: XCHD A,@R0 ;RESTORE INITIAL NUMBERMOV B,R7 ;GET THE NUBBLE TO MULTIPLYMOV A,@R1 ;GET THE OTHER NIBBLEMUL AB ;DO THE MULTIPLYMOV B,#10 ;NOW BCD ADJUSTDIV ABXCH A,B ;GET THE REMAINDERADD A,@R0 ;PROPAGATE THE PARTIAL PRODUCTSDA A ;BCD ADJUSTJNB ACC.4,MNL1 ;PROPAGATE PARTIAL PRODUCT CARRYINC B;MNL1: INC R0XCHD A,@R0 ;SAVE THE NEW PRODUCTDEC R0MOV A,B ;GET BACK THE QUOTIENTDEC R1CJNE R1,#FP_NIB1-1,MNLOOP;ADD A,FP_ACCX ;GET THE OVERFLOWDA A ;ADJUSTMOV @R0,A ;SAVE ITRET ;EXIT;$EJECT;***************************************************************;LOAD_POINTERS: ; Load the ARG_STACK into R0 and bump R1;;***************************************************************;MOV P2,#ARG_STACK_PAGEMOV R0,ARG_STACKMOV A,#FP_NUMBER_SIZEADD A,R0MOV R1,ARET;;***************************************************************;MUL_DIV_EXP_AND_SIGN:;; Load the sign into R7, R6. R5 gets the sign for; multiply and divide.;;***************************************************************;ACALL FP_CLEAR ;CLEAR INTERNAL MEMORY;MDES1: ACALL LOAD_POINTERS ;LOAD REGISTERSMOVX A,@R0 ;ARG 1 EXPMOV R7,A ;SAVED IN R7MOVX A,@R1 ;ARG 2 EXPMOV R6,A ;SAVED IN R6DEC R0 ;BUMP POINTERS TO SIGNDEC R1MOVX A,@R0 ;GET THE SIGNMOV R4,A ;SIGN OF ARG1MOVX A,@R1 ;GET SIGN OF NEXT ARGMOV R3,A ;SIGN OF ARG2XRL A,R4 ;ACC GETS THE NEW SIGNMOV R5,A ;R5 GETS THE NEW SIGN;; Bump the pointers to point at the LS digit;DEC R0DEC R1;RET;$EJECT;***************************************************************;LOADR1_MANTISSA:;; Load the mantissa of R0 into FP_Digits;;***************************************************************;PUSH R0B0 ;SAVE REGISTER 1MOV R0,#FP_DIG78 ;SET UP THE POINTER;LOADR1: MOVX A,@R1MOV @R0,ADEC R1DEC R0CJNE R0,#FP_CARRY,LOADR1;POP R0B0RET;$EJECT;***************************************************************;HEXSCAN: ; Scan a string to determine if it is a hex number; set carry if hex, else carry = 0;;***************************************************************;ACALL GET_DPTR_CHARACTERPUSH DPHPUSH DPL ;SAVE THE POINTER;HEXSC1: MOVX A,@DPTR ;GET THE CHARACTERACALL DIGIT_CHECK ;SEE IF A DIGITJC HS1 ;CONTINUE IF A DIGITACALL HEX_CHECK ;SEE IF HEXJC HS1;CLR ACC.5 ;NO LOWER CASECJNE A,#'H',HEXDONSETB CSJMP HEXDO1 ;NUMBER IS VALID HEX, MAYBE;HEXDON: CLR C;HEXDO1: POP DPL ;RESTORE POINTERPOP DPHRET;HS1: INC DPTR ;BUMP TO NEXT CHARACTERSJMP HEXSC1 ;LOOP;HEX_CHECK: ;CHECK FOR A VALID ASCII HEX, SET CARRY IF FOUND;CLR ACC.5 ;WASTE LOWER CASECJNE A,#'F'+1,$+3 ;SEE IF F OR LESSJC HC1RET;HC1: CJNE A,#'A',$+3 ;SEE IF A OR GREATERCPL CRET;$EJECT;PUSHR2R0:;MOV R3,#HIGH CONVT ;CONVERSION LOCATIONMOV R1,#LOW CONVTACALL CONVERT_BINARY_TO_ASCII_STRINGMOV A,#0DH ;A CR TO TERMINATEMOVX @R1,A ;SAVE THE CRMOV DPTR,#CONVT;; Falls thru to FLOATING INPUT;$EJECT;***************************************************************;FLOATING_POINT_INPUT: ; Input a floating point number pointed to by; the DPTR;;***************************************************************;ACALL FP_CLEAR ;CLEAR EVERYTHINGACALL GET_DPTR_CHARACTERACALL PLUS_MINUS_TESTMOV MSIGN,C ;SAVE THE MANTISSA SIGN;; Now, set up for input loop;MOV R0,#FP_ACCCMOV R6,#7FH ;BASE EXPONENTSETB F0 ;SET INITIAL FLAG;INLOOP: ACALL GET_DIGIT_CHECKJNC GTEST ;IF NOT A CHARACTER, WHAT IS IT?ANL A,#0FH ;STRIP ASCIIACALL STDIG ;STORE THE DIGITS;INLPIK: INC DPTR ;BUMP POINTER FOR LOOPSJMP INLOOP ;LOOP FOR INPUT;GTEST: CJNE A,#'.',GT1 ;SEE IF A RADIXJB FOUND_RADIX,INERRSETB FOUND_RADIXCJNE R0,#FP_ACCC,INLPIKSETB FIRST_RADIX ;SET IF FIRST RADIXSJMP INLPIK ;GET ADDITIONAL DIGITS;GT1: JB F0,INERR ;ERROR IF NOT CLEAREDCJNE A,#'e',$+5 ;CHECK FOR LOWER CASESJMP $+5CJNE A,#'E',FINISH_UPACALL INC_AND_GET_DPTR_CHARACTERACALL PLUS_MINUS_TESTMOV XSIGN,C ;SAVE SIGN STATUSACALL GET_DIGIT_CHECKJNC INERR;ANL A,#0FH ;STRIP ASCII BIAS OFF THE CHARACTERMOV R5,A ;SAVE THE CHARACTER IN R5;GT2: INC DPTRACALL GET_DIGIT_CHECKJNC FINISH1ANL A,#0FH ;STRIP OFF BIASXCH A,R5 ;GET THE LAST DIGITMOV B,#10 ;MULTIPLY BY TENMUL ABADD A,R5 ;ADD TO ORIGINAL VALUEMOV R5,A ;SAVE IN R5JNC GT2 ;LOOP IF NO CARRYMOV R5,#0FFH ;FORCE AN ERROR;FINISH1:MOV A,R5 ;GET THE SIGNJNB XSIGN,POSNUM ;SEE IF EXPONENT IS POS OR NEGCLR CSUBB A,R6CPL AINC AJC FINISH2MOV A,#01HRET;POSNUM: ADD A,R6 ;ADD TO EXPONENTJNC FINISH2;POSNM1: MOV A,#02HRET;FINISH2:XCH A,R6 ;SAVE THE EXPONENT;FINISH_UP:;MOV FP_EXP,R6 ;SAVE EXPONENTCJNE R0,#FP_ACCC,$+5ACALL FP_CLEAR ;CLEAR THE MEMORY IF 0MOV A,ARG_STACK ;GET THE ARG STACKCLR CSUBB A,#FP_NUMBER_SIZE+FP_NUMBER_SIZEMOV ARG_STACK,A ;ADJUST FOR STOREAJMP PACK;STDIG: CLR F0 ;CLEAR INITIAL DESIGNATORJNZ STDIG1 ;CONTINUE IF NOT ZEROCJNE R0,#FP_ACCC,STDIG1JNB FIRST_RADIX,RET_X;DECX: DJNZ R6,RET_X;INERR: MOV A,#0FFH;RET_X: RET;STDIG1: JB DONE_LOAD,FRTESTCLR FIRST_RADIX;FRTEST: JB FIRST_RADIX,DECX;FDTEST: JB FOUND_RADIX,FDT1INC R6;FDT1: JB DONE_LOAD,RET_XCJNE R0,#FP_ACC8+1,FDT2SETB DONE_LOAD;FDT2: MOV @R0,A ;SAVE THE STRIPPED ACCUMULATORINC R0 ;BUMP THE POINTERRET ;EXIT;$EJECT;***************************************************************;; I/O utilities;;***************************************************************;INC_AND_GET_DPTR_CHARACTER:;INC DPTR;GET_DPTR_CHARACTER:;MOVX A,@DPTR ;GET THE CHARACTERCJNE A,#' ',PMT1 ;SEE IF A SPACE;; Kill spaces;SJMP INC_AND_GET_DPTR_CHARACTER;PLUS_MINUS_TEST:;CJNE A,#0E3H,$+5 ;SEE IF A PLUS, PLUS TOKEN FROM BASICSJMP PMT3CJNE A,#'+',$+5SJMP PMT3CJNE A,#0E5H,$+5 ;SEE IF MINUS, MINUS TOKEN FROM BASICSJMP PMT2CJNE A,#'-',PMT1;PMT2: SETB C;PMT3: INC DPTR;PMT1: RET;$EJECT;***************************************************************;FLOATING_POINT_OUTPUT: ; Output the number, format is in location 23;; IF FORMAT = 00 - FREE FLOATING; = FX - EXPONENTIAL (X IS THE NUMBER OF SIG DIGITS); = NX - N = NUM BEFORE RADIX, X = NUM AFTER RADIX; N + X = 8 MAX;;***************************************************************;ACALL MDES1 ;GET THE NUMBER TO OUTPUT, R0 IS POINTERACALL POP_AND_EXIT ;OUTPUT POPS THE STACKMOV A,R7MOV R6,A ;PUT THE EXPONENT IN R6ACALL UNPACK_R0 ;UNPACK THE NUMBERMOV R0,#FP_NIB1 ;POINT AT THE NUMBERMOV A,FORMAT ;GET THE FORMATMOV R3,A ;SAVE IN CASE OF EXP FORMATJZ FREE ;FREE FLOATING?CJNE A,#0F0H,$+3 ;SEE IF EXPONENTIALJNC EXPOUT;; If here, must be integer USING format;MOV A,R6 ;GET THE EXPONENTJNZ $+4MOV R6,#80HMOV A,R3 ;GET THE FORMATSWAP A ;SPLIT INTEGER AND FRACTIONANL A,#0FHMOV R2,A ;SAVE INTEGERACALL NUM_LT ;GET THE NUMBER OF INTEGERSXCH A,R2 ;FLIP FOR SUBBCLR CSUBB A,R2MOV R7,AJNC $+8MOV R5,#'?' ;OUTPUT A QUESTION MARKACALL SOUT1 ;NUMBER IS TOO LARGE FOR FORMATAJMP FREECJNE R2,#00,USING0 ;SEE IF ZERODEC R7ACALL SS7ACALL ZOUT ;OUTPUT A ZEROSJMP USING1;USING0: ACALL SS7 ;OUTPUT SPACES, IF NEED TOMOV A,R2 ;OUTPUT DIGITSMOV R7,AACALL OUTR0;USING1: MOV A,R3ANL A,#0FH ;GET THE NUMBER RIGHT OF DPMOV R2,A ;SAVE ITJZ PMT1 ;EXIT IF ZEROACALL ROUT ;OUTPUT DPACALL NUM_RTCJNE A,2,USINGX ;COMPARE A TO R2;USINGY: MOV A,R2AJMP Z7R7;USINGX: JNC USINGY;USING2: XCH A,R2CLR CSUBB A,R2XCH A,R2ACALL Z7R7 ;OUTPUT ZEROS IF NEED TOMOV A,R2MOV R7,AAJMP OUTR0;; First, force exponential output, if need to;FREE: MOV A,R6 ;GET THE EXPONENTJNZ FREE1 ;IF ZERO, PRINT ITACALL SOUTAJMP ZOUT;FREE1: MOV R3,#0F0H ;IN CASE EXP NEEDEDMOV A,#80H-DIGIT-DIGIT-1ADD A,R6JC EXPOUTSUBB A,#0F7HJC EXPOUT;; Now, just print the number;ACALL SINOUT ;PRINT THE SIGN OF THE NUMBERACALL NUM_LT ;GET THE NUMBER LEFT OF DPCJNE A,#8,FREE4AJMP OUTR0;FREE4: ACALL OUTR0ACALL ZTEST ;TEST FOR TRAILING ZEROSJZ U_RET ;DONE IF ALL TRAILING ZEROSACALL ROUT ;OUTPUT RADIX;FREE2: MOV R7,#1 ;OUTPUT ONE DIGITACALL OUTR0JNZ U_RETACALL ZTESTJZ U_RETSJMP FREE2 ;LOOP;EXPOUT: ACALL SINOUT ;PRINT THE SIGNMOV R7,#1 ;OUTPUT ONE CHARACTERACALL OUTR0ACALL ROUT ;OUTPUT RADIXMOV A,R3 ;GET FORMATANL A,#0FH ;STRIP INDICATORJZ EXPOTX;MOV R7,A ;OUTPUT THE NUMBER OF DIGITSDEC R7 ;ADJUST BECAUSE ONE CHAR ALREADY OUTACALL OUTR0SJMP EXPOT4;EXPOTX: ACALL FREE2 ;OUTPUT UNTIL TRAILING ZEROS;EXPOT4: ACALL SOUT ;OUTPUT A SPACEMOV R5,#'E'ACALL SOUT1 ;OUTPUT AN EMOV A,R6 ;GET THE EXPONENTJZ XOUT0 ;EXIT IF ZERODEC A ;ADJUST FOR THE DIGIT ALREADY OUTPUTCJNE A,#80H,XOUT2 ;SEE WHAT IT IS;XOUT0: ACALL SOUTCLR ASJMP XOUT4;XOUT2: JC XOUT3 ;NEGATIVE EXPONENTMOV R5,#'+' ;OUTPUT A PLUS SIGNACALL SOUT1SJMP XOUT4;XOUT3: ACALL MOUTCPL A ;FLIP BITSINC A ;BUMP;XOUT4: CLR ACC.7MOV R0,AMOV R2,#0MOV R1,#LOW CONVT ;CONVERSION LOCATIONMOV R3,#HIGH CONVTACALL CONVERT_BINARY_TO_ASCII_STRINGMOV R0,#LOW CONVT ;NOW, OUTPUT EXPONENT;EXPOT5: MOVX A,@R0 ;GET THE CHARACTERMOV R5,A ;OUTPUT ITACALL SOUT1INC R0 ;BUMP THE POINTERMOV A,R0 ;GET THE POINTERCJNE A,R1B0,EXPOT5 ;LOOP;U_RET: RET ;EXIT;OUTR0: ; Output the characters pointed to by R0, also bias ascii;MOV A,R7 ;GET THE COUNTERJZ OUTR ;EXIT IF DONEMOV A,@R0 ;GET THE NUMBERORL A,#30H ;ASCII BIASINC R0 ;BUMP POINTER AND COUNTERDEC R7MOV R5,A ;PUT CHARACTER IN OUTPUT REGISTERACALL SOUT1 ;OUTPUT THE CHARACTERCLR A ;JUST FOR TESTCJNE R0,#FP_NIB8+1,OUTR0MOV A,#55H ;KNOW WHERE EXIT OCCURED;OUTR: RET;ZTEST: MOV R1,R0B0 ;GET POINTER REGISTER;ZT0: MOV A,@R1 ;GET THE VALUEJNZ ZT1INC R1 ;BUMP POINTERCJNE R1,#FP_NIB8+1,ZT0;ZT1: RET;NUM_LT: MOV A,R6 ;GET EXPONENTCLR C ;GET READY FOR SUBBSUBB A,#80H ;SUB EXPONENT BIASJNC NL1 ;OK IF NO CARRYCLR A ;NO DIGITS LEFT;NL1: MOV R7,A ;SAVE THE COUNTRET;NUM_RT: CLR C ;SUBB AGAINMOV A,#80H ;EXPONENT BIASSUBB A,R6 ;GET THE BIASED EXPONENTJNC NR1CLR A;NR1: RET ;EXIT;SPACE7: MOV A,R7 ;GET THE NUMBER OF SPACESJZ NR1 ;EXIT IF ZEROACALL SOUT ;OUTPUT A SPACEDEC R7 ;BUMP COUNTERSJMP SPACE7 ;LOOP;Z7R7: MOV R7,A;ZERO7: MOV A,R7 ;GET COUNTERJZ NR1 ;EXIT IF ZEROACALL ZOUT ;OUTPUT A ZERODEC R7 ;BUMP COUNTERSJMP ZERO7 ;LOOP;SS7: ACALL SPACE7;SINOUT: MOV A,R4 ;GET THE SIGNJZ SOUT ;OUTPUT A SPACE IF ZERO;MOUT: MOV R5,#'-'SJMP SOUT1 ;OUTPUT A MINUS IF NOT;ROUT: MOV R5,#'.' ;OUTPUT A RADIXSJMP SOUT1;ZOUT: MOV R5,#'0' ;OUTPUT A ZEROSJMP SOUT1;SOUT: MOV R5,#' ' ;OUTPUT A SPACE;SOUT1: AJMP OUTPUT;$EJECT;***************************************************************;CONVERT_ASCII_STRING_TO_BINARY:;;DPTR POINTS TO ASCII STRING;PUT THE BINARY NUMBER IN R2:R0, ERROR IF >64K;;***************************************************************;CASB: ACALL HEXSCAN ;SEE IF HEX NUMBERMOV ADD_IN,C ;IF ADD_IN IS SET, THE NUMBER IS HEXACALL GET_DIGIT_CHECKCPL C ;FLIP FOR EXITJC RCASBMOV R3,#00H ;ZERO R3:R1 FOR LOOPMOV R1,#00HSJMP CASB5;CASB2: INC DPTRMOV R0B0,R1 ;SAVE THE PRESENT CONVERTED VALUEMOV R0B0+2,R3 ;IN R2:R0ACALL GET_DIGIT_CHECKJC CASB5JNB ADD_IN,RCASB ;CONVERSION COMPLETEACALL HEX_CHECK ;SEE IF HEX NUMBERJC CASB4 ;PROCEED IF GOODINC DPTR ;BUMP PAST HSJMP RCASB;CASB4: ADD A,#9 ;ADJUST HEX ASCII BIAS;CASB5: MOV B,#10JNB ADD_IN,CASB6MOV B,#16 ;HEX MODE;CASB6: ACALL MULNUM ;ACCUMULATE THE DIGITSJNC CASB2 ;LOOP IF NO CARRY;RCASB: CLR A ;RESET ACCMOV ACC.OVERFLOW,C ;IF OVERFLOW, SAY SORET ;EXIT;$EJECT;MULNUM10:MOV B,#10;;***************************************************************;MULNUM: ; Take the next digit in the acc (masked to 0FH); accumulate in R3:R1;;***************************************************************;PUSH ACC ;SAVE ACCPUSH B ;SAVE MULTIPLIERMOV A,R1 ;PUT LOW ORDER BITS IN ACCMUL AB ;DO THE MULTIPLYMOV R1,A ;PUT THE RESULT BACKMOV A,R3 ;GET THE HIGH ORDER BYTEMOV R3,B ;SAVE THE OVERFLOWPOP B ;GET THE MULTIPLIERMUL AB ;DO ITMOV C,OV ;SAVE OVERFLOW IN F0MOV F0,CADD A,R3 ;ADD OVERFLOW TO HIGH RESULTMOV R3,A ;PUT IT BACKPOP ACC ;GET THE ORIGINAL ACC BACKORL C,F0 ;OR CARRY AND OVERFLOWJC MULX ;NO GOOD IF THE CARRY IS SET;MUL11: ANL A,#0FH ;MASK OFF HIGH ORDER BITSADD A,R1 ;NOW ADD THE ACCMOV R1,A ;PUT IT BACKCLR A ;PROPAGATE THE CARRYADDC A,R3MOV R3,A ;PUT IT BACK;MULX: RET ;EXIT WITH OR WITHOUT CARRY;;***************************************************************;CONVERT_BINARY_TO_ASCII_STRING:;;R3:R1 contains the address of the string;R2:R0 contains the value to convert;DPTR, R7, R6, and ACC gets clobbered;;***************************************************************;CLR A ;NO LEADING ZEROSMOV DPTR,#10000 ;SUBTRACT 10000ACALL RSUB ;DO THE SUBTRACTIONMOV DPTR,#1000 ;NOW 1000ACALL RSUBMOV DPTR,#100 ;NOW 100ACALL RSUBMOV DPTR,#10 ;NOW 10ACALL RSUBMOV DPTR,#1 ;NOW 1ACALL RSUBJZ RSUB2 ;JUMP OVER RET;RSUB_R: RET;RSUB: MOV R6,#-1 ;SET UP THE COUNTER;RSUB1: INC R6 ;BUMP THE COUNTERXCH A,R2 ;DO A FAST COMPARECJNE A,DPH,$+3XCH A,R2JC FAST_DONEXCH A,R0 ;GET LOW BYTESUBB A,DPL ;SUBTRACT, CARRY IS CLEAREDXCH A,R0 ;PUT IT BACKXCH A,R2 ;GET THE HIGH BYTESUBB A,DPH ;ADD THE HIGH BYTEXCH A,R2 ;PUT IT BACKJNC RSUB1 ;LOOP UNTIL CARRY;XCH A,R0ADD A,DPL ;RESTORE R2:R0XCH A,R0XCH A,R2ADDC A,DPHXCH A,R2;FAST_DONE:;ORL A,R6 ;OR THE COUNT VALUEJZ RSUB_R ;RETURN IF ZERO;RSUB2: MOV A,#'0' ;GET THE ASCII BIASADD A,R6 ;ADD THE COUNT;RSUB4: MOV P2,R3 ;SET UP P2MOVX @R1,A ;PLACE THE VALUE IN MEMORYINC R1CJNE R1,#00H,RSUB3 ;SEE IF RAPPED AROUNDINC R3 ;BUMP HIGH BYTE;RSUB3: RET ;EXIT;$EJECT;***************************************************************;HEXOUT: ; Output the hex number in R3:R1, supress leading zeros, if set;;***************************************************************;ACALL SOUT ;OUTPUT A SPACEMOV C,ZSURP ;GET ZERO SUPPRESSION BITMOV ADD_IN,CMOV A,R3 ;GET HIGH NIBBLE AND PRINT ITACALL HOUTHIMOV A,R3ACALL HOUTLO;HEX2X: CLR ADD_IN ;DON'T SUPPRESS ZEROSMOV A,R1 ;GET LOW NIBBLE AND PRINT ITACALL HOUTHIMOV A,R1ACALL HOUTLOMOV R5,#'H' ;OUTPUT H TO INDICATE HEX MODE;SOUT_1: AJMP SOUT1;HOUT1: CLR ADD_IN ;PRINTED SOMETHING, SO CLEAR ADD_INADD A,#90H ;CONVERT TO ASCIIDA AADDC A,#40HDA A ;GOT IT HEREMOV R5,A ;OUTPUT THE BYTESJMP SOUT_1;HOUTHI: SWAP A ;SWAP TO OUTPUT HIGH NIBBLE;HOUTLO: ANL A,#0FH ;STRIPJNZ HOUT1 ;PRINT IF NOT ZEROJNB ADD_IN,HOUT1 ;OUTPUT A ZERO IF NOT SUPRESSEDRET;$EJECTORG 1FEBH ;FOR LINK COMPATABILITY;;GET_DIGIT_CHECK: ; Get a character, then check for digit;ACALL GET_DPTR_CHARACTER;DIGIT_CHECK: ;CHECK FOR A VALID ASCII DIGIT, SET CARRY IF FOUND;CJNE A,#'9'+1,$+3 ;SEE IF ASCII 9 OR LESSJC DC1RET;DC1: CJNE A,#'0',$+3 ;SEE IF ASCII 0 OR GREATERCPL CRET;END
123version https://git-lfs.github.com/spec/v1oid sha256:486e3decac675616a733ac91e4730a424e10a8af6a73d71bd34b2c4655618a8bsize 16746123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511# Makefile.in generated by automake 1.7.5 from Makefile.am.# @configure_input@# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003# Free Software Foundation, Inc.# This Makefile.in is free software; the Free Software Foundation# gives unlimited permission to copy and/or distribute it,# with or without modifications, as long as this notice is preserved.# This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY, to the extent permitted by law; without# even the implied warranty of MERCHANTABILITY or FITNESS FOR A# PARTICULAR PURPOSE.@SET_MAKE@srcdir = @srcdir@top_srcdir = @top_srcdir@VPATH = @srcdir@pkgdatadir = $(datadir)/@PACKAGE@pkglibdir = $(libdir)/@PACKAGE@pkgincludedir = $(includedir)/@PACKAGE@top_builddir = .am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cdINSTALL = @INSTALL@install_sh_DATA = $(install_sh) -c -m 644install_sh_PROGRAM = $(install_sh) -cinstall_sh_SCRIPT = $(install_sh) -cINSTALL_HEADER = $(INSTALL_DATA)transform = $(program_transform_name)NORMAL_INSTALL = :PRE_INSTALL = :POST_INSTALL = :NORMAL_UNINSTALL = :PRE_UNINSTALL = :POST_UNINSTALL = :host_triplet = @host@ACLOCAL = @ACLOCAL@AMDEP_FALSE = @AMDEP_FALSE@AMDEP_TRUE = @AMDEP_TRUE@AMTAR = @AMTAR@AUTOCONF = @AUTOCONF@AUTOHEADER = @AUTOHEADER@AUTOMAKE = @AUTOMAKE@AWK = @AWK@CC = @CC@CCDEPMODE = @CCDEPMODE@CFLAGS = @CFLAGS@CPP = @CPP@CPPFLAGS = @CPPFLAGS@CYGPATH_W = @CYGPATH_W@DEFS = @DEFS@DEPDIR = @DEPDIR@ECHO_C = @ECHO_C@ECHO_N = @ECHO_N@ECHO_T = @ECHO_T@EGREP = @EGREP@EXEEXT = @EXEEXT@INSTALL_DATA = @INSTALL_DATA@INSTALL_PROGRAM = @INSTALL_PROGRAM@INSTALL_SCRIPT = @INSTALL_SCRIPT@INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@LDFLAGS = @LDFLAGS@LEX = @LEX@LEXLIB = @LEXLIB@LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@LIBOBJS = @LIBOBJS@LIBS = @LIBS@LN_S = @LN_S@LTLIBOBJS = @LTLIBOBJS@MAKEINFO = @MAKEINFO@OBJEXT = @OBJEXT@PACKAGE = @PACKAGE@PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@PACKAGE_NAME = @PACKAGE_NAME@PACKAGE_STRING = @PACKAGE_STRING@PACKAGE_TARNAME = @PACKAGE_TARNAME@PACKAGE_VERSION = @PACKAGE_VERSION@PATH_SEPARATOR = @PATH_SEPARATOR@PTHREAD_CC = @PTHREAD_CC@PTHREAD_CFLAGS = @PTHREAD_CFLAGS@PTHREAD_LIBS = @PTHREAD_LIBS@SET_MAKE = @SET_MAKE@SHELL = @SHELL@STRIP = @STRIP@VERSION = @VERSION@ac_ct_CC = @ac_ct_CC@ac_ct_STRIP = @ac_ct_STRIP@am__fastdepCC_FALSE = @am__fastdepCC_FALSE@am__fastdepCC_TRUE = @am__fastdepCC_TRUE@am__include = @am__include@am__leading_dot = @am__leading_dot@am__quote = @am__quote@bindir = @bindir@build = @build@build_alias = @build_alias@build_cpu = @build_cpu@build_os = @build_os@build_vendor = @build_vendor@datadir = @datadir@exec_prefix = @exec_prefix@host = @host@host_alias = @host_alias@host_cpu = @host_cpu@host_os = @host_os@host_vendor = @host_vendor@includedir = @includedir@infodir = @infodir@install_sh = @install_sh@libdir = @libdir@libexecdir = @libexecdir@localstatedir = @localstatedir@mandir = @mandir@oldincludedir = @oldincludedir@prefix = @prefix@program_transform_name = @program_transform_name@sbindir = @sbindir@sharedstatedir = @sharedstatedir@sysconfdir = @sysconfdir@target_alias = @target_alias@SUBDIRS = srcEXTRA_DIST = book/README doc/ChangeLog doc/README src/gnuchessx TODODISTCLEANFILES = *~ src/GCint.hsubdir = .ACLOCAL_M4 = $(top_srcdir)/aclocal.m4mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirsCONFIG_HEADER = $(top_builddir)/src/config.hCONFIG_CLEAN_FILES =DIST_SOURCES =RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \ps-recursive install-info-recursive uninstall-info-recursive \all-recursive install-data-recursive install-exec-recursive \installdirs-recursive install-recursive uninstall-recursive \check-recursive installcheck-recursiveDIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \Makefile.in NEWS TODO acinclude.m4 aclocal.m4 config.guess \config.sub configure configure.ac depcomp install-sh missing \mkinstalldirsDIST_SUBDIRS = $(SUBDIRS)all: all-recursive.SUFFIXES:am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \configure.lineno$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)cd $(top_srcdir) && \$(AUTOMAKE) --gnu MakefileMakefile: $(srcdir)/Makefile.in $(top_builddir)/config.statuscd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)$(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)$(SHELL) ./config.status --recheck$(srcdir)/configure: $(srcdir)/configure.ac $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)cd $(srcdir) && $(AUTOCONF)$(ACLOCAL_M4): configure.ac acinclude.m4cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)uninstall-info-am:# This directory's subdirectories are mostly independent; you can cd# into them and run `make' without going through this Makefile.# To change the values of `make' variables: instead of editing Makefiles,# (1) if the variable is set in `config.status', edit `config.status'# (which will cause the Makefiles to be regenerated when you run `make');# (2) otherwise, pass the desired values on the `make' command line.$(RECURSIVE_TARGETS):@set fnord $$MAKEFLAGS; amf=$$2; \dot_seen=no; \target=`echo $@ | sed s/-recursive//`; \list='$(SUBDIRS)'; for subdir in $$list; do \echo "Making $$target in $$subdir"; \if test "$$subdir" = "."; then \dot_seen=yes; \local_target="$$target-am"; \else \local_target="$$target"; \fi; \(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \done; \if test "$$dot_seen" = "no"; then \$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \fi; test -z "$$fail"mostlyclean-recursive clean-recursive distclean-recursive \maintainer-clean-recursive:@set fnord $$MAKEFLAGS; amf=$$2; \dot_seen=no; \case "$@" in \distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \*) list='$(SUBDIRS)' ;; \esac; \rev=''; for subdir in $$list; do \if test "$$subdir" = "."; then :; else \rev="$$subdir $$rev"; \fi; \done; \rev="$$rev ."; \target=`echo $@ | sed s/-recursive//`; \for subdir in $$rev; do \echo "Making $$target in $$subdir"; \if test "$$subdir" = "."; then \local_target="$$target-am"; \else \local_target="$$target"; \fi; \(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \done && test -z "$$fail"tags-recursive:list='$(SUBDIRS)'; for subdir in $$list; do \test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \donectags-recursive:list='$(SUBDIRS)'; for subdir in $$list; do \test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \doneETAGS = etagsETAGSFLAGS =CTAGS = ctagsCTAGSFLAGS =tags: TAGSID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \unique=`for i in $$list; do \if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \done | \$(AWK) ' { files[$$0] = 1; } \END { for (i in files) print i; }'`; \mkid -fID $$uniqueTAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \$(TAGS_FILES) $(LISP)tags=; \here=`pwd`; \if (etags --etags-include --version) >/dev/null 2>&1; then \include_option=--etags-include; \else \include_option=--include; \fi; \list='$(SUBDIRS)'; for subdir in $$list; do \if test "$$subdir" = .; then :; else \test -f $$subdir/TAGS && \tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \fi; \done; \list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \unique=`for i in $$list; do \if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \done | \$(AWK) ' { files[$$0] = 1; } \END { for (i in files) print i; }'`; \test -z "$(ETAGS_ARGS)$$tags$$unique" \|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \$$tags $$uniquectags: CTAGSCTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \$(TAGS_FILES) $(LISP)tags=; \here=`pwd`; \list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \unique=`for i in $$list; do \if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \done | \$(AWK) ' { files[$$0] = 1; } \END { for (i in files) print i; }'`; \test -z "$(CTAGS_ARGS)$$tags$$unique" \|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \$$tags $$uniqueGTAGS:here=`$(am__cd) $(top_builddir) && pwd` \&& cd $(top_srcdir) \&& gtags -i $(GTAGS_ARGS) $$heredistclean-tags:-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tagsDISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)top_distdir = .distdir = $(PACKAGE)-$(VERSION)am__remove_distdir = \{ test ! -d $(distdir) \|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \&& rm -fr $(distdir); }; }GZIP_ENV = --bestdistuninstallcheck_listfiles = find . -type f -printdistcleancheck_listfiles = find . -type f -printdistdir: $(DISTFILES)$(am__remove_distdir)mkdir $(distdir)$(mkinstalldirs) $(distdir)/book $(distdir)/doc $(distdir)/src@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \list='$(DISTFILES)'; for file in $$list; do \case $$file in \$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \esac; \if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \if test "$$dir" != "$$file" && test "$$dir" != "."; then \dir="/$$dir"; \$(mkinstalldirs) "$(distdir)$$dir"; \else \dir=''; \fi; \if test -d $$d/$$file; then \if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \fi; \cp -pR $$d/$$file $(distdir)$$dir || exit 1; \else \test -f $(distdir)/$$file \|| cp -p $$d/$$file $(distdir)/$$file \|| exit 1; \fi; \donelist='$(SUBDIRS)'; for subdir in $$list; do \if test "$$subdir" = .; then :; else \test -d $(distdir)/$$subdir \|| mkdir $(distdir)/$$subdir \|| exit 1; \(cd $$subdir && \$(MAKE) $(AM_MAKEFLAGS) \top_distdir="$(top_distdir)" \distdir=../$(distdir)/$$subdir \distdir) \|| exit 1; \fi; \done-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \! -type d ! -perm -400 -exec chmod a+r {} \; -o \! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \|| chmod -R a+r $(distdir)dist-gzip: distdir$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz$(am__remove_distdir)dist dist-all: distdir$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz$(am__remove_distdir)# This target untars the dist file and tries a VPATH configuration. Then# it guarantees that the distribution is self-contained by making another# tarfile.distcheck: dist$(am__remove_distdir)GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -chmod -R a-w $(distdir); chmod a+w $(distdir)mkdir $(distdir)/_buildmkdir $(distdir)/_instchmod a-w $(distdir)dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \&& cd $(distdir)/_build \&& ../configure --srcdir=.. --prefix="$$dc_install_base" \$(DISTCHECK_CONFIGURE_FLAGS) \&& $(MAKE) $(AM_MAKEFLAGS) \&& $(MAKE) $(AM_MAKEFLAGS) dvi \&& $(MAKE) $(AM_MAKEFLAGS) check \&& $(MAKE) $(AM_MAKEFLAGS) install \&& $(MAKE) $(AM_MAKEFLAGS) installcheck \&& $(MAKE) $(AM_MAKEFLAGS) uninstall \&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \distuninstallcheck \&& chmod -R a-w "$$dc_install_base" \&& ({ \(cd ../.. && $(mkinstalldirs) "$$dc_destdir") \&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \} || { rm -rf "$$dc_destdir"; exit 1; }) \&& rm -rf "$$dc_destdir" \&& $(MAKE) $(AM_MAKEFLAGS) dist-gzip \&& rm -f $(distdir).tar.gz \&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck$(am__remove_distdir)@echo "$(distdir).tar.gz is ready for distribution" | \sed 'h;s/./=/g;p;x;p;x'distuninstallcheck:@cd $(distuninstallcheck_dir) \&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \|| { echo "ERROR: files left after uninstall:" ; \if test -n "$(DESTDIR)"; then \echo " (check DESTDIR support)"; \fi ; \$(distuninstallcheck_listfiles) ; \exit 1; } >&2distcleancheck: distclean@if test '$(srcdir)' = . ; then \echo "ERROR: distcleancheck can only run from a VPATH build" ; \exit 1 ; \fi@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \|| { echo "ERROR: files left in build directory after distclean:" ; \$(distcleancheck_listfiles) ; \exit 1; } >&2check-am: all-amcheck: check-recursiveall-am: Makefileinstalldirs: installdirs-recursiveinstalldirs-am:install: install-recursiveinstall-exec: install-exec-recursiveinstall-data: install-data-recursiveuninstall: uninstall-recursiveinstall-am: all-am@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-aminstallcheck: installcheck-recursiveinstall-strip:$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \INSTALL_STRIP_FLAG=-s \`test -z '$(STRIP)' || \echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` installmostlyclean-generic:clean-generic:distclean-generic:-rm -f Makefile $(CONFIG_CLEAN_FILES)-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)maintainer-clean-generic:@echo "This command is intended for maintainers to use"@echo "it deletes files that may require special tools to rebuild."clean: clean-recursiveclean-am: clean-generic mostlyclean-amdistclean: distclean-recursive-rm -f $(am__CONFIG_DISTCLEAN_FILES)distclean-am: clean-am distclean-generic distclean-tagsdvi: dvi-recursivedvi-am:info: info-recursiveinfo-am:install-data-am:install-exec-am:install-info: install-info-recursiveinstall-man:installcheck-am:maintainer-clean: maintainer-clean-recursive-rm -f $(am__CONFIG_DISTCLEAN_FILES)-rm -rf autom4te.cachemaintainer-clean-am: distclean-am maintainer-clean-genericmostlyclean: mostlyclean-recursivemostlyclean-am: mostlyclean-genericpdf: pdf-recursivepdf-am:ps: ps-recursiveps-am:uninstall-am: uninstall-info-amuninstall-info: uninstall-info-recursive.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \clean-generic clean-recursive ctags ctags-recursive dist \dist-all dist-gzip distcheck distclean distclean-generic \distclean-recursive distclean-tags distcleancheck distdir \distuninstallcheck dvi dvi-am dvi-recursive info info-am \info-recursive install install-am install-data install-data-am \install-data-recursive install-exec install-exec-am \install-exec-recursive install-info install-info-am \install-info-recursive install-man install-recursive \install-strip installcheck installcheck-am installdirs \installdirs-am installdirs-recursive maintainer-clean \maintainer-clean-generic maintainer-clean-recursive mostlyclean \mostlyclean-generic mostlyclean-recursive pdf pdf-am \pdf-recursive ps ps-am ps-recursive tags tags-recursive \uninstall uninstall-am uninstall-info-am \uninstall-info-recursive uninstall-recursive# Tell versions [3.59,3.63) of GNU make to not export all variables.# Otherwise a system limit (for SysV at least) may be exceeded..NOEXPORT:
123version https://git-lfs.github.com/spec/v1oid sha256:49930df1c49c773d08c9244aa7bf6e6c2b7a90e8469d2f017348fe1150bd5f7dsize 315041234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492#! /bin/sh# Configuration validation subroutine script.# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.timestamp='2003-05-09'# This file is (in principle) common to ALL GNU software.# The presence of a machine in this file suggests that SOME GNU software# can handle that machine. It does not imply ALL GNU software can.## This file is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place - Suite 330,# Boston, MA 02111-1307, USA.# As a special exception to the GNU General Public License, if you# distribute this file as part of a program that contains a# configuration script generated by Autoconf, you may include it under# the same distribution terms that you use for the rest of that program.# Please send patches to <config-patches@gnu.org>. Submit a context# diff and a properly formatted ChangeLog entry.## Configuration subroutine to validate and canonicalize a configuration type.# Supply the specified configuration type as an argument.# If it is invalid, we print an error message on stderr and exit with code 1.# Otherwise, we print the canonical config type on stdout and succeed.# This file is supposed to be the same for all GNU packages# and recognize all the CPU types, system types and aliases# that are meaningful with *any* GNU software.# Each package is responsible for reporting which valid configurations# it does not support. The user should be able to distinguish# a failure to support a valid configuration from a meaningless# configuration.# The goal of this file is to map all the various variations of a given# machine specification into a single specification in the form:# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM# or in some cases, the newer four-part form:# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM# It is wrong to echo any other type of specification.me=`echo "$0" | sed -e 's,.*/,,'`usage="\Usage: $0 [OPTION] CPU-MFR-OPSYS$0 [OPTION] ALIASCanonicalize a configuration name.Operation modes:-h, --help print this help, then exit-t, --time-stamp print date of last modification, then exit-v, --version print version number, then exitReport bugs and patches to <config-patches@gnu.org>."version="\GNU config.sub ($timestamp)Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."help="Try \`$me --help' for more information."# Parse command linewhile test $# -gt 0 ; docase $1 in--time-stamp | --time* | -t )echo "$timestamp" ; exit 0 ;;--version | -v )echo "$version" ; exit 0 ;;--help | --h* | -h )echo "$usage"; exit 0 ;;-- ) # Stop option processingshift; break ;;- ) # Use stdin as input.break ;;-* )echo "$me: invalid option $1$help"exit 1 ;;*local*)# First pass through any local machine types.echo $1exit 0;;* )break ;;esacdonecase $# in0) echo "$me: missing argument$help" >&2exit 1;;1) ;;*) echo "$me: too many arguments$help" >&2exit 1;;esac# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).# Here we must recognize all the valid KERNEL-OS combinations.maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`case $maybe_os innto-qnx* | linux-gnu* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)os=-$maybe_osbasic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`;;*)basic_machine=`echo $1 | sed 's/-[^-]*$//'`if [ $basic_machine != $1 ]then os=`echo $1 | sed 's/.*-/-/'`else os=; fi;;esac### Let's recognize common machines as not being operating systems so### that things like config.sub decstation-3100 work. We also### recognize some manufacturers as not being operating systems, so we### can provide default operating systems below.case $os in-sun*os*)# Prevent following clause from handling this invalid input.;;-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \-apple | -axis)os=basic_machine=$1;;-sim | -cisco | -oki | -wec | -winbond)os=basic_machine=$1;;-scout);;-wrs)os=-vxworksbasic_machine=$1;;-chorusos*)os=-chorusosbasic_machine=$1;;-chorusrdb)os=-chorusrdbbasic_machine=$1;;-hiux*)os=-hiuxwe2;;-sco5)os=-sco3.2v5basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`;;-sco4)os=-sco3.2v4basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`;;-sco3.2.[4-9]*)os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`;;-sco3.2v[4-9]*)# Don't forget version if it is 3.2v4 or newer.basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`;;-sco*)os=-sco3.2v2basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`;;-udk*)basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`;;-isc)os=-isc2.2basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`;;-clix*)basic_machine=clipper-intergraph;;-isc*)basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`;;-lynx*)os=-lynxos;;-ptx*)basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`;;-windowsnt*)os=`echo $os | sed -e 's/windowsnt/winnt/'`;;-psos*)os=-psos;;-mint | -mint[0-9]*)basic_machine=m68k-atarios=-mint;;esac# Decode aliases for certain CPU-COMPANY combinations.case $basic_machine in# Recognize the basic CPU types without company name.# Some are omitted here because they have special meanings below.1750a | 580 \| a29k \| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \| clipper \| d10v | d30v | dlx | dsp16xx \| fr30 | frv \| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \| i370 | i860 | i960 | ia64 \| ip2k \| m32r | m68000 | m68k | m88k | mcore \| mips | mipsbe | mipseb | mipsel | mipsle \| mips16 \| mips64 | mips64el \| mips64vr | mips64vrel \| mips64orion | mips64orionel \| mips64vr4100 | mips64vr4100el \| mips64vr4300 | mips64vr4300el \| mips64vr5000 | mips64vr5000el \| mipsisa32 | mipsisa32el \| mipsisa32r2 | mipsisa32r2el \| mipsisa64 | mipsisa64el \| mipsisa64sb1 | mipsisa64sb1el \| mipsisa64sr71k | mipsisa64sr71kel \| mipstx39 | mipstx39el \| mn10200 | mn10300 \| msp430 \| ns16k | ns32k \| openrisc | or32 \| pdp10 | pdp11 | pj | pjl \| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \| pyramid \| sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \| sh64 | sh64le \| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \| strongarm \| tahoe | thumb | tic80 | tron \| v850 | v850e \| we32k \| x86 | xscale | xstormy16 | xtensa \| z8k)basic_machine=$basic_machine-unknown;;m6811 | m68hc11 | m6812 | m68hc12)# Motorola 68HC11/12.basic_machine=$basic_machine-unknownos=-none;;m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k);;# We use `pc' rather than `unknown'# because (1) that's what they normally are, and# (2) the word "unknown" tends to confuse beginning users.i*86 | x86_64)basic_machine=$basic_machine-pc;;# Object if more than one company name word.*-*-*)echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2exit 1;;# Recognize the basic CPU types with company name.580-* \| a29k-* \| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \| arm-* | armbe-* | armle-* | armeb-* | armv*-* \| avr-* \| bs2000-* \| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \| clipper-* | cydra-* \| d10v-* | d30v-* | dlx-* \| elxsi-* \| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \| h8300-* | h8500-* \| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \| i*86-* | i860-* | i960-* | ia64-* \| ip2k-* \| m32r-* \| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \| m88110-* | m88k-* | mcore-* \| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \| mips16-* \| mips64-* | mips64el-* \| mips64vr-* | mips64vrel-* \| mips64orion-* | mips64orionel-* \| mips64vr4100-* | mips64vr4100el-* \| mips64vr4300-* | mips64vr4300el-* \| mips64vr5000-* | mips64vr5000el-* \| mipsisa32-* | mipsisa32el-* \| mipsisa32r2-* | mipsisa32r2el-* \| mipsisa64-* | mipsisa64el-* \| mipsisa64sb1-* | mipsisa64sb1el-* \| mipsisa64sr71k-* | mipsisa64sr71kel-* \| mipstx39-* | mipstx39el-* \| msp430-* \| none-* | np1-* | nv1-* | ns16k-* | ns32k-* \| orion-* \| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \| pyramid-* \| romp-* | rs6000-* \| sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \| tahoe-* | thumb-* \| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \| tron-* \| v850-* | v850e-* | vax-* \| we32k-* \| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \| xtensa-* \| ymp-* \| z8k-*);;# Recognize the various machine names and aliases which stand# for a CPU type and a company and sometimes even an OS.386bsd)basic_machine=i386-unknownos=-bsd;;3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)basic_machine=m68000-att;;3b*)basic_machine=we32k-att;;a29khif)basic_machine=a29k-amdos=-udi;;adobe68k)basic_machine=m68010-adobeos=-scout;;alliant | fx80)basic_machine=fx80-alliant;;altos | altos3068)basic_machine=m68k-altos;;am29k)basic_machine=a29k-noneos=-bsd;;amd64)basic_machine=x86_64-pc;;amdahl)basic_machine=580-amdahlos=-sysv;;amiga | amiga-*)basic_machine=m68k-unknown;;amigaos | amigados)basic_machine=m68k-unknownos=-amigaos;;amigaunix | amix)basic_machine=m68k-unknownos=-sysv4;;apollo68)basic_machine=m68k-apolloos=-sysv;;apollo68bsd)basic_machine=m68k-apolloos=-bsd;;aux)basic_machine=m68k-appleos=-aux;;balance)basic_machine=ns32k-sequentos=-dynix;;c90)basic_machine=c90-crayos=-unicos;;convex-c1)basic_machine=c1-convexos=-bsd;;convex-c2)basic_machine=c2-convexos=-bsd;;convex-c32)basic_machine=c32-convexos=-bsd;;convex-c34)basic_machine=c34-convexos=-bsd;;convex-c38)basic_machine=c38-convexos=-bsd;;cray | j90)basic_machine=j90-crayos=-unicos;;crds | unos)basic_machine=m68k-crds;;cris | cris-* | etrax*)basic_machine=cris-axis;;da30 | da30-*)basic_machine=m68k-da30;;decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)basic_machine=mips-dec;;decsystem10* | dec10*)basic_machine=pdp10-decos=-tops10;;decsystem20* | dec20*)basic_machine=pdp10-decos=-tops20;;delta | 3300 | motorola-3300 | motorola-delta \| 3300-motorola | delta-motorola)basic_machine=m68k-motorola;;delta88)basic_machine=m88k-motorolaos=-sysv3;;dpx20 | dpx20-*)basic_machine=rs6000-bullos=-bosx;;dpx2* | dpx2*-bull)basic_machine=m68k-bullos=-sysv3;;ebmon29k)basic_machine=a29k-amdos=-ebmon;;elxsi)basic_machine=elxsi-elxsios=-bsd;;encore | umax | mmax)basic_machine=ns32k-encore;;es1800 | OSE68k | ose68k | ose | OSE)basic_machine=m68k-ericssonos=-ose;;fx2800)basic_machine=i860-alliant;;genix)basic_machine=ns32k-ns;;gmicro)basic_machine=tron-gmicroos=-sysv;;go32)basic_machine=i386-pcos=-go32;;h3050r* | hiux*)basic_machine=hppa1.1-hitachios=-hiuxwe2;;h8300hms)basic_machine=h8300-hitachios=-hms;;h8300xray)basic_machine=h8300-hitachios=-xray;;h8500hms)basic_machine=h8500-hitachios=-hms;;harris)basic_machine=m88k-harrisos=-sysv3;;hp300-*)basic_machine=m68k-hp;;hp300bsd)basic_machine=m68k-hpos=-bsd;;hp300hpux)basic_machine=m68k-hpos=-hpux;;hp3k9[0-9][0-9] | hp9[0-9][0-9])basic_machine=hppa1.0-hp;;hp9k2[0-9][0-9] | hp9k31[0-9])basic_machine=m68000-hp;;hp9k3[2-9][0-9])basic_machine=m68k-hp;;hp9k6[0-9][0-9] | hp6[0-9][0-9])basic_machine=hppa1.0-hp;;hp9k7[0-79][0-9] | hp7[0-79][0-9])basic_machine=hppa1.1-hp;;hp9k78[0-9] | hp78[0-9])# FIXME: really hppa2.0-hpbasic_machine=hppa1.1-hp;;hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)# FIXME: really hppa2.0-hpbasic_machine=hppa1.1-hp;;hp9k8[0-9][13679] | hp8[0-9][13679])basic_machine=hppa1.1-hp;;hp9k8[0-9][0-9] | hp8[0-9][0-9])basic_machine=hppa1.0-hp;;hppa-next)os=-nextstep3;;hppaosf)basic_machine=hppa1.1-hpos=-osf;;hppro)basic_machine=hppa1.1-hpos=-proelf;;i370-ibm* | ibm*)basic_machine=i370-ibm;;# I'm not sure what "Sysv32" means. Should this be sysv3.2?i*86v32)basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`os=-sysv32;;i*86v4*)basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`os=-sysv4;;i*86v)basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`os=-sysv;;i*86sol2)basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`os=-solaris2;;i386mach)basic_machine=i386-machos=-mach;;i386-vsta | vsta)basic_machine=i386-unknownos=-vsta;;iris | iris4d)basic_machine=mips-sgicase $os in-irix*);;*)os=-irix4;;esac;;isi68 | isi)basic_machine=m68k-isios=-sysv;;m88k-omron*)basic_machine=m88k-omron;;magnum | m3230)basic_machine=mips-mipsos=-sysv;;merlin)basic_machine=ns32k-utekos=-sysv;;mingw32)basic_machine=i386-pcos=-mingw32;;miniframe)basic_machine=m68000-convergent;;*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)basic_machine=m68k-atarios=-mint;;mips3*-*)basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`;;mips3*)basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown;;mmix*)basic_machine=mmix-knuthos=-mmixware;;monitor)basic_machine=m68k-rom68kos=-coff;;morphos)basic_machine=powerpc-unknownos=-morphos;;msdos)basic_machine=i386-pcos=-msdos;;mvs)basic_machine=i370-ibmos=-mvs;;ncr3000)basic_machine=i486-ncros=-sysv4;;netbsd386)basic_machine=i386-unknownos=-netbsd;;netwinder)basic_machine=armv4l-rebelos=-linux;;news | news700 | news800 | news900)basic_machine=m68k-sonyos=-newsos;;news1000)basic_machine=m68030-sonyos=-newsos;;news-3600 | risc-news)basic_machine=mips-sonyos=-newsos;;necv70)basic_machine=v70-necos=-sysv;;next | m*-next )basic_machine=m68k-nextcase $os in-nextstep* );;-ns2*)os=-nextstep2;;*)os=-nextstep3;;esac;;nh3000)basic_machine=m68k-harrisos=-cxux;;nh[45]000)basic_machine=m88k-harrisos=-cxux;;nindy960)basic_machine=i960-intelos=-nindy;;mon960)basic_machine=i960-intelos=-mon960;;nonstopux)basic_machine=mips-compaqos=-nonstopux;;np1)basic_machine=np1-gould;;nv1)basic_machine=nv1-crayos=-unicosmp;;nsr-tandem)basic_machine=nsr-tandem;;op50n-* | op60c-*)basic_machine=hppa1.1-okios=-proelf;;or32 | or32-*)basic_machine=or32-unknownos=-coff;;OSE68000 | ose68000)basic_machine=m68000-ericssonos=-ose;;os68k)basic_machine=m68k-noneos=-os68k;;pa-hitachi)basic_machine=hppa1.1-hitachios=-hiuxwe2;;paragon)basic_machine=i860-intelos=-osf;;pbd)basic_machine=sparc-tti;;pbb)basic_machine=m68k-tti;;pc532 | pc532-*)basic_machine=ns32k-pc532;;pentium | p5 | k5 | k6 | nexgen | viac3)basic_machine=i586-pc;;pentiumpro | p6 | 6x86 | athlon | athlon_*)basic_machine=i686-pc;;pentiumii | pentium2)basic_machine=i686-pc;;pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`;;pentiumpro-* | p6-* | 6x86-* | athlon-*)basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`;;pentiumii-* | pentium2-*)basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`;;pn)basic_machine=pn-gould;;power) basic_machine=power-ibm;;ppc) basic_machine=powerpc-unknown;;ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`;;ppcle | powerpclittle | ppc-le | powerpc-little)basic_machine=powerpcle-unknown;;ppcle-* | powerpclittle-*)basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`;;ppc64) basic_machine=powerpc64-unknown;;ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`;;ppc64le | powerpc64little | ppc64-le | powerpc64-little)basic_machine=powerpc64le-unknown;;ppc64le-* | powerpc64little-*)basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`;;ps2)basic_machine=i386-ibm;;pw32)basic_machine=i586-unknownos=-pw32;;rom68k)basic_machine=m68k-rom68kos=-coff;;rm[46]00)basic_machine=mips-siemens;;rtpc | rtpc-*)basic_machine=romp-ibm;;s390 | s390-*)basic_machine=s390-ibm;;s390x | s390x-*)basic_machine=s390x-ibm;;sa29200)basic_machine=a29k-amdos=-udi;;sb1)basic_machine=mipsisa64sb1-unknown;;sb1el)basic_machine=mipsisa64sb1el-unknown;;sequent)basic_machine=i386-sequent;;sh)basic_machine=sh-hitachios=-hms;;sparclite-wrs | simso-wrs)basic_machine=sparclite-wrsos=-vxworks;;sps7)basic_machine=m68k-bullos=-sysv2;;spur)basic_machine=spur-unknown;;st2000)basic_machine=m68k-tandem;;stratus)basic_machine=i860-stratusos=-sysv4;;sun2)basic_machine=m68000-sun;;sun2os3)basic_machine=m68000-sunos=-sunos3;;sun2os4)basic_machine=m68000-sunos=-sunos4;;sun3os3)basic_machine=m68k-sunos=-sunos3;;sun3os4)basic_machine=m68k-sunos=-sunos4;;sun4os3)basic_machine=sparc-sunos=-sunos3;;sun4os4)basic_machine=sparc-sunos=-sunos4;;sun4sol2)basic_machine=sparc-sunos=-solaris2;;sun3 | sun3-*)basic_machine=m68k-sun;;sun4)basic_machine=sparc-sun;;sun386 | sun386i | roadrunner)basic_machine=i386-sun;;sv1)basic_machine=sv1-crayos=-unicos;;symmetry)basic_machine=i386-sequentos=-dynix;;t3e)basic_machine=alphaev5-crayos=-unicos;;t90)basic_machine=t90-crayos=-unicos;;tic4x | c4x*)basic_machine=tic4x-unknownos=-coff;;tic54x | c54x*)basic_machine=tic54x-unknownos=-coff;;tic55x | c55x*)basic_machine=tic55x-unknownos=-coff;;tic6x | c6x*)basic_machine=tic6x-unknownos=-coff;;tx39)basic_machine=mipstx39-unknown;;tx39el)basic_machine=mipstx39el-unknown;;toad1)basic_machine=pdp10-xklos=-tops20;;tower | tower-32)basic_machine=m68k-ncr;;udi29k)basic_machine=a29k-amdos=-udi;;ultra3)basic_machine=a29k-nyuos=-sym1;;v810 | necv810)basic_machine=v810-necos=-none;;vaxv)basic_machine=vax-decos=-sysv;;vms)basic_machine=vax-decos=-vms;;vpp*|vx|vx-*)basic_machine=f301-fujitsu;;vxworks960)basic_machine=i960-wrsos=-vxworks;;vxworks68)basic_machine=m68k-wrsos=-vxworks;;vxworks29k)basic_machine=a29k-wrsos=-vxworks;;w65*)basic_machine=w65-wdcos=-none;;w89k-*)basic_machine=hppa1.1-winbondos=-proelf;;xps | xps100)basic_machine=xps100-honeywell;;ymp)basic_machine=ymp-crayos=-unicos;;z8k-*-coff)basic_machine=z8k-unknownos=-sim;;none)basic_machine=none-noneos=-none;;# Here we handle the default manufacturer of certain CPU types. It is in# some cases the only manufacturer, in others, it is the most popular.w89k)basic_machine=hppa1.1-winbond;;op50n)basic_machine=hppa1.1-oki;;op60c)basic_machine=hppa1.1-oki;;romp)basic_machine=romp-ibm;;rs6000)basic_machine=rs6000-ibm;;vax)basic_machine=vax-dec;;pdp10)# there are many clones, so DEC is not a safe betbasic_machine=pdp10-unknown;;pdp11)basic_machine=pdp11-dec;;we32k)basic_machine=we32k-att;;sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)basic_machine=sh-unknown;;sh64)basic_machine=sh64-unknown;;sparc | sparcv9 | sparcv9b)basic_machine=sparc-sun;;cydra)basic_machine=cydra-cydrome;;orion)basic_machine=orion-highlevel;;orion105)basic_machine=clipper-highlevel;;mac | mpw | mac-mpw)basic_machine=m68k-apple;;pmac | pmac-mpw)basic_machine=powerpc-apple;;*-unknown)# Make sure to match an already-canonicalized machine name.;;*)echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2exit 1;;esac# Here we canonicalize certain aliases for manufacturers.case $basic_machine in*-digital*)basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`;;*-commodore*)basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`;;*);;esac# Decode manufacturer-specific aliases for certain operating systems.if [ x"$os" != x"" ]thencase $os in# First match some system type aliases# that might get confused with valid system types.# -solaris* is a basic system type, with this one exception.-solaris1 | -solaris1.*)os=`echo $os | sed -e 's|solaris1|sunos4|'`;;-solaris)os=-solaris2;;-svr4*)os=-sysv4;;-unixware*)os=-sysv4.2uw;;-gnu/linux*)os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`;;# First accept the basic system types.# The portable systems comes first.# Each alternative MUST END IN A *, to match a version number.# -sysv* is not here because it comes later, after sysvr4.-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \| -aos* \| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \| -chorusos* | -chorusrdb* \| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \| -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \| -powermax* | -dnix*)# Remember, each alternative MUST END IN *, to match a version number.;;-qnx*)case $basic_machine inx86-* | i*86-*);;*)os=-nto$os;;esac;;-nto-qnx*);;-nto*)os=`echo $os | sed -e 's|nto|nto-qnx|'`;;-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \| -windows* | -osx | -abug | -netware* | -os9* | -beos* \| -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*);;-mac*)os=`echo $os | sed -e 's|mac|macos|'`;;-linux*)os=`echo $os | sed -e 's|linux|linux-gnu|'`;;-sunos5*)os=`echo $os | sed -e 's|sunos5|solaris2|'`;;-sunos6*)os=`echo $os | sed -e 's|sunos6|solaris3|'`;;-opened*)os=-openedition;;-wince*)os=-wince;;-osfrose*)os=-osfrose;;-osf*)os=-osf;;-utek*)os=-bsd;;-dynix*)os=-bsd;;-acis*)os=-aos;;-atheos*)os=-atheos;;-386bsd)os=-bsd;;-ctix* | -uts*)os=-sysv;;-nova*)os=-rtmk-nova;;-ns2 )os=-nextstep2;;-nsk*)os=-nsk;;# Preserve the version number of sinix5.-sinix5.*)os=`echo $os | sed -e 's|sinix|sysv|'`;;-sinix*)os=-sysv4;;-triton*)os=-sysv3;;-oss*)os=-sysv3;;-svr4)os=-sysv4;;-svr3)os=-sysv3;;-sysvr4)os=-sysv4;;# This must come after -sysvr4.-sysv*);;-ose*)os=-ose;;-es1800*)os=-ose;;-xenix)os=-xenix;;-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)os=-mint;;-aros*)os=-aros;;-kaos*)os=-kaos;;-none);;*)# Get rid of the `-' at the beginning of $os.os=`echo $os | sed 's/[^-]*-//'`echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2exit 1;;esacelse# Here we handle the default operating systems that come with various machines.# The value should be what the vendor currently ships out the door with their# machine or put another way, the most popular os provided with the machine.# Note that if you're going to try to match "-MANUFACTURER" here (say,# "-sun"), then you have to tell the case statement up towards the top# that MANUFACTURER isn't an operating system. Otherwise, code above# will signal an error saying that MANUFACTURER isn't an operating# system, and we'll never get to this point.case $basic_machine in*-acorn)os=-riscix1.2;;arm*-rebel)os=-linux;;arm*-semi)os=-aout;;# This must come before the *-dec entry.pdp10-*)os=-tops20;;pdp11-*)os=-none;;*-dec | vax-*)os=-ultrix4.2;;m68*-apollo)os=-domain;;i386-sun)os=-sunos4.0.2;;m68000-sun)os=-sunos3# This also exists in the configure program, but was not the# default.# os=-sunos4;;m68*-cisco)os=-aout;;mips*-cisco)os=-elf;;mips*-*)os=-elf;;or32-*)os=-coff;;*-tti) # must be before sparc entry or we get the wrong os.os=-sysv3;;sparc-* | *-sun)os=-sunos4.1.1;;*-be)os=-beos;;*-ibm)os=-aix;;*-wec)os=-proelf;;*-winbond)os=-proelf;;*-oki)os=-proelf;;*-hp)os=-hpux;;*-hitachi)os=-hiux;;i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)os=-sysv;;*-cbm)os=-amigaos;;*-dg)os=-dgux;;*-dolphin)os=-sysv3;;m68k-ccur)os=-rtu;;m88k-omron*)os=-luna;;*-next )os=-nextstep;;*-sequent)os=-ptx;;*-crds)os=-unos;;*-ns)os=-genix;;i370-*)os=-mvs;;*-next)os=-nextstep3;;*-gould)os=-sysv;;*-highlevel)os=-bsd;;*-encore)os=-bsd;;*-sgi)os=-irix;;*-siemens)os=-sysv4;;*-masscomp)os=-rtu;;f30[01]-fujitsu | f700-fujitsu)os=-uxpv;;*-rom68k)os=-coff;;*-*bug)os=-coff;;*-apple)os=-macos;;*-atari*)os=-mint;;*)os=-none;;esacfi# Here we handle the case where we know the os, and the CPU type, but not the# manufacturer. We pick the logical manufacturer.vendor=unknowncase $basic_machine in*-unknown)case $os in-riscix*)vendor=acorn;;-sunos*)vendor=sun;;-aix*)vendor=ibm;;-beos*)vendor=be;;-hpux*)vendor=hp;;-mpeix*)vendor=hp;;-hiux*)vendor=hitachi;;-unos*)vendor=crds;;-dgux*)vendor=dg;;-luna*)vendor=omron;;-genix*)vendor=ns;;-mvs* | -opened*)vendor=ibm;;-ptx*)vendor=sequent;;-vxsim* | -vxworks* | -windiss*)vendor=wrs;;-aux*)vendor=apple;;-hms*)vendor=hitachi;;-mpw* | -macos*)vendor=apple;;-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)vendor=atari;;-vos*)vendor=stratus;;esacbasic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`;;esacecho $basic_machine$osexit 0# Local variables:# eval: (add-hook 'write-file-hooks 'time-stamp)# time-stamp-start: "timestamp='"# time-stamp-format: "%:y-%02m-%02d"# time-stamp-end: "'"# End:
123version https://git-lfs.github.com/spec/v1oid sha256:905c5abaac6482a39ff7048c1cd7213b8014601f7dea17b75bf3549a2790c682size 17351234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162dnl Process this file with autoconf to produce a configure script.AC_INIT(src/atak.c)AC_PREREQ(2.13)AM_INIT_AUTOMAKE(gnuchess, 5.07)AM_CONFIG_HEADER(src/config.h)dnl Checks for programs.AC_PROG_CCAC_PROG_INSTALLAC_PROG_AWKAC_PROG_LN_SAC_STRUCT_TMAM_PROG_LEXdnl --with and --enable thingsAC_ARG_WITH(readline,AC_HELP_STRING([--with-readline],[use readline library if available (default is YES)]),ac_cv_use_readline=$withval,ac_cv_use_readline=yes)dnl Check for readline library _and_ headersif test x"$ac_cv_use_readline" = "xyes"; thenAC_CHECK_LIB(ncurses, tputs)AC_CHECK_LIB(readline, readline)AC_CHECK_HEADERS(readline/readline.h readline/history.h)fidnl Checks for header files.AC_HEADER_STDCdnl Either we should make these checks fail with andnl AC_MSG_ERROR or we should treat missing headersdnl with #ifdef somehow. (As it stands, it still givesdnl valuable debugging info for bug reports, but not more.)AC_CHECK_HEADERS(time.h sys/time.h unistd.h errno.h fcntl.h libintl.h)dnl Checks for typedefs, structures, and compiler characteristics.AC_C_CONSTAC_C_VOLATILEAC_FUNC_REALLOCAC_HEADER_STDBOOLAC_C_INLINEAC_TYPE_SIZE_TAC_HEADER_TIMEAX_CREATE_STDINT_H(src/GCint.h)dnl Checks for library functions.AC_TYPE_SIGNALAC_FUNC_MALLOCAC_FUNC_MEMCMPdnl See above, how do we treat failure here?AC_CHECK_FUNCS(gettimeofday strchr strcspn strstr strerror memset strdup strtol)dnl Don't Check for getopt_longdnl just use bundled version like hello doesdnl AC_SUBST(LIBOBJS)dnl AC_CHECK_FUNCS(getopt_long , , [LIBOBJS="$LIBOBJS getopt.o getopt1.o"] )ACX_PTHREAD()AC_CONFIG_FILES(Makefile src/Makefile)AC_OUTPUT
123version https://git-lfs.github.com/spec/v1oid sha256:63d7c73fd93161ea6c05bb0753e6a647279e74ea1e72a6dbfaf615ab83712ce2size 8109512345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- saved from url=(0047)http://www.tim-mann.org/xboard/engine-intf.html --><HTML><HEAD><TITLE>Chess Engine Communication Protocol</TITLE><META http-equiv=Content-Type content="text/html; charset=windows-1252"><META content="MSHTML 6.00.2900.2523" name=GENERATOR></HEAD><BODY><HR noShade SIZE=2><H1>Chess Engine Communication Protocol</H1><H2><A href="http://www.tim-mann.org/">Tim Mann</A></H2><P>$Id: engine-intf.html,v 2.1 2003/10/27 19:21:00 mann Exp $<BR>Version 2;implemented in xboard/WinBoard 4.2.1 and later.<BR>Changes since version 1 areindicated in <FONT color=red>red</FONT>.<HR noShade SIZE=2><UL><LI><A href="http://www.tim-mann.org/xboard/engine-intf.html#1">1.Introduction</A><LI><A href="http://www.tim-mann.org/xboard/engine-intf.html#2">2.Connection</A><LI><A href="http://www.tim-mann.org/xboard/engine-intf.html#3">3.Debugging</A><LI><A href="http://www.tim-mann.org/xboard/engine-intf.html#4">4. How it gotthis way</A><LI><A href="http://www.tim-mann.org/xboard/engine-intf.html#5">5. WinBoardrequires Win32 engines</A><LI><A href="http://www.tim-mann.org/xboard/engine-intf.html#6">6. Hints oninput/output</A><LI><A href="http://www.tim-mann.org/xboard/engine-intf.html#7">7. Signals</A><LI><A href="http://www.tim-mann.org/xboard/engine-intf.html#8">8. Commandsfrom xboard to the engine</A><LI><A href="http://www.tim-mann.org/xboard/engine-intf.html#9">9. Commandsfrom the engine to xboard</A><LI><A href="http://www.tim-mann.org/xboard/engine-intf.html#10">10. ThinkingOutput</A><LI><A href="http://www.tim-mann.org/xboard/engine-intf.html#11">11. Timecontrol</A><LI><A href="http://www.tim-mann.org/xboard/engine-intf.html#12">12. AnalyzeMode</A><LI><A href="http://www.tim-mann.org/xboard/engine-intf.html#13">13. Idiomsand backward compatibility features</A> </LI></UL><HR noShade SIZE=2><H2><A name=1>1. Introduction</A></H2><P>This document is a set of rough notes on the protocol that xboard andWinBoard use to communicate with gnuchessx and other chess engines. These notesmay be useful if you want to connect a different chess engine to xboard.Throughout the notes, "xboard" means both xboard and WinBoard except where theyare specifically contrasted. </P><P>There are two reasons I can imagine someone wanting to do this: </P><OL><LI>You have, or are developing, a chess engine but you don't want to writeyour own graphical interface.<LI>You have, or are developing,a chess engine, and you want to interface itto the Internet Chess Server. </LI></OL><P>In case (2), if you are using xboard, you will need to configure the "Zippy"code into it, but WinBoard includes this code already. See the file <Ahref="http://www.tim-mann.org/xboard/zippy.README">zippy.README</A> in thexboard or WinBoard distribution for more information. </P><P>These notes are unpolished, but I've attempted to make them complete in thisrelease. If you notice any errors, omissions, or misleading statements, let meknow. </P><P>I'd like to hear from everyone who is trying to interface their own chessengine to xboard/WinBoard. Please join the mailing list for authors ofxboard/WinBoard compatible chess engines and post a message about what you'redoing. The list is now hosted by Yahoo Groups; you can join at <Ahref="http://groups.yahoo.com/group/chess-engines">http://groups.yahoo.com/group/chess-engines</A>,or you can read the list there without joining. The list is filtered to preventspam. </P><H2><A name=2>2. Connection</A></H2><P>An xboard chess engine runs as a separate process from xboard itself,connected to xboard through a pair of anonymous pipes. The engine does not haveto do anything special to set up these pipes. xboard sets up the pipes itselfand starts the engine with one pipe as its standard input and the other as itsstandard output. The engine then reads commands from its standard input andwrites responses to its standard output. This is, unfortunately, a little morecomplicated to do right than it sounds; see <Ahref="http://www.tim-mann.org/xboard/engine-intf.html#6">section 6</A> below.</P><P>And yes, contrary to some people's expectations, exactly the same thing istrue for WinBoard. Pipes and standard input/output are implemented in Win32 andwork fine. You don't have to use DDE, COM, DLLs, BSOD, or any of the otherinfinite complexity that Microsoft has created just to talk between twoprograms. A WinBoard chess engine is a Win32 console program that simply readsfrom its standard input and writes to its standard output. See sections <Ahref="http://www.tim-mann.org/xboard/engine-intf.html#5">5</A> and <Ahref="http://www.tim-mann.org/xboard/engine-intf.html#6">6</A> below foradditional details. </P><H2><A name=3>3. Debugging</A></H2><P>To diagnose problems in your engine's interaction with xboard, use the -debugflag on xboard's command line to see the messages that are being exchanged. InWinBoard, these messages are written to the file WinBoard.debug instead of goingto the screen. </P><P>You can turn debug mode on or off while WinBoard is running by pressingCtrl+Alt+F12. You can turn debug mode on or off while xboard is running bybinding DebugProc to a shortcut key (and pressing the key!); see theinstructions on shortcut keys in the xboard man page. </P><P>While your engine is running under xboard/WinBoard, you can send a commanddirectly to the engine by pressing Shift+1 (xboard) or Alt+1 (WinBoard 4.0.3 andlater). This brings up a dialog that you can type your command into. PressShift+2 (Alt+2) instead to send to the second chess engine in Two Machines mode.On WinBoard 4.0.2 and earlier, Ctrl+Alt is used in place of Alt; this had to bechanged due to a conflict with typing the @-sign on some European keyboards.</P><H2><A name=4>4. How it got this way</A></H2><P>Originally, xboard was just trying to talk to the existing command-lineinterface of GNU Chess 3.1+ and 4, which was designed for people to typecommands to. So the communication protocol is very ad-hoc. It might have beengood to redesign it early on, but because xboard and GNU Chess are separateprograms, I didn't want to force people to upgrade them together to versionsthat matched. I particularly wanted to keep new versions of xboard working withold versions of GNU Chess, to make it easier to compare the play of old and newgnuchess versions. I didn't foresee the need for a clean protocol to be usedwith other chess engines in the future. </P><P>Circumstances have changed over the years, and now there are many moreengines that work with xboard. I've had to make the protocol description moreprecise, I've added some features that GNU Chess does not support, and I'vespecified the standard semantics of a few features to be slightly different fromwhat GNU Chess 4 does. </P><P><FONT color=red>This release of the protocol specification is the first tocarry a version number of its own -- version 2. Previous releases simply carrieda last-modified date and were loosely tied to specific releases of xboard andWinBoard. The version number "1" applies generally to all those older versionsof the protocol. </FONT><FONT color=red><P>Protocol version 2 remains compatible with older engines but has several newcapabilities. In particular, it adds the "feature" command, a new mechanism formaking backward-compatible changes and extensions to the protocol. Engines thatdo not support a particular new feature do not have to use it; new features arenot enabled unless the engine specifically requests them using the featurecommand. If an engine does not send the feature command at all, the protocolbehavior is nearly identical to version 1. Several new features can be selectedby the feature command in version 2, including the "ping" command (recommendedfor all engines), the "setboard" command, and many optional parameters.Additional features will probably be added in future versions. </P></FONT><H2><A name=5>5. WinBoard requires Win32 engines</A></H2><P>Due to some Microsoft brain damage that I don't understand, WinBoard does notwork with chess engines that were compiled to use a DOS extender for 32-bitaddressing. (Probably not with 16-bit DOS or Windows programs either.) WinBoardworks only with engines that are compiled for the Win32 API. You can get a freecompiler that targets the Win32 API from <Ahref="http://sources.redhat.com/cygwin/">http://sources.redhat.com/cygwin/</A>.I think DJGPP 2.x should also work if you use the RSXNTDJ extension, but Ihaven't tried it. Of course, Microsoft Visual C++ will work. Most likely theother commercial products that support Win32 will work too (Borland, etc.), butI have not tried them. Delphi has been successfully used to write engines forWinBoard; if you want to do this, Tony Werten has donated some <Ahref="http://www.tim-mann.org/winboard/delphi.txt">sample code</A> that shouldhelp you get started. </P><H2><A name=6>6. Hints on input/output</A></H2><P>Beware of using buffered I/O in your chess engine. The C stdio library, C++streams, and the I/O packages in most other languages use buffering both oninput and output. That means two things. First, when your engine tries to writesome characters to xboard, the library stashes them in an internal buffer anddoes not actually write them to the pipe connected to xboard until either thebuffer fills up or you call a special library routine asking for it to beflushed. (In C stdio, this routine is named <TT>fflush</TT>.) Second, when yourengine tries to read some characters from xboard, the library does not read justthe characters you asked for -- it reads all the characters that are currentlyavailable (up to some limit) and stashes any characters you are not yet readyfor in an internal buffer. The next time you ask to read, you get the charactersfrom the buffer (if any) before the library tries to read more data from theactual pipe. </P><P>Why does this cause problems? First, on the output side, remember that yourengine produces output in small quantities (say, a few characters for a move, ora line or two giving the current analysis), and that data always needs to bedelivered to xboard/WinBoard for display immediately. If you use bufferedoutput, the data you print will sit in a buffer in your own address spaceinstead of being delivered. </P><P>You can usually fix the output buffering problem by asking for the bufferingto be turned off. In C stdio, you do this by calling <TT>setbuf(stdout,NULL)</TT>. A more laborious and error-prone method is to carefully call<TT>fflush(stdout)</TT> after every line you output; I don't recommend this. InC++, you can try <TT>cout.setf(ios::unitbuf)</TT>, which is documented incurrent editions of "The C++ Programming Language," but not older ones. AnotherC++ method that might work is <TT>cout.rdbuf()->setbuf(NULL, 0)</TT>.Alternatively, you can carefully call <TT>cout.flush()</TT> after every line yououtput; again, I don't recommend this. </P><P>Another way to fix the problem is to use unbuffered operating system calls towrite directly to the file descriptor for standard output. On Unix, this means<TT>write(1, ...)</TT> -- see the man page for write(2). On Win32, you can useeither the Unix-like <TT>_write(1, ...)</TT> or Win32 native routines like<TT>WriteFile</TT>. </P><P>Second, on the input side, you are likely to want to poll during your searchand stop it if new input has come in. If you implement pondering, you'll needthis so that pondering stops when the user makes a move. You should also pollduring normal thinking on your move, so that you can implement the "?" (movenow) command, and so that you can respond promptly to a "result", "force", or"quit" command if xboard wants to end the game or terminate your engine.Buffered input makes polling more complicated -- when you poll, you must stopyour search if there are <EM>either</EM> characters in the buffer <EM>or</EM>characters available from the underlying file descriptor. </P><P>The most direct way to fix this problem is to use unbuffered operating systemcalls to read (and poll) the underlying file descriptor directly. On Unix, use<TT>read(0, ...)</TT> to read from standard input, and use <TT>select()</TT> topoll it. See the man pages read(2) and select(2). (Don't follow the example ofGNU Chess 4 and use the FIONREAD ioctl to poll for input. It is not veryportable; that is, it does not exist on all versions of Unix, and is broken onsome that do have it.) On Win32, you can use either the Unix-like <TT>_read(0,...)</TT> or the native Win32 <TT>ReadFile()</TT> to read. Unfortunately, underWin32, the function to use for polling is different depending on whether theinput device is a pipe, a console, or something else. (More Microsoft braindamage here -- did they never hear of device independence?) For pipes, you canuse <TT>PeekNamedPipe</TT> to poll (even when the pipe is unnamed). Forconsoles, you can use <TT>GetNumberOfConsoleInputEvents</TT>. For sockets only,you can use <TT>select()</TT>. It might be possible to use<TT>WaitForSingleObject</TT> more generally, but I have not tried it. Some codeto do these things can be found in Crafty's utility.c, but I don't guaranteethat it's all correct or optimal. </P><P>A second way to fix the problem might be to ask your I/O library not tobuffer on input. It should then be safe to poll the underlying file descriptoras described above. With C, you can try calling <TT>setbuf(stdin, NULL)</TT>.However, I have never tried this. Also, there could be problems if you use<TT>scanf()</TT>, at least with certain patterns, because <TT>scanf()</TT>sometimes needs to read one extra character and "push it back" into the buffer;hence, there is a one-character pushback buffer even if you asked for stdio tobe unbuffered. With C++, you can try <TT>cin.rdbuf()->setbuf(NULL, 0)</TT>,but again, I have never tried this. </P><P>A third way to fix the problem is to check whether there are characters inthe buffer whenever you poll. C I/O libraries generally do not provide anyportable way to do this. Under C++, you can use<TT>cin.rdbuf()->in_avail()</TT>. This method has been reported to work withEXchess. Remember that if there are no characters in the buffer, you still haveto poll the underlying file descriptor too, using the method described above.</P><P>A fourth way to fix the problem is to use a separate thread to read fromstdin. This way works well if you are familiar with thread programming. Thisthread can be blocked waiting for input to come in at all times, while the mainthread of your engine does its thinking. When input arrives, you have the threadput the input into a buffer and set a flag in a global variable. Your searchroutine then periodically tests the global variable to see if there is input toprocess, and stops if there is. WinBoard and my Win32 ports of ICC timestamp andFICS timeseal use threads to handle multiple input sources. </P><H2><A name=7>7. Signals</A></H2><P>Engines that run on Unix need to be concerned with two Unix signals:<TT>SIGTERM</TT> and <TT>SIGINT</TT>. This applies both to engines that rununder xboard and (the unusual case of) engines that WinBoard remotely runs on aUnix host using the -firstHost or -secondHost feature. It does not apply toengines that run on Windows, because Windows does not have Unix-style signals.<FONT color=red>Beginning with version 2, you can now turn off the use of eitheror both signals. See the "feature" command in <Ahref="http://www.tim-mann.org/xboard/engine-intf.html#6">section 9</A> below.</FONT></P><P>First, when an engine is sent the "quit" command, it is also given a<TT>SIGTERM</TT> signal shortly afterward to make sure it goes away. If yourengine reliably responds to "quit", and the signal causes problems for you, youshould either ignore it by calling <TT>signal(SIGTERM, SIG_IGN)</TT> at thestart of your program, or disable it with the "feature" command.</P><P>Second, xboard will send an interrupt signal (<TT>SIGINT</TT>) at certaintimes when it believes the engine may not be listening to user input (thinkingor pondering). WinBoard currently does this only when the engine is runningremotely using the -firstHost or -secondHost feature, not when it is runninglocally. You probably need to know only enough about this grungy feature to keepit from getting in your way. </P><P>The <TT>SIGINT</TT>s are basically tailored to the needs of GNU Chess 4 onsystems where its input polling code is broken or disabled. Because they work ina rather peculiar way, it is recommended that you either ignore <TT>SIGINT</TT>by having your engine call <TT>signal(SIGINT, SIG_IGN)</TT>, or disable it withthe "feature" command.</P><P>Here are details for the curious. If xboard needs to send a command when itis the chess engine's move (such as before the "?" command), it sends a<TT>SIGINT</TT> first. If xboard needs to send commands when it is not the chessengine's move, but the chess engine may be pondering (thinking on its opponent'stime) or analyzing (analysis or analyze file mode), xboard sends a<TT>SIGINT</TT> before the first such command only. Another <TT>SIGINT</TT> isnot sent until another move is made, even if xboard issues more commands. Thisbehavior is necessary for GNU Chess 4. The first <TT>SIGINT</TT> stops it frompondering until the next move, but on some systems, GNU Chess 4 will die if itreceives a <TT>SIGINT</TT> when not actually thinking or pondering. </P><P>There are two reasons why WinBoard does not send the Win32 equivalent of<TT>SIGINT</TT> (which is called <TT>CTRL_C_EVENT</TT>) to local engines. First,the Win32 GNU Chess 4 port does not need it. Second, I could not find a way toget it to work. Win32 seems to be designed under the assumption that onlyconsole applications, not windowed applications, would ever want to send a<TT>CTRL_C_EVENT</TT>. </P><H2><A name=8>8. Commands from xboard to the engine</A></H2><P>All commands from xboard to the engine end with a newline (\n), even wherethat is not explicitly stated. All your output to xboard must be in completelines; any form of prompt or partial line will cause problems. </P><P>At the beginning of each game, xboard sends an initialization string. This iscurrently "new\nrandom\n" unless the user changes it with the initString orsecondInitString option. </P><P>xboard normally reuses the same chess engine process for multiple games. Atthe end of a game, xboard will send the "force" command (see below) to make sureyour engine stops thinking about the current position. It will later send theinitString again to start a new game. If your engine can't play multiple games,you can disable reuse <FONT color=red>either with the "feature" command(beginning in protocol version 2; see below) or </FONT>with xboard's -xreuse (or-xreuse2) command line option. xboard will then ask the process to quit aftereach game and start a new process for the next game. </P><DL><DT><STRONG>xboard</STRONG><DD>This command will be sent once immediately after your engine process isstarted. You can use it to put your engine into "xboard mode" if that isneeded. If your engine prints a prompt to ask for user input, you must turnoff the prompt and output a newline when the "xboard" command comes in.<P></P><DT><FONT color=red><STRONG>protover N</STRONG></FONT><DD><FONT color=red>Beginning in protocol version 2 (in which N=2), thiscommand will be sent immediately after the "xboard" command. If you receivesome other command immediately after "xboard" (such as "new"), you can assumethat protocol version 1 is in use. The "protover" command is the only newcommand that xboard always sends in version 2. All other new commands to theengine are sent only if the engine first enables them with the "feature"command. Protocol versions will always be simple integers so that they caneasily be compared.<P>Your engine should reply to the protover command by sending the "feature"command (see below) with the list of non-default feature settings that yourequire, if any.<P>Your engine should never refuse to run due to receiving a higher protocolversion number than it is expecting! New protocol versions will always becompatible with older ones by default; the larger version number is simply ahint that additional "feature" command options added in later protocolversions may be accepted. </FONT><P></P><DT><FONT color=red><STRONG>accepted</STRONG></FONT><DT><FONT color=red><STRONG>rejected</STRONG></FONT><DD><FONT color=red>These commands may be sent to your engine in reply to the"feature" command; see its documentation below. </FONT><P></P><DT><STRONG>new</STRONG><DD>Reset the board to the standard chess starting position. Set White onmove. Leave force mode and set the engine to play Black. Associate theengine's clock with Black and the opponent's clock with White. Reset clocksand time controls to the start of a new game. Stop clocks. Do not ponder onthis move, even if pondering is on. Remove any search depth limit previouslyset by the sd command.<P></P><DT><STRONG>variant VARNAME</STRONG><DD>If the game is not standard chess, but a variant, this command is sentafter "new" and before the first move or "edit" command. Currently definedvariant names are:<TABLE><TBODY><TR align=left><TH>wildcastle<TD>Shuffle chess where king can castle from d file<TR align=left><TH>nocastle<TD>Shuffle chess with no castling at all<TR align=left><TH>fischerandom<TD>Fischer Random (not supported yet)<TR align=left><TH>bughouse<TD>Bughouse, ICC/FICS rules<TR align=left><TH>crazyhouse<TD>Crazyhouse, ICC/FICS rules<TR align=left><TH>losers<TD>Win by losing all pieces or getting mated (ICC)<TR align=left><TH>suicide<TD>Win by losing all pieces including king, or by having fewer pieceswhen one player has no legal moves (FICS)<TR align=left><TH><FONT color=red>giveaway</FONT><TD><FONT color=red>Win by losing all pieces including king, or byhaving no legal moves (ICC)</FONT><TR align=left><TH>twokings<TD>Weird ICC wild 9<TR align=left><TH>kriegspiel<TD>Kriegspiel (engines not supported)<TR align=left><TH>atomic<TD>Atomic<TR align=left><TH>3check<TD>Win by giving check 3 times<TR align=left><TH>unknown<TD>Unknown variant (not supported) </TR></TBODY></TABLE><P></P><DT><STRONG>quit</STRONG><DD>The chess engine should immediately exit. This command is used when xboardis itself exiting, and also between games if the -xreuse command line optionis given (or -xreuse2 for the second engine). See also <Ahref="http://www.tim-mann.org/xboard/engine-intf.html#7">Signals</A> above.<P></P><DT><STRONG>random</STRONG><DD>This command is specific to GNU Chess 4. You can either ignore itcompletely (that is, treat it as a no-op) or implement it as GNU Chess does.The command toggles "random" mode (that is, it sets random = !random). Inrandom mode, the engine adds a small random value to its evaluation functionto vary its play. The "new" command sets random mode off.<P></P><DT><STRONG>force</STRONG><DD>Set the engine to play neither color ("force mode"). Stop clocks. Theengine should check that moves received in force mode are legal and made inthe proper turn, but should not think, ponder, or make moves of its own.<P></P><DT><STRONG>go</STRONG><DD>Leave force mode and set the engine to play the color that is on move.Associate the engine's clock with the color that is on move, the opponent'sclock with the color that is not on move. Start the engine's clock. Startthinking and eventually make a move.<P></P><DT><FONT color=red><STRONG>playother</STRONG></FONT><DD><FONT color=red>(This command is new in protocol version 2. It is not sentunless you enable it with the feature command.) Leave force mode and set theengine to play the color that is <I>not</I> on move. Associate the opponent'sclock with the color that is on move, the engine's clock with the color thatis not on move. Start the opponent's clock. If pondering is enabled, theengine should begin pondering. If the engine later receives a move, it shouldstart thinking and eventually reply. </FONT><P></P><DT><STRONG>white</STRONG><DD><FONT color=red>(This command is obsolete as of protocol version 2, but isstill sent in some situations to accommodate older engines unless you disableit with the feature command.) </FONT>Set White on move. Set the engine to playBlack. Stop clocks.<P></P><DT><STRONG>black</STRONG><DD><FONT color=red>(This command is obsolete as of protocol version 2, but isstill sent in some situations to accommodate older engines unless you disableit with the feature command.) </FONT>Set Black on move. Set the engine to playWhite. Stop clocks.<P></P><DT><STRONG>level MPS BASE INC</STRONG><DD>Set time controls. See the <Ahref="http://www.tim-mann.org/xboard/engine-intf.html#11">Time Control</A>section below.<P></P><DT><STRONG>st TIME</STRONG><DD>Set time controls. See the <Ahref="http://www.tim-mann.org/xboard/engine-intf.html#11">Time Control</A>section below. The commands "level" and "st" are not used together.<P></P><DT><STRONG>sd DEPTH</STRONG><DD>The engine should limit its thinking to DEPTH ply.<P></P><DT><STRONG>time N</STRONG><DD>Set a clock that always belongs to the engine. N is a number incentiseconds (units of 1/100 second). Even if the engine changes to playingthe opposite color, this clock remains with the engine.<P></P><DT><STRONG>otim N</STRONG><DD>Set a clock that always belongs to the opponent. N is a number incentiseconds (units of 1/100 second). Even if the opponent changes to playingthe opposite color, this clock remains with the opponent.<P>If needed for purposes of board display in force mode (where the engine isnot participating in the game) the time clock should be associated with thelast color that the engine was set to play, the otim clock with the oppositecolor. </P><P><FONT color=red>Beginning in protocol version 2, if you can't handle thetime and otim commands, you can use the "feature" command to disable them; seebelow. </FONT>The following techniques from older protocol versions also work:You can ignore the time and otim commands (that is, treat them as no-ops), orsend back "Error (unknown command): time" the first time you see "time". </P><DT><STRONG>MOVE</STRONG><DD>See below for the syntax of moves. If the move is illegal, print an errormessage; see the section "<Ahref="http://www.tim-mann.org/xboard/engine-intf.html#9">Commands from theengine to xboard</A>". If the move is legal and in turn, make it. If not inforce mode, stop the opponent's clock, start the engine's clock, startthinking, and eventually make a move.<P>When xboard sends your engine a move, it normally sends coordinatealgebraic notation. Examples:<P><TABLE><TBODY><TR align=left><TD>Normal moves:<TD>e2e4<TR align=left><TD>Pawn promotion:<TD>e7e8q<TR align=left><TD>Castling:<TD>e1g1, e1c1, e8g8, e8c8<TR align=left><TD>Bughouse/crazyhouse drop:<TD>P@h3<TR align=left><TD>ICS Wild 0/1 castling:<TD>d1f1, d1b1, d8f8, d8b8<TR align=left><TD>FischerRandom castling:<TD>O-O, O-O-O (oh, not zero) </TR></TBODY></TABLE><P><FONT color=red>Beginning in protocol version 2, you can use the featurecommand to select SAN (standard algebraic notation) instead; for example, e4,Nf3, exd5, Bxf7+, Qxf7#, e8=Q, O-O, or P@h3. Note that the last form, P@h3, isa extension to the PGN standard's definition of SAN, which does not supportbughouse or crazyhouse. </FONT></P><P>xboard doesn't reliably detect illegal moves, because it does not keeptrack of castling unavailability due to king or rook moves, or en passantavailability. If xboard sends an illegal move, send back an error message sothat xboard can retract it and inform the user; see the section "<Ahref="http://www.tim-mann.org/xboard/engine-intf.html#9">Commands from theengine to xboard</A>". </P><DT><FONT color=red><STRONG>usermove MOVE</STRONG></FONT><DD><FONT color=red>By default, moves are sent to the engine without a commandname; the notation is just sent as a line by itself. Beginning in protocolversion 2, you can use the feature command to cause the command name"usermove" to be sent before the move. Example: "usermove e2e4". </FONT><P></P><DT><STRONG>?</STRONG><DD>Move now. If your engine is thinking, it should move immediately;otherwise, the command should be ignored (treated as a no-op). It ispermissible for your engine to always ignore the ? command. The only badconsequence is that xboard's Move Now menu command will do nothing.<P>It is also permissible for your engine to move immediately if it gets anycommand while thinking, as long as it processes the command right aftermoving, but it's preferable if you don't do this. For example, xboard may sendpost, nopost, easy, hard, force, quit, <FONT color=red>or other commands</FONT>while the engine is on move. </P><DT><FONT color=red><STRONG>ping N</STRONG></FONT><DD><FONT color=red>In this command, N is a decimal number. When you receivethe command, reply by sending the string <STRONG>pong N</STRONG>, where N isthe same number you received. Important: You must not reply to a "ping"command until you have finished executing all commands that you receivedbefore it. Pondering does not count; if you receive a ping while pondering,you should reply immediately and continue pondering. Because of the way xboarduses the ping command, if you implement the other commands in this protocol,you should never see a "ping" command when it is your move; however, if youdo, you must not send the "pong" reply to xboard until after you send yourmove. For example, xboard may send "?" immediately followed by "ping". If youimplement the "?" command, you will have moved by the time you see thesubsequent ping command. Similarly, xboard may send a sequence like "force","new", "ping". You must not send the pong response until after you havefinished executing the "new" command and are ready for the new game to start.<P>The ping command is new in protocol version 2 and will not be sent unlessyou enable it with the "feature" command. Its purpose is to allow several raceconditions that could occur in previous versions of the protocol to be fixed,so it is highly recommended that you implement it. It is especially importantin simple engines that do not ponder and do not poll for input while thinking,but it is needed in all engines. </P></FONT><DT><STRONG>draw</STRONG><DD>The engine's opponent offers the engine a draw. To accept the draw, send"offer draw". To decline, ignore the offer (that is, send nothing). If you'replaying on ICS, it's possible for the draw offer to have been withdrawn by thetime you accept it, so don't assume the game is over because you accept a drawoffer. Continue playing until xboard tells you the game is over. See also"offer draw" below.<P></P><DT><STRONG>result RESULT {COMMENT}</STRONG><DD>After the end of each game, xboard will send you a result command. You canuse this command to trigger learning. RESULT is either 1-0, 0-1, 1/2-1/2, or*, indicating whether white won, black won, the game was a draw, or the gamewas unfinished. The COMMENT string is purely a human-readable comment; itscontent is unspecified and subject to change. In ICS mode, it is passedthrough from ICS uninterpreted. Example: <PRE>result 1-0 {White mates}</PRE><P>Here are some notes on interpreting the "result" command. Some apply onlyto playing on ICS ("Zippy" mode). </P><P>If you won but did not just play a mate, your opponent must have resignedor forfeited. If you lost but were not just mated, you probably forfeited ontime, or perhaps the operator resigned manually. If there was a draw for somenonobvious reason, perhaps your opponent called your flag when he hadinsufficient mating material (or vice versa), or perhaps the operator agreedto a draw manually. </P><P>You will get a result command even if you already know the game ended --for example, after you just checkmated your opponent. In fact, if you send the"RESULT {COMMENT}" command (discussed below), you will simply get the samething fed back to you with "result" tacked in front. You might not always geta "result *" command, however. In particular, you won't get one in local chessengine mode when the user stops playing by selecting Reset, Edit Game, Exit orthe like. </P><DT><FONT color=red><STRONG>setboard FEN</STRONG></FONT><DD><FONT color=red>The setboard command is the new way to set up positions,beginning in protocol version 2. It is not used unless it has been selectedwith the feature command. Here FEN is a position in Forsythe-Edwards Notation,as defined in the PGN standard.<P><I>Illegal positions:</I> Note that either setboard or edit can be used tosend an illegal position to the engine. The user can create any position withxboard's Edit Position command (even, say, an empty board, or a board with 64white kings and no black ones). If your engine receives a position that itconsiders illegal, I suggest that you send the response "tellusererror Illegalposition", and then respond to any attempted move with "Illegal move" untilthe next new, edit, or setboard command.</P></FONT><P></P><DT><STRONG>edit</STRONG><DD><FONT color=red>The edit command is the old way to set up positions. Forcompatibility with old engines, it is still used by default, but new enginesmay prefer to use the feature command (see below) to cause xboard to usesetboard instead. </FONT>The edit command puts the chess engine into a specialmode, where it accepts the following subcommands:<TABLE><TBODY><TR align=left><TH>c<TD>change current piece color, initially white<TR align=left><TH>Pa4 (for example)<TD>place pawn of current color on a4<TR align=left><TH>xa4 (for example)<TD>empty the square a4 (not used by xboard)<TR align=left><TH>#<TD>clear board<TR align=left><TH>.<TD>leave edit mode </TR></TBODY></TABLE><FONT color=red>See the Idiomssection below for additional subcommands used in ChessBase's implementation ofthe protocol. </FONT><P>The edit command does not change the side to move. To set up ablack-on-move position, xboard uses the following command sequence: </P><PRE> newforcea2a3edit<edit commands>.</PRE><P>This sequence is used to avoid the "black" command, which is now consideredobsolete and which many engines never did implement as specified in thisdocument. </P><P>After an edit command is complete, if a king and a rook are on their homesquares, castling is assumed to be available to them. En passant capture isassumed to be illegal on the current move regardless of the positions of thepawns. The clock for the 50 move rule starts at zero, and for purposes of thedraw by repetition rule, no prior positions are deemed to have occurred. </P><DT><STRONG>hint</STRONG><DD>If the user asks for a hint, xboard sends your engine the command "hint".Your engine should respond with "Hint: xxx", where xxx is a suggested move. Ifthere is no move to suggest, you can ignore the hint command (that is, treatit as a no-op).<P></P><DT><STRONG>bk</STRONG><DD>If the user selects "Book" from the xboard menu, xboard will send yourengine the command "bk". You can send any text you like as the response, aslong as each line begins with a blank space or tab (\t) character, and yousend an empty line at the end. The text pops up in a modal information dialog.<P></P><DT><STRONG>undo</STRONG><DD>If the user asks to back up one move, xboard will send you the "undo"command. xboard will not send this command without putting you in "force" modefirst, so you don't have to worry about what should happen if the user asks toundo a move your engine made. (GNU Chess 4 actually switches to playing theopposite color in this case.)<P></P><DT><STRONG>remove</STRONG><DD>If the user asks to retract a move, xboard will send you the "remove"command. It sends this command only when the user is on move. Your engineshould undo the last two moves (one for each player) and continue playing thesame color.<P></P><DT><STRONG>hard</STRONG><DD>Turn on pondering (thinking on the opponent's time, also known as"permanent brain"). xboard will not make any assumption about what yourdefault is for pondering or whether "new" affects this setting.<P></P><DT><STRONG>easy</STRONG><DD>Turn off pondering.<P></P><DT><STRONG>post</STRONG><DD>Turn on thinking/pondering output. See <Ahref="http://www.tim-mann.org/xboard/engine-intf.html#10">Thinking Output</A>section.<P></P><DT><STRONG>nopost</STRONG><DD>Turn off thinking/pondering output.<P></P><DT><STRONG>analyze</STRONG><DD>Enter analyze mode. See <Ahref="http://www.tim-mann.org/xboard/engine-intf.html#12">Analyze Mode</A>section.<P></P><DT><STRONG>name X</STRONG><DD>This command informs the engine of its opponent's name. When the engine isplaying on a chess server, xboard obtains the opponent's name from the server.<FONT color=red>When the engine is playing locally against a human user,xboard obtains the user's login name from the local operating system. When theengine is playing locally against another engine, xboard uses either the otherengine's filename or the name that the other engine supplied in the mynameoption to the feature command. By default, xboard uses the name command onlywhen the engine is playing on a chess server. Beginning in protocol version 2,you can change this with the name option to the feature command; see below.</FONT><P></P><DT><STRONG>rating</STRONG><DD>In ICS mode, xboard obtains the ICS opponent's rating from the "Creating:"message that appears before each game. (This message may not appear on serversusing outdated versions of the FICS code.) In Zippy mode, it sends theseratings on to the chess engine using the "rating" command. The chess engine'sown rating comes first, and if either opponent is not rated, his rating isgiven as 0. <FONT color=red>In the future this command may also be used inother modes, if ratings are known. </FONT>Example: <PRE>rating 2600 1500</PRE><P></P><DT><FONT color=red><STRONG>ics HOSTNAME</STRONG></FONT><DD><FONT color=red>If HOSTNAME is "-", the engine is playing against a localopponent; otherwise, the engine is playing on an Internet Chess Server (ICS)with the given hostname. This command is new in protocol version 2 and is notsent unless the engine has enabled it with the "feature" command. Example:"ics freechess.org" </FONT><P></P><DT><STRONG>computer</STRONG><DD>The opponent is also a computer chess engine. Some engines alter theirplaying style when they receive this command.<P></P><DT><FONT color=red><STRONG>pause</STRONG></FONT><DT><FONT color=red><STRONG>resume</STRONG></FONT><DD><FONT color=red>(These commands are new in protocol version 2 and will notbe sent unless feature pause=1 is set. At this writing, xboard actually doesnot use the commands at all, but it or other interfaces may use them in thefuture.) The "pause" command puts the engine into a special state where itdoes not think, ponder, or otherwise consume significant CPU time. The currentthinking or pondering (if any) is suspended and both player's clocks arestopped. The only command that the interface may send to the engine while itis in the paused state is "resume". The paused thinking or pondering (if any)resumes from exactly where it left off, and the clock of the player on moveresumes running from where it stopped. </FONT></DD></DL><H3>Bughouse commands:</H3><P>xboard now supports bughouse engines when in Zippy mode. See <Ahref="http://www.tim-mann.org/xboard/zippy.README">zippy.README</A> forinformation on Zippy mode and how to turn on the bughouse support. The bughousemove format is given above. xboard sends the following additional commands tothe engine when in bughouse mode. Commands to inform your engine of thepartner's game state may be added in the future. </P><DL><DT><STRONG>partner <player></STRONG><DD><player> is now your partner for future games. Example: <PRE>partner mann</PRE><P></P><DT><STRONG>partner</STRONG><DD>Meaning: You no longer have a partner.<P></P><DT><STRONG>ptell <text></STRONG><DD>Your partner told you <text>, either with a ptell or an ordinarytell.<P></P><DT><STRONG>holding [<white>] [<black>]</STRONG><DD>White currently holds <white>; black currently holds <black>.Example: <PRE>holding [PPPRQ] []</PRE><DT><STRONG>holding [<white>] [<black>]<color><piece></STRONG><DD>White currently holds <white>; black currently holds <black>,after <color> acquired <piece>. Example: <PRE>holding [PPPRQ] [R] BR</PRE></DD></DL><H2><A name=9>9. Commands from the engine to xboard</A></H2><P><FONT color=red>In general, an engine should not send any output to xboardthat is not described in this document. As the protocol is extended, newerversions of xboard may recognize additional strings as commands that werepreviously not assigned a meaning. </FONT></P><DL><DT><FONT color=red><STRONG>feature FEATURE1=VALUE1 FEATURE2=VALUE2...</STRONG> </FONT><DD><FONT color=red>Beginning with version 2, the protocol includes the"feature" command, which lets your engine control certain optional protocolfeatures. Feature settings are written as FEATURE=VALUE, where FEATURE is aname from the list below and VALUE is the value to be assigned. Features cantake string, integer, or boolean values; the type of value is listed for eachfeature. String values are written in double quotes (for example, <TT>featuremyname="Miracle Chess 0.9"</TT>), integers are written in decimal, and booleanvalues are written as 0 for false, 1 for true. Any number of features can beset in one feature command, or multiple feature commands can be given.<P>Your engine should send one or more feature commands immediately afterreceiving the "protover" command, since xboard needs to know the values ofsome features before sending further commands to the engine. Because enginesthat predate protocol version 2 do not send "feature", xboard uses a timeoutmechanism: when it first starts your engine, it sends "xboard" and "protoverN", then listens for feature commands for two seconds before sending any othercommands. To end this timeout and avoid the wait, set the feature "done=1" atthe end of your last feature command. To increase the timeout, if needed, setthe feature "done=0" before your first feature command and "done=1" at theend. If needed, it is okay for your engine to set done=0 soon as it starts,even before it receives the xboard and protover commands. This can be usefulif your engine takes a long time to initialize itself. It should be harmlesseven if you are talking to a (version 1) user interface that does notunderstand the "feature" command, since such interfaces generally ignorecommands from the engine that they do not understand. </P><P>The feature command is designed to let the protocol change without breakingengines that were written for older protocol versions. When a new feature isadded to the protocol, its default value is always chosen to be compatiblewith older versions of the protocol that did not have the feature. Any featurethat your engine does not set in a "feature" command retains its defaultvalue, so as the protocol changes, you do not have to change your engine tokeep up with it unless you want to take advantage of a new feature. Becausesome features are improvements to the protocol, while others are meant tocater to engines that do not implement all the protocol features, therecommended setting for a feature is not always the same as the defaultsetting. The listing below gives both default and recommended settings formost features. </P><P>You may want to code your engine so as to be able to work with multipleversions of the engine protocol. Protocol version 1 does not send the protovercommand and does not implement the feature command; if you send a featurecommand in protocol version 1, it will have no effect and there will be noresponse. In protocol version 2 or later, each feature F that you setgenerates the response "accepted F" if the feature is implemented, or"rejected F" if it is not. Thus an engine author can request any featurewithout having to keep track of which protocol version it was introduced in;you need only check whether the feature is accepted or rejected. Thismechanism also makes it possible for a user interface author to implement asubset of a protocol version by rejecting some features that are defined inthat version; however, you should realize that engine authors are likely tocode for xboard and may not be prepared to have a feature that they depend onbe rejected. </P><P>Here are the features that are currently defined. </P></FONT><DL><DT><FONT color=red><STRONG>ping</STRONG> (boolean, default 0, recommended1) </FONT><DD><FONT color=red>If ping=1, xboard may use the protocol's new "ping"command; if ping=0, xboard will not use the command. </FONT><DT><FONT color=red><STRONG>setboard</STRONG> (boolean, default 0,recommended 1) </FONT><DD><FONT color=red>If setboard=1, xboard will use the protocol's new"setboard" command to set up positions; if setboard=0, it will use the older"edit" command. </FONT><DT><FONT color=red><STRONG>playother</STRONG> (boolean, default 0,recommended 1) </FONT><DD><FONT color=red>If playother=1, xboard will use the protocol's new"playother" command when appropriate; if playother=0, it will not use thecommand. </FONT><DT><FONT color=red><STRONG>san</STRONG> (boolean, default 0) </FONT><DD><FONT color=red>If san=1, xboard will send moves to the engine instandard algebraic notation (SAN); for example, Nf3. If san=0, xboard willsend moves in coordinate notation; for example, g1f3. See MOVE in <Ahref="http://www.tim-mann.org/xboard/engine-intf.html#8">section 8</A> abovefor more details of both kinds of notation. </FONT><DT><FONT color=red><STRONG>usermove</STRONG> (boolean, default 0) </FONT><DD><FONT color=red>If usermove=1, xboard will send moves to the engine withthe command "usermove MOVE"; if usermove=0, xboard will send just the move,with no command name. </FONT><DT><FONT color=red><STRONG>time</STRONG> (boolean, default 1, recommended1) </FONT><DD><FONT color=red>If time=1, xboard will send the "time" and "otim"commands to update the engine's clocks; if time=0, it will not. </FONT><DT><FONT color=red><STRONG>draw</STRONG> (boolean, default 1, recommended1) </FONT><DD><FONT color=red>If draw=1, xboard will send the "draw" command if theengine's opponent offers a draw; if draw=0, xboard will not inform theengine about draw offers. Note that if draw=1, you may receive a draw offerwhile you are on move; if this will cause you to move immediately, youshould set draw=0. </FONT><DT><FONT color=red><STRONG>sigint</STRONG> (boolean, default 1) </FONT><DD><FONT color=red>If sigint=1, xboard may send SIGINT (the interruptsignal) to the engine as <Ahref="http://www.tim-mann.org/xboard/engine-intf.html#7">section 7</A>above; if sigint=0, it will not. </FONT><DT><FONT color=red><STRONG>sigterm</STRONG> (boolean, default 1) </FONT><DD><FONT color=red>If sigterm=1, xboard may send SIGTERM (the terminationsignal) to the engine as <Ahref="http://www.tim-mann.org/xboard/engine-intf.html#7">section 7</A>above; if sigterm=0, it will not. </FONT><DT><FONT color=red><STRONG>reuse</STRONG> (boolean, default 1, recommended1) </FONT><DD><FONT color=red>If reuse=1, xboard may reuse your engine for multiplegames. If reuse=0 (or if the user has set the -xreuse option on xboard'scommand line), xboard will kill the engine process after every game andstart a fresh process for the next game. </FONT><DT><FONT color=red><STRONG>analyze</STRONG> (boolean, default 1,recommended 1) </FONT><DD><FONT color=red>If analyze=0, xboard will not try to use the "analyze"command; it will pop up an error message if the user asks for analysis mode.If analyze=1, xboard will try to use the command if the user asks foranalysis mode. </FONT><DT><FONT color=red><STRONG>myname</STRONG> (string, default determined fromengine filename) </FONT><DD><FONT color=red>This feature lets you set the name that xboard will usefor your engine in window banners, in the PGN tags of saved game files, andwhen sending the "name" command to another engine. </FONT><DT><FONT color=red><STRONG>variants</STRONG> (string, see text below)</FONT><DD><FONT color=red>This feature indicates which chess variants your engineaccepts. It should be a comma-separated list of variant names. See the tableunder the "variant" command in <Ahref="http://www.tim-mann.org/xboard/engine-intf.html#8">section 8</A>above. If you do not set this feature, xboard will assume by default thatyour engine supports all variants. (However, the -zippyVariants command-lineoption still limits which variants will be accepted in Zippy mode.) It isrecommended that you set this feature to the correct value for your engine(just "normal" in most cases) rather than leaving the default in place, sothat the user will get an appropriate error message if he tries to play avariant that your engine does not support. </FONT><DT><FONT color=red><STRONG>colors</STRONG> (boolean, default 1, recommended0) </FONT><DD><FONT color=red>If colors=1, xboard uses the obsolete "white" and"black" commands in a stylized way that works with most older chess enginesthat require the commands. See the "<Ahref="http://www.tim-mann.org/xboard/engine-intf.html#13">Idioms</A>"section below for details. If colors=0, xboard does not use the "white" and"black" commands at all. </FONT><DT><FONT color=red><STRONG>ics</STRONG> (boolean, default 0) </FONT><DD><FONT color=red>If ics=1, xboard will use the protocol's new "ics"command to inform the engine of whether or not it is playing on a chessserver; if ics=0, it will not. </FONT><DT><FONT color=red><STRONG>name</STRONG> (boolean, see text below) </FONT><DD><FONT color=red>If name=1, xboard will use the protocol's "name" commandto inform the engine of the opponent's name; if name=0, it will not. Bydefault, name=1 if the engine is playing on a chess server; name=0 if not.</FONT><DT><FONT color=red><STRONG>pause</STRONG> (boolean, default 0) </FONT><DD><FONT color=red>If pause=1, xboard may use the protocol's new "pause"command; if pause=0, xboard assumes that the engine does not support thiscommand. </FONT><DT><FONT color=red><STRONG>done</STRONG> (integer, no default) </FONT><DD><FONT color=red>If you set done=1 during the initial two-second timeoutafter xboard sends you the "xboard" command, the timeout will end and xboardwill not look for any more feature commands before starting normaloperation. If you set done=0, the initial timeout is increased to one hour;in this case, you must set done=1 before xboard will enter normal operation.</FONT></DD></DL><P></P><DT><STRONG>Illegal move: MOVE</STRONG><DT><STRONG>Illegal move (REASON): MOVE</STRONG><DD>If your engine receives a MOVE command that is recognizably a move but isnot legal in the current position, your engine must print an error message inone of the above formats so that xboard can pass the error on to the user andretract the move. The (REASON) is entirely optional. Examples: <PRE> Illegal move: e2e4Illegal move (in check): Nf3Illegal move (moving into check): e1g1</PRE><P>Generally, xboard will never send an ambiguous move, so it does not matterwhether you respond to such a move with an Illegal move message or an Errormessage. </P><DT><STRONG>Error (ERRORTYPE): COMMAND</STRONG><DD>If your engine receives a command it does not understand or does notimplement, it should print an error message in the above format so that xboardcan parse it. Examples: <PRE> Error (ambiguous move): Nf3Error (unknown command): analyzeError (command not legal now): undoError (too many parameters): level 1 2 3 4 5 6 7</PRE><DT><STRONG>move MOVE</STRONG><DD>Your engine is making the move MOVE. Do not echo moves from xboard withthis command; send only new moves made by the engine. <FONT color=red><P>For the actual move text from your chess engine (in place of MOVE above),your move should be either<UL><LI>in coordinate notation (e.g., e2e4, e7e8q) with castling indicated bythe King's two-square move (e.g., e1g1), or<LI>in Standard Algebraic Notation (SAN) as defined in the Portable GameNotation standard (e.g, e4, Nf3, O-O, cxb5, Nxe4, e8=Q), with the extensionpiece@square (e.g., P@f7) to handle piece placement in bughouse andcrazyhouse. </LI></UL>xboard itself also accepts some variants of SAN, but forcompatibility with non-xboard interfaces, it is best not to rely on thisbehavior.<P></P><P>Warning: Even though all versions of this protocol specification haveindicated that xboard accepts SAN moves, some non-xboard interfaces are knownto accept only coordinate notation. See the Idioms section for moreinformation on the known limitations of some non-xboard interfaces. It shouldbe safe to send SAN moves if you receive a "protover 2" (or later) commandfrom the interface, but otherwise it is best to stick to coordinate notationfor maximum compatibility. An even more conservative approach would be foryour engine to send SAN to the interface only if you have set feature san=1(which causes the interface to send SAN to you) and have received "acceptedsan" in reply. </P></FONT><DT><STRONG>RESULT {COMMENT}</STRONG><DD>When your engine detects that the game has ended by rule, your engine mustoutput a line of the form "RESULT {comment}" (without the quotes), whereRESULT is a PGN result code (1-0, 0-1, or 1/2-1/2), and comment is the reason.Here "by rule" means that the game is definitely over because of what happenedon the board. In normal chess, this includes checkmate, stalemate, triplerepetition, the 50 move rule, or insufficient material; it does not includeloss on time or the like. Examples: <PRE> 0-1 {Black mates}1-0 {White mates}1/2-1/2 {Draw by repetition}1/2-1/2 {Stalemate}</PRE><P>xboard relays the result to the user, the ICS, the other engine in TwoMachines mode, and the PGN save file as required. </P><DT><STRONG>resign</STRONG><DD>If your engine wants to resign, it can send the command "resign".Alternatively, it can use the "RESULT {comment}" command if the string"resign" is included in the comment; for example "0-1 {White resigns}". xboardrelays the resignation to the user, the ICS, the other engine in Two Machinesmode, and the PGN save file as required.<P></P><DT><STRONG>offer draw</STRONG><DD>If your engine wants to offer a draw by agreement (as opposed to claiminga draw by rule), it can send the command "offer draw". xboard relays the offerto the user, the ICS, the other engine in Two Machines mode, and the PGN savefile as required. In Machine White, Machine Black, or Two Machines mode, theoffer is considered valid until your engine has made two more moves.<P></P><DT><FONT color=red><STRONG>tellopponent MESSAGE</STRONG></FONT><DD><FONT color=red>This command lets the engine give a message to itsopponent, independent of whether the opponent is a user on the local machineor a remote ICS user (Zippy mode). MESSAGE consists of any characters,including whitespace, to the end of the line. When the engine is playingagainst a user on the local machine, xboard pops up an information dialogcontaining the message. When the engine is playing against an opponent on theICS (Zippy mode), xboard sends "say MESSAGE\n" to the ICS.<P></P><DT><STRONG>tellothers MESSAGE</STRONG><DD>This command lets the engine give a message to people watching the gameother than the engine's opponent. MESSAGE consists of any characters,including whitespace, to the end of the line. When the engine is playingagainst a user on the local machine, this command does nothing. When theengine is playing against an opponent on the ICS (Zippy mode), xboard sends"whisper MESSAGE\n" to the ICS.<P></P><DT><STRONG>tellall MESSAGE</STRONG><DD>This command lets the engine give a message to its opponent and otherpeople watching the game, independent of whether the opponent is a user on thelocal machine or a remote ICS user (Zippy mode). MESSAGE consists of anycharacters, including whitespace, to the end of the line. When the engine isplaying against a user on the local machine, xboard pops up an informationdialog containing the message. When the engine is playing against an opponenton the ICS (Zippy mode), xboard sends "kibitz MESSAGE\n" to the ICS. </FONT><P></P><DT><STRONG>telluser MESSAGE</STRONG><DD>xboard pops up an information dialog containing the message. MESSAGEconsists of any characters, including whitespace, to the end of the line.<P></P><DT><STRONG>tellusererror MESSAGE</STRONG><DD>xboard pops up an error dialog containing the message. MESSAGE consists ofany characters, including whitespace, to the end of the line.<P></P><DT><STRONG>askuser REPTAG MESSAGE</STRONG><DD>Here REPTAG is a string containing no whitespace, and MESSAGE consists ofany characters, including whitespace, to the end of the line. xboard pops up aquestion dialog that says MESSAGE and has a typein box. If the user types in"bar", xboard sends "REPTAG bar" to the engine. The user can cancel the dialogand send nothing.<P></P><DT><STRONG>tellics MESSAGE</STRONG><DD>In Zippy mode, xboard sends "MESSAGE\n" to ICS. MESSAGE consists of anycharacters, including whitespace, to the end of the line.<P></P><DT><FONT color=red><STRONG>tellicsnoalias MESSAGE</STRONG></FONT><DD><FONT color=red>In Zippy mode, xboard sends "xMESSAGE\n" to ICS, where "x"is a character that prevents the ICS from expanding command aliases, if xboardknows of such a character. (On chessclub.com and chess.net, "/" is used; onfreechess.org, "$" is used.) MESSAGE consists of any characters, includingwhitespace, to the end of the line. </FONT></DD></DL><P><H2><A name=10>10. Thinking Output</A></H2><P>If the user asks your engine to "show thinking", xboard sends your engine the"post" command. It sends "nopost" to turn thinking off. In post mode, yourengine sends output lines to show the progress of its thinking. The engine cansend as many or few of these lines as it wants to, whenever it wants to.Typically they would be sent when the PV (principal variation) changes or thedepth changes. The thinking output should be in the following format: </P><PRE>ply score time nodes pv</PRE>Where:<TABLE><TBODY><TR align=left><TH>ply<TD>Integer giving current search depth.<TR align=left><TH>score<TD>Integer giving current evaluation in centipawns.<TR align=left><TH>time<TD>Current search time in centiseconds (ex: 1028 = 10.28 seconds).<TR align=left><TH>nodes<TD>Nodes searched.<TR align=left><TH>pv<TD>Freeform text giving current "best" line. You can continue the pv ontoanother line if you start each continuation line with at least four spacecharacters. </TR></TBODY></TABLE><P>Example: </P><PRE> 9 156 1084 48000 Nf3 Nc6 Nc3 Nf6</PRE><P>Meaning: </P>9 ply, score=1.56, time = 10.84 seconds, nodes=48000, PV = "Nf3Nc6 Nc3 Nf6"<P>Longer example from actual Crafty output: </P><PRE> 4 109 14 1435 1. e4 d5 2. Qf3 dxe4 3. Qxe4 Nc64 116 23 2252 1. Nf3 Nc6 2. e4 e64 116 27 2589 1. Nf3 Nc6 2. e4 e65 141 44 4539 1. Nf3 Nc6 2. O-O e5 3. e45 141 54 5568 1. Nf3 Nc6 2. O-O e5 3. e4</PRE><P>You can use the PV to show other things; for instance, while in book, Craftyshows the observed frequency of different reply moves in its book. In situationslike this where your engine is not really searching, start the PV with a '('character: </P><PRE> 0 0 0 0 (e4 64%, d4 24%)</PRE><P>GNU Chess output is very slightly different. The ply number is followed by anextra nonblank character, and the time is in seconds, not hundredths of seconds.For compatibility, xboard accepts the extra character and takes it as a flagindicating the different time units. Example: </P><PRE> 2. 14 0 38 d1d2 e8e73+ 78 0 65 d1d2 e8e7 d2d33& 14 0 89 d1d2 e8e7 d2d33& 76 0 191 d1e2 e8e7 e2e33. 76 0 215 d1e2 e8e7 e2e34& 15 0 366 d1e2 e8e7 e2e3 e7e64. 15 0 515 d1e2 e8e7 e2e3 e7e65+ 74 0 702 d1e2 f7f5 e2e3 e8e7 e3f45& 71 0 1085 d1e2 e8e7 e2e3 e7e6 e3f45. 71 0 1669 d1e2 e8e7 e2e3 e7e6 e3f46& 48 0 3035 d1e2 e8e7 e2e3 e7e6 e3e4 f7f5 e4d46. 48 0 3720 d1e2 e8e7 e2e3 e7e6 e3e4 f7f5 e4d47& 48 0 6381 d1e2 e8e7 e2e3 e7e6 e3e4 f7f5 e4d47. 48 0 10056 d1e2 e8e7 e2e3 e7e6 e3e4 f7f5 e4d48& 66 1 20536 d1e2 e8e7 e2e3 e7e6 e3d4 g7g5 a2a4 f7f58. 66 1 24387 d1e2 e8e7 e2e3 e7e6 e3d4 g7g5 a2a4 f7f59& 62 2 38886 d1e2 e8e7 e2e3 e7e6 e3d4 h7h5 a2a4 h5h4d4e49. 62 4 72578 d1e2 e8e7 e2e3 e7e6 e3d4 h7h5 a2a4 h5h4d4e410& 34 7 135944 d1e2 e8e7 e2e3 e7e6 e3d4 h7h5 c2c4 h5h4d4e4 f7f5 e4f410. 34 9 173474 d1e2 e8e7 e2e3 e7e6 e3d4 h7h5 c2c4 h5h4d4e4 f7f5 e4f4</PRE><P>If your engine is pondering (thinking on its opponent's time) in post mode,it can show its thinking then too. In this case your engine may omit the hintmove (the move it is assuming its opponent will make) from the thinking lines<EM>if and only if</EM> it sends xboard the move in the usual "Hint: xxx" formatbefore sending the first line. </P><H2><A name=11>11. Time control</A></H2><P>xboard supports three styles of time control: conventional chess clocks, theICS-style incremental clock, and an exact number of seconds per move. </P><P>In conventional clock mode, every time control period is the same. That is,if the time control is 40 moves in 5 minutes, then after each side has made 40moves, they each get an additional 5 minutes, and so on, ad infinitum. At somefuture time it would be nice to support a series of distinct time controls. Thisis very low on my personal priority list, but code donations to the xboardproject are accepted, so feel free to take a swing at it. I suggest you talk tome first, though. </P><P>The command to set a conventional time control looks like this: </P><PRE> level 40 5 0level 40 0:30 0</PRE><P>The 40 means that there are 40 moves per time control. The 5 means there are5 minutes in the control. In the second example, the 0:30 means there are 30seconds. The final 0 means that we are in conventional clock mode. </P><P>The command to set an incremental time control looks like this: </P><PRE> level 0 2 12</PRE><P>Here the 0 means "play the whole game in this time control period", the 2means "base=2 minutes", and the 12 means "inc=12 seconds". As in conventionalclock mode, the second argument to level can be in minutes and seconds. </P><P>At the start of the game, each player's clock is set to base minutes.Immediately after a player makes a move, inc seconds are added to his clock. Aplayer's clock counts down while it is his turn. Your flag can be calledwhenever your clock is zero or negative. (Your clock can go negative and thenbecome positive again because of the increment.) </P><P>A special rule on some ICS implementations: if you ask for a game withbase=0, the clocks really start at 10 seconds instead of 0. xboard itself doesnot know about this rule, so it passes the 0 on to the engine instead ofchanging it to 0:10. </P><P>ICS also has time odds games. With time odds, each player has his own (base,inc) pair, but otherwise things work the same as in normal games. The Zippyxboard accepts time odds games but ignores the fact that the opponent'sparameters are different; this is perhaps not quite the right thing to do, butgnuchess doesn't understand time odds. Time odds games are always unrated. </P><P>The command to set an exact number of seconds per move looks like this: </P><PRE> st 30</PRE><P>This means that each move must be made in at most 30 seconds. Time not usedon one move does not accumulate for use on later moves. </P><H2><A name=12>12. Analyze Mode</A></H2><P>xboard supports analyzing fresh games, edited positions, and games fromfiles. However, all of these look the same from the chess engine's perspective.Basically, the engine just has to respond to the "analyze" command. <FONTcolor=red>Beginning in protocol version 2, if your engine does not supportanalyze mode, it should use the feature command to set analyze=0. </FONT>Theolder method of printing the error message "Error (unknown command): analyze" inresponse to the "analyze" command will also work, however. </P><P>To enter analyze mode, xboard sends the command sequence "post", "analyze".Analyze mode in your engine should be similar to force mode, except that yourengine thinks about what move it would make next if it were on move. Your engineshould accept the following commands while in analyze mode: </P><UL><LI>Any legal move, as in force mode<LI><STRONG>undo</STRONG> Back up one move and analyze previousposition.<LI><STRONG>new</STRONG> Reset position to start of game but stayin analyze mode.<LI><FONT color=red><STRONG>setboard</STRONG> if you have set featuresetboard=1; otherwise <STRONG>edit</STRONG>. Exiting edit mode returns toanalyze mode. </FONT><LI><STRONG>exit</STRONG> Leave analyze mode.<LI><STRONG>.</STRONG> Send a search status update (optional); seebelow.<LI><FONT color=red><STRONG>bk</STRONG> Show book moves from thisposition, if any; see above.</FONT><LI><FONT color=red><STRONG>hint</STRONG> Show the predicted movefrom this position, if any; see above.</FONT> </LI></UL><P>If the user selects "Periodic Updates", xboard will send the string ".\n" tothe chess engine periodically during analyze mode, unless the last PV receivedbegan with a '(' character. </P><P>The chess engine should respond to ".\n" with a line like this: </P><PRE>stat01: time nodes ply mvleft mvtot <FONT color=red>mvname</FONT></PRE>Where:<TABLE><TBODY><TR align=left><TH>time<TD>Elapsed search time in centiseconds (ie: 567 = 5.67 seconds).<TR align=left><TH>nodes<TD>Nodes searched so far.<TR align=left><TH>ply<TD>Search depth so far.<TR align=left><TH>mvleft<TD>Number of moves left to consider at this depth.<TR align=left><TH>mvtot<TD>Total number of moves to consider.<TR align=left><TH><FONT color=red>mvname</FONT><TD><FONT color=red>Move currently being considered (SAN or coordinatenotation). Optional; added in protocol version 2.</FONT> </TR></TBODY></TABLE><P>Examples: </P><PRE> stat01: 1234 30000 7 5 30stat01: 1234 30000 7 5 30 Nf3</PRE><P>Meaning: </P><P>After 12.34 seconds, I've searched 7 ply/30000 nodes, there are a total of 30legal moves, and I have 5 more moves to search before going to depth 8. In thesecond example, of the 30 legal moves, the one I am currently searching isNf3.</P><P>Implementation of the "." command is optional. If the engine does not respondto the "." command with a "stat01..." line, xboard will stop sending "."commands. If the engine does not implement this command, the analysis windowwill use a shortened format to display the engine info. </P><P>To give the user some extra information, the chess engine can output thestrings "++\n" and "--\n", to indicate that the current search is failing highor low, respectively. You don't have to send anything else to say "Okay, I'm notfailing high/low anymore." xboard will figure this out itself. </P><H2><A name=13>13. Idioms and backward compatibility features</A></H2><P>Some engines have variant interpretations of the force/go/white/black,time/otim, and hard/easy command sets. In order to accommodate these olderengines, xboard uses these commands only according to the stylized patterns("idioms") given in this section. The obsolete white and black commands havehistorically been particularly troublesome, and it is recommended that newengines set the feature colors=0 and/or ignore the commands. </P><DL><DT><STRONG>time N</STRONG><DT><STRONG>otim N</STRONG><DT><STRONG>MOVE</STRONG><DD>Sent when the opponent makes a move and the engine is already playing theopposite color.<P></P><DT><STRONG>white</STRONG><DT><STRONG>go</STRONG><DD>Sent when the engine is in force mode or playing Black but should switchto playing White. This sequence is sent only when White is already on move.<FONT color=red>If you set the feature colors=0, "white" is not sent. </FONT><P></P><DT><STRONG>black</STRONG><DT><STRONG>go</STRONG><DD>Sent when the engine is in force mode or playing White but should switchto playing Black. This sequence is sent only when Black is already on move.<FONT color=red>If you set the feature colors=0, "black" is not sent. </FONT><P></P><DT><STRONG>white</STRONG><DT><STRONG>time N</STRONG><DT><STRONG>otim N</STRONG><DT><STRONG>black</STRONG><DT><STRONG>go</STRONG><DD>Sent when Black is on move, the engine is in force mode or playing White,and the engine's clock needs to be updated before it starts playing. Theinitial "white" is a kludge to accommodate GNU Chess 4's variantinterpretation of these commands. <FONT color=red>If you set the featurecolors=0, "white" and "black" are not sent. </FONT><P></P><DT><STRONG>black</STRONG><DT><STRONG>time N</STRONG><DT><STRONG>otim N</STRONG><DT><STRONG>white</STRONG><DT><STRONG>go</STRONG><DD>Sent when White is on move, the engine is in force mode or playing Black,and the engine's clock needs to be updated before it starts playing. Seeprevious idiom. The initial "black" is a kludge to accommodate GNU Chess 4'svariant interpretation of these commands. <FONT color=red>If you set thefeature colors=0, "black" and "white" are not sent. </FONT><P></P><DT><STRONG>hard</STRONG><DT><STRONG>easy</STRONG><DD>Sent in sequence to turn off pondering if xboard is not sure whether it ison. When xboard is sure, it will send "hard" or "easy" alone. xboard does thisbecause "easy" is a toggle in GNU Chess 4 but "hard" is an absolute on.</DD></DL><P>To support older engines, certain additional commands from the engine toxboard are also recognized. (These are commands by themselves, not values to beplaced in the comment field of the PGN result code.) These forms are notrecommended for new engines; use the PGN result code commands or the resigncommand instead. </P><TABLE><TBODY><TR align=left><TH>Command<TH>Interpreted as<TR align=left><TD>White resigns<TD>0-1 {White resigns}<TR align=left><TD>Black resigns<TD>1-0 {Black resigns}<TR align=left><TD>White<TD>1-0 {White mates}<TR align=left><TD>Black<TD>0-1 {Black mates}<TR align=left><TD>Draw<TD>1/2-1/2 {Draw}<TR align=left><TD>computer mates<TD>1-0 {White mates} or 0-1 {Black mates}<TR align=left><TD>opponent mates<TD>1-0 {White mates} or 0-1 {Black mates}<TR align=left><TD>computer resigns<TD>0-1 {White resigns} or 1-0 {Black resigns}<TR align=left><TD>game is a draw<TD>1/2-1/2 {Draw}<TR align=left><TD>checkmate<TD>1-0 {White mates} or 0-1 {Black mates} </TR></TBODY></TABLE><P>Commands in the above table are recognized if they begin a line and arbitrarycharacters follow, so (for example) "White mates" will be recognized as "White",and "game is a draw by the 50 move rule" will be recognized as "game is a draw".All the commands are case-sensitive. </P><P>An alternative move syntax is also recognized: </P><TABLE><TBODY><TR align=left><TH>Command<TH>Interpreted as<TR align=left><TD>NUMBER ... MOVE<TD>move MOVE </TR></TBODY></TABLE><P>Here NUMBER means any string of decimal digits, optionally ending in aperiod. MOVE is any string containing no whitespace. In this command format,xboard requires the "..." even if your engine is playing White. A command of theform NUMBER MOVE will be ignored. This odd treatment of the commands is neededfor compatibility with gnuchessx. The original reasons for it are lost in themists of time, but I suspect it was originally a bug in the earliest versions ofxboard, before I started working on it, which someone "fixed" in the wrong way,by creating a special version of gnuchess (gnuchessx) instead of changingxboard. </P><P>Any line that contains the words "offer" and "draw" is recognized as "offerdraw". </P><P>The "Illegal move" message is recognized even if spelled "illegal move" andeven if the colon (":") is omitted. This accommodates GNU Chess 4, which printsmessages like "Illegal move (no matching move)e2e4", and old versions of Crafty,which print just "illegal move". </P><P>In Zippy mode, for compatibility with older versions of Crafty, xboard passesthrough to ICS any line that begins "kibitz", "whisper", "tell", or "draw". Donot use this feature in new code. Instead, use the commands "tellall","tellothers", "tellopponent", "tellics" (if needed), "1/2-1/2 {COMMENT}", or"offer draw", as appropriate. </P><P><FONT color=red>If the engine responds to the "sd DEPTH" command with anerror message indicating the command is not supported (such as "Illegal move:sd"), xboard sets an internal flag and subsequently uses the command"depth\nDEPTH" instead, for the benefit of GNU Chess 4. Note the newline in themiddle of this command! New engines should not rely on this feature. </FONT></P><P><FONT color=red>If the engine responds to the "st TIME" command with an errormessage indicating the command is not supported (such as "Illegal move: st"),xboard sets an internal flag and subsequently uses the command "level 1 TIME"instead, for the benefit of GNU Chess 4. Note that this is not a standard use ofthe level command, as TIME seconds are not added after each player makes 1 move;rather, each move is made in at most TIME seconds. New engines should notimplement or rely on this feature. </FONT></P><FONT color=red><P>In support of the -firstHost/-secondHost features, which allow a chess engineto be run on another machine using the rsh protocol, xboard recognizes errormessages that are likely to come from rsh as fatal errors. The followingmessages are currently recognized: </P><BLOCKQUOTE>unknown host<BR>No remote directory<BR>not found<BR>No suchfile<BR>can't alloc<BR>Permission denied<BR></BLOCKQUOTE></FONT><P><FONT color=red>ChessBase/Fritz now implements the xboard/winboard protocoland can use WinBoard-compatible engines in its GUI. ChessBase's version of theprotocol is generally the same as version 1, except that they have added thecommands <STRONG>fritz</STRONG>, <STRONG>reset</STRONG>, and<STRONG>ponder</STRONG>, and the edit subcommands <STRONG>castle</STRONG> and<STRONG>ep</STRONG>. If you want your engine to work well with theChessBase/Fritz GUI, you may need to implement these additional commands, andyou should also be aware of the peculiar way that ChessBase uses the protocol.See their <Ahref="http://www.chessbase.com/Products/engines/winboard/tech.htm">web page</A>for documentation. </FONT></P><P><FONT color=red>ChessMaster 8000 also implements version 1 of thexboard/winboard protocol and can use WinBoard-compatible engines. The originalrelease of CM8000 also has one additional restriction: only pure coordinatenotation (e.g., e2e4) is accepted in the move command. A patch to correct thisshould be available from The Learning Company (makers of CM8000) in February2001. </FONT></P><HR noShade SIZE=2><ADDRESS>converted to HTML by <A href="http://www.jakob.at/steffen/">Steffen A.Jakob</A></ADDRESS></BODY></HTML>
123version https://git-lfs.github.com/spec/v1oid sha256:d8cf0e1c5513824eadf8fa8bb367e4a1500d61edc1e61d11e1d2ea17d072b07dsize 18016123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512READMEGNU CHESS 5by Stuart Cracraft <cracraft@gnu.org>copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 19931994, 1995, 1996, 1997, 1998, 1999, 2000, 2001Modified Simon Waters <simon@wretched.demon.co.uk> 2001Modified Simon Waters <simon@wretched.demon.co.uk> 2003IMPORTANT: Please send all updates to Simon at the above address.Table of ContentsIntroductionWho We AreData StructuresMove GeneratorSearchEvaluationBookHash TableAuxillary File Formats (PGN, EPD)Universal BoardCaveatsCompilersInternetXboard/WinboardCommand ListINTRODUCTIONWelcome to the GNU CHESS 5 README. This is somewhat different thana normal readme. You might consider this a manual. We've always foundmultiple documents confusing, overlapping and sometimes contradictoryas far as software documentation goes. By putting it all together inone place we hope to avoid these traditional inadequacies and be ableto maintain a single document. If you add documentation, add it tothis document only.GNU Chess 5 is the new version of GNU Chess. The goal of creating thisnew version was to eliminate perceived problems with past versions, themajor one being spaghetti-code that was extremely poorly documented, butanother being antiquated data structures and especially the ignominouslinked list. Another good reason was to have more standard file formatsfor game positions and game listings.WHO WE AREWe are the GNU Chess developers and you may reach us atbug-gnu-chess@gnu.orgWe are indebted to our sponsor, the Free Software Foundationwhose web page is:http://www.gnu.organd which also serves as our software depository for new versions ofGNU and GNU Chess.We also have a Usenet bulletin board, gnu.chess. Feel free to post andsupport. Please become a developer and contribute your time and coding skillto GNU Chess. Make a donation of your time and money.But, as developers we like to develop our own ideas. Thus, if you havean idea check to see that no one else is working on it (posting on theabove bulletin board or sending an email should be sufficient to findif someone is working on the idea and if you can collaborate withthem.)We don't like messages asking us to implement features. Everybodyhas a list a mile long. Instead, contribute by writing code or pointingout very clearly a bug. To report a bug, tell us the version numberof the program ("./gnuchess --version").The code is provided for the purpose of encouraging you to do theprogramming. If you lack the programming skills to do so, trydabbling in it. You might surprise yourself.DATA STRUCTURESThe primary data structure of GNU Chess is the bitboard. A bitboardis a 64-bit GNU C long long. It represents characteristics of a position.For example, 12 bitboards are sufficient to describe the whereaboutsof all the pieces for both sides, i.e.BitBoard board.b[2][6];So for example with a knight equal to 2 and white equal to 0 all theknights are located by the reference#define white 0#define knight 2... board.b[white][knight] ...Testing whether a particular square has a knight on it could be donewithif (BitBoard[B1] & board.b[white][knight]) { ... }Another set of move arrays is helpful for calculating the simple movesof a knight or a kingMoveArray[knight or king][sq]This returns a bitmap of the squares from which a knight or kingcould move from the square sq. Squares are based at 0 for a1 (White'squeen's rook 1) and numbered left to right up until 63 for h8 (Black'sking's rook 1).Another basic data structure is the board. It is defined in common.has the Board typedef:typedef struct{BitBoard b[2][7]; /* Pieces by side (0 - white, 1 blackby piece (1 - pawn ... 6 - king */BitBoard friend[2]; /* Friendly (this side's) pieces */BitBoard blocker; /* Enemy pieces */BitBoard blockerr90;BitBoard blockerr45;BitBoard blockerr315;short ep; /* Location of en passant square */short flag; /* Relevant flags relating to castle privs */short side; /* Color of side on move 0 - white 1 - black */short material[2]; /* Total material by side not inc. king */short pmaterial[2]; /* Total pawn material by side not inc. king */short castled[2]; /* True (1) if side is castled */short king[2]; /* Location of king 0 - a1 .. 63 - h8 */} Board;Basic data structure typedefs are defined in common.h and allocated inmain.c for the most part. Please read and understand those files. Thebest way to understand data structures is to add new evaluation terms.MOVE GENERATORThis is a rotated bit-board method which is considered state-of-the-artcurrently.SEARCHBased on Professor Tony Marsland's modification to alpha-beta minimax,called Principal Variation Search (PVS), this algorithm performs credibly.EVALUATIONEvaluation in this version is quite a bit different than before.Earlier versions used piece/square tables with some end-leafevaluation (but primary pc/sq tables). These are tables filled withvalues regarding the importance of having pieces on particular squares.It was filled once, at the beginning of the search.The drawback of pc/sq tables is that the information is typically ofless and less importance the deeper a program searches because theboard changes so much. With computers getting faster and faster, deeperand deeper searches are possible and so the pc/sq tables can providemisleading direction to the program, resulting in anti-positional moves.More recently there has been a return by some to what we espouse here:full end-leaf evaluation. Further, we use bitboards (64-bit quantities)to represents characteristics of the board. This harkens back, ironicallyto the early days of computer chess when giant number-crunching machinesback in the 60's used bitmaps to describe positions.Bitboards in this version of GNU are defined using the "BitBoard" typedefdefined in common.h. main.c contains most of the bitboards and theseare accessed and used throughout the program and particularly bythe move generator and the evaluator.The evaluator in eval.c consists of a series of scoring routines likeScoreP (), ScoreN (), ScoreB (), corresponding to the piece beingscored. The routine evaluates all pieces of that type (P - pawn,N - knight, B - bishop, etc.) on the current board and returns ascore.Typically a loop is used of the formshort sq; /* Location of the piece of this type */short s; /* Score value for all piecesBitBoard b; /* Stores the bitboard representing location of the piece */s = 0; /* Score starts out as zero */b = board.b[side][knight];while (b) {sq = leadz(b);CLEARBIT (b, sq);if (piece on sq has some property)s += SOME_BONUS_OR_PENALTY; /* defined in eval.h */}return(s);As you can see, this routine locates each piece in the 64-bit mapwhere the corresponding square of the 64 is set to 1 meaning a pieceis there. Hence for example in the opening position, board.b[white][bishop]would have the 3rd and 7th low-order bits set corresponding to the originallocations of bishops in a game on C1 and F1. Likewise the valuesBitPosArray[C1] and BitPosArray[F1] can be used to return 64-bitquantities for checking specific matches as inif (BitPosArray[A1] & board.b[side][bishop])s += SOME_VERY_NEGATIVE_PENALTY_FOR_BISHOP_IN_A1_CORNERWriting evaluation code comes very naturally using these methods. Tryto avoid too many specific square checks as those are expensive. Ideasas shown in the CTL() routine can be used to check for piece placementon specific squares being advantageous or disadvantageous.Primary evaluation is done with Evaluate(). Certain specifics arecalculated which are deemed very important such as king evaluationand pawn evaluation. Then a "lazy evaluation" scenario is checkedfor which can save time. Otherwise other pieces are also evaluated.Very important for evaluation is the ability to see what board youare evaluating. Typically this should be sufficient when you addthe new term:/* ... new logic ... */{s += SOME_NEW_BONUS (define in eval.h)printf("The condition is triggered:\n");ShowBoard ();getchar();}This lets you see the board at the point the condition is triggeredwhich adds the bonus or penalty to the evaluation score.BOOKThe opening book is implemented as a simple binary file consisting ofa set of sequential records of struct hashtype as defined in the modulebook.c. This data structure is simply two part, a 64-bit HashType (seecommon.h) and a 32-bit score.The binary book stored in book.dat is compiled from the file book.pgnusing the command "book add book.pgn" into a sequential set of binaryrecords in the format as described above. book.pgn is simply a set ofgame records in portable game notation format. A set of master gamesmay be used or specific openings programmed this way for a user-changeableopening book.HASH TABLEThe hash table is simply an area of memory where information aboutpositions is stored. In this version of the program there are twotypes of hash tables: general and pawn.The general hash table size is controlled by the variable HASHSLOTSas defined in common.h. Likewise the pawn hash table size is controlledby the variable PAWNSLOTS in common.h.The number of hashtable slots can be controlled from the commandline (Type "gnuchess -help" for details), or via the interactivehashsize command.Typically middle-game searches are sped up by 25%-50% by the generalhash table and by much more in endgames where there are few pieces(because so many of the positions turn out to be cached already inthe hash table.)Pawn evaluation is traditionally expensive because there are so manythings to evaluate. The pawn hash table remembers all the differentpawn structures in the search. Typically pawn structure evaluation(without reference to pieces) may be calculated by simple tablelookup this way 90-99% of the time. Hence, any amount of pawn logicthat is pure-pawn and not related to pieces may be added without guilt.On the other hand, pawn structure that relates to pieces must berecalculated for every position. See ScoreP() in eval.cAUXILLARY FILE FORMATS.dat - binary book format, simply a 64-bit position hash and a 32-bit score.pgn - game listing like 1. e4 e5 2. Nf3 etc..epd - epd-style format using FEN notation. See tests subdirectory for example.log.nnn - record of an entire game from computer's viewpoint (thinking, etc.)game.nnn - record of an entire game, similar to .pgn but auto-generatedThe .dat file format is a simple binary format for the compiled bookwhich is read by the program when it is using book. See the section BOOKfor more detail.EPD and PGN require little introduction. These are the uniformly acceptedstandards for position recording and game recording.Note that log.nnn and game.nnn files are written at the end of a gamewhen you use the "name" command to give the computer your name. It ishighly recommended to do this since the resulting two files that matchin a monotonically-increasing extension numbered suffix may be used forreporting bugs and keeping track of your games.COMPILERSWe like GNU C in all its various forms. For Unix and Linux, use GNU C.For Microsoft Windows platforms we compile and test using Cygwin,which is a port of many GNU packages, including GCC.Cygwin may require specific run time DLL's to provide the interface,these should be provided with any executable you receive.Whilst GCC is the supported compiler, a key goal is portability. Ifyou experience problems compiling GNU Chess with a modern C compilerplease let the developers know.INTERNETGNU CHESS 5 has been tested substantially on the Free Internet ChessServers (freechess.org) with Xboard (See Zippy documentation in theXboard/Winboard distribution http://www.tim-mann.org/).GNU Chess 5.06 and later should also operate with icsDrone. Testing5.06 with icsDrone 1.5.0 showed no immediate issues.XBOARD/WINBOARDRunning the program with the "--xboard" command line parameter sets itto produce output acceptable to and accept input suitable for xboardand winboard, the graphical display front-ends with mouse interface.For historical reasons the option "xboard" does not need to bepreceeded by "--", however we would encourage the new syntax.COMMAND LIST^CTypically the interrupt key stops a search in progress,makes the move last considered best and returns to thecommand promptquitQuit the program.exitIn analysis mode this stops analysis, otherwise it quits the program.helpProduces a help blurb corresponding to this list of commands.usageProduce blurb on command line options.(Same as "gnuchess --help")bookadd - compiles book.dat from book.pgnon - enables use of bookoff - disables use of bookbest - play best move from bookworst - play worst move from bookrandom - play any move from bookprefer (default) - choose a good move from book(Method subject to variation)versionprints out the version of this program(Same as "gnuchess --version")pgnsave FILENAMEsaves the game so far to the file from memorypgnload FILENAMEloads the game in the file into memoryforcemanualMakes the program stop moving. You may now enter movesto reach some position in the future.(Same as "gnuchess --manual")whiteProgram plays black, set white to move.blackProgram plays white, set black to move.(White and black commands are mainly for icsDroneand will cause the current en-passant capturesquare to be forgotten).goComputer takes whichever side is on move and begins itsthinking immediatelyeasyDisables thinking on opponent's time(Same as "gnuchess --easy").hardEnables thinking on opponent's timepostArranges for verbose thinking output showing variation, score,time, depth, etc.If pondering (see hard) is on, the program will outputit's thinking whilst the opponent is thinking.(Also "gnuchess --post")nopostTurns off verbose thinking outputname NAMELets you input your name. Also writes the log.nnn and acorresponding game.nnn file. For details please seeauxillary file format sections.resultMostly used by Internet Chess server.activateThis command reactivates a game that has been terminated automaticallydue to checkmate or no more time on the clock. However, it does notalter those conditions. You would have to undo a move or two oradd time to the clock with level or time in that case.rating COMPUTERRATING OPPONENTRATINGInputs the estimated rating for computer and for its opponentnewSets up new game (i.e. positions in original positions)timeInputs time left in game for computer in hundredths of a second.Mostly used by Internet Chess server.otim (NOT IMPLEMENTED)Mostly used by Internet Chess server.random (NOT IMPLEMENTED)Randomizes play by perturbing the evaluation score slightly.The degree of perturbation is adjustable.hashon - enables using the memory hash table to speed searchoff - disables the memory hash tablehashsize NSets the hash table to permit storage of N positionsN is rounded down to nearest power of 2.(Also "gnuchess --hashsize=N")nullon - enables using the null move heuristic to speed searchoff - disables using the null move heuristicxboardon - enables use of xboard/winboardoff - disables use of xboard/winboard(Also "gnuchess --xboard")depth NSets the program to look N ply (half-moves) deep for everysearch it performs. If there is a checkmate or other conditionthat does not allow that depth, then it will not belevel MOVES MINUTES INCREMENTSets time control to be MOVES in MINUTES with each move givingan INCREMENT (in seconds, i.e. Fischer-style clock).loadepdloadLoads a position in EPD format from disk into memory.saveepdsaveSaves game position into EPD format from memory to disk.switchSwitches side to movesolve FILENAMEsolveepd FILENAMESolves the positions in FILENAMEremoveBacks up two moves in game historyundoBacks up one move in game historyshowboard - displays the current boardtime - displays the time settingsmoves - shows all moves using one call to routineescape - shows moves that escape from check using one call to routinenoncapture - shows non-capture movescapture - shows capture moveseval [or score] - shows the evaluation per piece and overallgame - shows moves in game historypin - shows pinned piecestestmovelist - reads in an epd file and shows legal moves for its entriescapture - reads in an epd file and shows legal captures for its entriesmovegenspeed - tests speed of move generatorcapturespeed - tests speed of capture move generatoreval - reads in an epd file and shows evaluation for its entriesevalspeed tests speed of the evaluatoranalyzeSwitches program into analysis mode, this is primarily intended forcommunicating analysis to an external interface using the Xboardchess engine protocol. It enables "force", "post", and"hard", at the same time, whilst altering theoutput format of post to conform with the engine protocol.
123version https://git-lfs.github.com/spec/v1oid sha256:2c8793da47e981d8140965ee419c3c193bb2e7339312e05f3d9a98faad9c9e1bsize 36151234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374### uVision2 Project, (C) Keil Software### Do not modify !cExt (*.c)aExt (*.s*; *.src; *.a*)oExt (*.obj)lExt (*.lib)tExt (*.txt; *.h; *.inc)pExt (*.plm)CppX (*.cpp)DaveTm { 0,0,0,0,0,0,0,0 }Target (LPC2124), 0x0003 // Tools: 'ARM-GNU'GRPOPT 1,(Chess Code),1,0,0GRPOPT 2,(Startup Code),1,0,0GRPOPT 3,(Support Code),1,0,0OPTFFF 1,1,1,0,0,0,0,0,<.\src\atak.c><atak.c>OPTFFF 1,2,1,0,0,0,0,0,<.\src\book.c><book.c>OPTFFF 1,3,1,0,0,0,0,0,<.\src\cmd.c><cmd.c>OPTFFF 1,4,1,0,0,0,0,0,<.\src\debug.c><debug.c>OPTFFF 1,5,1,0,0,0,0,0,<.\src\epd.c><epd.c>OPTFFF 1,6,1,0,0,0,0,0,<.\src\eval.c><eval.c>OPTFFF 1,7,1,268435456,0,0,0,0,<.\src\genmove.c><genmove.c>OPTFFF 1,8,1,335544320,0,0,0,0,<.\src\getopt1.c><getopt1.c>OPTFFF 1,9,1,218103808,0,501,518,0,<.\src\getopt.c><getopt.c> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,230,255,255,255,225,0,0,0,225,0,0,0,120,4,0,0,205,2,0,0 }OPTFFF 1,10,1,0,0,0,0,0,<.\src\hash.c><hash.c>OPTFFF 1,11,1,0,0,0,0,0,<.\src\hung.c><hung.c>OPTFFF 1,12,1,0,0,0,0,0,<.\src\init.c><init.c>OPTFFF 1,13,1,0,0,1,1,0,<.\src\input.c><input.c> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,230,255,255,255,150,0,0,0,150,0,0,0,107,4,0,0,130,2,0,0 }OPTFFF 1,14,1,0,0,0,0,0,<.\src\iterate.c><iterate.c>OPTFFF 1,15,1,0,0,0,0,0,<.\src\lexpgn.c><lexpgn.c>OPTFFF 1,16,1,83886080,0,278,278,0,<.\src\main.c><main.c> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,230,255,255,255,50,0,0,0,50,0,0,0,7,4,0,0,30,2,0,0 }OPTFFF 1,17,1,0,0,0,0,0,<.\src\move.c><move.c>OPTFFF 1,18,1,0,0,0,0,0,<.\src\null.c><null.c>OPTFFF 1,19,1,0,0,0,0,0,<.\src\output.c><output.c>OPTFFF 1,20,1,0,0,0,0,0,<.\src\pgn.c><pgn.c>OPTFFF 1,21,1,0,0,0,0,0,<.\src\players.c><players.c>OPTFFF 1,22,1,0,0,0,0,0,<.\src\ponder.c><ponder.c>OPTFFF 1,23,1,0,0,0,0,0,<.\src\quiesce.c><quiesce.c>OPTFFF 1,24,1,0,0,0,0,0,<.\src\random.c><random.c>OPTFFF 1,25,1,0,0,0,0,0,<.\src\repeat.c><repeat.c>OPTFFF 1,26,1,0,0,0,0,0,<.\src\search.c><search.c>OPTFFF 1,27,1,0,0,0,0,0,<.\src\solve.c><solve.c>OPTFFF 1,28,1,0,0,0,0,0,<.\src\sort.c><sort.c>OPTFFF 1,29,1,0,0,0,0,0,<.\src\swap.c><swap.c>OPTFFF 1,30,1,0,0,0,0,0,<.\src\test.c><test.c>OPTFFF 1,31,1,0,0,0,0,0,<.\src\ttable.c><ttable.c>OPTFFF 1,32,1,0,0,0,0,0,<.\src\util.c><util.c>OPTFFF 2,33,2,0,0,231,231,0,<.\startup.s><startup.s> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,230,255,255,255,150,0,0,0,150,0,0,0,107,4,0,0,130,2,0,0 }OPTFFF 3,34,1,0,0,16,16,0,<.\src\syscalls.c><syscalls.c> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,230,255,255,255,125,0,0,0,125,0,0,0,82,4,0,0,105,2,0,0 }OPTFFF 3,35,1,805306370,0,113,135,0,<.\src\graphics.c><graphics.c> { 44,0,0,0,2,0,0,0,3,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,233,255,255,255,25,0,0,0,25,0,0,0,238,3,0,0,5,2,0,0 }OPTFFF 3,36,1,587202560,0,0,0,0,<.\src\pieces.c><pieces.c>OPTFFF 3,37,1,620756992,0,0,0,0,<.\src\eeprom.c><eeprom.c>TARGOPT 1, (LPC2124)ARMCLK=12000000OPTTT 1,1,1,0OPTHX 1,65535,0,0,0OPTLX 120,65,8,<.\>OPTOX 16OPTLT 1,1,1,0,1,1,0,1,0,0,0,0OPTXL 1,1,1,1,1,1,1,0,0OPTFL 1,0,1OPTBL 0,(Data Sheet)<DATASHTS\PHILIPS\LPC2114_2124.PDF>OPTBL 1,(User Manual)<DATASHTS\PHILIPS\UM_LPC21XX_LPC22XX.PDF>OPTDL (SARM.DLL)()(DARMP.DLL)(-pLPC21xx)(SARM.DLL)()(TARMP.DLL)(-pLPC21xx)OPTDBG 44029,-1,()()()()()()()()()() (BIN\UL2ARM.DLL)()()()OPTDF 0x2OPTLE <>OPTLC <>EndOpt
123version https://git-lfs.github.com/spec/v1oid sha256:a766656bd85da0e8a33dde781a89b562a94b43416da45ed43c8d77d85415955asize 4151123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153### uVision2 Project, (C) Keil Software### Do not modify !Target (LPC2124), 0x0003 // Tools: 'ARM-GNU'Group (Chess Code)Group (Startup Code)Group (Support Code)File 1,1,<.\src\atak.c><atak.c> 0x3E386DF4File 1,1,<.\src\book.c><book.c> 0x41DC3A26File 1,1,<.\src\cmd.c><cmd.c> 0x3F002642File 1,1,<.\src\debug.c><debug.c> 0x41E413F6File 1,1,<.\src\epd.c><epd.c> 0x3EFDC284File 1,1,<.\src\eval.c><eval.c> 0x3F321E68File 1,1,<.\src\genmove.c><genmove.c> 0x3E8F78E0File 1,1,<.\src\getopt1.c><getopt1.c> 0x3E500C40File 1,1,<.\src\getopt.c><getopt.c> 0x3E500C40File 1,1,<.\src\hash.c><hash.c> 0x3EE918B4File 1,1,<.\src\hung.c><hung.c> 0x3DFF2C28File 1,1,<.\src\init.c><init.c> 0x41DC35F6File 1,1,<.\src\input.c><input.c> 0x424BCE54File 1,1,<.\src\iterate.c><iterate.c> 0x3F002CF6File 1,1,<.\src\lexpgn.c><lexpgn.c> 0x41C212A2File 1,1,<.\src\main.c><main.c> 0x424B2F0CFile 1,1,<.\src\move.c><move.c> 0x3EE8FFA2File 1,1,<.\src\null.c><null.c> 0x3DFF2C28File 1,1,<.\src\output.c><output.c> 0x424ACC8CFile 1,1,<.\src\pgn.c><pgn.c> 0x3EFDD0C4File 1,1,<.\src\players.c><players.c> 0x3EE52422File 1,1,<.\src\ponder.c><ponder.c> 0x3E1DB864File 1,1,<.\src\quiesce.c><quiesce.c> 0x3E74C1D6File 1,1,<.\src\random.c><random.c> 0x3DFF2C28File 1,1,<.\src\repeat.c><repeat.c> 0x3DFF2C28File 1,1,<.\src\search.c><search.c> 0x3F00315AFile 1,1,<.\src\solve.c><solve.c> 0x3DFF2C28File 1,1,<.\src\sort.c><sort.c> 0x3EE52422File 1,1,<.\src\swap.c><swap.c> 0x3DFF2C28File 1,1,<.\src\test.c><test.c> 0x3DFF2C28File 1,1,<.\src\ttable.c><ttable.c> 0x3F002CF8File 1,1,<.\src\util.c><util.c> 0x3DFF2C28File 2,2,<.\startup.s><startup.s> 0x424A8D12File 3,1,<.\src\syscalls.c><syscalls.c> 0x424BCDEEFile 3,1,<.\src\graphics.c><graphics.c> 0x424BD0FCFile 3,1,<.\src\pieces.c><pieces.c> 0x421235ECFile 3,1,<.\src\eeprom.c><eeprom.c> 0x4249E66AOptions 1,0,0 // Target 'LPC2124'Device (LPC2124)Vendor (Philips)Cpu (IRAM(0x40000000-0x40003FFF) IROM(0-0x3FFFF) CLOCK(60000000) CPUTYPE(ARM7TDMI))FlashUt (LPC210x_ISP.EXE ("#H" ^X $D COM1: 9600 1))StupF ()FlashDR ()DevID ()Rgf (LPC21xx.H)Mem ()C ()A ()RL ()OH ()DBC_IFX ()DBC_CMS ()DBC_AMS ()DBC_LMS ()UseEnv=0EnvBin ()EnvInc ()EnvLib ()EnvReg (�Philips\)OrgReg (�Philips\)TgStat=16OutDir (.\)OutName (gnuchess)GenApp=1GenLib=0GenHex=1Debug=1Browse=1LstDir (.\)HexSel=1MG32K=0TGMORE=0RunUsr 0 0 <>RunUsr 1 0 <>BrunUsr 0 0 <>BrunUsr 1 0 <>SVCSID <>GLFLAGS=1022GCPUTYP (ARM7TDMI)TFlagsA { 0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }OCMARM { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }OCMARAM { 0,0,0,0,64,0,64,0,0 }OCMAROM { 1,0,0,0,0,0,0,4,0 }OCMXRAM { 0,0,0,0,0,0,0,0,0 }ACCFLG { 1,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }ACMISC ()ACDEFN ()ACUDEF ()ACINCD ()AASFLG { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }AAMISC ()AADEFN ()AAUDEF ()AAINCD ()PropFld { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }IncBld=1AlwaysBuild=0GenAsm=0AsmAsm=0PublicsOnly=0StopCode=3CustArgs ()LibMods ()ALDFLAG { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }ALDTADR (0x00000000)ALDDADR (0x40000000)ALDBSSR ()ALDICLB ()ALDICDR ()ALDMISC ()ALDSCAT (gnuchess.ld)OPTDL (SARM.DLL)()(DARMP.DLL)(-pLPC21xx)(SARM.DLL)()(TARMP.DLL)(-pLPC21xx)OPTDBG 44029,-1,()()()()()()()()()() (BIN\UL2ARM.DLL)()()()FLASH1 { 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }FLASH2 ()FLASH3 (LPC210x_ISP.EXE ("#H" ^X $D COM1: 9600 1))FLASH4 ()EndOptOptions 1,1,0 // Group 'Chess Code'PropFld { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }IncBld=2AlwaysBuild=2GenAsm=2AsmAsm=2PublicsOnly=2StopCode=11CustArgs ()LibMods ()ACCFLG { 34,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }ACMISC ()ACDEFN ()ACUDEF ()ACINCD (src)AASFLG { 10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }AAMISC ()AADEFN ()AAUDEF ()AAINCD ()EndOpt
123version https://git-lfs.github.com/spec/v1oid sha256:105d78511b7911a777dbaee3b7ecd9b65032375732170961accf2f6f7744abe2size 4711-T gnuchess.ld -Wl,-Map=".\gnuchess.map",-Ttext=0x00000000,-Tdata=0x40000000 -o gnuchess.elf "atak.o" "book.o" "cmd.o" "debug.o" "epd.o" "eval.o" "genmove.o" "getopt1.o" "getopt.o" "hash.o" "hung.o" "init.o" "input.o" "iterate.o" "lexpgn.o" "main.o" "move.o" "null.o" "output.o" "pgn.o" "players.o" "ponder.o" "quiesce.o" "random.o" "repeat.o" "search.o" "solve.o" "sort.o" "swap.o" "test.o" "ttable.o" "util.o" "startup.o" "syscalls.o" "graphics.o" "pieces.o" "eeprom.o"
123version https://git-lfs.github.com/spec/v1oid sha256:56dd9692d5be14aa5d5c245e876bb4813bd55708422a7b6c5e9082c0ac7407eesize 14091123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535/* GNU Chess 5.0 - atak.c - attack codeCopyright (c) 1999-2002 Free Software Foundation, Inc.GNU Chess is based on the two research programsCobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.GNU Chess is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Chess is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Chess; see the file COPYING. If not, write tothe Free Software Foundation, Inc., 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA.Contact Info:bug-gnu-chess@gnu.orgcracraft@ai.mit.edu, cracraft@stanfordalumni.org, cracraft@earthlink.net*/#include <stdio.h>#include <string.h>#include "common.h"short SqAtakd (short sq, short side)/**************************************************************************** To determine if sq is attacked by any pieces from side.***************************************************************************/{register BitBoard *a, b, *c, d, blocker;int t;a = board.b[side];/* Knights */if (a[knight] & MoveArray[knight][sq])return (true);/* Kings */if (a[king] & MoveArray[king][sq])return (true);/* Pawns */if (a[pawn] & MoveArray[ptype[1^side]][sq])return (true);c = FromToRay[sq];blocker = board.blocker;/* Bishops & Queen */b = (a[bishop] | a[queen]) & MoveArray[bishop][sq];d = ~b & blocker;while (b){t = leadz (b);if (!(c[t] & d))return (true);CLEARBIT (b, t);}/* Rooks & Queen */b = (a[rook] | a[queen]) & MoveArray[rook][sq];d = ~b & blocker;while (b){t = leadz (b);if (!(c[t] & d))return (true);CLEARBIT (b, t);}return (false);}extern const short raybeg[];extern const short rayend[];void GenAtaks (void)/*************************************************************************** To generate the attack table.* Ataks[side][0] holds the total attack tables.* Ataks[side][pawn] holds the BitBoard of squares attacked by all pawns.**************************************************************************/{int side;int sq;register BitBoard *a, b, *t, *a0;memset (Ataks, 0, sizeof (Ataks));for (side = white; side <= black; side++){a = board.b[side];/* Knight */t = &Ataks[side][knight];b = a[knight];while (b){sq = leadz (b);CLEARBIT (b, sq);*t |= MoveArray[knight][sq];}/* Bishops */t = &Ataks[side][bishop];b = a[bishop];while (b){sq = leadz (b);CLEARBIT (b, sq);*t |= BishopAttack(sq);}/* Rooks */t = &Ataks[side][rook];b = a[rook];while (b){sq = leadz (b);CLEARBIT (b, sq);*t |= RookAttack(sq);}/* Queen */t = &Ataks[side][queen];b = a[queen];while (b){sq = leadz (b);CLEARBIT (b, sq);*t |= QueenAttack(sq);}/* King */t = &Ataks[side][king];b = a[king];while (b){sq = leadz (b);CLEARBIT (b, sq);*t |= MoveArray[king][sq];}/* pawns */t = &Ataks[side][pawn];if (side == white){b = board.b[white][pawn] & ~FileBit[0];*t |= (b >> 7);b = board.b[white][pawn] & ~FileBit[7];*t |= (b >> 9);}else{b = board.b[black][pawn] & ~FileBit[0];*t |= (b << 9);b = board.b[black][pawn] & ~FileBit[7];*t |= (b << 7);}a0 = Ataks[side];a0[0] = a0[pawn] | a0[knight] | a0[bishop] | a0[rook] |a0[queen] | a0[king];}}BitBoard AttackTo (int sq, int side)/***************************************************************************** Generate a bitboard of all squares with pieces belonging to side* which attack sq.****************************************************************************/{register BitBoard *a, b, *c, e, blocker;int t;a = board.b[side];/* Knights */e = (a[knight] & MoveArray[knight][sq]);/* Kings */e |= (a[king] & MoveArray[king][sq]);/* Pawns */e |= (a[pawn] & MoveArray[ptype[1^side]][sq]);c = FromToRay[sq];blocker = board.blocker;/* Bishops & Queen */b = (a[bishop] | a[queen]) & MoveArray[bishop][sq];while (b){t = leadz (b);CLEARBIT (b, t);if (!(c[t] & blocker & NotBitPosArray[t]))e |= BitPosArray[t];}/* Rooks & Queen */b = (a[rook] | a[queen]) & MoveArray[rook][sq];while (b){t = leadz (b);CLEARBIT (b, t);if (!(c[t] & blocker & NotBitPosArray[t]))e |= BitPosArray[t];}return (e);}BitBoard AttackXTo (int sq, int side)/***************************************************************************** Generate a bitboard of all squares with pieces belonging to side* which attack sq. This routine is slightly different from AttackTo* as it includes X-ray attacks as well and these can go through the* opponents pieces as well (e.g. a white R will attack the squares* beyond the black R).****************************************************************************/{register BitBoard *a, b, *c, *d, e, blocker;int t;a = board.b[side];d = board.b[1^side];/* Knights */e = (a[knight] & MoveArray[knight][sq]);/* Kings */e |= (a[king] & MoveArray[king][sq]);c = FromToRay[sq];/* Bishops & Queen & Pawns */b = (a[pawn] & MoveArray[ptype[1^side]][sq]);blocker = board.blocker;blocker &= ~(a[bishop] | a[queen] | d[bishop] | d[queen] | b);b |= (a[bishop] | a[queen]) & MoveArray[bishop][sq];while (b){t = leadz (b);CLEARBIT (b, t);if (!(c[t] & blocker & NotBitPosArray[t]))e |= BitPosArray[t];}/* Rooks & Queen */b = (a[rook] | a[queen]) & MoveArray[rook][sq];blocker = board.blocker;blocker &= ~(a[rook] | a[queen] | d[rook] | d[queen]);while (b){t = leadz (b);CLEARBIT (b, t);if (!(c[t] & blocker & NotBitPosArray[t]))e |= BitPosArray[t];}return (e);}BitBoard AttackFrom (int sq, int piece, int side)/***************************************************************************** Generate a bitboard of all squares attacked by a piece on sq.****************************************************************************/{switch (piece){case pawn :return (MoveArray[ptype[side]][sq]);case knight :return (MoveArray[knight][sq]);case bishop :return (BishopAttack(sq));case rook :return (RookAttack(sq));case queen :return (QueenAttack(sq));case king :return (MoveArray[king][sq]);}return (0);}BitBoard AttackXFrom (int sq, int side)/***************************************************************************** Generate a bitboard of all squares attacked by a piece on sq. This* routine is different from AttackFrom in that it includes Xray attacks.* Caveat: This routine does not take into account xrays through pawns.****************************************************************************/{register BitBoard *a, b, c, blocker;int piece, dir, blocksq;a = board.b[side];piece = cboard[sq];blocker = board.blocker;b = 0;switch (piece){case pawn :b = MoveArray[ptype[side]][sq];break;case knight :b = MoveArray[knight][sq];break;case bishop : /* falls through as queens move diagnonally */case queen :blocker &= ~(a[bishop] | a[queen]);for (dir = raybeg[bishop]; dir < rayend[bishop]; dir++){c = Ray[sq][dir] & blocker;if (c == NULLBITBOARD)c = Ray[sq][dir];else{blocksq = (BitPosArray[sq] > c ? leadz (c) : trailz (c));c = FromToRay[sq][blocksq];}b |= c;}if (piece == bishop) /* Queen falls through as they move like rooks */break;blocker = board.blocker;case rook :blocker &= ~(a[rook] | a[queen]);for (dir = raybeg[rook]; dir < rayend[rook]; dir++){c = Ray[sq][dir] & blocker;if (c == NULLBITBOARD)c = Ray[sq][dir];else{blocksq = (BitPosArray[sq] > c ? leadz (c) : trailz (c));c = FromToRay[sq][blocksq];}b |= c;}break;case king :b = MoveArray[king][sq];break;}return (b);}int PinnedOnKing (int sq, int side)/***************************************************************************** Determine if the piece on sq is pinned against the King.* Side is the color of the piece.* Caveat: PinnedOnKing should only be called by GenCheckEscapes().* The more generic FindPins() function should be used for evaluating* pins against other pieces.****************************************************************************/{int xside;int KingSq, dir, sq1;BitBoard b, blocker;KingSq = board.king[side];if ((dir = directions[KingSq][sq]) == -1)return (false);xside = 1 ^ side;blocker = board.blocker;/* Path from piece to king is blocked, so no pin */if (FromToRay[KingSq][sq] & NotBitPosArray[sq] & blocker)return (false);b = (Ray[KingSq][dir] ^ FromToRay[KingSq][sq]) & blocker;if (b == NULLBITBOARD)return (false);sq1 = (sq > KingSq ? leadz (b) : trailz (b));/* If diagonal */if (dir <= 3 &&BitPosArray[sq1] & (board.b[xside][queen] | board.b[xside][bishop]))return (true);/* Rank / file */if (dir >= 4 &&BitPosArray[sq1] & (board.b[xside][queen] | board.b[xside][rook]))return (true);return (false);}void FindPins (BitBoard *pin)/***************************************************************************** This function creates a bitboard of all pieces which are pinned.****************************************************************************/{int side, xside;int sq, sq1;BitBoard b, c, e, f, t, *p;*pin = NULLBITBOARD;t = board.friends[white] | board.friends[black];for (side = white; side <= black; side++){xside = 1^side;p = board.b[xside];/* Check if bishop is pinning anything */e = p[rook] | p[queen] | p[king];e |= (p[bishop] | p[knight]) & ~Ataks[xside][0];b = board.b[side][bishop];while (b){sq = leadz (b);CLEARBIT (b, sq);c = MoveArray[bishop][sq] & e;while (c){sq1 = leadz (c);CLEARBIT (c, sq1);f = t & NotBitPosArray[sq] & FromToRay[sq1][sq];if ((board.friends[xside] & f) && nbits (f) == 1)*pin |= f;}}/* Check if rook is pinning anything */e = p[queen] | p[king];e |= (p[rook] | p[bishop] | p[knight]) & ~Ataks[xside][0];b = board.b[side][rook];while (b){sq = leadz (b);CLEARBIT (b, sq);c = MoveArray[rook][sq] & e;while (c){sq1 = leadz (c);CLEARBIT (c, sq1);f = t & NotBitPosArray[sq] & FromToRay[sq1][sq];if ((board.friends[xside] & f) && nbits (f) == 1)*pin |= f;}}/* Check if queen is pinning anything */e = board.b[xside][king];e |= (p[queen] | p[rook] | p[bishop] | p[knight]) & ~Ataks[xside][0];b = board.b[side][queen];while (b){sq = leadz (b);CLEARBIT (b, sq);c = MoveArray[queen][sq] & e;while (c){sq1 = leadz (c);CLEARBIT (c, sq1);f = t & NotBitPosArray[sq] & FromToRay[sq1][sq];if ((board.friends[xside] & f) && nbits (f) == 1)*pin |= f;}}}return ;}int MateScan (int side)/***************************************************************************** This routine scans the squares around the king to see if a Q + piece* is attacking any of them. If none, return 0, else return 1.* If the square is defended, there is no threat.* Limitations: Assume only 1 Q present.****************************************************************************/{int KingSq, QueenSq, sq;int xside;BitBoard b;xside = 1 ^ side;/* Opponent has no queen, forget it */if (board.b[xside][queen] == 0)return (0);KingSq = board.king[side];QueenSq = leadz (board.b[xside][queen]);b = QueenAttack(QueenSq) & MoveArray[king][KingSq];if (b == 0)return (0);while (b){sq = leadz (b);if (AttackTo (sq, side) == board.b[side][king] &&AttackXTo (sq, xside) != board.b[xside][queen])return (1);CLEARBIT (b, sq);}return (0);}
123version https://git-lfs.github.com/spec/v1oid sha256:908d10ffd45711827591d401a57928404b2d1b1a959d025d69c0f46f981dc776size 18451123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682/* GNU Chess 5.0 - book.c - book codeCopyright (c) 1999-2002 Free Software Foundation, Inc.GNU Chess is based on the two research programsCobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.GNU Chess is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Chess is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Chess; see the file COPYING. If not, write tothe Free Software Foundation, Inc., 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA.Contact Info:bug-gnu-chess@gnu.orgcracraft@ai.mit.edu, cracraft@stanfordalumni.org, cracraft@earthlink.netlukas@debian.org*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <errno.h>#include <unistd.h>#include "common.h"#include "book.h"#define MAXMOVES 200#define MAXMATCH 100static int bookcnt;static HashType posshash[MAXMOVES];/** This is the only authoritative variable telling us* whether a book has been allocated or not. (Other* parts may mess around with bookloaded.)*/static int book_allocated = 0;/** The last byte of magic_str should be the version* number of the format, in case we have to change it.** Format 0x01 had an index field which is now gone.** Format 0x03 uses an additional size header, which* comes directly after the magic string, and has the* number of entries as a big-endian encoded uint32_t* number.*/#define MAGIC_LENGTH 5static const char magic_str[] = "\x42\x23\x08\x15\x03";static int check_magic(FILE *f){char buf[MAGIC_LENGTH];int r;r = fread(&buf, 1, MAGIC_LENGTH, f);return (r == MAGIC_LENGTH &&memcmp(buf, magic_str, MAGIC_LENGTH) == 0);}static int write_magic(FILE *f){if (MAGIC_LENGTH != fwrite(&magic_str, 1, MAGIC_LENGTH, f)) {return BOOK_EIO;} else {return BOOK_SUCCESS;}}/* Write and read size information for the binary book */static int write_size(FILE *f, uint32_t size){unsigned char sizebuf[4];int k;for (k = 0; k < 4; k++) {sizebuf[k] = (size >> ((3-k)*8)) & 0xff;}if (1 == fwrite(&sizebuf, sizeof(sizebuf), 1, f)) {return BOOK_SUCCESS;} else {return BOOK_EIO;}}/* Returns 0 if some read error occurs */static uint32_t read_size(FILE *f){unsigned char sizebuf[4];uint32_t size = 0;int k;if (1 != fread(&sizebuf, sizeof(sizebuf), 1, f)) {return 0;}for (k = 0; k < 4; k++) {size = (size << 8) | sizebuf[k];}return size;}/** We now allocate memory for the book dynamically,* according to the size field in the header of the binary* book. However, during book building the following value* is used.*/#define MAX_DIGEST_BITS 20static int digest_bits;#define DIGEST_SIZE (1UL << digest_bits)#define DIGEST_MASK (DIGEST_SIZE - 1)static struct hashtype {uint16_t wins;uint16_t losses;uint16_t draws;HashType key;} *bookpos;static inline int is_empty(uint32_t index){returnbookpos[index].key == 0 &&bookpos[index].wins == 0 &&bookpos[index].draws == 0 &&bookpos[index].losses == 0;}/** Initial hash function, relies on the quality of the lower* bits of the 64 bit hash function*/#define DIGEST_START(i,key) \((i) = (key) & DIGEST_MASK)/** See if there is already a matching entry*/#define DIGEST_MATCH(i,the_key) \((the_key) == bookpos[i].key)/** See if the entry is empty*/#define DIGEST_EMPTY(i) is_empty(i)/** Check for collision*/#define DIGEST_COLLISION(i,key) \(!DIGEST_MATCH(i,key) && !DIGEST_EMPTY(i))/** The next macro is used in the case of hash collisions.* We use double hashing with the higher bits of the key.* In order to have the shift relatively prime to the hash* size, we OR by 1.*/#define DIGEST_NEXT(i,key) \((i) = ((i) + (((key) >> digest_bits) | 1)) & DIGEST_MASK)/* Mainly for debugging purposes */static int bookhashcollisions = 0;/** This is considered to be the limit for the hash, I chose* 95% because it is Monday... No, I am open for suggestions* for the right value, I just don't know.*/#define DIGEST_LIMIT (0.95 * DIGEST_SIZE)/** This is the record as it will be written in the binary* file in network byte order. HashType is uint64_t. To* avoid endianness and padding issues, we do not read or* write structs but put the values in an unsigned char array.*/static unsigned char buf[2+2+2+8];/* Offsets */static const int wins_off = 0;static const int losses_off = 2;static const int draws_off = 4;static const int key_off = 6;static void buf_to_book(void){HashType key;uint32_t i;key = ((uint64_t)buf[key_off] << 56)| ((uint64_t)buf[key_off+1] << 48)| ((uint64_t)buf[key_off+2] << 40)| ((uint64_t)buf[key_off+3] << 32)| ((uint64_t)buf[key_off+4] << 24)| ((uint64_t)buf[key_off+5] << 16)| ((uint64_t)buf[key_off+6] << 8)| ((uint64_t)buf[key_off+7]);/** This is an infinite loop if the hash is 100% full,* but other parts should check that this does not happen.*/for (DIGEST_START(i, key);DIGEST_COLLISION(i, key);DIGEST_NEXT(i, key))/* Skip */bookhashcollisions++;bookpos[i].wins += (buf[wins_off] << 8) | buf[wins_off +1];bookpos[i].draws += (buf[draws_off] << 8) | buf[draws_off +1];bookpos[i].losses += (buf[losses_off] << 8) | buf[losses_off+1];bookpos[i].key = key;}static void book_to_buf(uint32_t index){int k;for (k=0; k<2; k++) {buf[wins_off + k] = ((bookpos[index].wins) >> ((1-k)*8)) & 0xff;buf[draws_off + k] = ((bookpos[index].draws) >> ((1-k)*8)) & 0xff;buf[losses_off + k] = ((bookpos[index].losses) >> ((1-k)*8)) & 0xff;}for (k=0; k<8; k++) {buf[key_off + k] = ((bookpos[index].key) >> ((7-k)*8)) & 0xff;}}static int compare(const void *aa, const void *bb){const leaf *a = aa;const leaf *b = bb;if (b->score > a->score) return(1);else if (b->score < a->score) return(-1);else return(0);}/** Reads an existing binary book from f. The header must* already be skipped, when you call this function. The* variable digest_bits must be set to the correct value* before calling this function. If any book was allocated* before, it will be lost.*/static int read_book(FILE *f){if (book_allocated) {free(bookpos);book_allocated = 0;}bookpos = calloc(DIGEST_SIZE, sizeof(struct hashtype));if (bookpos == NULL) {return BOOK_ENOMEM;}book_allocated = 1;bookcnt = 0;bookhashcollisions = 0;while ( 1 == fread(&buf, sizeof(buf), 1, f) ) {buf_to_book();bookcnt++;}return BOOK_SUCCESS;}/** Return values are defined in common.h*/int BookBuilderOpen(void){FILE *rfp, *wfp;int res;if ((rfp = fopen(BOOKRUN,"rb")) != NULL) {printf("Opened existing book!\n");if (!check_magic(rfp)) {fprintf(stderr,"File %s does not conform to the current format.\n""Consider rebuilding your book.\n",BOOKRUN);return BOOK_EFORMAT;}/** We have to read the size header, but in book building we* use the maximum-sized hash table, so we discard the value.*/digest_bits = MAX_DIGEST_BITS;read_size(rfp);res = read_book(rfp);fclose(rfp);if (res != BOOK_SUCCESS) {fclose(rfp);return res;}printf("Read %d book positions\n", bookcnt);printf("Got %d hash collisions\n", bookhashcollisions);} else {wfp = fopen(BOOKRUN,"w+b");if (wfp == NULL) {fprintf(stderr, "Could not create %s file: %s\n",BOOKRUN, strerror(errno));return BOOK_EIO;}if (write_magic(wfp) != BOOK_SUCCESS) {fprintf(stderr, "Could not write to %s: %s\n",BOOKRUN, strerror(errno));return BOOK_EIO;}if (fclose(wfp) != 0) {fprintf(stderr, "Could not write to %s: %s\n",BOOKRUN, strerror(errno));return BOOK_EIO;}printf("Created new book %s!\n", BOOKRUN);rfp = fopen(BOOKRUN, "rb");if (rfp == NULL) {fprintf(stderr, "Could not open %s for reading: %s\n",BOOKRUN, strerror(errno));return BOOK_EIO;}digest_bits = MAX_DIGEST_BITS;/* We use read_book() here only to allocate memory */if (read_book(wfp) == BOOK_ENOMEM) {return BOOK_ENOMEM;}}return BOOK_SUCCESS;}/** Store the position and results of last search* if and only if in the first 10 moves of the game.* This routine is called after the computer makes its* most recent move. Lastly, after the 10th move, on* the 11th move, store the data out to the running file.*//** NOTE: Before you build a book, you have to call* BookBuilderOpen() now, after building it BookBuilderClose()* in order to actually write the book to disk.*/int BookBuilder(short result, uint8_t side){uint32_t i;/* Only first BOOKDEPTH moves */if (GameCnt > BOOKDEPTH)return BOOK_EMIDGAME;CalcHashKey();for (DIGEST_START(i, HashKey);;DIGEST_NEXT(i, HashKey)) {if (DIGEST_MATCH(i, HashKey)) {existpos++;break;} else if (DIGEST_EMPTY(i)) {if (bookcnt > DIGEST_LIMIT)return BOOK_EFULL;bookpos[i].key = HashKey;newpos++;bookcnt++;break;} else {bookhashcollisions++;}}if (side == white) {if (result == R_WHITE_WINS)bookpos[i].wins++;else if (result == R_BLACK_WINS)bookpos[i].losses++;else if (result == R_DRAW)bookpos[i].draws++;} else {if (result == R_WHITE_WINS)bookpos[i].losses++;else if (result == R_BLACK_WINS)bookpos[i].wins++;else if (result == R_DRAW)bookpos[i].draws++;}return BOOK_SUCCESS;}int BookBuilderClose(void){/** IMHO the following part needs no temporary file.* If two gnuchess invocations try to write the same* file at the same time, this goes wrong anyway.* Please correct me if I am wrong. If you generate* a temporary file, try to generate it in some writable* directory.*/FILE *wfp;unsigned int i;int errcode = BOOK_SUCCESS;wfp = fopen(BOOKRUN, "wb");if (wfp == NULL) {errcode = BOOK_EIO;goto bailout_noclose;}if (write_magic(wfp) != BOOK_SUCCESS) {errcode = BOOK_EIO;goto bailout;}if (write_size(wfp, bookcnt) != BOOK_SUCCESS) {errcode = BOOK_EIO;goto bailout;}for (i = 0; i < DIGEST_SIZE; i++) {if (!is_empty(i)) {book_to_buf(i);if (1 != fwrite(&buf, sizeof(buf), 1, wfp)) {errcode = BOOK_EIO;goto bailout;}}}printf("Got %d hash collisions\n", bookhashcollisions);bailout:if (fclose(wfp) != 0) {errcode = BOOK_EIO;}bailout_noclose:free(bookpos);book_allocated = 0;/* Let BookQuery allocate again */bookloaded = 0;return errcode;}/** Return values are defined in common.h* NOTE: This function now returns BOOK_SUCCESS on* success, which is 0. So all the possible callers* should adjust to this. (At present it is only called* in iterate.c.) It used to return 1 on success before.*/int BookQuery(int BKquery){/** BKquery denotes format; 0 text, 1 engine* In general out put is engine compliant, lines start with a blank* and end with emtpy line*/int i,j,k,icnt = 0, mcnt, found, tot, maxdistribution;int matches[MAXMATCH] ;leaf m[MAXMOVES];leaf pref[MAXMOVES];struct {uint16_t wins;uint16_t losses;uint16_t draws;} r[MAXMOVES];FILE *rfp = NULL;leaf *p;short side,xside,temp;uint32_t booksize;int res;// JKJ: No opening books!if (true || (bookloaded && !book_allocated)) {/* Something failed during loading the book */return BOOK_ENOBOOK;}if (!bookloaded) {char const * const *booktry;bookloaded = 1;for (booktry = bookbin; *booktry ; booktry++) {if (!(flags & XBOARD)) {fprintf(ofp, "Looking for opening book in %s...\n", *booktry);}rfp = fopen(*booktry, "rb");/* XXX: Any further error analysis here? -- Lukas */if (rfp == NULL) continue;if (!(flags & XBOARD))fprintf(ofp,"Read opening book (%s)...\n", *booktry);if (!check_magic(rfp)) {fprintf(stderr," File %s does not conform to the current format.\n"" Consider rebuilding it.\n\n",*booktry);fclose(rfp);rfp = NULL;} else break; /* Success, stop search */}if (rfp == NULL) {/* If appropriate print error */if (!(flags & XBOARD) || BKquery == 1)fprintf(ofp," No book found.\n\n");return BOOK_ENOBOOK;}if (!(flags & XBOARD)) {fprintf(ofp, "Loading book from %s.\n", *booktry);}/** The factor 1.06 is the minimum additional amount of* free space in the hash*/booksize = read_size(rfp) * 1.06;for (digest_bits = 1; booksize; booksize >>= 1) {digest_bits++;}res = read_book(rfp);if (res != BOOK_SUCCESS) {return res;}if (!(flags & XBOARD))fprintf(ofp,"%d hash collisions... ", bookhashcollisions);}mcnt = -1;side = board.side;xside = 1^side;TreePtr[2] = TreePtr[1];GenMoves(1);FilterIllegalMoves (1);for (p = TreePtr[1]; p < TreePtr[2]; p++) {MakeMove(side, &p->move);m[icnt].move = p->move;posshash[icnt] = HashKey;icnt++;UnmakeMove(xside,&p->move);}for (i = 0; i < icnt; i++) {for (DIGEST_START(j,posshash[i]);!DIGEST_EMPTY(j);DIGEST_NEXT(j, posshash[i])) {if (DIGEST_MATCH(j, posshash[i])) {found = 0;for (k = 0; k < mcnt; k++)if (matches[k] == i) {found = 1;break;}/* Position must have at least some wins to be played by book */if (!found) {matches[++mcnt] = i;pref[mcnt].move = m[matches[mcnt]].move;r[i].losses = bookpos[j].losses;r[i].wins = bookpos[j].wins;r[i].draws = bookpos[j].draws;/* by percent score starting from this book position */pref[mcnt].score = m[i].score =100*(r[i].wins+(r[i].draws/2))/(MAX(r[i].wins+r[i].losses+r[i].draws,1)) + r[i].wins/2;}if (mcnt >= MAXMATCH) {fprintf(ofp," Too many matches in book.\n\n");goto fini;}break; /* If we found a match, the following positions can not match */}}}fini:if (!(flags & XBOARD) || BKquery == 1){fprintf(ofp," Opening database: %d book positions.\n",bookcnt);if (mcnt+1 == 0) {fprintf(ofp," In this position, there is no book move.\n\n");} else if (mcnt+1 == 1) {fprintf(ofp," In this position, there is one book move:\n");} else {fprintf(ofp," In this position, there are %d book moves:\n", mcnt+1);}}/* No book moves */if (mcnt == -1) {return BOOK_ENOMOVES;}k = 0;if (mcnt+1) {if ( !(flags & XBOARD) || BKquery == 1 ) {for (i = 0; i <= mcnt; i++) {if (!(flags & XBOARD) || BKquery == 1 ) {SANMove(m[matches[i]].move,1);tot = r[matches[i]].wins+r[matches[i]].draws+r[matches[i]].losses;fprintf(ofp," %s(%2.0f/%d/%d/%d) ",SANmv,100.0*(r[matches[i]].wins+(r[matches[i]].draws/2.0))/tot,r[matches[i]].wins,r[matches[i]].losses,r[matches[i]].draws);if ((i+1) % 4 == 0) fputc('\n',ofp);}}if (!(flags & XBOARD) || BKquery == 1 )if (i % 4 != 0) fprintf(ofp," \n \n");}if (bookmode == BOOKRAND) {k = rand();k = k % (mcnt+1);RootPV = m[matches[k]].move;if (!(flags & XBOARD)) {printf("\n(Random picked move #%d %s%s from above list)\n",k,algbr[FROMSQ(RootPV)],algbr[TOSQ(RootPV)]);tot = r[matches[k]].wins+r[matches[k]].draws+r[matches[k]].losses;if (tot != 0)printf("B p=%2.0f\n",100.0*(r[matches[k]].wins+r[matches[k]].draws)/tot);elseprintf("p=NO EXPERIENCES\n");}} else if (bookmode == BOOKBEST) {qsort(&pref,mcnt+1,sizeof(leaf),compare);RootPV = pref[0].move;} else if (bookmode == BOOKWORST) {qsort(&pref,mcnt+1,sizeof(leaf),compare);RootPV = pref[mcnt].move;} else if (bookmode == BOOKPREFER) {qsort(&pref,mcnt+1,sizeof(leaf),compare);for (i = 0; i <= mcnt; i++) {if (!(flags & XBOARD) || BKquery == 1) {SANMove(pref[i].move,1);printf(" %s(%d) ",SANmv,pref[i].score);}m[i].move = pref[i].move;if (!(flags & XBOARD) || BKquery == 1)if ((i+1) % 8 == 0) fputc('\n',ofp);}if (!(flags & XBOARD) || BKquery == 1)if (i % 8 != 0) fprintf(ofp," \n \n");temp = (bookfirstlast > mcnt+1 ? mcnt+1 : bookfirstlast);/* Choose from the top preferred moves based on distribution */maxdistribution = 0;for (i = 0; i < temp; i++)maxdistribution += pref[i].score;/* Do not play moves that have only losses! */if (maxdistribution == 0)return BOOK_ENOMOVES;k = rand() % maxdistribution;maxdistribution = 0;for (i = 0; i < temp; i++) {maxdistribution += pref[i].score;if (k >= maxdistribution - pref[i].score &&k < maxdistribution){k = i;RootPV = m[k].move;break;}}}}return BOOK_SUCCESS;}
123version https://git-lfs.github.com/spec/v1oid sha256:3506a621a457a2341ede6db3c90c360ac267ade407177421521fdadb62040a6csize 163812345678910111213141516171819202122232425262728293031323334353637383940414243444546/* GNU Chess 5.0 - book.h - book symbolic definitionsCopyright (c) 1999-2002 Free Software Foundation, Inc.GNU Chess is based on the two research programsCobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.GNU Chess is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Chess is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Chess; see the file COPYING. If not, write tothe Free Software Foundation, Inc., 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA.Contact Info:bug-gnu-chess@gnu.orgcracraft@ai.mit.edu, cracraft@stanfordalumni.org, cracraft@earthlink.net*/#define BOOKSRC "book.src"/** BookQuery() tries the following filenames in order to find* a valid opening book. The array must be NULL-terminated.*/static char const * bookbin[] = {"book.dat","/usr/share/games/gnuchess/book.dat","/usr/lib/games/gnuchess/book.dat",NULL};/* The book which BookBuilder() uses */#define BOOKRUN "book.dat"#define R_WHITE_WINS 1#define R_BLACK_WINS 2#define R_DRAW 3#define R_NORESULT 4#define BOOKDEPTH 20 /* We gobble this many moves from each PGN book game */
123version https://git-lfs.github.com/spec/v1oid sha256:9065e333c93bbbe4cb003225d36ee3651c46e9074f2356f1487a0ce3700ca5cdsize 27586123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994/* GNU Chess 5.0 - cmd.c - command parserCopyright (c) 1999-2002 Free Software Foundation, Inc.GNU Chess is based on the two research programsCobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.GNU Chess is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Chess is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Chess; see the file COPYING. If not, write tothe Free Software Foundation, Inc., 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA.Contact Info:bug-gnu-chess@gnu.orgcracraft@ai.mit.edu, cracraft@stanfordalumni.org, cracraft@earthlink.net*/#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <ctype.h>#include <errno.h>#include "version.h"#include "common.h"#include "eval.h"static char logfile[MAXSTR];static char gamefile[MAXSTR];/** Splitting input is actually not neccessary, but we find* tokens separated by whitespace and put pointers on them.* How many do we need? We just take 3 for now. Check if the* fact that tokens are not 0-terminated but whitespace-terminated* generates bugs. (Already killed one bug in move.c)* We also kill trailing whitespace. (The trailing '\n' might* be really annoying otherwise.)*/#define TOKENS 3static char *token[TOKENS];char *endptr;static void split_input(void){/* r points to the last non-space character */char *s, *r;int k;for (k = 0, s = r = inputstr; k < TOKENS; ++k) {/* Skip leading whitespace */while (isspace(*s)) s++;token[k] = s;/* Skip token */while (*s && !isspace(*s)) r = s++;}while (*s) {while (isspace(*s)) s++;while (*s && !isspace(*s)) r = s++;}r[1] = '\0';}/** Compares two tokens, returns 1 on equality. Tokens* are separated by whitespace.*/static int tokeneq(const char *s, const char *t){while (*s && *t && !isspace(*s) && !isspace(*t)) {if (*s++ != *t++) return 0;}return (!*s || isspace(*s)) && (!*t || isspace(*t));}void cmd_accepted(void) {}void cmd_activate(void){CLEAR (flags, TIMEOUT);CLEAR (flags, ENDED);}void cmd_analyze(void){/** "analyze" mode is similar to force, hard and post together* in that it produces a text output like post, but must* think indefinitely like ponder.** Some additional output is expected in command ".\n" but if ignored* this should not be sent any more*//* TODO correct output, add fail high low */if (!(flags & ANALYZE)){preanalyze_flags=flags; /* save these flags for exit */SET (flags, ANALYZE);cmd_post();cmd_force();cmd_hard();}}void cmd_bk(void){/* Print moves from Open Book for Xboard/WinBoard *//* Lines must start with " " and end with blank line *//* No need to test for xboard as it is generally useful */BookQuery(1);printf("\n"); /* Blank line */fflush(stdout);}void cmd_black(void){/** No longer used by Xboard but requested as a feature*/NewPosition(); /* Reset some flags and settings */CLEAR ( flags, THINK);CLEAR ( flags, MANUAL);CLEAR (flags, TIMEOUT);computer = white;if ( board.side == white ) {board.side = black;board.ep = -1;}}void cmd_book(void){if (tokeneq(token[1], "add")) {if (access(token[2], F_OK) < 0) {printf("The syntax to add a new book is:\n\n\tbook add file.pgn\n");} else {BookPGNReadFromFile (token[2]);}} else if (tokeneq (token[1], "on") || tokeneq(token[1], "prefer")) {bookmode = BOOKPREFER;printf("book now on.\n");} else if (tokeneq (token[1], "off")) {bookmode = BOOKOFF;printf("book now off.\n");} else if (tokeneq (token[1], "best")) {bookmode = BOOKBEST;printf("book now best.\n");} else if (tokeneq (token[1], "worst")) {bookmode = BOOKWORST;printf("book now worst.\n");} else if (tokeneq (token[1], "random")) {bookmode = BOOKRAND;printf("book now random.\n");}}/* Our opponent is a computer */void cmd_computer(void) {}void cmd_depth(void){SearchDepth = atoi (token[1]);printf("Search to a depth of %d\n",SearchDepth);}/* Ignore draw offers */void cmd_draw(void) {}void cmd_easy(void) { CLEAR (flags, HARD); }/* Predecessor to setboard */void cmd_edit(void){if ( flags & XBOARD ) {printf("tellusererror command 'edit' not implemented\n");fflush(stdout);}}void cmd_epd(void){ParseEPD (token[1]);NewPosition();ShowBoard();printf ("\n%s : Best move = %s\n", id, solution);}void cmd_exit(void){/** "exit" is a synonym for quit except in engine mode* when it means leave analyze mode*/if ( flags & ANALYZE ){flags = preanalyze_flags ; /* this implicitly clears ANALYZE flag */} else {cmd_quit();}}void cmd_force(void) { SET (flags, MANUAL); }void cmd_go(void){SET (flags, THINK);CLEAR (flags, MANUAL);CLEAR (flags, TIMEOUT);CLEAR (flags, ENDED);computer = board.side;}void cmd_hard(void) { SET (flags, HARD); }void cmd_hash(void){if (tokeneq (token[1], "off"))CLEAR (flags, USEHASH);else if (tokeneq (token[1], "on"))SET (flags, USEHASH);printf ("Hashing %s\n", flags & USEHASH ? "on" : "off");}void cmd_hashsize(void){if (token[1][0] == 0) {printf("Current HashSize is %d slots\n", HashSize);} else {int i;/* i = atoi (token[1]); */errno = 0;i = strtol (token[1], &endptr, 10);if ( errno != 0 || *endptr != '\0' ){printf("Hashsize out of Range or Invalid\n");}else {CalcHashSize(i);InitHashTable ();}}}/* Give a possible move for the player to play */void cmd_hint(void){if ( flags & ENDED ){printf("The game is over.\n");} else {int HintMove;HintMove = TreePtr[1]->move; /* Pick first move in tree */if (IsLegalMove(HintMove)){GenMoves(1);SANMove(TreePtr[1]->move,1);printf("Hint: %s\n", SANmv);} else {printf("No hint available at this time\n");}}fflush(stdout);}void cmd_level(void){SearchDepth = 0;sscanf (token[1], "%d %f %d", &TCMove, &TCTime, &TCinc);if (TCMove == 0) {TCMove = 35 /* MIN((5*(GameCnt+1)/2)+1,60) */;printf("TCMove = %d\n",TCMove);suddendeath = 1;} elsesuddendeath = 0;if (TCTime == 0) {SET (flags, TIMECTL);SearchTime = TCinc / 2.0f ;printf("Fischer increment of %d seconds\n",TCinc);} else {SET (flags, TIMECTL);MoveLimit[white] = MoveLimit[black] = TCMove - (GameCnt+1)/2;TimeLimit[white] = TimeLimit[black] = TCTime * 60;if (!(flags & XBOARD)) {printf ("Time Control: %d moves in %.2f secs\n",MoveLimit[white], TimeLimit[white]);printf("Fischer increment of %d seconds\n",TCinc);}}}void cmd_list(void){if (token[1][0] == '?') {printf("name - list known players alphabetically\n");printf("score - list by GNU best result first \n");printf("reverse - list by GNU worst result first\n");} else {if (token[1][0] == '\0') DBListPlayer("rscore");else DBListPlayer(token[1]);}}void cmd_load(void){LoadEPD (token[1]);if (!ValidateBoard()) {SET (flags, ENDED);printf ("Board is wrong!\n");}}void cmd_manual(void) { SET (flags, MANUAL); }/* Move now, not applicable */void cmd_movenow(void) {}/** TODO: Add a logpath variable or macro, not always dump into current* dir. Again, how does one handle paths portably across Unix/Windows?* -- Lukas*/void cmd_name(void){int suffix = 0;/* name[sizeof name - 1] should always be 0 */strncpy(name, token[1], sizeof name - 1);for (suffix = 0; suffix < 1000; suffix++) {sprintf(logfile,"log.%03d",suffix);sprintf(gamefile,"game.%03d",suffix);/** There is an obvious race condition here but who cares, we just* bail out in case of failure... --Lukas*/if (access(logfile,F_OK) < 0) {ofp = fopen(logfile,"w");if (ofp == NULL) {ofp = stdout;fprintf(stderr, "Failed to open %s for writing: %s\n",logfile, strerror(errno));}return;}}fprintf(stderr, "Could not create logfile, all slots occupied.\n");fprintf(stderr, "You may consider deleting or renaming your existing logfiles.\n");}void cmd_new(void){InitVars ();NewPosition ();/* Protocol specification for ANALYZE says "new" does not end analysis */if (!(flags & ANALYZE))CLEAR (flags, MANUAL);CLEAR (flags, THINK);myrating = opprating = 0;}void cmd_nopost(void) { CLEAR (flags, POST); }void cmd_null(void){if (tokeneq (token[1], "off"))CLEAR (flags, USENULL);else if (tokeneq (token[1], "on"))SET (flags, USENULL);printf ("Null moves %s\n", flags & USENULL ? "on" : "off");}void cmd_otim(void) {}void cmd_pgnload(void) { PGNReadFromFile (token[1]); }/** XXX - Filenames with spaces will break here,* do we want to support them? I vote for "no"* - Lukas*/void cmd_pgnsave(void){if ( strlen(token[1]) > 0 )PGNSaveToFile (token[1], "");elseprintf("Invalid filename.\n");}void cmd_ping(void){/* If ping is received when we are on move, we are supposed toreply only after moving. In this version of GNU Chess, wenever read commands while we are on move, so we don't have toworry about that here. */printf("pong %s\n", token[1]);fflush(stdout);}void cmd_post(void) { SET (flags, POST); }void cmd_protover(void){if (flags & XBOARD) {/* Note: change this if "draw" command is added, etc. */printf("feature setboard=1 analyze=1 ping=1 draw=0 sigint=0"" variants=\"normal\" myname=\"%s %s\" done=1\n",PROGRAM, VERSION);fflush(stdout);}}void cmd_quit(void) { SET (flags, QUIT); }void cmd_random(void) {}void cmd_rating(void){myrating = atoi(token[1]);opprating = atoi(token[2]);fprintf(ofp,"my rating = %d, opponent rating = %d\n",myrating,opprating);/* Change randomness of book based on opponent rating. *//* Basically we play narrower book the higher the opponent */if (opprating >= 1700) bookfirstlast = 2;else if (opprating >= 1700) bookfirstlast = 2;else bookfirstlast = 2;}void cmd_rejected(void) {}void cmd_remove(void){if (GameCnt >= 0) {CLEAR (flags, ENDED);CLEAR (flags, TIMEOUT);UnmakeMove (board.side, &Game[GameCnt].move);if (GameCnt >= 0) {UnmakeMove (board.side, &Game[GameCnt].move);if (!(flags & XBOARD))ShowBoard ();}PGNSaveToFile ("game.log","");} elseprintf ("No moves to undo! \n");}void cmd_result(void){if (ofp != stdout) {fprintf(ofp, "result: %s\n",token[1]);fclose(ofp);ofp = stdout;printf("Save to %s\n",gamefile);PGNSaveToFile (gamefile, token[1]);DBUpdatePlayer (name, token[1]);}}void cmd_save(void){if ( strlen(token[1]) > 0 )SaveEPD (token[1]);elseprintf("Invalid filename.\n");}void cmd_setboard(void){/* setboard uses FEN, not EPD, but ParseEPD will accept FEN too */ParseEPD (token[1]);NewPosition();}void cmd_solve(void) { Solve (token[1]); }/* Set total time for move to be N seconds is "st N" */void cmd_st(void){/* Approximately level 1 0 N */sscanf(token[1],"%d",&TCinc);suddendeath = 0 ;/* Allow a little fussiness for failing low etc */SearchTime = TCinc * 0.90f ;CLEAR (flags, TIMECTL);}void cmd_switch(void){board.side = 1^board.side;board.ep = -1 ; /* Enpassant doesn't apply after switch */printf ("%s to move\n", board.side == white ? "White" : "Black");}void cmd_time(void){TimeLimit[1^board.side] = atoi(token[1]) / 100.0f ;}void cmd_undo(void){if (GameCnt >= 0)UnmakeMove (board.side, &Game[GameCnt].move);elseprintf ("No moves to undo! \n");MoveLimit[board.side]++;TimeLimit[board.side] += Game[GameCnt+1].et;if (!(flags & XBOARD)) ShowBoard ();}void cmd_usage(void){printf ("\n"" Usage: %s [OPTION]\n""\n"" -h, --help display this help and exit\n"" -v, --version display version information and exit\n""\n"" -x, --xboard start in engine mode\n"" -p, --post start up showing thinking\n"" -e, --easy disable thinking in opponents time\n"" -m, --manual enable manual mode\n"" -s size, --hashsize=size specify hashtable size in slots\n""\n"" Options xboard and post are accepted without leading dashes\n"" for backward compatibility\n""\n""Report bugs to <bug-gnu-chess@gnu.org>.\n""\n", progname);}/* Play variant, we instruct interface in protover we play normal */void cmd_variant(void) {}void cmd_version(void){if (!(flags & XBOARD))printf ("%s %s\n", PROGRAM, VERSION);elseprintf ("Chess\n");}void cmd_white(void){/** No longer used by Xboard but requested as a feature*/NewPosition(); /* Reset some flags and settings */CLEAR ( flags, THINK);CLEAR ( flags, MANUAL);CLEAR (flags, TIMEOUT);computer = black;if ( board.side == black ){board.side = white;board.ep = -1; /* Hack to fixed appearing pawn bug */}}void cmd_xboard(void){if (tokeneq (token[1], "off"))CLEAR (flags, XBOARD);else if (tokeneq (token[1], "on"))SET (flags, XBOARD);else if (!(flags & XBOARD)) { /* set if unset and only xboard called */SET (flags, XBOARD); /* like in xboard/winboard usage */}}/** Command with subcommands, could write secondary method* tables here*/void cmd_show (void)/************************************************************************** The show command driver section.*************************************************************************/{if (tokeneq (token[1], "board"))ShowBoard ();else if (tokeneq (token[1], "rating")){printf("My rating = %d\n",myrating);printf("Opponent rating = %d\n",opprating);}else if (tokeneq (token[1], "time"))ShowTime ();else if (tokeneq (token[1], "moves")) {GenCnt = 0;TreePtr[2] = TreePtr[1];GenMoves (1);ShowMoveList (1);printf ("No. of moves generated = %ld\n", GenCnt);}else if (tokeneq (token[1], "escape")) {GenCnt = 0;TreePtr[2] = TreePtr[1];GenCheckEscapes (1);ShowMoveList (1);printf ("No. of moves generated = %ld\n", GenCnt);}else if (tokeneq (token[1], "noncapture")){GenCnt = 0;TreePtr[2] = TreePtr[1];GenNonCaptures (1);FilterIllegalMoves (1);ShowMoveList (1);printf ("No. of moves generated = %ld\n", GenCnt);}else if (tokeneq (token[1], "capture")){GenCnt = 0;TreePtr[2] = TreePtr[1];GenCaptures (1);FilterIllegalMoves (1);ShowMoveList (1);printf ("No. of moves generated = %ld\n", GenCnt);}else if (tokeneq (token[1], "eval") || tokeneq (token[1], "score")){int s, wp, bp, wk, bk;BitBoard *b;phase = PHASE;GenAtaks ();FindPins (&pinned);hunged[white] = EvalHung(white);hunged[black] = EvalHung(black);b = board.b[white];pieces[white] = b[knight] | b[bishop] | b[rook] | b[queen];b = board.b[black];pieces[black] = b[knight] | b[bishop] | b[rook] | b[queen];wp = ScoreP (white);bp = ScoreP (black);wk = ScoreK (white);bk = ScoreK (black);printf ("White: Mat:%4d/%4d P:%d N:%d B:%d R:%d Q:%d K:%d Dev:%d h:%d x:%d\n",board.pmaterial[white], board.material[white], wp, ScoreN(white),ScoreB(white), ScoreR(white), ScoreQ(white), wk,ScoreDev(white), hunged[white], ExchCnt[white]);printf ("Black: Mat:%4d/%4d P:%d N:%d B:%d R:%d Q:%d K:%d Dev:%d h:%d x:%d\n",board.pmaterial[black], board.material[black], bp, ScoreN(black),ScoreB(black), ScoreR(black), ScoreQ(black), bk,ScoreDev(black), hunged[black], ExchCnt[black]);printf ("Phase: %d\t", PHASE);s = ( EvaluateDraw () ? DRAWSCORE : Evaluate (-INFINITY, INFINITY));printf ("score = %d\n", s);printf ("\n");}else if (tokeneq (token[1], "game"))ShowGame ();else if (tokeneq (token[1], "pin")){BitBoard b;GenAtaks ();FindPins (&b);ShowBitBoard (&b);}}void cmd_test (void)/*************************************************************************** The test command driver section.**************************************************************************/{if (tokeneq (token[1], "movelist"))TestMoveList ();else if (tokeneq (token[1], "capture"))TestCaptureList ();else if (tokeneq (token[1], "movegenspeed"))TestMoveGenSpeed ();else if (tokeneq (token[1], "capturespeed"))TestCaptureGenSpeed ();else if (tokeneq (token[1], "eval"))TestEval ();else if (tokeneq (token[1], "evalspeed"))TestEvalSpeed ();}/** This is more or less copied from the readme, and the* parser is not very clever, so the lines containing* command names should not be indented, the lines with* explanations following them should be indented. Do not* use tabs for indentation, only spaces. CAPITALS are* reserved for parameters in the command names. The* array must be terminated by two NULLs.** This one should be integrated in the method table.* (Very much like docstrings in Lisp.)*/static const char * const helpstr[] = {"^C"," Typically the interrupt key stops a search in progress,"," makes the move last considered best and returns to the"," command prompt","quit"," quit the program.","exit"," In analysis mode this stops analysis, otherwise it quits the program.","help"," Produces a help blurb corresponding to this list of commands.","book"," add - compiles book.dat from book.pgn"," on - enables use of book"," off - disables use of book"," worst - play worst move from book"," best - play best move from book"," prefer - default, same as 'book on'"," random - play any move from book","version"," prints out the version of this program","pgnsave FILENAME"," saves the game so far to the file from memory","pgnload FILENAME"," loads the game in the file into memory","force","manual"," Makes the program stop moving. You may now enter moves"," to reach some position in the future."," ","white"," Program plays white","black"," Program plays black","go"," Computer takes whichever side is on move and begins its"," thinking immediately","post"," Arranges for verbose thinking output showing variation, score,"," time, depth, etc.","nopost"," Turns off verbose thinking output","name NAME"," Lets you input your name. Also writes the log.nnn and a"," corresponding game.nnn file. For details please see"," auxillary file format sections.","result"," Mostly used by Internet Chess server.","activate"," This command reactivates a game that has been terminated automatically"," due to checkmate or no more time on the clock. However, it does not"," alter those conditions. You would have to undo a move or two or"," add time to the clock with level or time in that case.","rating COMPUTERRATING OPPONENTRATING"," Inputs the estimated rating for computer and for its opponent","new"," Sets up new game (i.e. positions in original positions)","time"," Inputs time left in game for computer in hundredths of a second."," Mostly used by Internet Chess server.","hash"," on - enables using the memory hash table to speed search"," off - disables the memory hash table","hashsize N"," Sets the hash table to permit storage of N positions","null"," on - enables using the null move heuristic to speed search"," off - disables using the null move heuristic","xboard"," on - enables use of xboard/winboard"," off - disables use of xboard/winboard","depth N"," Sets the program to look N ply (half-moves) deep for every"," search it performs. If there is a checkmate or other condition"," that does not allow that depth, then it will not be ","level MOVES MINUTES INCREMENT"," Sets time control to be MOVES in MINUTES with each move giving"," an INCREMENT (in seconds, i.e. Fischer-style clock).","load","epdload"," Loads a position in EPD format from disk into memory.","save","epdsave"," Saves game position into EPD format from memory to disk.","switch"," Switches side to move","solve FILENAME","solveepd FILENAME"," Solves the positions in FILENAME","remove"," Backs up two moves in game history","undo"," Backs up one move in game history","usage"," Display command line syntax","show"," board - displays the current board"," time - displays the time settings"," moves - shows all moves using one call to routine"," escape - shows moves that escape from check using one call to routine"," noncapture - shows non-capture moves"," capture - shows capture moves"," eval [or score] - shows the evaluation per piece and overall"," game - shows moves in game history"," pin - shows pinned pieces","test"," movelist - reads in an epd file and shows legal moves for its entries"," capture - reads in an epd file and shows legal captures for its entries"," movegenspeed - tests speed of move generator"," capturespeed - tests speed of capture move generator"," eval - reads in an epd file and shows evaluation for its entries"," evalspeed tests speed of the evaluator","bk"," show moves from opening book.",NULL,NULL};void cmd_help (void)/**************************************************************************** Display all the help commands.***************************************************************************/{const char * const *p;int count, len;if (strlen(token[1])>0) {for (p=helpstr, count=0; *p; p++) {if (strncmp(*p, token[1], strlen(token[1])) == 0) {puts(*p);while (*++p && **p != ' ') /* Skip aliases */ ;for (; *p && **p == ' '; p++) {puts(*p);}return;}}printf("Help for command %s not found\n\n", token[1]);}printf("List of commands: (help COMMAND to get more help)\n");for (p=helpstr, count=0; *p; p++) {len = strcspn(*p, " ");if (len > 0) {count += printf("%.*s ", len, *p);if (count > 60) {count = 0;puts("");}}}puts("");}/** Try a method table, one could also include the documentation* strings here*/struct methodtable {const char *name;void (*method) (void);};/* Last entry contains to NULL pointers *//* List commands we don't implement to avoid illegal moving them */const struct methodtable commands[] = {{ "?", cmd_movenow },{ "accepted", cmd_accepted },{ "activate", cmd_activate },{ "analyze", cmd_analyze },{ "bk", cmd_bk },{ "black", cmd_black },{ "book", cmd_book },{ "computer", cmd_computer },{ "depth", cmd_depth },{ "draw", cmd_draw },{ "easy", cmd_easy },{ "edit", cmd_edit },{ "epd", cmd_epd },{ "epdload", cmd_load },{ "epdsave", cmd_save },{ "exit", cmd_exit },{ "force", cmd_force },{ "go", cmd_go },{ "hard", cmd_hard },{ "hash", cmd_hash },{ "hashsize", cmd_hashsize },{ "help", cmd_help },{ "hint", cmd_hint },{ "level", cmd_level },{ "list", cmd_list },{ "load", cmd_load },{ "manual", cmd_manual },{ "name", cmd_name },{ "new", cmd_new },{ "nopost", cmd_nopost },{ "null", cmd_null },{ "otim", cmd_otim },{ "pgnload", cmd_pgnload },{ "pgnsave", cmd_pgnsave },{ "ping", cmd_ping },{ "post", cmd_post },{ "protover", cmd_protover },{ "quit", cmd_quit },{ "random", cmd_random },{ "rating", cmd_rating },{ "rejected", cmd_rejected },{ "remove", cmd_remove },{ "result", cmd_result },{ "save", cmd_save },{ "setboard", cmd_setboard },{ "show", cmd_show },{ "solve", cmd_solve },{ "solveepd", cmd_solve },{ "st", cmd_st },{ "switch", cmd_switch },{ "test", cmd_test },{ "time", cmd_time },{ "undo", cmd_undo },{ "usage", cmd_usage },{ "variant", cmd_variant },{ "version", cmd_version },{ "white", cmd_white },{ "xboard", cmd_xboard },{ NULL, NULL }};void parse_input(void)/*************************************************************************** This is the main user command interface driver.**************************************************************************/{leaf *ptr;const struct methodtable * meth;dbg_printf("parse_input() called, inputstr = *%s*\n", inputstr);split_input();for (meth = commands; meth->name != NULL; meth++) {if (tokeneq(token[0], meth->name)) {meth->method();return;}}/* OK, no known command, this should be a move */ptr = ValidateMove (token[0]);if (ptr != NULL) {SANMove (ptr->move, 1);MakeMove (board.side, &ptr->move);strcpy (Game[GameCnt].SANmv, SANmv);printf("%d. ",GameCnt/2+1);printf("%s",token[0]);if (ofp != stdout) {fprintf(ofp,"%d. ",GameCnt/2+1);fprintf(ofp,"%s",token[0]);}putchar('\n');fflush(stdout);if (ofp != stdout) {fputc('\n',ofp);fflush(ofp);}if (!(flags & XBOARD)) ShowBoard ();SET (flags, THINK);}else {/** Must Output Illegal move to prevent Xboard accepting illegal* en passant captures and other subtle mistakes*/printf("Illegal move: %s\n",token[0]);fflush(stdout);}}
123version https://git-lfs.github.com/spec/v1oid sha256:e855da4a9c0bb4d96e71b79761d1f7cca2d5dc3212b152f6f0bbe9dfafc5f44fsize 24657123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864/* GNU Chess 5.0 - common.h - common symbolic definitionsCopyright (c) 1999-2002 Free Software Foundation, Inc.GNU Chess is based on the two research programsCobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.GNU Chess is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Chess is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Chess; see the file COPYING. If not, write tothe Free Software Foundation, Inc., 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA.Contact Info:bug-gnu-chess@gnu.orgcracraft@ai.mit.edu, cracraft@stanfordalumni.org, cracraft@earthlink.net*/#ifndef COMMON_H#define COMMON_H#include <config.h>#ifndef __GNUC__# define __attribute__(x)#endif/** Include "uint64_t" and similar types using the ac_need_stdint_h ac macro*/#include "GCint.h"#include <stdio.h>#include <sys/types.h>/** Define time structures to get timeval for Timer*/#include <sys/time.h>/** Define macro for declaring 64bit constants for compilers not using ULL*/#ifdef _MSC_VER#define ULL(x) ((uint64_t)(x))#else#define ULL(x) x ## ULL#endif/** BitBoard is a key data type. It is a 64-bit value, in which each* bit represents a square on the board as defined by "enum Square".* Thus, bit position 0 represents a fact about square a1, and bit* position 63 represents a fact about square h8. For example, the* bitboard representing "white rook" positions will have a bit set* for every position occupied on the board by a white rook.*/typedef uint64_t BitBoard;typedef uint64_t HashType;typedef uint32_t KeyType;/** Board represents an entire board's state, and is structured to* simplify analysis:*/typedef struct{BitBoard b[2][7]; /* piece/pawn positions by side (0=white, 1=black)and then by piece (1=pawn..6=king). For example,b[white][knight] has bits set for every boardposition occupied by a White Knight. */BitBoard friends[2]; /* Friendly (this side's) pieces */BitBoard blocker;BitBoard blockerr90; /* rotated 90 degrees */BitBoard blockerr45; /* rotated 45 degrees */BitBoard blockerr315; /* rotated 315 degrees */short ep; /* Location of en passant square */short flag; /* Flags related to castle privileges */short side; /* Color of side on move: 0=white, 1=black */short material[2]; /* Total material by side not inc. king */short pmaterial[2]; /* Total pawn material by side not inc. king */short castled[2]; /* True (1) if side is castled */short king[2]; /* Location of king 0 - a1 .. 63 - h8 */} Board;/* leaf describes a leaf-level analysis result */typedef struct{int move; /* the move that produced this particular board */int score; /* the scored value of this leaf */} leaf;/** GameRec records an individual move made in the game; an entire* Game is a set of GameRec's:*/#define SANSZ 8 /* longest move is "exf8=Q+" so 7+1 */typedef struct{int move; /* The actual move made; this is NOT the move count! */short epsq; /* en passant square */short bflag; /* Flags for castle privs, see Board.flag */short Game50; /* The last value of GameCnt (a count of half-moves)that castled, captured, or moved a pawn */short mvboard;float et; /* elapsed time */HashType hashkey;HashType phashkey;char SANmv[SANSZ]; /* The move in SAN notation */char *comments;} GameRec;typedef struct{HashType key; /* Full 64 bit hash */int move; /* Best move */int score; /* Estimated score, may be lower or upper bound */uint8_t flag; /* Is this alpha, beta, quiescent or exact? */uint8_t depth; /* Search depth */} HashSlot;typedef struct{KeyType pkey;BitBoard passed;BitBoard weaked;int score;int phase;} PawnSlot;/* MACRO definitions */#ifndef MAX#define MAX(a,b) ((a) > (b) ? (a) : (b))#endif#ifndef MIN#define MIN(a,b) ((a) < (b) ? (a) : (b))#endif#define SET(a,b) \do { \(a) |= (b); \dbg_printf("Set 0x%x\n", (b)); \} while (0)#define CLEAR(a,b) \do { \(a) &= ~(b); \dbg_printf("Clear 0x%x\n", (b)); \} while (0)/* Draw score can be used to penalise draws if desired */#define DRAWSCORE 0#define MATERIAL (board.material[side] - board.material[1^side])#define PHASE (8 - (board.material[white]+board.material[black]) / 1150)#define KEY(a) (a >> 32)/* Attack MACROS */#define BishopAttack(sq) \(Bishop45Atak[sq][(board.blockerr45 >> Shift45[sq]) & Mask45[sq]] | \Bishop315Atak[sq][(board.blockerr315 >> Shift315[sq]) & Mask315[sq]])#define RookAttack(sq) \(Rook00Atak[sq][(board.blocker >> Shift00[sq]) & 0xFF] | \Rook90Atak[sq][(board.blockerr90 >> Shift90[sq]) & 0xFF])#define QueenAttack(sq) \(BishopAttack(sq) | RookAttack(sq))/* Some bit macros *//** gcc 2.95.4 completely screws up the macros with lookup tables* with -O2 on PPC, maybe this check has to be refined. (I don't know* whether other architectures also suffer from this gcc bug.) However,* with gcc 3.0, the lookup tables are _much_ faster than this direct* calculation.*/#if defined(__GNUC__) && defined(__PPC__) && __GNUC__ < 3# define SETBIT(b,i) ((b) |= ((ULL(1)<<63)>>(i)))# define CLEARBIT(b,i) ((b) &= ~((ULL(1)<<63)>>(i)))#else# define SETBIT(b,i) ((b) |= BitPosArray[i])# define CLEARBIT(b,i) ((b) &= NotBitPosArray[i])#endif#define RANK(i) ((i) >> 3)#define ROW(i) ((i) & 7)#define trailz(b) (leadz ((b) & ((~b) + 1)))/* Move Descriptions (moves) are represented internally as integers.* The lowest 6 bits define the destination ("TO") square, and* the next lowest 6 bits define the source ("FROM") square,* using the values defined by "enum Square" (0=a1, 63=h8).* Upper bits are used to identify other move information such as* a promotion (and to what), a capture (and of what),* CASTLING moves, and ENPASSANT moves; see the "constants for* move description" below for more information on these upper bits.*/#define PROMOTEPIECE(a) ((a >> 12) & 0x0007)#define CAPTUREPIECE(a) ((a >> 15) & 0x0007)#define TOSQ(a) ((a) & 0x003F)#define FROMSQ(a) ((a >> 6) & 0x003F)#define MOVE(a,b) (((a) << 6) | (b))/* constants for move description */#define KNIGHTPRM 0x00002000#define BISHOPPRM 0x00003000#define ROOKPRM 0x00004000#define QUEENPRM 0x00005000#define PROMOTION 0x00007000#define PAWNCAP 0x00008000#define KNIGHTCAP 0x00010000#define BISHOPCAP 0x00018000#define ROOKCAP 0x00020000#define QUEENCAP 0x00028000#define CAPTURE 0x00038000#define NULLMOVE 0x00100000#define CASTLING 0x00200000#define ENPASSANT 0x00400000#define MOVEMASK (CASTLING | ENPASSANT | PROMOTION | 0x0FFF)#define white 0#define black 1#define false 0#define true 1#define ks 0#define qs 1#define INFINITY 32767#define MATE 32767#define MATESCORE(a) ((a) > MATE-255 || (a) < -MATE+255)/* constants for Board */#define WKINGCASTLE 0x0001#define WQUEENCASTLE 0x0002#define BKINGCASTLE 0x0004#define BQUEENCASTLE 0x0008#define WCASTLE (WKINGCASTLE | WQUEENCASTLE)#define BCASTLE (BKINGCASTLE | BQUEENCASTLE)/* Material values */#define ValueP 100#define ValueN 350#define ValueB 350#define ValueR 550#define ValueQ 1100#define ValueK 2000/* Some special BitBoards */#define NULLBITBOARD ( ULL(0x0000000000000000))#define WHITESQUARES ( ULL(0x55AA55AA55AA55AA))#define BLACKSQUARES ( ULL(0xAA55AA55AA55AA55))#define CENTRESQUARES ( ULL(0x0000001818000000))#define COMPUTERHALF ( ULL(0xFFFFFFFF00000000))#define OPPONENTHALF ( ULL(0x00000000FFFFFFFF))/* Game flags */#define QUIT 0x0001#define TESTT 0x0002#define THINK 0x0004#define MANUAL 0x0008#define TIMEOUT 0x0010#define SPARE1 0x0020#define ENDED 0x0040#define USEHASH 0x0080#define SOLVE 0x0100#define USENULL 0x0200#define XBOARD 0x0400#define TIMECTL 0x0800#define POST 0x1000#define PONDER 0x2000 /* We are in pondering (during search) */#define HARD 0x4000 /* Pondering is turned on */#define ANALYZE 0x8000 /* In ANALYZE mode *//* Node types */#define PV 0#define ALL 1#define CUT 2/* Transposition table flags */#define EXACTSCORE 1#define LOWERBOUND 2#define UPPERBOUND 3#define POORDRAFT 4#define QUIESCENT 5#define STICKY 8/* Book modes */#define BOOKOFF 0#define BOOKRAND 1#define BOOKBEST 2#define BOOKWORST 3#define BOOKPREFER 4/* The various phases during move selection */#define PICKHASH 1#define PICKGEN1 2#define PICKCAPT 3#define PICKKILL1 4#define PICKKILL2 5#define PICKGEN2 6#define PICKHIST 7#define PICKREST 8#define PICKCOUNTER 9#define MAXTREEDEPTH 2000#define MAXPLYDEPTH 65#define MAXGAMEDEPTH 600/*Smaller HASHSLOT defaults 20011017 to improve blitz playand make it easier to run on old machines*/#define HASHSLOTS 1024#define PAWNSLOTS 512extern short distance[64][64];extern short taxicab[64][64];extern unsigned char lzArray[65536];extern short Shift00[64];extern short Shift90[64];extern short Shift45[64];extern short Shift315[64];extern BitBoard DistMap[64][8];extern BitBoard BitPosArray[64];extern BitBoard NotBitPosArray[64];extern BitBoard MoveArray[8][64];extern BitBoard Ray[64][8];extern BitBoard FromToRay[64][64];extern BitBoard RankBit[8];extern BitBoard FileBit[8];extern BitBoard Ataks[2][7];extern BitBoard PassedPawnMask[2][64];extern BitBoard IsolaniMask[8];extern BitBoard SquarePawnMask[2][64];extern BitBoard Rook00Atak[64][256];extern BitBoard Rook90Atak[64][256];extern BitBoard Bishop45Atak[64][256];extern BitBoard Bishop315Atak[64][256];extern BitBoard pinned;extern BitBoard rings[4];extern BitBoard boxes[2];extern BitBoard stonewall[2];extern BitBoard pieces[2];extern BitBoard mask_kr_trapped_w[3];extern BitBoard mask_kr_trapped_b[3];extern BitBoard mask_qr_trapped_w[3];extern BitBoard mask_qr_trapped_b[3];extern BitBoard boardhalf[2];extern BitBoard boardside[2];extern short directions[64][64];extern unsigned char BitCount[65536];extern leaf Tree[MAXTREEDEPTH];extern leaf *TreePtr[MAXPLYDEPTH];extern int RootPV;extern GameRec Game[MAXGAMEDEPTH];extern int RealGameCnt;extern short RealSide;extern int GameCnt;extern int computer;extern unsigned int flags;extern unsigned int preanalyze_flags;extern Board board;extern int cboard[64];extern int Mvboard[64];extern HashType hashcode[2][7][64];extern HashType ephash[64];extern HashType WKCastlehash;extern HashType WQCastlehash;extern HashType BKCastlehash;extern HashType BQCastlehash;extern HashType Sidehash;extern HashType HashKey;extern HashType PawnHashKey;extern HashSlot *HashTab[2];extern PawnSlot *PawnTab[2];extern int Idepth;extern int SxDec;extern int Game50;extern int lazyscore[2];extern int maxposnscore[2];extern int rootscore;extern int lastrootscore;extern unsigned long GenCnt;extern unsigned long NodeCnt;extern unsigned long QuiesCnt;extern unsigned long EvalCnt;extern unsigned long EvalCall;extern unsigned long ChkExtCnt;extern unsigned long OneRepCnt;extern unsigned long RcpExtCnt;extern unsigned long PawnExtCnt;extern unsigned long HorzExtCnt;extern unsigned long ThrtExtCnt;extern unsigned long KingExtCnt;extern unsigned long NullCutCnt;extern unsigned long FutlCutCnt;extern unsigned long RazrCutCnt;extern unsigned long TotalGetHashCnt;extern unsigned long GoodGetHashCnt;extern unsigned long TotalPutHashCnt;extern unsigned long CollHashCnt;extern unsigned long TotalPawnHashCnt;extern unsigned long GoodPawnHashCnt;extern unsigned long RepeatCnt;extern unsigned HashSize;extern unsigned long TTHashMask;extern unsigned long PHashMask;extern int slider[8];extern int Value[7];extern char SANmv[SANSZ];extern unsigned long history[2][4096];extern int killer1[MAXPLYDEPTH];extern int killer2[MAXPLYDEPTH];extern int ChkCnt[MAXPLYDEPTH];extern int ThrtCnt[MAXPLYDEPTH];extern char id[32];extern char solution[64];extern float SearchTime;extern int SearchDepth;extern int MoveLimit[2];extern float TimeLimit[2];extern int TCMove;extern int TCinc;extern float TCTime;extern int hunged[2];extern int phase;extern int Hashmv[MAXPLYDEPTH];extern short RootPieces;extern short RootPawns;extern short RootMaterial;extern short RootAlpha;extern short RootBeta;extern short pickphase[MAXPLYDEPTH];extern short InChk[MAXPLYDEPTH];extern short KingThrt[2][MAXPLYDEPTH];extern short KingSafety[2];extern short pscore[64];extern short bookmode;extern short bookfirstlast;extern int range[8];extern int ptype[2];extern char algbr[64][3];extern char algbrfile[9];extern char algbrrank[9];extern char notation[8];extern char lnotation[8];extern int r90[64];extern int r45[64];extern int r315[64];extern int Mask45[64];extern int Mask315[64];extern int rank6[2];extern int rank7[2];extern int rank8[2];extern char *progname;extern FILE *ofp;extern int myrating, opprating, suddendeath;#define MAXNAMESZ 50extern char name[MAXNAMESZ];extern int computerplays;extern int wasbookmove;extern int nmovesfrombook;extern float maxtime;extern int n; /* Last mobility returned by CTL */extern int ExchCnt[2];extern int newpos, existpos; /* For book statistics */extern int bookloaded;enum Piece { empty, pawn, knight, bishop, rook, queen, king, bpawn };enum Square { A1, B1, C1, D1, E1, F1, G1, H1,A2, B2, C2, D2, E2, F2, G2, H2,A3, B3, C3, D3, E3, F3, G3, H3,A4, B4, C4, D4, E4, F4, G4, H4,A5, B5, C5, D5, E5, F5, G5, H5,A6, B6, C6, D6, E6, F6, G6, H6,A7, B7, C7, D7, E7, F7, G7, H7,A8, B8, C8, D8, E8, F8, G8, H8 };enum File { A_FILE, B_FILE, C_FILE, D_FILE, E_FILE, F_FILE, G_FILE, H_FILE };/****************************************************************************** The various function prototypes. They are group into the *.c files* in which they are defined.*****************************************************************************//** Explanation of the #ifdef NO_INLINE conditionals:** Define NO_INLINE only if you really must, implementations will be* provided by the corresponding *.c files. The better solution is to* not define it, in which case inlines.h will be included which* provides static inline version of these functions.*//* The initialization routines */void InitSystem (void);void Initialize (void);void InitLzArray (void);void InitBitPosArray (void);void InitMoveArray (void);void InitRay (void);void InitFromToRay (void);void InitRankFileBit (void);void InitBitCount (void);void InitPassedPawnMask (void);void InitIsolaniMask (void);void InitSquarePawnMask (void);void InitRandomMasks (void);void InitRotAtak (void);void InitDistance (void);void InitVars (void);void InitHashCode (void);void InitHashTable (void);void CalcHashSize (int);void NewPosition (void);void InitFICS (void);void InitInput (void);/* Cleanup routines */void CleanupInput(void);/* The book routines */int BookQuery (int);int BookBuilderOpen(void);int BookBuilder (short result, uint8_t side);int BookBuilderClose(void);/** Return values (errorcodes) for the book routines,* maybe one should have a global enum of errorcodes*/enum {BOOK_SUCCESS,BOOK_EFORMAT, /* Wrong format (e.g. produced by older version) */BOOK_EMIDGAME, /* Move is past the opening book's move limit */BOOK_EIO, /* I/O error, e.g. caused by wrong permissions */BOOK_EFULL, /* Book hash is full, new position was not added. */BOOK_ENOBOOK, /* No book present */BOOK_ENOMOVES, /* No moves found (in BookQuery() only) */BOOK_ENOMEM /* Memory allocation failed */};/* The move generation routines */void GenMoves (short);void GenCaptures (short);void GenNonCaptures (short);void GenCheckEscapes (short);void FilterIllegalMoves (short);/* The move routines */void MakeMove (int, int *);void UnmakeMove (int, int *);void MakeNullMove (int);void UnmakeNullMove (int);void SANMove (int, int);leaf *ValidateMove (char *);leaf *IsInMoveList (int, int, int, char);int IsLegalMove (int);char *AlgbrMove (int);/* The attack routines */short SqAtakd (short sq, short side);void GenAtaks (void);BitBoard AttackTo (int, int);BitBoard AttackXTo (int, int);BitBoard AttackFrom (int, int, int);BitBoard AttackXFrom (int, int);int PinnedOnKing (int, int);void FindPins (BitBoard *);int MateScan (int);/* The swap routines */int SwapOff (int);void AddXrayPiece (int, int, int, BitBoard *, BitBoard *);/* The EPD routines */short ReadEPDFile (const char *, short);int ParseEPD (char *);void LoadEPD (char *);void SaveEPD (char *);/* Error codes for ParseEPD */enum {EPD_SUCCESS,EPD_ERROR};void UpdateFriends (void);void UpdateCBoard (void);void UpdateMvboard (void);void EndSearch (int);short ValidateBoard (void);/* PGN routines */void PGNSaveToFile (const char *, const char *);void PGNReadFromFile (const char *);void BookPGNReadFromFile (const char *);int IsTrustedPlayer(const char *name);/* The hash routines */void CalcHashKey (void);void ShowHashKey (HashType);/* The evaluation routines */int ScoreP (short);int ScoreN (short);int ScoreB (short);int ScoreR (short);int ScoreQ (short);int ScoreK (short);int ScoreDev (short);int Evaluate (int, int);short EvaluateDraw (void);/* Hung routines */int EvalHung (int);/* The search routines */void Iterate (void);int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype);int SearchRoot (short depth, int alpha, int beta);int Quiesce (uint8_t ply, int alpha, int beta);void pick (leaf *, short);short Repeat (void);void ShowLine (int, int, char);/** Set up a timer by first calling StartTiming(), saving* the return value and feeding it to GetElapsed() for* timings in seconds.*/typedef struct timeval Timer;extern double ElapsedTime;extern Timer StartTime;Timer StartTiming (void);double GetElapsed (Timer start);/* The transposition table routies */void TTPut (uint8_t side, uint8_t depth, uint8_t ply,int alpha, int beta, int score, int move);/* Returns flag if it finds an entry, 0 otherwise */uint8_t TTGet (uint8_t side, uint8_t depth, uint8_t ply,int *score, int *move);short TTGetPV (uint8_t side, uint8_t ply, int score, int *move);void TTClear (void);void PTClear (void);/* Sorting routines */void SortCaptures (int);void SortMoves (int);void SortRoot (void);int PhasePick (leaf **, int);int PhasePick1 (leaf **, int);/* Some output routines */void ShowMoveList (int);void ShowSmallBoard (void);void ShowBoard (void);void ShowBitBoard (BitBoard *);void ShowCBoard (void);void ShowMvboard (void);void ShowGfxBoard (void);void ShowGame (void);void ShowTime (void);/* Random numbers routines */uint32_t Rand32 (void);HashType Rand64 (void);/* Solver routines */void Solve (char *);/* Test routines */void TestMoveGenSpeed (void);void TestNonCaptureGenSpeed (void);void TestCaptureGenSpeed (void);void TestMoveList (void);void TestNonCaptureList (void);void TestCaptureList (void);void TestEvalSpeed (void);void TestEval (void);/* Player database */void DBSortPlayer (const char *style);void DBListPlayer (const char *style);void DBReadPlayer (void);void DBWritePlayer (void);int DBSearchPlayer (const char *player);void DBUpdatePlayer (const char *player, const char *resultstr);void DBTest (void);/* Input thread and thread function */#include <pthread.h>extern pthread_t input_thread;void *input_func(void *);/** Status variable used by the input thread to signal* pending input. Thought about using flags for this* but this can be refined and is conceptually different* from flags.*/enum {INPUT_NONE,INPUT_AVAILABLE};extern volatile int input_status;/** Function to wake up the input thread, should be called after* input has been parsed.*/void input_wakeup(void);/* Wait for input. */void wait_for_input(void);/** Input routine, initialized to one of the specific* input routines. The given argument is the prompt.*/void (*getline) (char *);#define MAXSTR 128extern char inputstr[MAXSTR];/* Input parser */void parse_input(void);/* Pondering */void ponder(void);/* The command subroutines */void ShowCmd (char *);void BookCmd (char *);void TestCmd (char *);/* Commands from the input engine */void cmd_accepted(void);void cmd_activate(void);void cmd_analyze(void);void cmd_bk(void);void cmd_black(void);void cmd_book(void);void cmd_computer(void);void cmd_depth(void);void cmd_draw(void);void cmd_easy(void);void cmd_edit(void);void cmd_epd(void);void cmd_exit(void);void cmd_force(void);void cmd_go(void);void cmd_hard(void);void cmd_hash(void);void cmd_hashsize(void);void cmd_help (void);void cmd_hint(void);void cmd_level(void);void cmd_list(void);void cmd_load(void);void cmd_manual(void);void cmd_movenow(void);void cmd_name(void);void cmd_new(void);void cmd_nopost(void);void cmd_null(void);void cmd_otim(void);void cmd_pgnload(void);void cmd_pgnsave(void);void cmd_ping(void);void cmd_post(void);void cmd_protover(void);void cmd_quit(void);void cmd_random(void);void cmd_rating(void);void cmd_rejected(void);void cmd_remove(void);void cmd_result(void);void cmd_save(void);void cmd_setboard(void);void cmd_show (void);void cmd_solve(void);void cmd_st(void);void cmd_switch(void);void cmd_test (void);void cmd_time(void);void cmd_undo(void);void cmd_usage(void);void cmd_variant(void);void cmd_version(void);void cmd_white(void);void cmd_xboard(void);/** Define NO_INLINE only if you really must, implementations will be* provided by the corresponding *.c files. The better solution is to* not define it, in which case inlines.h will be included which* provides static inline version of these functions.*//* Some utility routines */#ifdef NO_INLINEunsigned char leadz (BitBoard);unsigned char nbits (BitBoard);#else# include "inlines.h"#endif/* More elaborate debugging output to logfile *//* All the following functions are no-ops if DEBUG is not defined *//** dbg_open() can be called with NULL as argument, using a default* filename, defined in debug.c, for the debug log. Otherwise the* argument is the filename. If dbg_open() fails or is not called at* all, debugging output goes to stderr by default.*/int dbg_open(const char *name);/* Same format rules as printf() */int dbg_printf(const char *fmt, ...);/* Closes the debugging log, if it is not stderr */int dbg_close(void);# ifdef DEBUG# include <assert.h># define ASSERT(x) assert(x)# else# define ASSERT(x)# endif#endif /* !COMMON_H */
123version https://git-lfs.github.com/spec/v1oid sha256:7d85afbab6f114838556afce446fc75c2197f2e6be2a555abcd91d4960beb0ccsize 4935123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173/* src/config.h. Generated by configure. *//* src/config.h.in. Generated from configure.ac by autoheader. *//* Define to 1 if you have the <errno.h> header file. */#define HAVE_ERRNO_H 1/* Define to 1 if you have the <fcntl.h> header file. */#define HAVE_FCNTL_H 1/* Define to 1 if you have the `gettimeofday' function. */#define HAVE_GETTIMEOFDAY 1/* Define to 1 if you have the <inttypes.h> header file. */#define HAVE_INTTYPES_H 1/* Define to 1 if you have the <libintl.h> header file. *//* #undef HAVE_LIBINTL_H *//* Define to 1 if you have the `ncurses' library (-lncurses). *//* #undef HAVE_LIBNCURSES *//* Define to 1 if you have the `readline' library (-lreadline). */#undef HAVE_LIBREADLINE/* Define to 1 if your system has a GNU libc compatible `malloc' function, andto 0 otherwise. */#define HAVE_MALLOC 1/* Define to 1 if you have the <memory.h> header file. */#define HAVE_MEMORY_H 1/* Define to 1 if you have the `memset' function. */#define HAVE_MEMSET 1/* Define if you have POSIX threads libraries and header files. */#undef HAVE_PTHREAD/* Define to 1 if you have the <readline/history.h> header file. */#undef HAVE_READLINE_HISTORY_H/* Define to 1 if you have the <readline/readline.h> header file. */#undef HAVE_READLINE_READLINE_H/* Define to 1 if your system has a GNU libc compatible `realloc' function,and to 0 otherwise. */#define HAVE_REALLOC 1/* Define to 1 if stdbool.h conforms to C99. */#define HAVE_STDBOOL_H 1/* Define to 1 if you have the <stdint.h> header file. */#define HAVE_STDINT_H 1/* Define to 1 if you have the <stdlib.h> header file. */#define HAVE_STDLIB_H 1/* Define to 1 if you have the `strchr' function. */#define HAVE_STRCHR 1/* Define to 1 if you have the `strcspn' function. */#define HAVE_STRCSPN 1/* Define to 1 if you have the `strdup' function. */#define HAVE_STRDUP 1/* Define to 1 if you have the `strerror' function. */#define HAVE_STRERROR 1/* Define to 1 if you have the <strings.h> header file. */#define HAVE_STRINGS_H 1/* Define to 1 if you have the <string.h> header file. */#define HAVE_STRING_H 1/* Define to 1 if you have the `strstr' function. */#define HAVE_STRSTR 1/* Define to 1 if you have the `strtol' function. */#define HAVE_STRTOL 1/* Define to 1 if you have the <sys/stat.h> header file. */#define HAVE_SYS_STAT_H 1/* Define to 1 if you have the <sys/time.h> header file. */#define HAVE_SYS_TIME_H 1/* Define to 1 if you have the <sys/types.h> header file. */#define HAVE_SYS_TYPES_H 1/* Define to 1 if you have the <time.h> header file. */#define HAVE_TIME_H 1/* Define to 1 if you have the <unistd.h> header file. */#define HAVE_UNISTD_H 1/* Define to 1 if the system has the type `_Bool'. */#define HAVE__BOOL 1/* Name of package */#define PACKAGE "gnuchess"/* Define to the address where bug reports for this package should be sent. */#define PACKAGE_BUGREPORT ""/* Define to the full name of this package. */#define PACKAGE_NAME ""/* Define to the full name and version of this package. */#define PACKAGE_STRING ""/* Define to the one symbol short name of this package. */#define PACKAGE_TARNAME ""/* Define to the version of this package. */#define PACKAGE_VERSION ""/* Define to the necessary symbol if this constant uses a non-standard name onyour system. *//* #undef PTHREAD_CREATE_JOINABLE *//* Define as the return type of signal handlers (`int' or `void'). */#define RETSIGTYPE void/* The number of bytes in type char *//* #undef SIZEOF_CHAR *//* The number of bytes in type int *//* #undef SIZEOF_INT *//* The number of bytes in type long *//* #undef SIZEOF_LONG *//* The number of bytes in type short *//* #undef SIZEOF_SHORT *//* The number of bytes in type void* *//* #undef SIZEOF_VOIDP *//* Define to 1 if you have the ANSI C header files. */#define STDC_HEADERS 1/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */#define TIME_WITH_SYS_TIME 1/* Define to 1 if your <sys/time.h> declares `struct tm'. *//* #undef TM_IN_SYS_TIME *//* Version number of package */#define VERSION "5.07"/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a`char[]'. */#define YYTEXT_POINTER 1/* Define to empty if `const' does not conform to ANSI C. *//* #undef const *//* Define as `__inline' if that's what the C compiler calls it, or to nothingif it is not supported. *//* #undef inline *//* Define to rpl_malloc if the replacement function should be used. *//* #undef malloc *//* Define to rpl_realloc if the replacement function should be used. *//* #undef realloc *//* Define to `unsigned' if <sys/types.h> does not define. *//* #undef size_t *//* Define to empty if the keyword `volatile' does not work. Warning: validcode using `volatile' can become incorrect without. Disable with care. *//* #undef volatile */
123version https://git-lfs.github.com/spec/v1oid sha256:a1f186c838c136770c76d684ac4cd4ef86a957aa13e574346a1109be59fad7c1size 154012345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273/** debug.c - Debugging output*/#include "common.h"#ifdef DEBUG#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <sys/time.h>#include <fcntl.h>#include <stdarg.h>#define MAX_DEBUG 1000#define DEBUG_FILENAME "gnuchess.debug"/* Default to stderr */static int debug_fd = 2;int dbg_open(const char *name){//int flags = O_WRONLY | O_CREAT | O_APPEND;//int mode = 0777;//if (name == NULL) {// debug_fd = open(DEBUG_FILENAME, flags, mode);//} else {// debug_fd = open(name, flags, mode);// }//if (-1 == debug_fd) {// debug_fd = 2;// return -1;///}dbg_printf("--- Opening debug log ---\n");return debug_fd;}int dbg_close(void){/* We don't want to close stderr */if (debug_fd == 2) {return -1;}dbg_printf("--- Closing debug log ---\n");return close(debug_fd);}int dbg_printf(const char *fmt, ...){va_list ap;char buf[MAX_DEBUG];struct timeval tv;gettimeofday(&tv, NULL);sprintf(buf, "%010ld.%06ld: ", tv.tv_sec, tv.tv_usec);write(debug_fd, buf, strlen(buf));va_start(ap, fmt);vsnprintf(buf, MAX_DEBUG, fmt, ap);va_end(ap);return write(debug_fd, buf, strlen(buf));}#else /* !DEBUG */int dbg_open(const char *name __attribute__((unused)) ) { return 0; }int dbg_printf(const char *fmt __attribute__((unused)), ...) { return 0; }int dbg_close(void) { return 0; }#endif /* DEBUG */
123version https://git-lfs.github.com/spec/v1oid sha256:db4b99b6bff19bf6a2d48387aa4c69012824f68c10537b83d8e198570334ef7dsize 2729123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106/********************************************************************//********************************************************************//***** *****//***** L A B C E N T E R E L E C T R O N I C S *****//***** *****//***** PROTEUS VSM GNU CHESS SAMPLE *****//***** *****//***** LPC2000 I2C EEPROM Module *****//***** *****//********************************************************************//********************************************************************/#include <stdio.h>#include <stdlib.h>#include <LPC21xx.H>#include "eeprom.h"extern VOID sleep (INT);#define AA 0x04#define SI 0x08#define STO 0x10#define STA 0x20#define I2CEN 0x40VOID eeprom_init ()// Initialize the I2C Interface{ PINSEL0 |= 0x00000050;I2SCLL = 15; // I2C bus will run at 100kHz with 12MHz clockI2SCLH = 15;I2CONSET = I2CEN;}BYTE eeprom_read (INT addr)// Read single byte of the EEPROM.{ BYTE data;i2c_start(0xA0); // Select write modei2c_write(addr);i2c_start(0xA1); // Select read modedata = i2c_read(FALSE);i2c_stop();return data;}VOID eeprom_write (INT addr, BYTE data)// Write single byte of the EEPROM.{ i2c_start(0xA0); // Select write modei2c_write(addr);i2c_write(data);i2c_stop();sleep(2);}BOOL i2c_start (INT addr){ // Send the start condition:I2DAT = addr;I2CONSET = STA;while (!(I2CONSET & SI));if ((I2STAT & 0xF8) != 0x08 && (I2STAT & 0xF8) != 0x10) // Start or restartreturn FALSE;// Send the slave address and read/write bit//I2CONCLR |= STA;I2CONCLR = SI;while (!(I2CONSET & SI));if (addr & 1){ if (((I2STAT & 0xF8) != 0x40))return FALSE;}else{ if ((I2STAT & 0xF8) != 0x18)return FALSE;}// start condition and slave address are acknowledged:return TRUE;}BOOL i2c_stop (){ // Send a stop:I2CONSET = STO;I2CONCLR = SI;return TRUE;}INT i2c_read (BOOL ack){ if (ack)I2CONSET = AA;I2CONCLR = SI;while (!(I2CONSET & SI));return (I2STAT & 0xF0) == 0x50 ? I2DAT : -1;}INT i2c_write (BYTE data){ I2DAT = data;I2CONCLR = SI;while (!(I2CONSET & SI));return (I2STAT & 0xF8) == 0x28 ? data : -1;}
123version https://git-lfs.github.com/spec/v1oid sha256:63573a0394e4919236dd1d206f183cbdd567b3beb7401e0f506ebdd127f97d96size 124912345678910111213141516171819202122232425262728293031323334353637/********************************************************************//********************************************************************//***** *****//***** L A B C E N T E R E L E C T R O N I C S *****//***** *****//***** PROTEUS VSM GNU CHESS SAMPLE *****//***** *****//***** I2C EEPROM I/O Header *****//***** *****//********************************************************************//********************************************************************/// Portability types:#ifndef VOID#define VOID voidtypedef int INT;typedef unsigned UINT;typedef int BOOL;typedef unsigned char BYTE;typedef unsigned short WORD;#endif// Booleans#ifndef TRUE#define TRUE 1#define FALSE 0#endifVOID eeprom_init();BYTE eeprom_read (INT addr);VOID eeprom_write (INT addr, BYTE data);BOOL i2c_start (INT addr);BOOL i2c_stop ();INT i2c_write (BYTE data);INT i2c_read (BOOL ack);
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 ADC using an AD1674 sdcc/8051 ADC using an AD1674.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 ADC using an AD1674/AD1674 & 80C51.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 DAC using a DAC1230/DAC1230_8051.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 DC Motor Controller/8051 DC Motor Controller.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 LCD Driver/LCDDEMO.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 Memory/ExtMem.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 Stepper Motor Controller/Stepper.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 Timer with LCD/8051 Timer.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 with ERM19264 GLCD 3xKS0108B/ERM19264.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 with LCD1602 LCD controller/LCD1602.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 with Memory Mapped LCD1602/8051 with Memory Mapped LCD1602.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8051 with a DS18B20 Temperture Sensor/DS18B20.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/BASIC-52.LST
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/BASIC-52.PDF
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/BASIC-52.SDI
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/Basic-52.asm
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/Basic-52.hex+422-3
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/FP-52.HEX+97-3
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/FP-52.LST+2277-3
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/FP-52.SDI+1610-3
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/Fp-52.asm+1610-3
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/basic-52.DSN
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/8052 Basic/basic-52.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/ASEM51 Calculator/CALC.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/ASEM51_Stepper/Stepper.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/C51 Calculator/calc.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/C8051F38x/C8051F380 7-seg LED.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/C8051F38x/C8051F380 Blinking LED.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/C8051F38x/C8051F380 Input.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/C8051F38x/C8051F380 Output.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for 8051/C8051F38x/C8051F380 UARTs Two.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/GNUCHESS.pdsprj
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/Makefile.in+511-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/config.sub+1492-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/configure.ac+62-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/doc/Chess Engine Protocol.htm+1367-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/doc/README+512-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/gnuchess.Opt+74-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/gnuchess.Uv2+153-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/gnuchess.lnp+1-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/gnuchess.map
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/atak.c+535-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/book.c+682-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/book.h+46-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/cmd.c+994-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/common.h+864-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/config.h+173-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/debug.c+73-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/eeprom.c+106-3
Proteus 8 Professional/DATA/SAMPLES/VSM for ARM7/GNU Chess/src/eeprom.h+37-3