void SeniorVMHandle::b_sub(long _register1,long _register2) { b_not(_register1); pop(T_INVALID); pop(T_TMP_R8_8L); b_add(T_TMP_R8_8L,_register2); // pop(T_INVALID); pop(T_TMP_REGISTER6); //eflag 1 b_copy_stack(); b_not_and(); pop(T_TMP_REGISTER7); //eflag 2 //pop(T_TMP_REGISTER8); //结果 d_not(T_TMP_REGISTER6); pop(T_INVALID); w_push_imm_sx(0xf7ea); d_not_and(); pop(T_INVALID); pop(T_TMP_REGISTER6); d_not(T_TMP_REGISTER7); pop(T_INVALID); w_push_imm_sx(0x815); d_not_and(); pop(T_INVALID); pop(T_TMP_REGISTER7); d_add(T_TMP_REGISTER6,T_TMP_REGISTER7); pop(T_INVALID); }
void SeniorVMHandle::w_sub(long _register1,long _register2) { w_not(_register1); //sub eax,ebx = add((not eax),ebx) pop(T_INVALID); pop(T_TMP_R16_8); b_add(T_TMP_R16_8,_register2); // pop(T_INVALID); pop(T_TMP_REGISTER6); //eflag 1 w_copy_stack(); w_not_and(); pop(T_TMP_REGISTER7); //eflag 2 //pop(T_TMP_REGISTER8); //结果 d_not(T_TMP_REGISTER6); pop(T_INVALID); w_push_imm_sx(0xf7ea); d_not_and(); pop(T_INVALID); pop(T_TMP_REGISTER6); d_not(T_TMP_REGISTER7); pop(T_INVALID); w_push_imm_sx(0x815); d_not_and(); pop(T_INVALID); pop(T_TMP_REGISTER7); d_add(T_TMP_REGISTER6,T_TMP_REGISTER7); pop(T_INVALID); }
/* writes <len> bytes from message <msg> to the channel's buffer. Returns -1 in * case of success, -2 if the message is larger than the buffer size, or the * number of bytes available otherwise. The send limit is automatically * adjusted to the amount of data written. FIXME-20060521: handle unaligned * data. Note: this function appends data to the buffer's output and possibly * overwrites any pending input data which are assumed not to exist. */ int co_inject(struct channel *chn, const char *msg, int len) { int max; if (len == 0) return -1; if (len < 0 || len > c_size(chn)) { /* we can't write this chunk and will never be able to, because * it is larger than the buffer. This must be reported as an * error. Then we return -2 so that writers that don't care can * ignore it and go on, and others can check for this value. */ return -2; } c_realign_if_empty(chn); max = b_contig_space(&chn->buf); if (len > max) return max; memcpy(ci_tail(chn), msg, len); b_add(&chn->buf, len); c_adv(chn, len); chn->total += len; return -1; }
void converttobin() { int temp[1024]; binadd[0]=1; for(int i=0;i<110;i++) { if(goodness2[0].kdo[i]>0) { b_mult(binadd, goodness2[0].kdo[i] , temp); b_add(temp,BIN); goodness2[0].kdo[i]=0; } b_mult( binadd, k ,binadd); } binsub[0]=1; for(int i=0;i<110;i++) { if(goodness2[0].kdo[i]<0) { b_mult(binsub, -goodness2[0].kdo[i] , temp); b_sub(temp,BIN); goodness2[0].kdo[i]=0; } b_mult( binsub, k , binsub); } }
/* Inserts <str> followed by "\r\n" at position <pos> relative to channel <c>'s * input head. The <len> argument informs about the length of string <str> so * that we don't have to measure it. <str> must be a valid pointer and must not * include the trailing "\r\n". * * The number of bytes added is returned on success. 0 is returned on failure. */ int ci_insert_line2(struct channel *c, int pos, const char *str, int len) { struct buffer *b = &c->buf; char *dst = c_ptr(c, pos); int delta; delta = len + 2; if (b_tail(b) + delta >= b_wrap(b)) return 0; /* no space left */ if (b_data(b) && b_tail(b) + delta > b_head(b) && b_head(b) >= b_tail(b)) return 0; /* no space left before wrapping data */ /* first, protect the end of the buffer */ memmove(dst + delta, dst, b_tail(b) - dst); /* now, copy str over dst */ memcpy(dst, str, len); dst[len] = '\r'; dst[len + 1] = '\n'; b_add(b, delta); return delta; }
/* Tries to copy block <blk> at once into the channel's buffer after length * controls. The chn->o and to_forward pointers are updated. If the channel * input is closed, -2 is returned. If the block is too large for this buffer, * -3 is returned. If there is not enough room left in the buffer, -1 is * returned. Otherwise the number of bytes copied is returned (0 being a valid * number). Channel flag READ_PARTIAL is updated if some data can be * transferred. */ int ci_putblk(struct channel *chn, const char *blk, int len) { int max; if (unlikely(channel_input_closed(chn))) return -2; if (len < 0) return -3; max = channel_recv_limit(chn); if (unlikely(len > max - c_data(chn))) { /* we can't write this chunk right now because the buffer is * almost full or because the block is too large. Return the * available space or -2 if impossible. */ if (len > max) return -3; return -1; } if (unlikely(len == 0)) return 0; /* OK so the data fits in the buffer in one or two blocks */ max = b_contig_space(&chn->buf); memcpy(ci_tail(chn), blk, MIN(len, max)); if (len > max) memcpy(c_orig(chn), blk + max, len - max); b_add(&chn->buf, len); channel_add_input(chn, len); return len; }
void b_mult(int * src, long f, int * dst) { int temp[1024]; for(int i=0;i<1024;i++) { temp[i]=src[i]; dst[i]=0; } while(f--)b_add(temp,dst); }
/* Tries to copy block <blk> at once into the channel's buffer after length * controls. The chn->o and to_forward pointers are updated. If the channel * input is closed, -2 is returned. If the block is too large for this buffer, * -3 is returned. If there is not enough room left in the buffer, -1 is * returned. Otherwise the number of bytes copied is returned (0 being a valid * number). Channel flag READ_PARTIAL is updated if some data can be * transferred. */ int ci_putblk(struct channel *chn, const char *blk, int len) { int max; if (unlikely(channel_input_closed(chn))) return -2; if (len < 0) return -3; max = channel_recv_limit(chn); if (unlikely(len > max - c_data(chn))) { /* we can't write this chunk right now because the buffer is * almost full or because the block is too large. Return the * available space or -2 if impossible. */ if (len > max) return -3; return -1; } if (unlikely(len == 0)) return 0; /* OK so the data fits in the buffer in one or two blocks */ max = b_contig_space(&chn->buf); memcpy(ci_tail(chn), blk, MIN(len, max)); if (len > max) memcpy(c_orig(chn), blk + max, len - max); b_add(&chn->buf, len); chn->total += len; if (chn->to_forward) { unsigned long fwd = len; if (chn->to_forward != CHN_INFINITE_FORWARD) { if (fwd > chn->to_forward) fwd = chn->to_forward; chn->to_forward -= fwd; } c_adv(chn, fwd); } /* notify that some data was read from the SI into the buffer */ chn->flags |= CF_READ_PARTIAL; return len; }
/* Tries to copy character <c> into the channel's buffer after some length * controls. The chn->o and to_forward pointers are updated. If the channel * input is closed, -2 is returned. If there is not enough room left in the * buffer, -1 is returned. Otherwise the number of bytes copied is returned * (1). Channel flag READ_PARTIAL is updated if some data can be transferred. */ int ci_putchr(struct channel *chn, char c) { if (unlikely(channel_input_closed(chn))) return -2; if (!channel_may_recv(chn)) return -1; *ci_tail(chn) = c; b_add(&chn->buf, 1); chn->flags |= CF_READ_PARTIAL; if (chn->to_forward >= 1) { if (chn->to_forward != CHN_INFINITE_FORWARD) chn->to_forward--; c_adv(chn, 1); } chn->total++; return 1; }