dg@wrs.UUCP (David Goodenough) (09/09/87)
In article <613@sugar.UUCP> peter@sugar.UUCP (Peter da Silva) writes: >> [ description of how to make an assembler that handles long/short branches ] >But that doesn't resolve the problem of how to deal with near and far >cals to seperately compiled code. If the calling sequence of the 8086 >was a little more logical, you could have 2 entry points for the routine: >near and far. The near would just push the segment and fall through to >the far. Unfortunately, segment is not the top of the stack in a far >call. See Kernighan's April column in Computer Language. I may be missing the point here, but as I remember, the objection was that the offending push can't be done without destroying a register. However since *ALL* C's I've seen are able to return a value, you just use that register i.e. AX on the 8086, and since AX is probably going to get munged in the procedure you are safe: nearentry: pop ax ; save pc in ax push cs ; do the push everyones bitching about push ax ; restore pc farentry: code ...... retfar ; or however you do a far return Caveat: I do agree with his point that if you need to preserve all regs thru a procedure then this is a problem, but in C this is not usually the case. -- dg@wrs.UUCP - David Goodenough +---+ | +-+-+ +-+-+ | +---+