;->s.scall
;
;


R0 RN 0
R1 RN 1
R2 RN 2
R3 RN 3
R4 RN 4
R5 RN 5
R6 RN 6
R7 RN 7
R8 RN 8
R9 RN 9
R10 RN 10
R11 RN 11
R12 RN 12
R13 RN 13
R14 RN 14
R15 RN 15
PC  RN 15


a1 RN 0
a2 RN 1
a3 RN 2
a4 RN 3
v1 RN 4
v2 RN 5
v3 RN 6
v4 RN 7
v5 RN 8
v6 RN 9
sl RN 10
fp RN 11
ip RN 12
sp RN 13
lk RN 14
lr RN 14
pc RN 15

f0 FN 0
f1 FN 1
f2 FN 2
f3 FN 3
f4 FN 4
f5 FN 5
f6 FN 6
f7 FN 7





 AREA  SRASM, CODE



; ****************************************************************************


callblock
 DCD   0


scallset

 MOV   ip,sp
 STMFD sp!,{v1-v6,fp,ip,lk,pc}
 SUB   fp,ip,#4

 STR   a1,callblock

 LDMEA fp,{v1-v6,fp,sp,pc}


OS_SynchroniseCodeAreas * &6E
XOS_MASK   * &00020000 ; mask to make a swi a RISC OS V-error SWI

XOS_SynchroniseCodeAreas * OS_SynchroniseCodeAreas :OR: XOS_MASK


; v1 points to word which has been changed


scallsync
 STMFD sp!,{a1-a4,v1-v6,lk}

 MOV   a1,#1
 MOV   a2,v1
 MOV   a3,v1

 SWI   XOS_SynchroniseCodeAreas

 LDMFD sp,{a1-a4,v1-v6,pc}


scall

 MOV   ip,sp
 STMFD sp!,{v1-v6,fp,ip,lk,pc}
 SUB   fp,ip,#4


 LDR   v3,callblock
 ADD   v1,v3,#4

 LDR   v2,[v1]
 STMFD sp!,{v2}

 LDR   v2,return
 STR   v2,[v1]

 BL    scallsync

 ADR   lk,calllx

 STMFD sp!,{lk}

 MOV   pc,v3

return
 LDMFD sp!,{pc}

calllx

 LDR   v1,callblock
 ADD   v1,v1,#4

 LDMFD sp!,{v2}
 STR   v2,[v1]

 BL    scallsync

 LDMEA fp,{v1-v6,fp,sp,pc}


 EXPORT scall
 EXPORT scallset

 END


