1 eÿmon.s
\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0×
\ 6.define .mon
9 ! Expects on stack: monitor call number
11 ! Implemented are the following monitor calls:
18 ! If called with a number of a call that is not implemented,
19 ! a trap is generated.
27 pop h ! monitor call number
30 jz monexit ! is it an exit?
32 jz monread ! is it a read?
34 jz monwrite ! is it a write?
36 jz monopen ! is it an open?
38 jz monclose ! is it a close?
47 pop h ! file-descriptor, not used
48 pop h ! hl = pointer to output buffer
49 pop d ! de = number of bytes to be read
50 lxi b,0 ! bc will contain the number of bytes actually read
56 call putchar ! echo character
62 cpi 0x0A ! is it a newline?
70 pop h ! file-descriptor, not used
71 pop h ! hl = pointer to output buffer
72 pop d ! de = number of bytes
88 pop h ! pointer to string
91 push h ! push file descriptor
92 push h ! push error code twice
98 xthl ! remove file descriptor and push error code
102 pop h ! file descriptor
105 xthl ! remove argp and push error code
114 \0trp.s
\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0ô
\v.define .trp
115 .define earray, erange, eset, eiovfl, efovfl, efunfl, eidivz, eidivz
116 .define efdivz, eiund, efund, econv, estack, eheap, eillins, eoddz
117 .define ecase, ememflt, ebadptr, ebadpc, ebadlae, ebadmon, ebadlin, ebadgto
126 ! Expects trap number on stack.
127 ! Just returns if trap has to be ignored.
128 ! Otherwise it calls a user-defined trap handler if provided.
129 ! When no user-defined trap handler is provided or when the user-defined
130 ! trap handler causes a new trap, a message is printed
131 ! and control is returned to the monitor.
156 EUNIMPL = 63 ! unimplemented em-instruction called
223 eillins:lxi h,EILLINS
238 ememflt:lxi h,EMEMFLT
243 ebadptr:lxi h,EBADPTR
253 ebadlae:lxi h,EBADLAE
258 ebadmon:lxi h,EBADMON
263 ebadlin:lxi h,EBADLIN
268 ebadgto:lxi h,EBADGTO
273 eunimpl:lxi h,EUNIMPL
281 push h ! trap number and return address exchanged
284 jnc 3f ! jump if trap cannot be ignored
286 ! check if trap has to be ignored
287 xchg ! de = trap number
289 push h ! hl = set to be tested
291 call .inn2 ! de = 1 if bit is set, 0 otherwise
294 jnc 3f ! jump if trap should not be ignored
295 pop h ! remove trap number
296 ret ! OGEN DICHT EN ... SPRING!!!
299 lhld .trapproc ! user defined trap handler?
302 jz 1f ! jump if there was not
304 sta .trapproc ! .trapproc := 0
308 pchl ! call user defined trap handler
333 text1: .asciz "trap number "
334 text2: .asciz "\nline "
335 text3: .asciz " of file "
337 inn2.s
\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Z
\ 2.define .inn2
344 ! Bit test on 16 bits set
345 ! Expects on stack: bit number
347 ! Yields in de-registers: 0 if bit is reset or bit number out of range
354 pop h !set to be tested
361 mov a,l !l-reg contains the wanted bit
366 mov a,h !h-reg contains the wanted bit
373 3: xra a !return 0 if bit number out of range
380 prstring.s
\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0D
\ 1.define prstring
387 ! print a string of characters to the console
388 ! entry: de-reg points to the string
389 ! string terminator is 0x00
390 ! exit: de-reg points to string terminator
403 prdec.s
\0.s
\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0U
\ 2.define prdec
410 ! print hl-reg as a decimal number.
441 push h ! save pointer to new value
465 pchar.her.s
\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Ý
\ 1.define getchar, putchar
472 ! These getchar and putchar routines can be used for HERMAC computer
474 ! Read a character from HERMAC-monitor
475 ! Character is returned in a-reg
487 ! Write character on HERMAC monitor
488 ! Assumes character in a-reg