03.01.2015 Views

80C186EC/80C188EC Microprocessor User's Manual

80C186EC/80C188EC Microprocessor User's Manual

80C186EC/80C188EC Microprocessor User's Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

MATH COPROCESSING<br />

$mod186<br />

name example_80C187_init<br />

;<br />

;FUNCTION: This function initializes the 80C187 numerics coprocessor.<br />

;<br />

;SYNTAX: extern unsigned char far 187_init(void);<br />

;<br />

;INPUTS: None<br />

;<br />

;OUTPUTS: unsigned char - 0000h -> False -> coprocessor not initialized<br />

; ffffh -> True -> coprocessor initialized<br />

;<br />

;NOTE:<br />

Parameters are passed on the stack as required by<br />

; high-level languages.<br />

;<br />

lib_80186 segment public ’code’<br />

assume cs:lib_80186<br />

_187_initproc far<br />

public _187_init<br />

push bp ;save caller’s bp<br />

mov bp, sp ;get current top of stack<br />

cli<br />

fninit<br />

fnstcw [bp-2]<br />

sti<br />

;disable maskable interrupts<br />

;init 80C187 processor<br />

;get current control word<br />

;enable interrupts<br />

mov ax, [bp-2]<br />

and ax, 0300h ;mask off unwanted control bits<br />

cmp ax, 0300h ;PC bits = 11<br />

je Ok ;yes: processor ok<br />

xor ax, ax ;return false (80C187 not ok)<br />

pop bp ;restore caller’s bp<br />

ret<br />

Ok: and [bp-2], 0fffeh ;unmask possible exceptions<br />

fldcw [bp-2]<br />

_187_initendp<br />

lib_80186ends<br />

end<br />

mov ax,0ffffh ;return true (80C187 ok)<br />

pop bp ;restore caller’s bp<br />

ret<br />

Example 14-1. Initialization Sequence for 80C187 Math Coprocessor<br />

14-15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!