Plan 9 from Bell Labs’s /usr/web/sources/contrib/ericvh/go-plan9/src/pkg/runtime/plan9/mkfile

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


NPROC=1
</$objtype/mkfile

%/sys.s:VD:	/sys/src/libc/9syscall/sys.h
	SYS=`{sed '/^#define._X[123]/d; s/#define.([A-Z0-9_]*).*/\1/' /sys/src/libc/9syscall/sys.h}
	echo $stem/sys.s
	rm -f $stem/sys.s
	for(I in $SYS) {
		i=`{echo $I|tr A-Z a-z}
		n=`{sed -n '/[ 	]'$I'[ 	]/s/.*	//p' /sys/src/libc/9syscall/sys.h}
		if(~ $i exits) i=_exits
		{switch($stem){
		case 68000 68020
			echo TEXT $i'(SB)', 1, '$0'
			echo MOVL '$'$n, R0
			echo TRAP '$0'
			echo RTS
		case mips
			echo TEXT $i'(SB)', 1, '$0'
			echo MOVW R1, '0(FP)'
			echo MOVW '$'$n, R1
			echo SYSCALL
			if(~ $i seek) {
				echo 'MOVW $-1,R5'
				echo 'BNE R1,R5,4(PC)'
				echo 'MOVW a+0(FP),R5'
				echo 'MOVW R1,0(R5)'
				echo 'MOVW R1,4(R5)'
			}
			echo RET
		case mips2
			echo TEXT $i'(SB)', 1, '$0'
			echo MOVW R1, '0(FP)'
			echo MOVW '$'$n, R1
			echo ADD '$4',R29
			echo SYSCALL
			echo ADD '$-4',R29
			echo RET
		case spim
			echo TEXT $i'(SB)', 1, '$0'
			echo MOVW R1, '0(FP)'
			echo MOVW '$'$n, R1
			echo ADD '$4',R29	# mips2 only?
			echo SYSCALL
			echo ADD '$-4',R29	# mips2 only?
			if(~ $i seek) {		# untested so far - geoff
				echo 'MOVW $-1,R5'
				echo 'BNE R1,R5,4(PC)'
				echo 'MOVW a+0(FP),R5'
				echo 'MOVW R1,0(R5)'
				echo 'MOVW R1,4(R5)'
			}
			echo RET
		case 386
			echo TEXT $i'(SB)', 1, '$0'
			echo MOVL '$'$n, AX
			echo INT '$'64
			if(~ $i seek) {
				echo 'CMPL AX,$-1'
				echo 'CJNE 4(PC)'
				echo 'CMOVL a+0(FP),CX'
				echo 'CMOVL AX,0(CX)'
				echo 'CMOVL AX,4(CX)'
			}
			echo RET
		case amd64
			if(~ $i seek)
				echo TEXT _seek'(SB)', 1, '$0'
			if not
				echo TEXT $i'(SB)', 1, '$0'
			echo MOVQ RARG, 'a0+0(FP)'
			echo MOVQ '$'$n, RARG
			echo SYSCALL
			echo RET
		case sparc sparc64
			echo TEXT $i'(SB)', 1, '$0'
			echo MOVW R7, '0(FP)'
			echo MOVW '$'$n, R7
			echo TA R0
			if(~ $i seek) {
				echo 'CMP R7,$-1'
				echo 'CBNE 4(PC)'
				echo 'CMOVW a+0(FP),R8'
				echo 'CMOVW R7,0(R8)'
				echo 'CMOVW R7,4(R8)'
			}
			echo RETURN
		case 3210
			echo TEXT $i'(SB)', 1, '$0'
			echo MOVW R3, '0(FP)'
			echo MOVW '$'$n, R3
			echo WORD '$0x06000000'
			echo RETURN
		case 29000
			echo TEXT $i'(SB)', 1, '$0'
			echo MOVL R69, '0(FP)'
			echo MOVL '$'$n, R69
			echo EMULATE 0
			echo RET
		case arm
			echo TEXT $i'(SB)', 1, '$0'
			echo MOVW R0, '0(FP)'
			echo MOVW '$'$n, R0
			echo SWI 0
			if(~ $i seek) {
				echo 'CMP $-1,R0'
				echo 'CBNE 4(PC)'
				echo 'CMOVW a+0(FP),R1'
				echo 'CMOVW R0,0(R1)'
				echo 'CMOVW R0,4(R1)'
			}
			echo RET
		case power
			echo TEXT $i'(SB)', 1, '$0'
			echo MOVW R3, '0(FP)'
			echo MOVW '$'$n, R3
			echo SYSCALL
			if(~ $i seek) {
				echo 'CMP R3,$-1'
				echo 'CBNE 4(PC)'
				echo 'CMOVW a+0(FP),R8'
				echo 'CMOVW R3,0(R8)'
				echo 'CMOVW R3,4(R8)'
			}
			echo RETURN
		case alpha
			j=$i
			if(~ $i seek) j=_seek
			echo TEXT $j'(SB)', 1, '$0'
			echo MOVL R0, '0(FP)'
			echo MOVQ '$'$n, R0
			echo CALL_PAL '$'0x83
			echo RET
		}} >> $stem/sys.s
	}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].