[February , 27, 2008] 回乡偶记

		     回乡偶记

(一)回来之后,听亲戚讲述我奶奶家的历史,让我颇感惊讶。第一件事情是,

我爷爷是48年县城的第一批秘密党员。那时候还没有解放,秘密入的;第二件

事情是,我奶奶家是地主。汗,我一直以为我是“根正苗红”的“三代贫农”

----不过要从我爷爷出身算,是。

(二)飞回来上班的。印象深刻的是坐火车次次都有人广播找医生;坐飞机似乎

次次都有带小孩子的,哭声不断。

(三)飞机上打起来了。一个男人,带着一个女的,女的怀抱很小的孩子,还有

个大约11岁的男孩,不知道什么关系。飞机上的空间挺小的,前面的一个人将

座椅放下来了,大约是阻挡了他的活动吧,双方发生了争执。只见这个人,

向前一探,一把将前排那个乘客的衬衣撕开了。声音很响,刹那间“锦帛相见”

这个词语竟然跳入脑中... ...稍后,飞机上的工作人员过来了,请后面的这个

人到后舱。随后,传出那个男人的声音。他说,这要是在地上,早把他的脑袋

拧下来了... ...又说,我们东北人就是这样,这也不是什么歧视的问题... ...

听了然人觉得好笑。这么大的脾气至少是个“处长”什么的吧。随后,抱着孩子的

女子,急忙掏出200块,求前面的男的私了。再后来,飞机准备降落了,机上工作

人员拿了4个装呕吐物的袋子(没用过的),让旁边的乘客帮着写下事情的经过。

衬衣被撕坏的乘客始终坚持必须道歉,而施暴者坚持不肯。另外也只肯出200块。

再后来,飞机降落了,其余的乘客鱼贯而出,飞机上的这5个人准备到地面解决问题。

坐我前面的女乘客走到“受害者”面前说,最看不惯你这种人,欺负孤儿寡母的,

还说衬衣500块,这不是讹人吗(一时间我都闹不清楚逻辑关系了)。那个人,

讪讪无语。东北女人豪爽,汗~

(四)飞机准备降落了,空中小姐敲厕所门,让里面的人抓紧出来... ...和火车差

不多啊~ 火车到站,就要关闭厕所,通常是乘务员狂敲一阵让里面的人出来。我也

多次见过乘客面目狰狞的恳求乘务员通融一下,行个方便。

(五)在家掰辣椒。晾干的红辣椒准备做辣椒油吃。我用手揉碎之。摸了一下鼻子,

立马火烧火燎。求助于老娘,老娘说,你要用剪子,或者套上塑料带,直接用手会很辣,

严重的话手指都会觉得辣。哎,你真没有生活常识啊。辣了吧,用醋试试。我急忙找了

个棉签,沾上醋,擦之。无效,还仿佛扩散了。黄豆大的汗珠不断落下。忽然问,

这个好用吗?老娘曰,不知道,不过你看凉菜咸了或者辣了都是加醋啊!后面我又偷着

试验了油性的化妆品,也不好用。最后打了一盆凉水,扎在里面了......

    晚上,睡觉的时候舔了一下手指,还是很辣的,不敢乱摸了。

					Zoologist
					2008-2-27

[February , 22, 2008] Watcom C 的笔记7 Watcom C (7)

Watcom C 的笔记7 Watcom C (7)

		        判断是否在 Windows 下

    之前使用int 2Fh,ax=1600h 的方法已经失效;现在提出检测CR0 的Bit0 

(V86 enabled位)。在Windows的DOS box是 v86 mode。

#include <stdio.h>
#include <i86.h>

extern short isV86( void );
#pragma aux isV86 =       \
    "smsw  ax           ",      \
    "test  ax, 1        ",      \
    "jz    V86       ",      \
    "xor   ax, ax       ",      \
    "V86:            ",      \
    "mov   ax, 1        "       \
value [ ax ];

void main()
{
		if (isV86() ==0) 
					{printf("The program is running in pure DOS\n");}
		else 
					{printf("The program is running in Windows!\n");}	
}			

    实验表明,DOS下,上面的程序不好用,仍然会判断为在Windows下,因为DOS4GW

