⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 【汇编语言编程使用工具】【十六进制数相加校验和计算程序】
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Buttons, StdCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Edit1: TEdit;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    Label2: TLabel;
    Edit2: TEdit;
    Label3: TLabel;
    Edit3: TEdit;
    Label4: TLabel;
    Edit4: TEdit;
    Label5: TLabel;
    SpeedButton3: TSpeedButton;
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure Edit4Change(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  ab_show:boolean;    //用于控制是否显示;
implementation
uses StrUtils;
{$R *.dfm}

procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
application.Terminate;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  newstr1,he,oldstr:string;
  tj:boolean;
  i:integer;
begin
   i:=1;
   he:='';
   tj:=true;
  // 取出要参与校验和计算的字符串给oldstr
  if (length(edit1.Text) mod 2)<>0 then
    begin
      showmessage('你输入的源码个数有错,不能是奇数个,请重输入!');
      exit;
    end;
  oldstr:=copy(edit1.Text,strtoint(edit4.Text),length(edit1.Text)-strtoint(edit4.Text)+1);
  while tj=true do
    begin
      newstr1:=copy(oldstr,i,2);
      oldstr:=copy(oldstr,i+2,length(oldstr)-2);
      //开始计算校验和并给he变量
      if he='' then
        begin
          he:=inttohex(strtointdef('$'+newstr1,16)+ strtointdef('$'+'00',16),2);
          he:=rightstr(he,2);
        end
      else
        begin
          he:=inttohex(strtointdef('$'+newstr1,16)+ strtointdef('$'+he,16),2);
          he:=rightstr(he,2);
        end;
      if  length(oldstr) =0 then tj:=false;
    end;
  edit3.Text:=he;
  edit2.Text:=edit1.Text+he;
end;

procedure TForm1.Edit4Change(Sender: TObject);
begin
    // 起始位置一定要是奇数位
  if (strtoint(edit4.Text) mod 2)=0 then
    begin
      showmessage('你输入的起始位置有错,不能是偶数位,一定是要奇数位,请重输入!');
      edit4.Text:='1';
      exit;
    end;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
ab_show:=true;
end;

procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
if ab_show=true then
   begin
     form1.Height:=239+90;
     ab_show:=false;
   end
else
   begin
     form1.Height:=239;
     ab_show:=true;
   end;

end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -