OpenCores
URL https://opencores.org/ocsvn/oms8051mini/oms8051mini/trunk

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [verif/] [sw/] [C/] [cast.c] - Blame information for rev 17

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dinesha
/*
2
 * Copyright (c) 1999-2001 Tony Givargis.  Permission to copy is granted
3
 * provided that this header remains intact.  This software is provided
4
 * with no warranties.
5
 *
6
 * Version : 2.9
7
 */
8
 
9
/*---------------------------------------------------------------------------*/
10
 
11
#include <8051.h>
12
 
13
/*---------------------------------------------------------------------------*/
14
 
15
unsigned char cast(unsigned long l) {
16
 
17
    return (unsigned char)l;
18
}
19
 
20
/*---------------------------------------------------------------------------*/
21
 
22
void main() {
23
 
24
    unsigned long l = 0x01234567;
25
    unsigned char cErrCnt = 0;
26
    P0 = cast(l >> 24);
27
    if(P0 != 0x01) cErrCnt ++;
28
    P0 = cast(l >> 16);
29
    if(P0 != 0x23) cErrCnt ++;
30
    P0 = cast(l >>  8);
31
    if(P0 != 0x45) cErrCnt ++;
32
    P0 = cast(l >>  0);
33
    if(P0 != 0x67) cErrCnt ++;
34
 
35
    if(cErrCnt !=0) {
36
        P2 = 0x55; // Test Fail
37
        P3 = cErrCnt;
38
 
39
    } else {
40
       P2 = 0xAA; // Test PASS
41
       P3 = 0xAA; // Test PASS
42
    }
43
 
44
    while(1);
45
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.