1	.xdef push_shortint
2
3.text
4push_shortint:
5| Saving %d2 as well is a really dirty trick to reserve four extra bytes on the stack.
6| Only two are needed, but this is smaller than subtracting and adding.
7	movem.l %d2-%d6/%a5,-(%sp)
8| Put address of push_quantum into %a5.
9	move.l 0xC8,%a5
10	move.l (%a5,3000),%a5  /* push_quantum */
11| %d4: Number of bytes.
12	clr.w %d4
13| Put POSINT_TAG in %d6.
14	moveq.l #31,%d6
15| Move parameter to %d3.
16	move.w 28(%sp),%d3
17| If it is zero, the value should be zero bytes long.
18	jbeq .L__finished
19| If negative, put NEGINT_TAG in %d6 and negate it.
20	jbge .L__mainloop
21	moveq.l #32,%d6
22	neg.w %d3
23.L__mainloop:
24| Push rightmost quantum of the value.
25	move.w %d3,(%sp)
26	jsr (%a5)
27| Add 1 to the number of bytes.
28	addq.w #1,%d4
29| Shift the value to the right by one quantum.
30	lsr.w #8,%d3
31| Finished if remaining value is zero.
32	jbne .L__mainloop
33.L__finished:
34| Push number of bytes.
35	move.w %d4,(%sp)
36	jsr (%a5)
37| Push tag.
38	move.w %d6,(%sp)
39	jsr (%a5)
40| See above.
41| There is no problem in "restoring" %d2, since it may be trashed.
42	movem.l (%sp)+,%d2-%d6/%a5
43	rts
44