实现的也是要使得程序进入保护模式。

Function 0400H This function returns the version of DPMI services supported. Note that this
is not necessarily the version of any operating system that supports DPMI. It
should be used by programs to determine what calls are legal in the current
environment. Pass the following information:
AX = 0400H
The information returned is:
AH = Major version
AL = Minor version
BX = Flags Bit 0 = 1 if running under an 80386 DPMI implementation. Bit 1
= 1 if processor is returned to real mode for reflected interrupts (as
opposed to Virtual 8086 mode). Bit 2 = 1 if virtual memory is
supported. Bit 3 is reserved and undefined. All other bits are zero
and reserved for later use.
CL = Processor type
02 = 80286
03 = 80386
04 = 80486
05 = Pentium
DH = Current value of virtual master PIC base interrupt
DL = Current value of virtual slave PIC base interrupt
Carry flag clear (call cannot fail)

     返回值中的 BX Bit1 =1 表明返回到Real Mode下;Bit1 =0 表明返回的是V86模式下。

#include <stdio.h>
#include <i86.h>

void main()
{
		union	REGS r;

		r.w.ax=0x400;
		int386(0x31,&r,&r);

		if ((r.w.bx & 2)==0) 
					{printf("The program is in Windows!\n");}
		else 
					{{printf("The program is in DOS!\n");}}	
}			

     实验表明很好用~

						Z.t
						2008-1-20

[February , 18, 2008] Watcom C 的笔记6 Watcom C (6)

Watcom C 的笔记6 Watcom C (6)

          命令行参数的获得

    标准C语言定义如下: int main(int argc,char *argv[])。

第一个字符串 argv[0] 是包含全路径的程序名。

#include <stdio.h>
int main(int argc,char *argv[])
{
 int i;
 printf("You have input %d arguments. Argv[0]=[%s]\n",argc-1,argv[0]);
 //argv[0] is file name
 for (i=1;i<argc;i++)
   {
    printf("argument %d:[%s]\n",i,argv[i]);
   }
 return 0;
}

G:\>getarg /L p oo.bak
DOS/4GW Protected Mode Run-time  Version 1.97
Copyright (c) Rational Systems, Inc. 1990-1994
You have input 3 arguments. Argv[0]=[G:\GETARG.EXE]
argument 1:[/L]
argument 2:[p]
argument 3:[oo.bak]

    修改一下,枚举文件和目录的例子:

#include <stdio.h>
#include <dos.h>
int main(int argc,char *argv[])
{
	struct find_t fileinfo;
	unsigned	rc;
	/* Display name and size of "*.c" files */
	rc=_dos_findfirst("*.*",_A_NORMAL+_A_RDONLY+_A_HIDDEN+_A_SYSTEM+_A_SUBDIR,&fileinfo);
	while ( rc == 0)
	  {
	  	//take care of this: the priority of "==" is higher than "&"
	  	if ((fileinfo.attrib & _A_SUBDIR)==0) 
	  					{printf("%14s %10ld\n",fileinfo.name,fileinfo.size);} //File
	  	else 	
	  					{printf("%14s      <DIR>\n",fileinfo.name);}					//Directory
	  	rc= _dos_findnext(&fileinfo);
	  }	

 return 0;
}

运行结果:

       RDTSC.C        429
           PCI      <DIR>
      PRACTICE      <DIR>
   GETCHAR.EXE      33236
      COMP.BAT        107
   GETCHAR.OBJ        483
       PTEST.C        667
       HELLO.C         86
          NOTE      <DIR>
     PTEST.OBJ        551
     PTEST.EXE      33256
      GETARG.C        257
     EMUFILE.C        596
      MAIN.EXE      33372
      MAIN.OBJ        504
         R.TXT       1543
    GETARG.OBJ        526
     HELLO.OBJ        409
   EMUFILE.EXE      33384
   EMUFILE.OBJ        574
     HELLO.EXE      33216
   MEMTEST.OBJ        464
     HELLO.ERR         54

						Z.t
						2008-1-19