via威盛——笔试题1

来源:互联网 发布:前端内置数据库 编辑:程序博客网 时间:2024/06/06 02:47
 
威盛笔试试题
  2002年软件笔试题
1.三组程序,找出你认为的错误。
a.c b.c c.c 代表的是三个文件名,以下extern后面的long都可以省略
  (1)a.c long temp[255];
b.c extern long *temp;
不可以,程序运行时会告诉你非法访问。原因在于,指向类型T的指针并不等价于类型T的数组。extern long *temp声明的是一个指针变量而不是字符数组,因此与实际的定义不同,从而造成运行时非法访问。应该将声明改为extern long temp[]
  (2)a.c long temp[255];
b.c extern long temp[256];
可能越界
  (3)a.c long temp[255];
b.c extern long temp[];
正确
  2.在第一个声明处编译出了奇怪的错误,为什么?
  #include
  #include “myfun1.h”
  #include “myfun2.h”
  int myInt1;
  int myInt2;
  3.printf(“0x%x”, (&0)[1]); 请问打印了什么?
  4.汇编,用ax,bx,cx,dx,求1000×1000/30(四舍五入),结果放在ax中。
  5.编最优化Bubble(int *pIntArray,int L),要求:交换元素不能用临时变量,如果有序需要最优。
6.用任意一种编程语言写n!的算法。
F(n)
{
If(n==1) return 1;
Else return n*f(n-1);
}
3, printf("0x%x", (&0)[-1]); 请问打印了什么?
4, 结构体内某项偏移地址
 
#define list_entry(ptr, type, member) /
       ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
 
struct test{
    int a;
    int b;
    double c;
   
};
int main(int argc, char *argv[])
{
    cout << &((test *)0)->b;
 
    return 0;
}
000004
5, 汇编,用ax,bx,cx,dx, 求1000*1000/30(四舍五入), 结果放在ax中.
6, 1,2,3,4,5,6,7,8,9从栈里出来的可能性.
7, 求一个struct的sizeof.(略)
8, 编最优化Bubble(int *pIntArray,int L),要求:交换元素不能用临时变量,如果有序,
需要最优.
:交换元素不能用临时变量
void exchange1( int &a, int &b)
   {
       a=a+b;
       b=a-b;
       a=a-b;
   }
依照上面的顺序得出来一行:a = (a = a + b) - (b = a - b);
       void exchange2(int& a,int& b)
{
    a=a^b;
    b=a^b;
    a=a^b;
}
依照上面的顺序得出来一行:a = (a = a ^ b) ^ (b = a ^ b);
设一交换标志,无交换就停止执行
  2003 Software Engineer笔试题
  1. Describe x86 PC’s architecture in a diagram cpu,core chipset, Cache,DRAM, IO-subsystem, IO-Bus
  2. SWI instruction is often called a “supervisor call”, describe the actions in detail
  * Save the address of the instruction after the SWI in rl4_svc.
  * Save the CPSR in SPSR_svc.
  * Enter supervisor mode and disable IRQs.
  * Set the PC to 08 and begin executing the instruction there.
  3.
  * What is PIO operation? advantage and disadvantage?
* DMA operation? advantage and disadvantage?
直接内存访问(DMA)方式是一种完全由硬件执行I/O交换的工作方式。DMA控制器从CPU完全接管对总线的控制。数据交换不经过CPU,而直接在内存和I/O设备之间进行。
* Scatter/Gather DMA engine? how does it operate?
Scatter-gather&nbspDMA方式使用一个链表描述物理上不连续的存储空间,然后把链表首地址告诉DMA masterDMA master在传输完一块物理连续的数据后,不用发起中断,而是根据链表来传输下一块物理上连续的数据,直到传输完毕后再发起一次中断
  4. MP3 decoder related. (a flow chart of decoding is presented)
  * advantages of Huffman encoding?
  * why the aliasing reduction is necessary?
  * analytical expression in mathematics of the IMDCT?
  * which block in the flow chart is suitable for the software implementation and which for the hardware? why?
  5. Assembly codes -> C language (about 15 lines).
  6. Graduation thesis description.
      
5。说出你的最大弱点及改进方法。
6。说出你的理想。说出你想达到的目标。
 
发信人: luckyok (小丫头骗子),
信区: job
标 题: 【合集】威盛笔试题目(大家一起回忆)
发信站: 饮水思源 (2002111822:04:53 星期一), 站内信件  
☆──────────────────────────────────────☆     
mikelish (困了) 于 2002111818:40:40 星期一 提到:  
 
1。说明线程和进程的关系。
 
2。C程序写结果。  
#include <stdio.h>   
#define ADD(p) {p++;(*p)++;}   
 
Add(int *p) {p++;(*p)++;}   
int a[]={0,1,2};   
 
int main()   
{
 int *p=a;     
 ADD(p)     
 ADD(p)     
 printf("%d,%d,%d/n",a[0],a[1],a[2]);
 p=a;
 Add(p);
 Add(p);
 printf("%d,%d,%d/n",a[0],a[1],a[2]);
}
0,2,3
0,4,3
 
3。说明下面的的表达有没有不同,如果不同,请说明不同在哪里。
 char* s1="hello";
 char s2[]="world";
 VC下编译无错,执行是出现非法错误。但是TC2下编译运行都没有错误。
第一题:hellopello
第二天:hi risesun (offer) 的大作中提到: : 头两题VC中编译没有错误,但是运行时有内存不能写的错误。 : 第一题中char* str1 = "hello"; : 系统先给字符串常量"hello"分配内存,其中"hello"const的,然后分配指针空间,把 : "hello"的首地址赋给str1。所以*str1是不能作为lvalue的。 : 第二题的问题类似。 : 但是如果改成char str1[] = "hello"; : 就行了。因为此时系统先给字符串常量"hello"分配内存,然后为字符数组str1分配空间 : ,执行strcpy的操作,这样str1指向的空间就没有const属性了。 : 第三题中,reti是中断返回,此时不能带参数返回(ret 4之类的),而且还要清除中断 : 标志。
4.说明下面程序的作用。  
 func(char*a,char*b)  
 {    
     while(*a++=*b++);
     return;
 }
 Strcpy
5.printf可以接受多个参数,为什么,请写出printf的原型。
_CRTIMP int __cdecl printf(const char *, ...);
_CRTIMP int __cdecl vprintf(const char *, va_list);
6.说明malloc和calloc的区别。
Calloc初始化内存为0
7。int31h function 06写出在C中使用x86汇编指令 程序。     (本题记不清了,反正就是考C中嵌入汇编指令。)
 
8。写程序。  
Struct A     {      Struct A * next;     }    A组成了一个单向链表,请写出一个程序,用于检测单向链表是否形成环。
 
 
// 威盛面试题 // X86汇编程序的等价 C 程序V0.1
 
struct NODE
{
 int val;
 struct NODE *curr;
};
 
void g()
{
 ....;
 NODE a[3];
 for (int i = 0; i < 3; i++)
 {
   f(&a[i], i);
 }
}
 
void f(NODE *pN, int val)
{
 pN->val = val;
 pN->curr = pN; // 这一句是依据ASM程序直译的, // 感觉有些怪怪的!? }
 
在 sjhcool (sjhcool) 的大作中提到: 】 :
把下面一段汇编翻译成C代码:
XOR SI,SI
JMP 02DC:02CB
MOV AX,SI
MUL BX
BX = Sizeof struct NODE
ADD AX,NODE
PUSH AX
PUSH SI
CALL 02E4
ADD SP,+04
 
原创粉丝点击