
Perhaps you could tie a small amount of information to each thread, outlining any saferam areas it uses and how much, whether or not it uses TIOS romcalls, stack usage etc?
Moderator: MaxCoderz Staff
Code: Select all
+----------------+-.
| | \ 16 bytes
| Register store | > (PC, SP, AF, BC,
| | / DE, HL, IX, IY)
+----------------+-:
| Variable space | \
| | IX points to the start
| |Grows down| | of the variable space.
: v v :
: :
: ^ ^ :
| | Grows up | | SP points to the end
| | of the stack space.
| Stack space | /
+----------------+-'
Code: Select all
mutex:
ld (hl), $c9 ; overwrite self with "ret" insn.
scf
ret
Code: Select all
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; acquire_mutex:
;;
;; This routine will block until the mutex is acquired.
;;
;; INPUTS:
;;
;; REGISTERS
;;
;; * HL - address of mutex to acquire.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
acquire_mutex:
or a
call $ + $0006 ; indirect call to hl (see below)
jr nc, acquire_mutex
ret
jp (hl)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; timeout_mutex:
;;
;; This routine will block until the mutex is acquired or the timeout
;; period elapses.
;;
;; INPUTS:
;;
;; REGISTERS
;;
;; * A - timeout value (0 == 256).
;; * HL - address of mutex to acquire.
;;
;; OUTPUTS:
;;
;; REGISTERS
;;
;; * F - carry flag set if mutex was acquired.
;; - carry flag clear if timeout elapsed.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
timeout_mutex:
or a
call $ + $0008 ; indirect call to hl (see below)
ret c
dec a
jr nz, timeout_mutex
ret
jp (hl)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; release_mutex:
;;
;; Releases an acquired mutex.
;;
;; INPUTS:
;;
;; REGISTERS
;;
;; * HL - address of mutex to release.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
release_mutex:
ld (hl), $36 ; overwrite mutex with LD (hl), $c9
ret
Code: Select all
di
CS
ei