如题

解决方案 »

  1.   

    http://dev.csdn.net/develop/article/30/30684.shtm
    根据格式自己写阿
      

  2.   

    用无类型文件,这样写吗?
    var  UntypedFile:file;
      buffer:array[0..2] of byte;
      NumrecsWriten:integer;
    begin
      Assignfile(UntypedFile,'filename.hex');
      if fileExists('filename.hex') then
          reset(UntypedFile)
      else
          Rewrite(UntypedFile);
      try
        seek(UntypedFile,fileSize(UntypedFile));
        buffer[0]:=$01;
        buffer[1]:=$02;
        buffer[2]:=$03;
        BlockWrite(UntypedFile,buffer,1,NumrecsWriten);
      fianlly
        CloseFile(UntypedFile);
      end;
    end;
      

  3.   

    比如这样一段代码
    CODE SEGMENT
    ASSUME CS:CODE
    org 2000h
    START:  MOV AL,80H
    CODE ENDS
    END  START
    编译后列表为
    2000 B080          MOV AL,80
    2002 206375        AND [BP+DI+75],AH
    是不是说数据就是 B080 206375 呢,请高手指点啊.
      

  4.   

    这个问题折磨了我好几天了.现在总算是有眉目了。
    现在帖出部分代码,供参考也请各为好友指出不足之处.
    再次深深感谢回帖的朋友.function MakeCC(Str: String):String;
    var
      I,J : integer;
      temp : String;
    begin
      J := 0;
      for i := 1 to (StrLen(PChar(str)) div 2) do begin
        j:= j+HexToInt(copy(str,((i-1)*2+2),2));
      end;
      j:= 1 + not(j);
      temp:= IntToHex( j,2);
      result := Copy (IntToHex( j,2),StrLen(PChar(IntToHex( j,2)))-1,2);
    end;function MakeIntelHex(HexData,StartAddr,EndAddr:String;HexfilePath : String) : boolean;
    {
      功能:生成intel hex文件
      参数:hexData: 16进制数据的字符串 StartAddr ; EndAddr : 起始,结束地址
      LineData : 每一行的数据
    }
    var
      lastData : Integer;
      DataLine : Integer;
      LineData : array[1..2050] of String;
      TempAddr : String;
      tempData : String;
      i,j:integer;
      buffer : array[0..2050] of byte;
      HexFile : TextFile;
      NumrecsWriten:integer;  
    begin
      result := false;
      DataLine := StrLen(PChar(HexData)) div (32*2);
      LastData := Strlen(PChar(HexData)) mod (32*2);
      i:=0;
    if  DataLine <> 0 then begin
      for i:= 1 to DataLine do begin
        tempAddr := IntToHex(HexToInt(StartAddr)+32*(i-1),4);
        tempData := Copy(HexData,(i-1)*64+1,64); 
        LineData[i] := ':20'+TempAddr+TempData;
        LineData[i] := LineData[i] + MakeCC(LineData[i]);
      end;
      if LastData <> 0  then begin
        DEC(i);
        tempAddr := IntToHex(HexToInt(StartAddr)+32*(i-1)+ (LastData div 2),4);
        INC(i);
        tempData := Copy(HexData,(i-1)*64+1,64);
        LineData[i] := ':'+IntToHex((StrLen(PChar(tempData)) div 2),2)+TempAddr+TempData;
        LineData[i] := LineData[i] + MakeCC(LineData[i]);
      end;
    end  else begin
        i := 1;
        tempAddr := IntToHex(HexToInt(StartAddr),4);
        tempData := Copy(HexData,1,64);
        LineData[i] := ':'+IntToHex((StrLen(PChar(tempData)) div 2),2)+TempAddr+TempData;
        LineData[i] := LineData[i] + MakeCC(LineData[i]);
    end; 
      INC(i);
      LineData[i] := ':00000001FF';
      Assignfile(HexFile,HexfilePath);
      Rewrite(HexFile);
      try
      for j := 1 to i do begin
          writeln(HexFile,LineData[j]);
      end
      finally
          CloseFile(HexFile);
      end;
    end;