求2个字节的关系(200)

  • 主题发起人 主题发起人 me555555
  • 开始时间 开始时间
M

me555555

Unregistered / Unconfirmed
GUEST, unregistred user!
00=1B,01=1B,02=1B,03=1B,04=1B,05=1B,06-=1B,07=1B08=1A,09=1A,10=1A,0A=1A,0B=1A,0C=1A,0D=1A,OF=1A10=19,11=19,12=19,13=19,14=19,15=19,16-=19,17=1918=18,19=18,11=18,1A=18,1B=18,1C=18,1D=18,1F=1820=1F,21=1F,22=1F,23=1F,24=1F,25=1F,26-=1F,27=1F28=1E,29=1E,12=1E,2A=1E,2B=1E,2C=1E,2D=1E,2F=1E30=1D,31=1D,32=1D,33=1D,34=1D,35=1D,36-=1D,37=1D38=1C,39=1C,13=1C,3A=1C,3B=1C,3C=1C,3D=1C,3F=1C40=13,41=13,42=13,43=13,44=13,45=13,46-=13,47=1348=12,49=12,12=12,4A=12,4B=12,4C=12,4D=12,4F=1250=11,51=11,52=11,53=11,54=11,55=11,56-=11,57=1158=10,59=10,10=10,5A=10,5B=10,5C=10,5D=10,5F=1060=17,61=17,62=17,63=17,64=17,65=17,66-=17,67=1768=16,69=16,16=16,6A=16,6B=16,6C=16,6D=16,6F=1670=15,71=15,72=15,73=15,74=15,75=15,76-=15,77=1578=14,79=14,17=14,7A=14,7B=14,7C=14,7D=14,7F=1480=0B,81=0B,82=0B,83=0B,84=0B,85=0B,86-=0B,87=0B88=0A,89=0A,18=0A,0A=0A,0B=0A,8C=0A,8D=0A,8F=0A90=09,91=09,92=09,93=09,94=09,95=09,96-=09,97=0998=08,99=08,19=08,9A=08,9B=08,9C=08,9D=08,9F=08A0=0F,A1=0F,A2=0F,A3=0F,A4=0F,A5=0F,A6-=0F,A7=0FA8=0E,A9=0E,0E=0E,AA=0E,AB=0E,AC=0E,AD=0E,AF=0EB0=0D,B1=0D,B2=0D,B3=0D,B4=0D,B5=0D,B6-=0D,B7=0DB8=0C,B9=0C,0C=0C,BB=0C,BB=0C,BC=0C,BD=0C,BF=0CC0=03,C1=03,C2=03,C3=03,C4=03,C5=03,C6-=03,C7=03C8=02,C9=02,02=02,CC=02,CC=02,CC=02,CD=02,CF=02D0=01,D1=01,D2=01,D3=01,D4=01,D5=01,D6-=01,D7=01D8=00,D9=00,00=00,DD=00,DD=00,DD=00,DD=00,DF=00E0=07,E1=07,E2=07,E3=07,E4=07,E5=07,E6-=07,E7=07E8=06,E9=06,06=06,EE=06,EE=06,EE=06,EE=06,EF=06F0=05,F1=05,F2=05,F3=05,F4=05,F5=05,F6-=05,F7=05F8=04,F9=04,04=04,FF=04,FF=04,FF=04,FF=04,FF=04上面是2个字节的对应关系。等号左边是从00-FF(即0-255)等号右边。每增加8发生变化。而有一定规律从00-1F现求这个规律用not ad or xor shr shl 来表示
 
if _in=255result:='255=27 => FF=1B'elseResult:=Trim(IntToStr(_In))+'= => '+Trim(IntToHex(In))+'='+Trim(IntToHex($1b+_In-1))
 
楼主的问题没有说清楚index value0 = 27 1 = 592 = 913 = 123 4 = 1555 = 187 6 = 219 7 = 251 8 = 26 楼主的问题是不是求index和Value的转换公式呀,例如给出索引然后求该索引对应的值呀或者是给出值求该值对应的索引呀,如果是这样的话,最简单的方法是定义一查找表,就是楼主列出的值,根据查找表的索引可以得到值,在查找表里搜索值可以得到该值对应的索引。根据楼主给出的数据的规律,最后一个数据255=27是错误的,应该是255=228才对.如果不用查找表的话:var g_ConvertArray:array[0..31] of Byte= ( 27,26,25,24, 31,30,29,28, 19,18,17,16, 23,22,21,20, 11,10,09,08, 15,14,13,12, 03,02,01,00, 07,06,05,04 );function ValueToIndex(Value:Byte):Byte;var iMod,iDiv,index,i:Byte;begin iMod:=Value mod 32; iDiv :=Value div 32; index:=0; for i:=0 to 31 do if g_ConvertArray=iMod then begin index:=i*8; break; end; result:=index+iDiv;end;function IndexToValue(index:Byte):Byte;var iMod,iBase:Byte;begin iBase:=index div 8; iMod:=index mod 8; iBase:=g_ConvertArray[iBase]; result:=iBase+iMod*32;end;procedure TForm1.Button1Click(Sender: TObject);begin //例如:1=59 edit2.Text:=IntToStr(IndexToValue(StrToInt(edit1.Text)));end;procedure TForm1.Button2Click(Sender: TObject);begin //例如:59=1 edit2.Text:=IntToStr(ValueToIndex(StrToInt(edit1.Text)));end;
 
这个就可以得到你要的结果,除了FF有点特殊,按照给出的规律FF转换后的结果应该是228,跟你的结果不一样,你单独处理一下就行了edit2.Text:=IntToHex(IndexToValue(StrToInt('$'+edit1.Text)),2);//例如edit1.text='F1',转换的结果edit2.text:='25'你自己测试一下ValueToIndex函数跟IndexToValue函数正好相反
 
既然转换都有了,做个表得了,吃饱没事撑着搞算法做什么.真的要搞,把那个EXE里的ASM RIP下来用也就行了,没必要话脑筋,浪费生命.
 
00=1B,01=1B,02=1B,03=1B,04=1B,05=1B,06-=1B,07=1B08=1A,09=1A,10=1A,0A=1A,0B=1A,0C=1A,0D=1A,OF=1A10=19,11=19,12=19,13=19,14=19,15=19,16-=19,17=1918=18,19=18,11=18,1A=18,1B=18,1C=18,1D=18,1F=1820=1F,21=1F,22=1F,23=1F,24=1F,25=1F,26-=1F,27=1F28=1E,29=1E,12=1E,2A=1E,2B=1E,2C=1E,2D=1E,2F=1E30=1D,31=1D,32=1D,33=1D,34=1D,35=1D,36-=1D,37=1D38=1C,39=1C,13=1C,3A=1C,3B=1C,3C=1C,3D=1C,3F=1C40=13,41=13,42=13,43=13,44=13,45=13,46-=13,47=1348=12,49=12,12=12,4A=12,4B=12,4C=12,4D=12,4F=1250=11,51=11,52=11,53=11,54=11,55=11,56-=11,57=1158=10,59=10,10=10,5A=10,5B=10,5C=10,5D=10,5F=1060=17,61=17,62=17,63=17,64=17,65=17,66-=17,67=1768=16,69=16,16=16,6A=16,6B=16,6C=16,6D=16,6F=1670=15,71=15,72=15,73=15,74=15,75=15,76-=15,77=1578=14,79=14,17=14,7A=14,7B=14,7C=14,7D=14,7F=1480=0B,81=0B,82=0B,83=0B,84=0B,85=0B,86-=0B,87=0B88=0A,89=0A,18=0A,0A=0A,0B=0A,8C=0A,8D=0A,8F=0A90=09,91=09,92=09,93=09,94=09,95=09,96-=09,97=0998=08,99=08,19=08,9A=08,9B=08,9C=08,9D=08,9F=08A0=0F,A1=0F,A2=0F,A3=0F,A4=0F,A5=0F,A6-=0F,A7=0FA8=0E,A9=0E,0E=0E,AA=0E,AB=0E,AC=0E,AD=0E,AF=0EB0=0D,B1=0D,B2=0D,B3=0D,B4=0D,B5=0D,B6-=0D,B7=0DB8=0C,B9=0C,0C=0C,BB=0C,BB=0C,BC=0C,BD=0C,BF=0CC0=03,C1=03,C2=03,C3=03,C4=03,C5=03,C6-=03,C7=03C8=02,C9=02,02=02,CC=02,CC=02,CC=02,CD=02,CF=02D0=01,D1=01,D2=01,D3=01,D4=01,D5=01,D6-=01,D7=01D8=00,D9=00,00=00,DD=00,DD=00,DD=00,DD=00,DF=00E0=07,E1=07,E2=07,E3=07,E4=07,E5=07,E6-=07,E7=07E8=06,E9=06,06=06,EE=06,EE=06,EE=06,EE=06,EF=06F0=05,F1=05,F2=05,F3=05,F4=05,F5=05,F6-=05,F7=05F8=04,F9=04,04=04,FF=04,FF=04,FF=04,FF=04,FF=04上面是2个字节的对应关系。等号左边是从00-FF(即0-255)等号右边。每增加8发生变化。而有一定规律从00-1F现求这个规律用not ad or xor shr shl 来表示
 
