Embedded C interview Questions - How to initialize the processor ?

Embedded C interview questions

How to initialize the processor?

The following example shows how to initialize a processor here the example of 80187 is taken.


name example_80C187_init


; FUNCTION: This function initializes the 80C187 numeric

; co-processor.


; SYNTAX: extern unsigned char far 187_init (void);


; INPUTS: None


; OUTPUTS: unsigned char - 0000h -> False -> coprocessor not

; Initialized

; ffffh -> True -> coprocessor

; Initialized

; NOTE: Parameters are passed on the stack as required by

; high-level languages.


lib_80186 segment public 'code'

assume cs:lib_80186

public _187_init

_187_init proc far

push bp ;save caller's bp

mov bp, sp ;get current top of stack

cli ;disable maskable


fninit ;init 80C187 processor

fnstcw [bp-2] ;get current control word

sti ;enable interrupts

mov ax, [bp-2]

and ax, 0300h ;mask off unwanted control


cmp ax, 0300h ;PC bits = 11

je Ok ;yes: processor ok

xor ax, ax ;return false (80C187 not


pop bp ;restore caller's bp


Ok: and [bp-2], 0fffeh ;unmask possible exceptions fldcw [bp-2]

mov ax,0ffffh ;return true (80C187 ok)

pop bp ;restore caller's bp


_187_init endp

lib_80186 ends


No comments:

Post a comment