
C/C++
咕噜咕噜斯基
哎哟, 不错哦.
展开
-
What does the C ??!??! operator do?!
原帖: http://stackoverflow.com/questions/7825055/what-does-the-c-operator-do============================================================================================================================转载 2012-10-05 11:40:20 · 950 阅读 · 0 评论 -
位逆序算法
// 位逆序算法, 可延伸至任意位#include // 采用分治算法unsigned int bitrev(unsigned int a){ a = ((a >> 16) & 0x0000FFFF) | ((a << 16) & 0xFFFF0000); // 交换 16 位子区间数据 a = ((a >> 8) & 0x00FF00FF) | ((a << 8)转载 2012-11-01 08:20:32 · 1105 阅读 · 0 评论 -
回调函数例程
//==============================================================================================// 回调函数常用于对异步事件的处理.// 对异步事件的处理,首先将异步事件发生时需要执行的代码编写成一个函数,并将该函数注册成为// 回调函数,这样当该异步事件发生时,系统会自动调用事先注册好的回调函原创 2012-11-01 08:26:20 · 1480 阅读 · 1 评论 -
CSL_init.c (MSP430 & IAR)
源码转自: https://docs.google.com/viewer?pid=sites&srcid=ZGVmYXVsdGRvbWFpbnxtaWNyb3JvYm90aWNzbGFib3JhdG9yeXxneDozNmUxOWY5Mjk3OTMzOGJm&docid=c9324b44940f445906e9f2223be5dadd%7C453122719589940673d062e71b9fe原创 2012-10-13 22:03:13 · 2237 阅读 · 0 评论 -
Real-time frameworks
// 注: 这是我从一老外的课件里摘取出来的. 并非原创.===============================================================================================================原创 2012-11-25 16:51:20 · 686 阅读 · 0 评论 -
IEEE 754 Converter
This page allows you to convert between the decimal representation of numbers (like "1.02") and the binary format used by all modern CPUs (IEEE 754 floating point). The conversion is limited to single原创 2012-11-26 08:59:22 · 1337 阅读 · 0 评论 -
各种编程语言速度、内存、代码的比较
点击最上面选择语言, 然后show:http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=go&lang2=gcc原创 2012-11-17 16:32:12 · 5656 阅读 · 0 评论 -
在线的C/C++参考网站
// C语言: C89, C99, C11// C++ : C++98, C++03, C++11中文的:http://zh.cppreference.com/w/英文的: http://en.cppreference.com/w/原创 2012-11-17 15:58:36 · 1435 阅读 · 0 评论 -
Hierarchical state machines
// 注: 这是我从一老外的课件里摘取出来的. 并非原创.===============================================================================================================原创 2012-11-25 16:42:55 · 854 阅读 · 0 评论 -
内存碎片
原文: http://wangminshe89.iteye.com/blog/1421462=====================================================================================================内存碎片的产生内存分配有静态分配和动态分配两种静态分配在程序编译链接时分配的大转载 2012-10-13 20:08:11 · 786 阅读 · 0 评论 -
[DSP+ARM] 函数优化(整理)
原帖: http://bbs.21ic.com/icview-382765-1-1.html===============================================================================================================================Inline函数 在 C++ 中,原创 2012-10-11 19:04:32 · 1405 阅读 · 0 评论 -
指针做形参做局部变量以及内存分配
原文: http://www.cnblogs.com/stoneJin/archive/2011/09/21/2183962.html===============================================================================================================================一级转载 2012-10-10 18:52:08 · 860 阅读 · 0 评论 -
Jump Tables via Function Pointer Arrays in C/C++
by Nigel Jones=================================================================================================================Jump tables, also called branch tables, are an efficient means转载 2012-09-16 09:16:17 · 1733 阅读 · 0 评论 -
C 语言中宏的使用
作者: Hai Shalom 译者: KISSMonX原文地址:http://www.rt-embedded.com/blog/archives/macros-in-the-c-programming-language/================================================翻译 2012-05-03 20:02:10 · 1955 阅读 · 0 评论 -
回调函数和中断处理函数
原文: http://www.sdembed.com/thread-157-1-1.html====================================================================================1,回调函数。回调函数的原理是使用函数指针实现类似“软中断”的概念。比如在上层的两个函数A和B,把自己的函数指针传给了C转载 2012-10-04 22:42:00 · 15868 阅读 · 0 评论 -
crt0.o and crt1.o — What's the difference?
原帖: http://stackoverflow.com/questions/2709998/crt0-o-and-crt1-o-whats-the-difference=================================================================================================================转载 2012-10-02 11:26:34 · 2600 阅读 · 0 评论 -
MSP430(G2553)用看门狗定时器来产生周期信号
#include #include volatile unsigned int i = 0; // 中断服务子程序中所用到的全局变量, 最好定义成 volatile 型, 具体原因和用法可以参考我的其他博文介绍void main (void){ WDTCTL = WDT_MDLY_0_5; // 周期 0.5ms, 设置可参考下面头文件中的截段 IE1 |= WDT原创 2012-09-12 22:15:01 · 4018 阅读 · 0 评论 -
main()是程序运行的第一个函数吗?
程序运行到main()函数之前,CPU做了那些事情?main()是程序运行的第一个函数吗? 你是否真的明白——编译、链接、重定位以及虚拟地址? 或许,你不需要知道和理解这些知识就能够编程,而且工资还很高,但这些都不是你不知道的理由。 在早期的计算机中,由于所有程序在运行时所访问的地址都是物理地址,所以各个程序所使用的地址空间不是 互相隔离的,如果因为转载 2012-08-19 17:26:14 · 3078 阅读 · 0 评论 -
分享MSP430用TB捕获脉宽问题与解决心得
原帖: http://bbs.21ic.com/icview-293369-1-1.html=============================================================================================================================硬件:单片机:MSP430F149 晶振:32转载 2012-09-30 20:23:35 · 2469 阅读 · 0 评论 -
MSP430的C语言编写注意事项
原帖:http://bbs.21ic.com/icview-292712-1-1.html==============================================================================================================================微处理器一般用于特定环境和特定用途,出于成本、功耗转载 2012-09-29 21:43:39 · 1574 阅读 · 2 评论 -
从 51 到 ARM, 这路怎么走?
原帖: http://www.amobbs.com/thread-5462507-1-1.html说的不错, 尤其是 23 楼的那哥们, 嘿嘿......抓住, 记录下来, 分享.//////////////////////////////////////////////////////////////////////////////////////////////////////////转载 2012-07-07 13:34:13 · 8369 阅读 · 1 评论 -
Event-Driven Programming
// 注: 这是我从一老外的课件里摘取出来的. 并非原创.============================================================================================原创 2012-11-25 16:37:32 · 943 阅读 · 0 评论 -
C 语言程序中与存储器相关的常见错误(即指针相关)
对于书写 C 语言程序的程序员而言, 与存储器有关的错误是非常让人郁闷无语的, 因为不管是在空间还是时间上, 错误和异常通常是在距离错误根源有一段时间或空间距离上才表现出来. 给查找真正的错误源带来很大困难. 将错误的数据写到错误的位置, 程序可能在最终失败前运行了好几个小时甚至几天几月(嵌入式系统), 但是程序的错误已经离真正的源头很远了, 呈现的错误也好像是"刻舟求剑"的结果, 只有刀痕没有原创 2012-10-03 15:38:43 · 2541 阅读 · 0 评论 -
Using GNU C __attribute__
原文地址:http://www.unixwiz.net/techtips/gnu-c-attributes.htmlOne of the best (but little known) features of GNU C is the __attribute__ mechanism, which allows a developer to attach characteristics to转载 2012-08-28 16:06:07 · 966 阅读 · 0 评论 -
Resolving/Debugging user space crashes and segmentation faults
By Hai Shalom原文地址: http://www.rt-embedded.com/blog/archives/resolving-crashes-and-segmentation-faults/============================================================================================转载 2013-05-19 16:40:56 · 1916 阅读 · 0 评论 -
内存屏障--- asm volatile("" ::: "memory")
Compiler memory barrierThese barriers prevent a compiler from reordering instructions, they do not prevent reordering by CPU.The GNU inline assembler statementasm volatile("" ::: "memory");原创 2013-06-16 14:17:38 · 18740 阅读 · 0 评论 -
Idling along, (or what to do in the idle task)
by Nigel Jones原文: http://embeddedgurus.com/stack-overflow/2013/04/idling-along/=================================================================================================================转载 2013-07-08 10:21:45 · 1119 阅读 · 0 评论 -
What`s in your main() header?
by Nigel Jones原文: http://embeddedgurus.com/stack-overflow/2013/02/whats-in-your-main-header/-----------------------------------------------------------------------------------------------------转载 2013-02-21 15:07:00 · 948 阅读 · 0 评论 -
达夫设备
转自: 维基百科在计算机科学领域,达夫设备(英文:Duff's device)是串行复制(serial copy)的一种优化实现,通过汇编语言编程时一常用方法,实现展开循环,进而提高执行效率。这一方法据信为当时供职于卢卡斯影业的汤姆·达夫于1983年11月发明,并可能是迄今为止利用C语言switch语句特性所作的最巧妙的实现。在编程时,循环展开注重于利用批量处理,减少总转载 2013-07-12 15:58:04 · 1288 阅读 · 0 评论 -
嵌入式系统高效编程
作者:Hai Shalom 译者: KISSMonX原文地址:http://www.rt-embedded.com/blog/archives/writing-efficient-c-code-for-embedded-systems//*** 注:** 本文的翻译是业余捣鼓的, 本人是个菜鸟, 不是谦虚. 呵呵...... 早就弄好了, 今天才发.翻译 2012-05-14 18:39:18 · 1118 阅读 · 0 评论 -
MSP430用按键中断控制定时器产生持续 1s 的周期信号
//////////////////////////////////////////////////////////////////////////////////////////////////////// 2012 年吉林省大学生电子设计大赛 C题> ----(声源部分)// 要求: 有信号产生电路, 放大电路, 声音频率 800Hz 左右, 按一次键响声持续 1 秒.//原创 2012-09-12 22:25:22 · 5249 阅读 · 4 评论 -
关于 keil C51 warning C182: Pointer to Different Objects 解决.
帮助文档里的解释是: " Pointer to Different Objects "这里的警告一般都是犯的类型不匹配的错误, 例如int 型与 int * 类型互相赋值. 等等.我这里犯的错误是, 我使用了函数指针, 而且参数超过了三个, 由于 keil 编译器的参数并不经过栈来传递参数, 按照帮助文档的解决方法, 要加 reentrant 关键字来告诉编译器原创 2013-09-04 15:11:24 · 32503 阅读 · 0 评论 -
volatile 修饰的变量"副作用/序列点"问题
这个问题是因为这个帖子而起, 也是这段代码有点不明白. 和自己预期的值不一样, 所以就编译反汇编看了下.编译工具: Code:blocks(GCC), CPU(Intel Core i3 32位), OS(windows 7 / 32bit).参考书籍: 深入理解计算机系统(Bryant & Hallaron)更多了解关于 volatile 可以参考: http://blog.cs原创 2012-09-29 12:24:39 · 1495 阅读 · 1 评论 -
Embedded software 5 most destructive bugs
By Hai Shalom原文地址: http://www.rt-embedded.com/blog/archives/5-most-destructive-bugs/================================================================================================================转载 2013-05-19 16:30:32 · 1063 阅读 · 0 评论 -
Writing a good README
原文: http://blog.thefrontiergroup.com.au/2013/05/writing-a-good-readme/ By: Jordan Maguire=====================================================================================================转载 2013-05-17 08:01:18 · 1038 阅读 · 0 评论 -
霸气的强制类型转换和指令码函数
#include void(* swap)() = (void(*)()) "\x8b\x44\x24\x04\x8b\x5c\x24\x08\x8b\x00\x8b\x1b\x31\xc3\x31" \"xd8\x31\xc3\x8b\x4c\x24\x04\x89\x01\x8b\x4c\x24\x08\x89\x19\xc3";// works on GCC 3+4int mai转载 2013-03-06 15:25:14 · 1398 阅读 · 0 评论 -
memcpy() 函数的效率与平台相关.
先来看看微软开发工具下的 memcpy() 源代码(E:\Microsoft Visual Studio 9.0\VC\crt\src):/****memcpy.c - contains memcpy routine** Copyright (c) Microsoft Corporation. All rights reserved.**Purpose:*原创 2012-09-27 19:13:01 · 2882 阅读 · 0 评论 -
IAR for MSP430 和 AVR 单片机, 数据类型和指针大小(编译器手册)
====================================================================================================================================================================================================原创 2012-09-14 22:36:56 · 2765 阅读 · 0 评论 -
char 型数据本质上是没有算术和逻辑运算的
------------------------------------------------------------------------------------------------------------------------------"A character, a short integer, or an integer bit-field, all either signe原创 2012-09-13 14:35:34 · 2603 阅读 · 0 评论 -
用一个双字节变量表示两个单字节组成的双字节数据
想想应该有好几种方法, 当然了, 这两个单字节变量的地址得考虑是连续的还是不连续的和考虑大小端序问题.对于地址不连续的情况: unsigned char H_Byte, L_Byte;unsigned short Two_Bytes = (H_Byte << 8) + L_Byte; // 1unsigned short Two_Bytes = (H_Byte * 0x原创 2012-09-28 21:55:23 · 4870 阅读 · 0 评论