原创 HAL的不同方式访问字符器件的空间开销简单比较.(Nios II)

2009-10-16 12:56 2856 15 15 分类: FPGA/CPLD

Unix类型


 


7133d1de-39f3-400b-bbed-f6728f95cd64.JPG


#include "system.h"
#include "fcntl.h"
#include "unistd.h"

int main(void)
{
  int fd; // file descriptor
  char msg[] = "Hello Nios!";
  
  fd = open("/dev/jtag_uart", O_WRONLY);
  write(fd, msg, sizeof(msg)-1);
  close(fd);

  return 0;
}


 


Info: (hello_nios.elf) 2608 Bytes program size (code + initialized data).
Info:                  8189 KBytes free for stack + heap.


 


ANSI C


 


7d28622b-decd-4633-88a0-3b63d03acb28.JPG


#include "system.h"
#include <stdio.h>

int main (void)
{
  FILE *fp; // file pointer
  char msg[] = "Hello Nios!";
  
  fp = fopen("/dev/jtag_uart", "w");
  fprintf(fp, msg);
  fclose(fp);
  
  return 0;
}


Info: (hello_nios.elf) 43 KBytes program size (code + initialized data).
Info:                  8148 KBytes free for stack + heap.


 

 C++流

 

(略)

 

文章评论0条评论)

登录后参与讨论
我要评论
0
15
关闭 站长推荐上一条 /2 下一条