use hkpcore; use Win32::OLE::Variant; my @words=qw/data xdata bit org equ set db dw ds end add addc subb inc dec mul div da anl orl xrl clr cpl rl rlc rr rrc swap mov movx movx push pop xch xchd clr setb cpl anl orl mov jc jnc jb jnb jbc acall lcall ret reti ajmp ljmp sjmp jmp jz jnz cjne djnz nop/; my $asm_prog_class ='asm_prog'; my $asm_line_class ='asm_line'; my $asm_command_class='asm_command'; my $asm_comment_class='asm_comment'; my $asm_bold ='asm_bold'; my $asm_under='asm_under'; my $asm_noita='asm_noita'; sub filt($$@){ my $want_struct=shift; my $progress=shift; my @lines=@_; my $res=''; my $reg; $reg=join '|',@words; $res.=< A '51 listing HEAD $res.=< PRE my $size=scalar @lines; my $cur=0; my $code; while($code=shift @lines){ &$progress($cur++,$size) if defined $progress; chomp $code; $code =~ s/&/&/g; $code =~ s//>/g; # back apos (@ tilde key) # ~baaa~ ~Baaa~ # ~uaaa~ ~Uaaa~ # ~iaaa~ ~Iaaa~ $code =~ s!`[bB]([^`]+?)\`!$1!g; # bold $code =~ s!`[uU]([^`]+?)\`!$1!g; # underl $code =~ s!`[iI]([^`]+?)\`!$1!g; # underl # comment not @ beging $code =~ s! ; ([^\n]*)! ; $1!g; # comment @ begin of line $code =~ s!^;([^\n]*)!; $1!g; # reg words my @terms=split /;/,$code; $terms[0] =~ s!(\b)($reg)(\b)!$1$2$3!g; $code=join ';',@terms; $code =~ s/[\n\r]+//g; my $tmp=sprintf "[%04d] ",$cur; $tmp.=$code; $tmp =~ s/[\n\r]+//g; $res.=$tmp."\n"; } $res.=< PRE $res.=< TAIL $res; }# filt my $pcore = hkp_CreateObjectHKPCore(); sub progress($$){ my $cur=shift; my $lines=shift; return if $cur & 3; $pcore->hkp_FuncOpen($hkp_f_Progress); $pcore->hkp_DataAddInt($hkp_STATUS_PERCENT_COMPLETED,int($cur/$lines*100)); $pcore->hkp_DataAdd ($hkp_STATUS_PROGRESS_MESSAGE,"Processing ..."); $pcore->hkp_AddDataInt($hkp_STATUS_LINES_IN_TOTAL,int($cur)); $pcore->hkp_AddDataInt($hkp_STATUS_LINES_IN_CURRENT,int($cur)); $pcore->hkp_AddDataInt($hkp_STATUS_LINES_OUT_TOTAL,int($cur)); $pcore->hkp_AddDataInt($hkp_STATUS_LINES_OUT_CURRENT,int($cur)); $pcore->hkp_AddDataInt($hkp_STATUS_DIVIDER_LINES,int($cur)); $pcore->hkp_FuncRun(); $pcore->hkp_FuncClose(); }# progress if('-hkpreg' eq $ARGV[0]) { # Register the plugin. my $v = hkp_CreateObjectHKPCore(); $v->hkp_DataSetGlobalSuffix('_1'); $v->hkp_DataAdd($hkp_NAME,'ASM\'51'); $v->hkp_DataAdd($hkp_ICON_CAPTION,'51'); $v->hkp_DataAdd($hkp_SECTION,'js29a'); $v->hkp_DataAddInt($hkp_MODE_IN_TEXT_SELECTED, 1); $v->hkp_DataAddInt($hkp_MODE_IN_TEXT_FULL, 1); $v->hkp_DataAddInt($hkp_MODE_SHOW_STATUS, 1 ); # enable progress $v->hkp_DataSetGlobalSuffix(''); } elsif('-hkprun' eq $ARGV[0]){ my $v = hkp_CreateObjectHKPCore(); $text = Variant(VT_BSTR|VT_BYREF, ''); my $want_struct=0; $v->hkp_DataGet($hkp_INPUT_SELECTED, $text); chomp $text; if($text eq ''){ $v->hkp_DataGet($hkp_INPUT, $text); $want_struct=1; } my @lines=split /\n/,$text; my $all=filt($want_struct,\&progress,@lines); $v->hkp_DataAdd('OUTPUT', $all); }