legacy-cc

The earliest versions of the very first c compiler known to exist in the wild written by the late legend himself dmr. https://github.com/mortdeus/legacy-cc
git clone http://git.hanabi.in/repos/legacy-cc.git
Log | Files | Refs | README

regtab.s (5288B)


      1 / c code tables-- compile to register
      2 
      3 fp = 1		/ enable floating-point
      4 
      5 .globl	_regtab
      6 
      7 _regtab=.; .+2
      8 	20.;	cr20
      9 	21.;	cr20
     10 	22.;	cr20
     11 	30.;	cr30
     12 	31.;	cr30
     13 	32.;	cr32
     14 	33.;	cr32
     15 	34.;	cr34
     16 	35.;	cr35
     17 	29.;	cr29
     18 	36.;	cr36
     19 	37.;	cr37
     20 	38.;	cr38
     21 	101.;	cr100
     22 	80.;	cr80
     23 	40.;	cr40
     24 	41.;	cr40	/ - like +
     25 	42.;	cr42
     26 	43.;	cr43
     27 	44.;	cr43
     28 	45.;	cr45
     29 	46.;	cr45
     30 	47.;	cr47
     31 	48.;	cr48
     32 	60.;	cr60
     33 	61.;	cr60
     34 	62.;	cr60
     35 	63.;	cr60
     36 	64.;	cr60
     37 	65.;	cr60
     38 	66.;	cr60
     39 	67.;	cr60
     40 	68.;	cr60
     41 	69.;	cr60
     42 	70.;	cr70
     43 	71.;	cr70
     44 	72.;	cr72
     45 	73.;	cr73
     46 	74.;	cr73
     47 	75.;	cr75
     48 	76.;	cr75
     49 	77.;	cr77
     50 	78.;	cr78
     51 	102.;	cr102
     52 	97.;	cr97
     53 	0
     54 
     55 / goto
     56 cr102:
     57 %i,n
     58 	jmp	*A1
     59 
     60 %n*,n
     61 	F*
     62 	jmp	*#1(R)
     63 
     64 %n,n
     65 	F
     66 	jmp	(R)
     67 
     68 / call
     69 cr100:
     70 %n*,n
     71 	F*
     72 	jsr	pc,*#1(R)
     73 
     74 %a,n
     75 	jsr	pc,*A1
     76 
     77 %n,n
     78 	F
     79 	jsr	pc,(R)
     80 
     81 / name, constant
     82 cr20:
     83 %z,n
     84 	clr	R
     85 
     86 %aw,n
     87 	mov	A,R
     88 
     89 %ab,n
     90 	movb	A,R
     91 
     92 .if fp
     93 %af,n
     94 	M
     95 	movf	A,R
     96 
     97 .endif
     98 
     99 /++,-- prefix
    100 cr30:
    101 %ai,n
    102 %abp,n
    103 %ab,n
    104 	IB1	A1
    105 	movB1	A1,R
    106 
    107 %a,n
    108 	I'	$2,A1
    109 	mov	A1,R
    110 
    111 %nbp*,n
    112 %ni*,n
    113 %nb*,n
    114 	F*
    115 	IB1	#1(R)
    116 	movB1	#1(R),R
    117 
    118 %n*,n
    119 	F*
    120 	I'	$2,#1(R)
    121 	mov	#1(R),R
    122 
    123 / ++,-- postfix
    124 cr32:
    125 %ai,n
    126 %abp,n
    127 %ab,n
    128 	movB1	A1,R
    129 	IB1	A1
    130 
    131 %a,n
    132 	mov	A1,R
    133 	I'	$2,A1
    134 
    135 %nbp*,n
    136 %nb*,n
    137 %ni*,n
    138 	F*
    139 	movB1	#1(R),-(sp)
    140 	IB1	#1(R)
    141 	movB1	(sp)+,R
    142 
    143 %n*,n
    144 	F*
    145 	mov	#1(R),-(sp)
    146 	I'	$2,#1(R)
    147 	mov	(sp)+,R
    148 
    149 / !
    150 cr34:
    151 %n,n
    152 	FC
    153 	beq	1f
    154 	clr	R
    155 	br	2f
    156 1:	mov	$1,R
    157 2:
    158 
    159 / &unary
    160 cr35:
    161 %a,n
    162 	mov	$A1,R
    163 
    164 / & unary of auto
    165 cr29:
    166 %e,n
    167 	mov	r5,R
    168 	add	Z,R
    169 
    170 / *unary
    171 cr36:
    172 %abp*,n
    173 	F
    174 	movb	(R),R
    175 
    176 %a*,n
    177 	F
    178 	mov	(R),R
    179 
    180 %abp,n
    181 	movb	*A1,R
    182 
    183 %a,n
    184 	mov	*A1,R
    185 
    186 %nbp*,n
    187 	F*
    188 	movb	*#1(R),R
    189 
    190 %n*,n
    191 	F*
    192 	mov	*#1(R),R
    193 
    194 %nbp,n
    195 	H*
    196 	movb	~(R),R
    197 
    198 %n,n
    199 	H*
    200 	mov	~(R),R
    201 
    202 / - unary
    203 cr37:
    204 %n,n
    205 	F
    206 	neg	R
    207 
    208 / ~
    209 cr38:
    210 %n,n
    211 	F
    212 	com	R
    213 
    214 / =
    215 cr80:
    216 %a,n
    217 	S
    218 	movB1	R,A1
    219 
    220 %n*,a
    221 	F*
    222 	movB1	A2,#1(R)
    223 	movB1	#1(R),R
    224 
    225 %n*,e
    226 	F*
    227 	S1
    228 	movB1	R1,#1(R)
    229 	mov	R1,R
    230 
    231 %n*,n
    232 	FS*
    233 	S
    234 	movB1	R,*(sp)+
    235 
    236 / |
    237 cr48:
    238 %n,a
    239 	F
    240 	bisB2	A2,R
    241 
    242 %n,e*
    243 	F
    244 	S1*
    245 	bisB2	#2(R1),R
    246 
    247 %n,e
    248 	F
    249 	S1
    250 	bis	R1,R
    251 
    252 %n,n
    253 	FS
    254 	S
    255 	bis	(sp)+,R
    256 
    257 / &
    258 cr47:
    259 %n,c
    260 	F
    261 	bic	$!C2,R
    262 
    263 %n,e
    264 	F
    265 	S1
    266 	com	R1
    267 	bic	R1,R
    268 
    269 %n,n
    270 	FS
    271 	S
    272 	com	(sp)
    273 	bic	(sp)+,R
    274 
    275 / relationals
    276 cr60:
    277 %n,n
    278 	HC
    279 	I	2f
    280 	clr	R
    281 	br	1f
    282 2:	mov	$1,R
    283 1:
    284 
    285 / >>, <<
    286 cr45:
    287 %a,aw
    288 	movB1	A1,I'
    289 	I	A2,lsh
    290 	movB1	I',R
    291 
    292 %n*,aw
    293 	F*
    294 	movB1	#1(R),I'
    295 	I	A2,lsh
    296 	movB1	I',R
    297 
    298 %n,aw
    299 	F
    300 	mov	R,I'
    301 	I	A2,lsh
    302 	mov	I',R
    303 
    304 %a,nw*
    305 	S*
    306 	movB1	A1,(r4)
    307 	I	#2(R),lsh
    308 	mov	(r4),R
    309 
    310 %a,n
    311 	S
    312 	movB1	A1,I'
    313 	I	R,lsh
    314 	mov	I',R
    315 
    316 %n,n
    317 	FS
    318 	S
    319 	mov	(sp)+,I'
    320 	I	R,lsh
    321 	mov	I',R
    322 
    323 / +, -
    324 cr40:
    325 %n,aw
    326 	F
    327 	I	A2,R
    328 
    329 %n,ew*
    330 	F
    331 	S1*
    332 	I	#2(R1),R
    333 
    334 %n,e
    335 	F
    336 	S1
    337 	I	R1,R
    338 
    339 %n,nw*
    340 	SS*
    341 	F
    342 	I	*(sp)+,R
    343 
    344 %n,n
    345 	SS
    346 	F
    347 	I	(sp)+,R
    348 
    349 / *
    350 cr42:
    351 %aw,a
    352 	mov	A1,(r4)+
    353 	movB2	A2,(r4)
    354 	mov	-(r4),R
    355 
    356 %n,a
    357 	F
    358 	mov	R,(r4)+
    359 	movB2	A2,(r4)
    360 	mov	-(r4),R
    361 
    362 %n,e
    363 	F
    364 	S1
    365 	mov	R,(r4)+
    366 	mov	R1,(r4)
    367 	mov	-(r4),R
    368 
    369 %n,n
    370 	FS
    371 	S
    372 	mov	(sp)+,(r4)+
    373 	mov	R,(r4)
    374 	mov	-(r4),R
    375 
    376 / /; mod
    377 cr43:
    378 %a,a
    379 	movB1	A1,(r4)
    380 	movB2	A2,div
    381 	mov	I,R
    382 
    383 %a,n
    384 	S
    385 	movB1	A1,(r4)
    386 	mov	R,div
    387 	mov	I,R
    388 
    389 %n,a
    390 	F
    391 	mov	R,(r4)
    392 	movB2	A2,div
    393 	mov	I,R
    394 
    395 %n,e
    396 	F
    397 	S1
    398 	mov	R,(r4)
    399 	mov	R1,div
    400 	mov	I,R
    401 
    402 %e,n
    403 	S
    404 	F1
    405 	mov	R1,(r4)
    406 	mov	R,div
    407 	mov	I,R
    408 
    409 %n,n
    410 	FS
    411 	S
    412 	mov	(sp)+,(r4)
    413 	mov	R,div
    414 	mov	I,R
    415 
    416 / =*
    417 cr72:
    418 %a,a
    419 	movB1	A1,(r4)
    420 	movB2	A2,mul
    421 	movB1	(r4),A1
    422 	mov	(r4),R
    423 
    424 %a,n
    425 	S
    426 	mov	R,(r4)+
    427 	movB1	A1,(r4)
    428 	mov	-(r4),R
    429 	movB1	R,A1
    430 
    431 %n*,a
    432 	F*
    433 	movB1	#1(R),(r4)
    434 	movB2	A2,mul
    435 	movB1	(r4),#1(R)
    436 	mov	(r4),R
    437 
    438 %n*,e
    439 	F*
    440 	S1
    441 	movB1	#1(R),(r4)
    442 	mov	R1,mul
    443 	movB1	(r4),#1(R)
    444 	mov	(r4),R
    445 
    446 %e*,n
    447 	S
    448 	F1*
    449 	movB1	#1(R1),(r4)
    450 	mov	R,mul
    451 	movB1	(r4),#1(R1)
    452 	mov	(r4),R
    453 
    454 %n*,n
    455 	FS*
    456 	S
    457 	movB1	*(sp),(r4)
    458 	mov	R,mul
    459 	movB1	(r4),*(sp)+
    460 	mov	(r4),R
    461 
    462 / =mod, =/
    463 cr73:
    464 %a,a
    465 	movB1	A1,(r4)
    466 	movB2	A2,div
    467 	movB1	I,A1
    468 	mov	I,R
    469 
    470 %a,n
    471 	S
    472 	movB1	A1,(r4)
    473 	mov	R,div
    474 	mov	I,R
    475 	movB1	R,A1
    476 
    477 %n*,a
    478 	F*
    479 	movB1	#1(R),(r4)
    480 	movB2	A2,div
    481 	movB1	I,#1(R)
    482 	mov	I,R
    483 
    484 %n*,e
    485 	F*
    486 	S1
    487 	movB1	#1(R),(r4)
    488 	mov	R1,div
    489 	movB1	I,#1(R)
    490 	mov	I,R
    491 
    492 %e*,n
    493 	S
    494 	F1*
    495 	movB1	#1(R1),(r4)
    496 	mov	R,div
    497 	movB1	I,#1(R1)
    498 	mov	I,R
    499 
    500 %n*,n
    501 	FS*
    502 	S
    503 	movB1	*(sp),(r4)
    504 	mov	R,div
    505 	movB1	I,*(sp)+
    506 	mov	I,R
    507 
    508 / =|
    509 cr78:
    510 %a,a
    511 	bisBE	A2,A1
    512 	movB1	A1,R
    513 
    514 %a,n
    515 	S
    516 	bisB1	R,A1
    517 	movB1	A1,R
    518 
    519 %n*,a
    520 	F*
    521 	bisBE	A2,#1(R)
    522 	movB1	#1(R),R
    523 
    524 %e*,n*
    525 	S*
    526 	F1*
    527 	bisBE	#1(R1),#2(R)
    528 	movB1	#2(R),R
    529 
    530 %e*,n
    531 	S
    532 	F1*
    533 	bisBE	R,#1(R1)
    534 	movB1	#1(R1),R
    535 
    536 %n*,e*
    537 	F*
    538 	S1*
    539 	bisBE	#2(R1),#1(R)
    540 	movB1	#1(R),R
    541 
    542 %n*,e
    543 	F*
    544 	S1
    545 	bisBE	R1,#1(R)
    546 	movB2	#1(R),R
    547 
    548 %n*,n*
    549 	FS*
    550 	S*
    551 	bisBE	#2(R),*(sp)
    552 	movB2	*(sp)+,R
    553 
    554 %n*,n
    555 	FS*
    556 	S
    557 	bisBE	R,*(sp)
    558 	mov	*(sp)+,R
    559 
    560 / =&
    561 cr77:
    562 %a,c
    563 	bicB1	$!C2,A1
    564 	movB2	A1,R
    565 
    566 %a,n
    567 	S
    568 	com	R
    569 	bicB1	R,A1
    570 	movB1	A1,R
    571 
    572 %e*,n
    573 	S
    574 	F1*
    575 	com	R
    576 	bicB1	R,#1(R1)
    577 	movB1	#1(R1),R
    578 
    579 %n*,e
    580 	F*
    581 	S1
    582 	com	R1
    583 	bicB1	R1,#1(R)
    584 	movB1	#1(R),R
    585 
    586 %n*,n
    587 	FS*
    588 	S
    589 	com	R
    590 	bicB1	R,*(sp)
    591 	movB1	*(sp)+,R
    592 
    593 / =>>, =<<
    594 cr75:
    595 %a,aw
    596 	movB1	A1,I'
    597 	I	A2,lsh
    598 	movB1	I',A1
    599 	movB1	I',R
    600 
    601 %a,n
    602 	S
    603 	movB1	A1,I'
    604 	I	R,lsh
    605 	movB1	I',A1
    606 	movB1	I',R
    607 
    608 %n*,e
    609 	F*
    610 	S1
    611 	movB1	#1(R),I'
    612 	I	R1,lsh
    613 	movB1	I',#1(R)
    614 	movB1	I',R
    615 
    616 %e*,n
    617 	S
    618 	F1*
    619 	movB1	#1(R1),I'
    620 	I	R,lsh
    621 	movB	I',#1(R1)
    622 	movB1	I',R
    623 
    624 %n*,n
    625 	FS*
    626 	S
    627 	movB1	*(sp),I'
    628 	I	R,lsh
    629 	movB1	I',*(sp)+
    630 	movB1	I',R
    631 
    632 / =+
    633 cr70:
    634 %aw,aw
    635 	I	A2,A1
    636 	mov	A1,R
    637 
    638 %aw,nw*
    639 	S*
    640 	I	#2(R),A1
    641 	mov	A1,R
    642 
    643 %aw,n
    644 	S
    645 	I	R,A1
    646 	mov	A1,R
    647 
    648 %ew*,nw*
    649 	S*
    650 	F1*
    651 	I	#2(R),#1(R1)
    652 	mov	#1(R1),R
    653 
    654 %a,nw*
    655 	S*
    656 	movB1	A1,R1
    657 	I	#2(R),R1
    658 	movB1	R1,#2(R)
    659 	mov	R1,R
    660 
    661 %a,n
    662 	S
    663 	movB1	A1,R1
    664 	I	R1,R
    665 	movB1	R,A1
    666 
    667 %ew*,n
    668 	S
    669 	F1*
    670 	I	R,#1(R1)
    671 	mov	#1(R1),R
    672 
    673 %nw*,n
    674 	SS
    675 	F*
    676 	I	(sp)+,#1(R)
    677 	mov	#1(R),R
    678 
    679 %n*,n
    680 	SS
    681 	F*
    682 	movB1	#1(R),R1
    683 	I	(sp)+,R1
    684 	movB1	R1,#1(R)
    685 	mov	R1,R
    686 
    687 / int -> int[]
    688 cr97:
    689 %n,n
    690 	F
    691 	asl	R
    692 
    693 .data
    694 .even
    695 .text
    696