00800 / machine language assist 00801 / for 11/40 00802 00803 00804 / non-UNIX instructions 00805 mfpi = 6500^tst 00806 mtpi = 6600^tst 00807 halt = 0 00808 wait = 1 00809 reset = 5 00810 rtt = 6 00811 00812 .globl start, _end, _edata, _main, dump 00813 dump: 00814 start: 00815 mov $trap,34 00816 00817 / Set location 0 and 2 to catch traps and jumps to 0 00818 00819 mov $42,0 / illegal instruction if jump 00820 mov $777,2 / trace trap at high priority if trap 00821 00822 / initialize systems segments 00823 00824 mov $KISA0,r0 00825 mov $KISD0,r1 00826 mov $200,r4 00827 clr r2 00828 mov $6,r3 00829 1: 00830 mov r2,(r0)+ 00831 mov $77406,(r1)+ / 4k rw 00832 add r4,r2 00833 sob r3,1b 00834 00835 / initialize user segment 00836 00837 mov $_end+63.,r2 00838 ash $-6,r2 00839 bic $!1777,r2 00840 mov r2,(r0)+ / ksr6 = sysu 00841 mov $usize-1\<8|6,(r1)+ 00842 00843 / initialize io segment 00844 / set up counts on supervisor segments 00845 00846 mov $IO,(r0)+ 00847 mov $77406,(r1)+ / rw 4k 00848 00849 / get a sp and start segmentation 00850 00851 mov $_u+[usize*64.],sp 00852 00853 inc SSR0 00854 / test for floating point 00855 mov $1f,nofault 00856 setd / jumps to 1f if no fpu 00857 inc fpp 00858 1: 00859 clr nofault 00860 00861 / clear bss 00862 00863 mov $_edata,r0 00864 1: 00865 clr (r0)+ 00866 cmp r0,$_end 00867 blo 1b 00868 00869 / clear user block 00870 00871 mov $_u,r0 00872 1: 00873 clr (r0)+ 00874 cmp r0,$_u+[usize*64.] 00875 blo 1b 00876 00877 / set up previous mode and call main 00878 / on return, enter user mode at 0R 00879 00880 mov $30000,PS 00881 jsr pc,_main 00882 mov $170000,-(sp) 00883 clr -(sp) 00884 rtt 00885 00886 .globl trap, call 00887 .globl _trap 00888 00889 / all traps and interrupts are 00890 / vectored thru this routine. 00891 00892 trap: 00893 mov PS,saveps 00894 tst nofault 00895 bne 1f 00896 mov SSR0,ssr 00897 mov SSR2,ssr+4 00898 mov $1,SSR0 00899 jsr r0,call1; jmp _trap 00900 / no return 00901 1: 00902 mov $1,SSR0 00903 mov nofault,(sp) 00904 rtt 00905 .text 00906 00907 .globl _runrun 00908 call1: 00909 mov saveps,-(sp) 00910 bic $HIPRI,PS 00911 br 1f 00912 00913 call: 00914 mov PS,-(sp) 00915 1: 00916 mov r1,-(sp) 00917 mfpi sp 00918 mov 4(sp),-(sp) 00919 bic $!37,(sp) 00920 bit $30000,PS 00921 beq 1f 00922 jsr pc,(r0)+ 00923 tstb _runrun 00924 beq 2f 00925 mov $12.,(sp) / trap 12 is give up cpu 00926 jsr pc,_trap 00927 2: 00928 tst (sp)+ 00929 mtpi sp 00930 br 2f 00931 1: 00932 bis $30000,PS 00933 jsr pc,(r0)+ 00934 cmp (sp)+,(sp)+ 00935 2: 00936 mov (sp)+,r1 00937 tst (sp)+ 00938 mov (sp)+,r0 00939 rtt 00940 .globl _savfp 00941 _savfp: 00942 tst fpp 00943 beq 8f 00944 mov 2(sp),r1 00945 stfps (r1)+ 00946 setd 00947 movf fr0,(r1)+ 00948 movf fr1,(r1)+ 00949 movf fr2,(r1)+ 00950 movf fr3,(r1)+ 00951 movf fr4,fr0 00952 movf fr0,(r1)+ 00953 movf fr5,fr0 00954 movf fr0,(r1)+ 00955 8: 00956 rts pc 00957 00958 .globl _restfp 00959 _restfp: 00960 tst fpp 00961 beq 8f 00962 mov 2(sp),r1 00963 mov r1,r0 00964 setd 00965 add $8.+2.,r1 00966 movf (r1)+,fr1 00967 movf (r1)+,fr2 00968 movf (r1)+,fr3 00969 movf (r1)+,fr0 00970 movf fr0,fr4 00971 movf (r1)+,fr0 00972 movf fr0,fr5 00973 movf 2(r0),fr0 00974 ldfps (r0) 00975 8: 00976 rts pc 00977 00978 .globl _addupc 00979 _addupc: 00980 mov r2,-(sp) 00981 mov 6(sp),r2 / base of prof with base,leng,off,scale 00982 mov 4(sp),r0 / pc 00983 sub 4(r2),r0 / offset 00984 clc 00985 ror r0 00986 mov 6(r2),r1 00987 clc 00988 ror r1 00989 mul r1,r0 / scale 00990 ashc $-14.,r0 00991 inc r1 00992 bic $1,r1 00993 cmp r1,2(r2) / length 00994 bhis 1f 00995 add (r2),r1 / base 00996 mov nofault,-(sp) 00997 mov $2f,nofault 00998 mfpi (r1) 00999 add 12.(sp),(sp) 01000 mtpi (r1) 01001 br 3f 01002 2: 01003 clr 6(r2) 01004 3: 01005 mov (sp)+,nofault 01006 1: 01007 mov (sp)+,r2 01008 rts pc 01009 01010 .globl _display 01011 _display: 01012 rts pc 01013 01014 / Character list get/put 01015 01016 /.globl _getc, _putc 01017 /.globl _cfreelist 01018 / 01019 /_getc: 01020 / mov 2(sp),r1 01021 / mov PS,-(sp) 01022 / mov r2,-(sp) 01023 / bis $HIPRI,PS 01024 / bic $40,PS 01025 / mov 2(r1),r2 / first ptr 01026 / beq 9f / empty 01027 / movb (r2)+,r0 / character 01028 / bic $!377,r0 01029 / mov r2,2(r1) 01030 / dec (r1)+ / count 01031 / bne 1f 01032 / clr (r1)+ 01033 / clr (r1)+ / last block 01034 / br 2f 01035 /1: 01036 / bit $7,r2 01037 / bne 3f 01038 / mov -10(r2),(r1) / next block 01039 / add $2,(r1) 01040 /2: 01041 / dec r2 01042 / bic $7,r2 01043 / mov _cfreelist,(r2) 01044 / mov r2,_cfreelist 01045 /3: 01046 / mov (sp)+,r2 01047 / mov (sp)+,PS 01048 / rts pc 01049 /9: 01050 / clr 4(r1) 01051 / mov $-1,r0 01052 / mov (sp)+,r2 01053 / mov (sp)+,PS 01054 / rts pc 01055 / 01056 /_putc: 01057 / mov 2(sp),r0 01058 / mov 4(sp),r1 01059 / mov PS,-(sp) 01060 / mov r2,-(sp) 01061 / mov r3,-(sp) 01062 / bis $HIPRI,PS 01063 / bic $40,PS 01064 / mov 4(r1),r2 / last ptr 01065 / bne 1f 01066 / mov _cfreelist,r2 01067 / beq 9f 01068 / mov (r2),_cfreelist 01069 / clr (r2)+ 01070 / mov r2,2(r1) / first ptr 01071 / br 2f 01072 /1: 01073 / bit $7,r2 01074 / bne 2f 01075 / mov _cfreelist,r3 01076 / beq 9f 01077 / mov (r3),_cfreelist 01078 / mov r3,-10(r2) 01079 / mov r3,r2 01080 / clr (r2)+ 01081 /2: 01082 / movb r0,(r2)+ 01083 / mov r2,4(r1) 01084 / inc (r1) / count 01085 / clr r0 01086 / mov (sp)+,r3 01087 / mov (sp)+,r2 01088 / mov (sp)+,PS 01089 / rts pc 01090 /9: 01091 / mov pc,r0 01092 / mov (sp)+,r3 01093 / mov (sp)+,r2 01094 / mov (sp)+,PS 01095 / rts pc 01096 01097 .globl _backup 01098 .globl _regloc 01099 _backup: 01100 mov 2(sp),ssr+2 01101 mov r2,-(sp) 01102 jsr pc,backup 01103 mov r2,ssr+2 01104 mov (sp)+,r2 01105 movb jflg,r0 01106 bne 2f 01107 mov 2(sp),r0 01108 movb ssr+2,r1 01109 jsr pc,1f 01110 movb ssr+3,r1 01111 jsr pc,1f 01112 movb _regloc+7,r1 01113 asl r1 01114 add r0,r1 01115 mov ssr+4,(r1) 01116 clr r0 01117 2: 01118 rts pc 01119 1: 01120 mov r1,-(sp) 01121 asr (sp) 01122 asr (sp) 01123 asr (sp) 01124 bic $!7,r1 01125 movb _regloc(r1),r1 01126 asl r1 01127 add r0,r1 01128 sub (sp)+,(r1) 01129 rts pc 01130 01131 / hard part 01132 / simulate the ssr2 register missing on 11/40 01133 01134 backup: 01135 clr r2 / backup register ssr1 01136 mov $1,bflg / clrs jflg 01137 mov ssr+4,r0 01138 jsr pc,fetch 01139 mov r0,r1 01140 ash $-11.,r0 01141 bic $!36,r0 01142 jmp *0f(r0) 01143 0: t00; t01; t02; t03; t04; t05; t06; t07 01144 t10; t11; t12; t13; t14; t15; t16; t17 01145 01146 t00: 01147 clrb bflg 01148 01149 t10: 01150 mov r1,r0 01151 swab r0 01152 bic $!16,r0 01153 jmp *0f(r0) 01154 0: u0; u1; u2; u3; u4; u5; u6; u7 01155 01156 u6: / single op, m[tf]pi, sxt, illegal 01157 bit $400,r1 01158 beq u5 / all but m[tf], sxt 01159 bit $200,r1 01160 beq 1f / mfpi 01161 bit $100,r1 01162 bne u5 / sxt 01163 01164 / simulate mtpi with double (sp)+,dd 01165 bic $4000,r1 / turn instr into (sp)+ 01166 br t01 01167 01168 / simulate mfpi with double ss,-(sp) 01169 1: 01170 ash $6,r1 01171 bis $46,r1 / -(sp) 01172 br t01 01173 01174 u4: / jsr 01175 mov r1,r0 01176 jsr pc,setreg / assume no fault 01177 bis $173000,r2 / -2 from sp 01178 rts pc 01179 01180 t07: / EIS 01181 clrb bflg 01182 01183 u0: / jmp, swab 01184 u5: / single op 01185 f5: / movei, movfi 01186 ff1: / ldfps 01187 ff2: / stfps 01188 ff3: / stst 01189 mov r1,r0 01190 br setreg 01191 01192 t01: / mov 01193 t02: / cmp 01194 t03: / bit 01195 t04: / bic 01196 t05: / bis 01197 t06: / add 01198 t16: / sub 01199 clrb bflg 01200 01201 t11: / movb 01202 t12: / cmpb 01203 t13: / bitb 01204 t14: / bicb 01205 t15: / bisb 01206 mov r1,r0 01207 ash $-6,r0 01208 jsr pc,setreg 01209 swab r2 01210 mov r1,r0 01211 jsr pc,setreg 01212 01213 / if delta(dest) is zero, 01214 / no need to fetch source 01215 01216 bit $370,r2 01217 beq 1f 01218 01219 / if mode(source) is R, 01220 / no fault is possible 01221 01222 bit $7000,r1 01223 beq 1f 01224 01225 / if reg(source) is reg(dest), 01226 / too bad. 01227 01228 mov r2,-(sp) 01229 bic $174370,(sp) 01230 cmpb 1(sp),(sp)+ 01231 beq u7 01232 01233 / start source cycle 01234 / pick up value of reg 01235 01236 mov r1,r0 01237 ash $-6,r0 01238 bic $!7,r0 01239 movb _regloc(r0),r0 01240 asl r0 01241 add ssr+2,r0 01242 mov (r0),r0 01243 01244 / if reg has been incremented, 01245 / must decrement it before fetch 01246 01247 bit $174000,r2 01248 ble 2f 01249 dec r0 01250 bit $10000,r2 01251 beq 2f 01252 dec r0 01253 2: 01254 01255 / if mode is 6,7 fetch and add X(R) to R 01256 01257 bit $4000,r1 01258 beq 2f 01259 bit $2000,r1 01260 beq 2f 01261 mov r0,-(sp) 01262 mov ssr+4,r0 01263 add $2,r0 01264 jsr pc,fetch 01265 add (sp)+,r0 01266 2: 01267 01268 / fetch operand 01269 / if mode is 3,5,7 fetch * 01270 01271 jsr pc,fetch 01272 bit $1000,r1 01273 beq 1f 01274 bit $6000,r1 01275 bne fetch 01276 1: 01277 rts pc 01278 01279 t17: / floating point instructions 01280 clrb bflg 01281 mov r1,r0 01282 swab r0 01283 bic $!16,r0 01284 jmp *0f(r0) 01285 0: f0; f1; f2; f3; f4; f5; f6; f7 01286 01287 f0: 01288 mov r1,r0 01289 ash $-5,r0 01290 bic $!16,r0 01291 jmp *0f(r0) 01292 0: ff0; ff1; ff2; ff3; ff4; ff5; ff6; ff7 01293 01294 f1: / mulf, modf 01295 f2: / addf, movf 01296 f3: / subf, cmpf 01297 f4: / movf, divf 01298 ff4: / clrf 01299 ff5: / tstf 01300 ff6: / absf 01301 ff7: / negf 01302 inc fflg 01303 mov r1,r0 01304 br setreg 01305 01306 f6: 01307 bit $400,r1 01308 beq f1 / movfo 01309 br f5 / movie 01310 01311 f7: 01312 bit $400,r1 01313 beq f5 / movif 01314 br f1 / movof 01315 01316 ff0: / cfcc, setf, setd, seti, setl 01317 u1: / br 01318 u2: / br 01319 u3: / br 01320 u7: / illegal 01321 incb jflg 01322 rts pc 01323 01324 setreg: 01325 mov r0,-(sp) 01326 bic $!7,r0 01327 bis r0,r2 01328 mov (sp)+,r0 01329 ash $-3,r0 01330 bic $!7,r0 01331 movb 0f(r0),r0 01332 tstb bflg 01333 beq 1f 01334 bit $2,r2 01335 beq 2f 01336 bit $4,r2 01337 beq 2f 01338 1: 01339 cmp r0,$20 01340 beq 2f 01341 cmp r0,$-20 01342 beq 2f 01343 asl r0 01344 2: 01345 tstb fflg 01346 beq 3f 01347 asl r0 01348 stfps r1 01349 bit $200,r1 01350 beq 3f 01351 asl r0 01352 3: 01353 bisb r0,r2 01354 rts pc 01355 01356 0: .byte 0,0,10,20,-10,-20,0,0 01357 01358 fetch: 01359 bic $1,r0 01360 mov nofault,-(sp) 01361 mov $1f,nofault 01362 mfpi (r0) 01363 mov (sp)+,r0 01364 mov (sp)+,nofault 01365 rts pc 01366 01367 1: 01368 mov (sp)+,nofault 01369 clrb r2 / clear out dest on fault 01370 mov $-1,r0 01371 rts pc 01372 01373 .bss 01374 bflg: .=.+1 01375 jflg: .=.+1 01376 fflg: .=.+1 01377 .text 01378 01379 .text 01380 01381 .globl _fubyte, _subyte 01382 .globl _fuibyte, _suibyte 01383 .globl _fuword, _suword 01384 .globl _fuiword, _suiword 01385 _fuibyte: 01386 _fubyte: 01387 mov 2(sp),r1 01388 bic $1,r1 01389 jsr pc,gword 01390 cmp r1,2(sp) 01391 beq 1f 01392 swab r0 01393 1: 01394 bic $!377,r0 01395 rts pc 01396 01397 _suibyte: 01398 _subyte: 01399 mov 2(sp),r1 01400 bic $1,r1 01401 jsr pc,gword 01402 mov r0,-(sp) 01403 cmp r1,4(sp) 01404 beq 1f 01405 movb 6(sp),1(sp) 01406 br 2f 01407 1: 01408 movb 6(sp),(sp) 01409 2: 01410 mov (sp)+,r0 01411 jsr pc,pword 01412 clr r0 01413 rts pc 01414 _fuiword: 01415 _fuword: 01416 mov 2(sp),r1 01417 fuword: 01418 jsr pc,gword 01419 rts pc 01420 01421 gword: 01422 mov PS,-(sp) 01423 bis $HIPRI,PS 01424 mov nofault,-(sp) 01425 mov $err,nofault 01426 mfpi (r1) 01427 mov (sp)+,r0 01428 br 1f 01429 01430 _suiword: 01431 _suword: 01432 mov 2(sp),r1 01433 mov 4(sp),r0 01434 suword: 01435 jsr pc,pword 01436 rts pc 01437 01438 pword: 01439 mov PS,-(sp) 01440 bis $HIPRI,PS 01441 mov nofault,-(sp) 01442 mov $err,nofault 01443 mov r0,-(sp) 01444 mtpi (r1) 01445 1: 01446 mov (sp)+,nofault 01447 mov (sp)+,PS 01448 rts pc 01449 01450 err: 01451 mov (sp)+,nofault 01452 mov (sp)+,PS 01453 tst (sp)+ 01454 mov $-1,r0 01455 rts pc 01456 rts pc 01457 .globl _copyin, _copyout 01458 .globl _copyiin, _copyiout 01459 _copyiin: 01460 _copyin: 01461 jsr pc,copsu 01462 1: 01463 mfpi (r0)+ 01464 mov (sp)+,(r1)+ 01465 sob r2,1b 01466 br 2f 01467 01468 _copyiout: 01469 _copyout: 01470 jsr pc,copsu 01471 1: 01472 mov (r0)+,-(sp) 01473 mtpi (r1)+ 01474 sob r2,1b 01475 2: 01476 mov (sp)+,nofault 01477 mov (sp)+,r2 01478 clr r0 01479 rts pc 01480 01481 copsu: 01482 mov (sp)+,r0 01483 mov r2,-(sp) 01484 mov nofault,-(sp) 01485 mov r0,-(sp) 01486 mov 10(sp),r0 01487 mov 12(sp),r1 01488 mov 14(sp),r2 01489 asr r2 01490 mov $1f,nofault 01491 rts pc 01492 01493 1: 01494 mov (sp)+,nofault 01495 mov (sp)+,r2 01496 mov $-1,r0 01497 rts pc 01498 01499 .globl _idle, _waitloc 01500 _idle: 01501 mov PS,-(sp) 01502 bic $HIPRI,PS 01503 wait 01504 waitloc: 01505 mov (sp)+,PS 01506 rts pc 01507 .data 01508 _waitloc: 01509 waitloc 01510 .text 01511 01512 .globl _save 01513 _save: 01514 mov (sp)+,r1 01515 mov (sp),r0 01516 mov r2,(r0)+ 01517 mov r3,(r0)+ 01518 mov r4,(r0)+ 01519 mov r5,(r0)+ 01520 mov sp,(r0)+ 01521 mov r1,(r0)+ 01522 clr r0 01523 jmp (r1) 01524 01525 .globl _resume 01526 _resume: 01527 mov 2(sp),r0 / new process 01528 mov 4(sp),r1 / new stack 01529 bis $HIPRI,PS 01530 mov r0,KISA6 / In new process 01531 mov (r1)+,r2 01532 mov (r1)+,r3 01533 mov (r1)+,r4 01534 mov (r1)+,r5 01535 mov (r1)+,sp 01536 mov $1,r0 01537 bic $HIPRI,PS 01538 jmp *(r1)+ 01539 01540 .globl _spl0, _spl1, _spl4, _spl5, _spl6, _spl7, _splx 01541 _spl0: 01542 mov PS,r0 01543 bic $HIPRI,PS 01544 rts pc 01545 01546 _spl1: 01547 mov PS,r0 01548 bis $HIPRI,PS 01549 bic $300,PS 01550 rts pc 01551 01552 _spl4: 01553 mov PS,r0 01554 bis $HIPRI,PS 01555 bic $140,PS 01556 rts pc 01557 01558 _spl5: 01559 mov PS,r0 01560 bis $HIPRI,PS 01561 bic $100,PS 01562 rts pc 01563 01564 _spl6: 01565 mov PS,r0 01566 bis $HIPRI,PS 01567 bic $40,PS 01568 rts pc 01569 01570 _spl7: 01571 mov PS,r0 01572 bis $HIPRI,PS 01573 rts pc 01574 01575 _splx: 01576 mov 2(sp),PS 01577 rts pc 01578 01579 .globl _copyseg 01580 _copyseg: 01581 mov PS,-(sp) 01582 mov UISA0,-(sp) 01583 mov UISA1,-(sp) 01584 mov $30340,PS 01585 mov 10(sp),UISA0 01586 mov 12(sp),UISA1 01587 mov UISD0,-(sp) 01588 mov UISD1,-(sp) 01589 mov $6,UISD0 01590 mov $6,UISD1 01591 mov r2,-(sp) 01592 clr r0 01593 mov $8192.,r1 01594 mov $32.,r2 01595 1: 01596 mfpi (r0)+ 01597 mtpi (r1)+ 01598 sob r2,1b 01599 mov (sp)+,r2 01600 mov (sp)+,UISD1 01601 mov (sp)+,UISD0 01602 mov (sp)+,UISA1 01603 mov (sp)+,UISA0 01604 mov (sp)+,PS 01605 rts pc 01606 01607 .globl _clearseg 01608 _clearseg: 01609 mov PS,-(sp) 01610 mov UISA0,-(sp) 01611 mov $30340,PS 01612 mov 6(sp),UISA0 01613 mov UISD0,-(sp) 01614 mov $6,UISD0 01615 clr r0 01616 mov $32.,r1 01617 1: 01618 clr -(sp) 01619 mtpi (r0)+ 01620 sob r1,1b 01621 mov (sp)+,UISD0 01622 mov (sp)+,UISA0 01623 mov (sp)+,PS 01624 rts pc 01625 01626 .globl _piget, _piput 01627 _piget: 01628 mov PS,-(sp) 01629 jsr pc,2f 01630 mfpi (r0) 01631 mov (sp)+,r0 01632 1: 01633 mov (sp)+,PS 01634 rts pc 01635 01636 _piput: 01637 mov PS,-(sp) 01638 jsr pc,2f 01639 mov 10(sp),r1 01640 mov r1,-(sp) 01641 mtpi (r0) 01642 br 1b 01643 2: 01644 mov 6(sp),r0 01645 mov 10(sp),r1 01646 ashc $-6,r0 01647 mov HIPRI,PS 01648 mov r1,KISA7 01649 mov 10(sp),r0 01650 bic $!77,r0 01651 bis $160000,r0 01652 rts pc 01653 01654 / Long quotient 01655 01656 .globl ldiv 01657 ldiv: 01658 jsr r5,csv 01659 mov 10.(r5),r3 01660 sxt r4 01661 bpl 1f 01662 neg r3 01663 1: 01664 cmp r4,8.(r5) 01665 bne hardldiv 01666 mov 6.(r5),r2 01667 mov 4.(r5),r1 01668 bge 1f 01669 neg r1 01670 neg r2 01671 sbc r1 01672 com r4 01673 1: 01674 mov r4,-(sp) 01675 clr r0 01676 div r3,r0 01677 mov r0,r4 /high quotient 01678 mov r1,r0 01679 mov r2,r1 01680 div r3,r0 01681 bvc 1f 01682 sub r3,r0 / this is the clever part 01683 div r3,r0 01684 tst r1 01685 sxt r1 01686 add r1,r0 / cannot overflow! 01687 1: 01688 mov r0,r1 01689 mov r4,r0 01690 tst (sp)+ 01691 bpl 9f 01692 neg r0 01693 neg r1 01694 sbc r0 01695 9: 01696 jmp cret 01697 01698 hardldiv: 01699 4 01700 01701 / Long remainder 01702 01703 .globl lrem 01704 lrem: 01705 jsr r5,csv 01706 mov 10.(r5),r3 01707 sxt r4 01708 bpl 1f 01709 neg r3 01710 1: 01711 cmp r4,8.(r5) 01712 bne hardlrem 01713 mov 6.(r5),r2 01714 mov 4.(r5),r1 01715 mov r1,r4 01716 bge 1f 01717 neg r1 01718 neg r2 01719 sbc r1 01720 1: 01721 clr r0 01722 div r3,r0 01723 mov r1,r0 01724 mov r2,r1 01725 div r3,r0 01726 bvc 1f 01727 sub r3,r0 01728 div r3,r0 01729 tst r1 01730 beq 9f 01731 add r3,r1 01732 1: 01733 tst r4 01734 bpl 9f 01735 neg r1 01736 9: 01737 sxt r0 01738 jmp cret 01739 01740 / The divisor is known to be >= 2^15. Only 16 cycles are 01741 / needed to get a remainder. 01742 hardlrem: 01743 4 01744 01745 .globl csv 01746 csv: 01747 mov r5,r0 01748 mov sp,r5 01749 mov r4,-(sp) 01750 mov r3,-(sp) 01751 mov r2,-(sp) 01752 jsr pc,(r0) 01753 01754 .globl cret 01755 cret: 01756 mov r5,r2 01757 mov -(r2),r4 01758 mov -(r2),r3 01759 mov -(r2),r2 01760 mov r5,sp 01761 mov (sp)+,r5 01762 rts pc 01763 01764 .globl _u 01765 _u = 140000 01766 usize = 16. 01767 01768 HIPRI = 340 01769 01770 PS = 177776 01771 SSR0 = 177572 01772 SSR2 = 177576 01773 KISA0 = 172340 01774 KISA6 = 172354 01775 KISA7 = 172356 01776 KISD0 = 172300 01777 MTC = 172522 01778 TUC = 172440 01779 UISA0 = 177640 01780 UISA1 = 177642 01781 UISD0 = 177600 01782 UISD1 = 177602 01783 IO = 7600 01784 01785 .data 01786 .globl _ka6 01787 .globl _cputype 01788 01789 _ka6: KISA6 01790 _cputype:40. 01791 stk: 0 01792 01793 .bss 01794 nofault:.=.+2 01795 ssr: .=.+6 01796 saveps: .=.+2 01797 power: .=.+2 01798 fpp: .=.+2 01799 01800 .globl _stst01801 .text 01802 .globl _stst01803 stst = 170300^tst 01804 _stst: 01805 tst fpp 01806 beq 9f 01807 stst r0 01808 mov r0,*2(sp) 01809 9: 01810 rts pc 01811 01812 01813 01814 01815 01816 01817 01818 01819 01820 01821 01822 01823 01824 01825 01826 01827 01828 01829 01830 01831 01832 01833 01834 01835 01836 01837 01838 01839 01840 01841 01842 01843 01844 01845 01846 01847 01848 01849