;firstly, we have the RSX header. db 0,0,0 ; The loader puts the serial number here jp entrypoint ; Beginning of the program next: db 0c3h dw 000 ; Jump to the next module in line. If the ;routine makes BDOS calls, then they should be:- ;jmp next ; previous: dw 000 ; The address of the previous module or 0005H ;if it is the first in line. db 00h ; The remove flag (-1 if it should be removed) ;if this is set to 00, then it can set this flag to -1 when it has terminated ;so as to remove the RSX. db 00h ; Nonbank db 'COMMS ',0,0,0 ;end of RSX header ds 80 our_sp: ds 4 his_sp: dw 00 surpressed: db 00 stopped:db 00 main_:: ; Dummy entrypoint (never called) entrypoint: push af ld a,(surpressed) and a jp nz,do_next ; Is there a lock on this? push bc push de push hl ; Save the environment ld hl,0 add hl,sp ; And the stack ld (his_sp),hl ld sp,our_sp push bc ; Push the function number push de ; And the parameter xor a dec a ld (surpressed),a ; Prevent reentrancy ld a,c ; Look at the function number again cp 60 ; Is it our special one? jp nz,not_ours call rsx_entry## jp hop_over not_ours: cp 10 ; Was it a read console buffer? jp nz,hop_over loop_again: call rsx_entry## ld c,6 ; Direct console io ld e,0feh ; Console status call next ; From the bdos and a jp z,loop_again hop_over: pop de pop bc xor a ld (surpressed),a ; Allow RSX_entry to be called ld hl,(his_sp) ; Restore the stack ld sp,hl pop hl pop de pop bc do_next: pop af jp next ; And go to the next. end