1 ; *********************************************************** 2 ; * * 3 ; * Copyright, (C) Honeywell Bull Inc., 1987 * 4 ; * * 5 ; * Copyright, (C) Honeywell Information Systems Inc., 1986 * 6 ; * * 7 ; *********************************************************** 8 9 page 55,132 10 ; HISTORY COMMENTS: 11 ; 1) change(86-08-30,Flegel), approve(87-07-13,MCR7580), 12 ; audit(87-07-13,Leskiw), install(87-08-07,MR12.1-1072): 13 ; Created. 14 ; END HISTORY COMMENTS 15 16 ;/* : PROCEDURE FUNCTION (setlock) 17 18 ;This procedure provides a means of setting locks in order to provide 19 ;a means of setting locks on critical sections of instructions (code). 20 ;The lock byte specified is exchanged with the value passed and the older 21 ;value is returned in ax (typical return register both for 'C' routines and 22 ;assembler. 23 ; 24 ; char lockbyte; lockbyte db 0 25 ; setlock (&lockbyte); mov bx,offset lockbyte 26 ; push bx 27 ; call setlock 28 ; 29 ;Where lockbyte MUST be a static variable (not from the stack). 30 ; 31 ;Thus register ax is NOT preserved. 32 ;*/ 33 34 ;/* : NOTES 35 ; 36 ;This implementation is simple as it allows only true/false settings on the 37 ;lockbyte. 38 ;*/ 39 40 ;/* : RETURNS 41 42 ;ax = old value of lock byte. 43 ;*/ 44 45 include dos.mac ;Lattice include file 46 47 ;************************************************************** 48 ; DATA 49 ;************************************************************** 50 dseg 51 52 ;--------- External Declarations 53 54 ;--------- Public Declarations 55 public setlock 56 57 ;--------- Local Memory Declarations 58 59 endds 60 61 ;************************************************************** 62 ; MAIN 63 ;************************************************************** 64 pseg 65 66 ;-------- External Procedures 67 68 setlock proc near 69 push bp 70 mov bp,sp 71 72 push bx 73 mov bx,[bp+4] ; address of lock in bx 74 75 xor ax,ax 76 mov al,1 ; set test register 77 lock xchg [bx],al ; exchange register with lock 78 79 pop bx 80 pop bp 81 ret 82 83 setlock endp 84 85 endps 86 end 87 ^Z