php作客户端,C++作服务端的socket通信 15
请问这样可以实现么?我写的php客户端可以发出并且C++的服务端做出正确回应,但是C++服务端发出的消息php端没办法接受到,请问这是为什么??...
请问这样可以实现么?我写的php客户端可以发出并且C++的服务端做出正确回应,但是C++服务端发出的消息php端没办法接受到,请问这是为什么??
展开
1个回答
2015-03-09
展开全部
8259A共有三个工作命令字,但下例中只用过OCW1.
| OCW1将所有的中断都屏蔽掉, OCW2&OCW3也就没什么意义了.
| ** ICW stands for Initialization Command Word;
| OCW for Operation Command Word.
1. mov al,#0x11
out #0x20,al
.word 0x00eb,0x00eb | jmp +2, jmp +2
2. out #0xA0,al | and to 8259A-2
.word 0x00eb,0x00eb
3. mov al,#0x20 | 向主8259A写入ICW2.
out #0x21,al | 硬件中断入口地址0x20, 并由ICW1
| 得知中断向量长度 = 8 bytes.
.word 0x00eb,0x00eb
4. mov al,#0x28 | start of hardware int's 2 (0x28)
out #0xA1,al | 第二块8259A的中断入口是0x28.
.word 0x00eb,0x00eb
5. mov al,#0x04 | 8259-1 is master
out #0x21,al | Interrupt Request 2有级联处理.
.word 0x00eb,0x00eb
mov al,#0x02 | 8259-2 is slave
out #0xA1,al | 于上面对应,告诉大家我就是IR2对应
| 级联处理器.
.word 0x00eb,0x00eb
6. mov al,#0x01 | 8086 mode for both
out #0x21,al
.word 0x00eb,0x00eb
out #0xA1,al
.word 0x00eb,0x00eb
mov al,#0xFF | mask off all interrupts for now
out #0x21,al
.word 0x00eb,0x00eb
out #0xA1,al
| well, that certainly wasn't fun :-(. Hopefully it works, and we don't
| need no steenking BIOS anyway (except for the initial loading :-).
| The BIOS-routine wants lots of unnecessary data, and it's less
| "interesting" anyway. This is how REAL programmers do it.
|
| Well, now's the time to actually move into protected mode. To make
| things as simple as possible, we do no register set-up or anything,
| we let the gnu-compiled 32-bit programs do that. We just jump to
| absolute address 0x00000, in 32-bit protected mode.
mov ax,#0x0001 | protected mode (PE) bit
lmsw ax | This is it!
jmpi 0,8 | jmp offset 0 of segment 8 (cs)
*********************************************************************************
| This routine checks that the keyboard command queue is empty
| No timeout is used - if this hangs there is something wrong with
| the machine, and we probably couldn't proceed anyway.
empty_8042:
.word 0x00eb,0x00eb
in al,#0x64
| 8042 status port
test al,#2
| is input buffer full?
jnz empty_8042
| yes - loop
ret
*********************************************************************************
| This routine loads the system at address 0x10000, making sure
| no 64kB boundaries are crossed. We try to load it as fast as
| possible, loading whole tracks whenever we can.
|
| in: es - starting address segment (normally 0x1000)
|
| This routine has to be recompiled to fit another drive type,
| just change the "sectors" variable at the start of the file
| (originally 18, for a 1.44Mb drive)
|
sread: .word 1 | sectors read of current track
head: .word 0 | current head
track: .word 0 | current track
**read-it子函数********************************************************************
read_it:
mov ax,es
| ES当前应0x1000,对,是这样的!
test ax,#0x0fff
| 目的操作数与源操作数进行逻辑与操作,结果只反映在标志位上,对两个操作数无影响
| 必需确保ES处在64KB段边界上,即0x?000:XXXX.
| 要不你就会收到一个"DMA..."什么什么的ERR.
die: jne die
| jne:不相等/不等于零时转移,ZF=0
| es must be at 64kB boundary
xor bx,bx
| bx is starting address within segment
rp_read:
| **** 循环入口处 ****
mov ax,es
cmp ax,#ENDSEG
| have we loaded all yet?
jb ok1_read
| ax<#ENDSEG时转移
ret
ok1_read:
mov ax,#sectors
| 1.44M, sectors=18,linux的后续版本
| 中已改成由操作系统来探测sectors的值.
sub ax,sread
| AX内记载需要读的扇区数,初始sread为1,
| 即跳过第一道的第一扇区(BOOT区)
mov cx,ax
shl cx,#9
| CX左移9位,相当于:CX*512=17*512=8704字节
| CX算出需要读出的扇区的字节数, ax*512.
add cx,bx
| BX是当前段内偏移.
| 下面连续的两个转移指令开始还真让人莫名其妙.
jnc ok2_read
| jnc:无进位(或借位)时转移;CF=0
| 不要超过64k
| 这里先检查当前段内的空间够不够装ax个扇区
| cx算出字节数,加上当前偏移试试,够了的话,就
| 跳到ok2_read去读吧!
je ok2_read
| 这么巧的事也有,刚刚够! 读!
| 如果到了这里就确认溢出了,看下面的:
xor ax,ax
sub ax,bx
shr ax,#9
| 这段代码我觉得很精巧.
| shr指令执行逻辑右移操作。每执行一次,使目的操作数右移一位,移出的最低位送入标志CF,空出的高位| 补0;
| 它主要目的就是算出如果当前段内空间不够的话,
| 那么反算出剩余空间最多能装多少个扇区,那么
| 就读出多少个.(Hint,段内空间是扇区的整数倍)
ok2_read:
call read_track
| 读取当前磁道.
mov cx,ax
| (别忙,这里暂时不关cx什么事!)
add ax,sread
| AX是这次读出的扇区数, sread是该磁道已读出的扇区,相加更新AX的值.
cmp ax,#sectors
| 该磁道所有的扇区都读出了吗?
jne ok3_read
| 尚未,还不能移到下个磁道!
mov ax,#1
sub ax,head
| head对应软盘来说只能是0,1
jne ok4_read
| 0,1 head都读过了才准往下走!
inc track
| 终于可以读下个磁道了,真累!
ok4_read:
mov head,ax
xor ax,ax
ok3_read:
mov sread,ax
| 如果是由于还没读完所有的磁道?
| 那么ax记载当前磁道已读出的扇区,更新sread.
| 如果已读完18个扇区,ax被上一行代码置零.
shl cx,#9 <----|
| cx记载最近一次读的扇区数,*512算成字节.
add bx,cx
| bx是缓冲区的偏移.往前移!
jnc rp_read
| 看看当前段(64K)是不是已经装满了?
| 这里是不会超出当前段的,(见上的代码)
| 最多也就是刚刚装满. :-)
mov ax,es
| 装满了!移到下一段!!!
add ax,#0x1000
mov es,ax
xor bx,bx
| 偏移置零!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询