|
|
1.1 ! root 1: //////// ! 2: / ! 3: / Intel 8086 C runtime. ! 4: / SMALL model. ! 5: / ! 6: //////// ! 7: ! 8: .globl lrmod ! 9: .globl lrsgn ! 10: .globl llmod ! 11: .globl llsgn ! 12: ! 13: //////// ! 14: / ! 15: / These four routines transform an unsigned operator into ! 16: / a signed operator. They are called with the arguments on the stack ! 17: / as pushed by the compiler, and a pointer to the "r" format unsigned ! 18: / operator routine in "ax". The C style call frame for the signed ! 19: / operator is created here. ! 20: / ! 21: //////// ! 22: ! 23: alow = 8 ! 24: ahigh = 10 ! 25: bptr = 12 ! 26: blow = 12 ! 27: bhigh = 14 ! 28: fptr = -4 ! 29: ! 30: lrmod: mov dx,$1 / set remainder flag. ! 31: jmp l0 ! 32: ! 33: lrsgn: sub dx,dx / clear remainder flag. ! 34: jmp l0 ! 35: ! 36: llmod: mov dx,$0x8001 / set lvalue, remainder flags. ! 37: jmp l0 ! 38: ! 39: llsgn: mov dx,$0x8000 / set lvalue flag. ! 40: ! 41: l0: push si / standard ! 42: push di / c ! 43: push bp / function ! 44: mov bp,sp / linkage. ! 45: ! 46: push bx / save bx. ! 47: mov bx,ax / function adr to bx. ! 48: mov di,dx / flags to di. ! 49: push bx / save function in fptr. ! 50: sub si,si / clear sign flag. ! 51: or di,di / check lvalue flag. ! 52: jns l1 / rvalue passed. ! 53: mov bx,bptr(bp) / grab address of operand abd ! 54: mov dx,2(bx) / grab the b ! 55: mov ax,(bx) / operand. ! 56: jmp l2 ! 57: ! 58: l1: mov dx,bhigh(bp) ! 59: mov ax,blow(bp) ! 60: ! 61: l2: or dx,dx / check sign. ! 62: jns l3 / jump if operand positive. ! 63: neg dx / negate ! 64: neg ax / the ! 65: sbb dx,$0 / operand. ! 66: shr di,$1 / check remainder flag. ! 67: jc l3 / jump if doing remainder. ! 68: inc si / flip result sign. ! 69: ! 70: l3: push dx / push onto ! 71: push ax / stack as function arg. ! 72: ! 73: mov dx,ahigh(bp) / grab the ! 74: mov ax,alow(bp) / other operand. ! 75: or dx,dx / check the operand sign. ! 76: jns l4 / jump if positive. ! 77: neg dx / negate ! 78: neg ax / the ! 79: sbb dx,$0 / operand. ! 80: inc si / and flip the sign. ! 81: ! 82: l4: push dx / push other operand as ! 83: push ax / an argument. ! 84: ! 85: icall fptr(bp) / call unsigned op. ! 86: add sp,$10 / pop off 5 words. ! 87: ! 88: shr si,$1 / do we need to negate ?? ! 89: jnc l5 / nope. ! 90: neg dx / negate ! 91: neg ax / the ! 92: sbb dx,$0 / result. ! 93: ! 94: l5: pop bx / restore saved bx. ! 95: mov sp,bp / standard ! 96: pop bp / c ! 97: pop di / function ! 98: pop si / return ! 99: ret / sequence.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.