Logo GNU
Kodovani Předchozí Následující Obsah

35. Assembler z BCC ve floating point verzi


Tady jsem vynechal main, protože byl příliš dlouhý

        .286p
        ifndef  ??version
?debug  macro
        endm
publicdll macro name
        public  name
        endm
$comm   macro   name,dist,size,count
        comm    dist name:BYTE:count*size
        endm
        else
$comm   macro   name,dist,size,count
        comm    dist name[size]:BYTE:count
        endm
        endif
        ?debug  S "formulas.c"
        ?debug  C E9388F96220A666F726D756C61732E63
        ?debug  C E90E95422113433A5C435C494E434C5544455C74696D652E68
_TEXT   segment byte public 'CODE'
_TEXT   ends
DGROUP  group   _DATA,_BSS
        assume  cs:_TEXT,ds:DGROUP
_DATA   segment word public 'DATA'
d@      label   byte
d@w     label   word
_DATA   ends
_BSS    segment word public 'BSS'
b@      label   byte
b@w     label   word
_BSS    ends
_DATA   segment word public 'DATA'
maxiter label   word
        db      128
        db      150
        db      152
        db      0
_DATA   ends
_TEXT   segment byte public 'CODE'
   ;
   ;    static int mand_calc(register number_t cre, register number_t cim, register number_t pre, register number_t pim)
   ;
        assume  cs:_TEXT
mand_calc       proc    near
        push    bp
        mov     bp,sp
        sub     sp,46
   ;
   ;    {
   ;        register number_t rp = 0, ip = 0;
   ;
        fldz
        fstp    tbyte ptr [bp-10]
        fldz
        fstp    tbyte ptr [bp-20]
   ;
   ;        register unsigned long iter = maxiter;
   ;
        fwait
        mov     ax,word ptr DGROUP:maxiter+2
        mov     dx,word ptr DGROUP:maxiter
        mov     word ptr [bp-22],ax
        mov     word ptr [bp-24],dx
   ;
   ;        register number_t zre, zim;
   ;        zre = cre;
   ;
        fld     tbyte ptr [bp+4]
        fstp    tbyte ptr [bp-34]
   ;
   ;        zim = cim;
   ;
        fld     tbyte ptr [bp+14]
        fstp    tbyte ptr [bp-44]
        fwait
        jmp     short @1@74
@1@50:
   ;
   ;        while ((iter) && (rp + ip < 4)) {
   ;                ip = (zim * zim);
   ;
        fld     tbyte ptr [bp-44]
        fld     tbyte ptr [bp-44]
        fmul
        fstp    tbyte ptr [bp-20]
   ;
   ;                zim = (zim * zre) * 2 + pim;
   ;
        fld     tbyte ptr [bp-44]
        fld     tbyte ptr [bp-34]
        fmul
        fmul    dword ptr DGROUP:s@+4
        fld     tbyte ptr [bp+34]
        fadd
        fstp    tbyte ptr [bp-44]
   ;
   ;                rp = (zre * zre);
   ;
        fld     tbyte ptr [bp-34]
        fld     tbyte ptr [bp-34]
        fmul
        fstp    tbyte ptr [bp-10]
   ;
   ;                zre = rp - ip + pre;
   ;
        fld     tbyte ptr [bp-10]
        fld     tbyte ptr [bp-20]
        fsub
        fld     tbyte ptr [bp+24]
        fadd
        fstp    tbyte ptr [bp-34]
   ;
   ;                iter--;
   ;
        fwait
        sub     word ptr [bp-24],1
        sbb     word ptr [bp-22],0
@1@74:
        mov     ax,word ptr [bp-24]
        or      ax,word ptr [bp-22]
        je      short @1@122
        fld     tbyte ptr [bp-10]
        fld     tbyte ptr [bp-20]
        fadd
        fcomp   dword ptr DGROUP:s@
        fstsw   word ptr [bp-46]
        fwait
        mov     ax,word ptr [bp-46]
        sahf
        jb      short @1@50
@1@122:
   ;
   ;
   ;            }
   ;        iter = maxiter - iter;
   ;
        mov     ax,word ptr DGROUP:maxiter+2
        mov     dx,word ptr DGROUP:maxiter
        sub     dx,word ptr [bp-24]
        sbb     ax,word ptr [bp-22]
        mov     word ptr [bp-22],ax
        mov     word ptr [bp-24],dx
   ;
   ;        return(iter);
   ;
        mov     ax,word ptr [bp-24]
   ;
   ;    }
   ;
        leave
        ret
mand_calc       endp
   ;
   ;    main()
   ;
        assume  cs:_TEXT


Předchozí Následující Obsah

Dotazy a připomínky ohledně stránky posílejte na hubicka@paru.cas.cz