00=1B,01=1B,02=1B,03=1B,04=1B,05=1B,06-=1B,07=1B08=1A,09=1A,10=1A,0A=1A,0B=1A,0C=1A,0D=1A,OF=1A10=19,11=19,12=19,13=19,14=19,15=19,16-=19,17=1918=18,19=18,11=18,1A=18,1B=18,1C=18,1D=18,1F=1820=1F,21=1F,22=1F,23=1F,24=1F,25=1F,26-=1F,27=1F28=1E,29=1E,12=1E,2A=1E,2B=1E,2C=1E,2D=1E,2F=1E30=1D,31=1D,32=1D,33=1D,34=1D,35=1D,36-=1D,37=1D38=1C,39=1C,13=1C,3A=1C,3B=1C,3C=1C,3D=1C,3F=1C40=13,41=13,42=13,43=13,44=13,45=13,46-=13,47=1348=12,49=12,12=12,4A=12,4B=12,4C=12,4D=12,4F=1250=11,51=11,52=11,53=11,54=11,55=11,56-=11,57=1158=10,59=10,10=10,5A=10,5B=10,5C=10,5D=10,5F=1060=17,61=17,62=17,63=17,64=17,65=17,66-=17,67=1768=16,69=16,16=16,6A=16,6B=16,6C=16,6D=16,6F=1670=15,71=15,72=15,73=15,74=15,75=15,76-=15,77=1578=14,79=14,17=14,7A=14,7B=14,7C=14,7D=14,7F=1480=0B,81=0B,82=0B,83=0B,84=0B,85=0B,86-=0B,87=0B88=0A,89=0A,18=0A,0A=0A,0B=0A,8C=0A,8D=0A,8F=0A90=09,91=09,92=09,93=09,94=09,95=09,96-=09,97=0998=08,99=08,19=08,9A=08,9B=08,9C=08,9D=08,9F=08A0=0F,A1=0F,A2=0F,A3=0F,A4=0F,A5=0F,A6-=0F,A7=0FA8=0E,A9=0E,0E=0E,AA=0E,AB=0E,AC=0E,AD=0E,AF=0EB0=0D,B1=0D,B2=0D,B3=0D,B4=0D,B5=0D,B6-=0D,B7=0DB8=0C,B9=0C,0C=0C,BB=0C,BB=0C,BC=0C,BD=0C,BF=0CC0=03,C1=03,C2=03,C3=03,C4=03,C5=03,C6-=03,C7=03C8=02,C9=02,02=02,CC=02,CC=02,CC=02,CD=02,CF=02D0=01,D1=01,D2=01,D3=01,D4=01,D5=01,D6-=01,D7=01D8=00,D9=00,00=00,DD=00,DD=00,DD=00,DD=00,DF=00E0=07,E1=07,E2=07,E3=07,E4=07,E5=07,E6-=07,E7=07E8=06,E9=06,06=06,EE=06,EE=06,EE=06,EE=06,EF=06F0=05,F1=05,F2=05,F3=05,F4=05,F5=05,F6-=05,F7=05F8=04,F9=04,04=04,FF=04,FF=04,FF=04,FF=04,FF=04上面是2个字节的对应关系。等号左边是从00-FF(即0-255)等号右边。每增加8发生变化。而有一定规律从00-1F现求这个规律用not ad or xor shr shl 来表示
 
后退
顶部