1*0a6a1f1dSLionel Sambuc/* $NetBSD: fork.S,v 1.1 2014/09/03 19:34:26 matt Exp $ */ 2*0a6a1f1dSLionel Sambuc 3*0a6a1f1dSLionel Sambuc/* 4*0a6a1f1dSLionel Sambuc * pid = fork(); 5*0a6a1f1dSLionel Sambuc * 6*0a6a1f1dSLionel Sambuc * r12 == 0 in parent process, 1 in child process. 7*0a6a1f1dSLionel Sambuc * r11 == pid of child in parent, pid of parent in child. 8*0a6a1f1dSLionel Sambuc */ 9*0a6a1f1dSLionel Sambuc 10*0a6a1f1dSLionel Sambuc#include "SYS.h" 11*0a6a1f1dSLionel Sambuc 12*0a6a1f1dSLionel Sambuc_SYSCALL(__fork,fork) 13*0a6a1f1dSLionel Sambuc l.addi r12,r12,-1 # from 1 to 0 in child, 0 to -1 in parent 14*0a6a1f1dSLionel Sambuc l.and r11,r11,r12 # return 0 in child, pid in parent 15*0a6a1f1dSLionel Sambuc l.jr lr 16*0a6a1f1dSLionel Sambuc l.nop 17*0a6a1f1dSLionel SambucEND(__fork) 18