2016-11-20 6 views
3

BorlandのTASMでマクロを展開する方法はありますか? TASM互換の.ASMファイルを変換して、すべてのマクロを展開したいのですが。 これを行うオプションが見つかりませんでした。TASMマクロの展開方法

+0

TASMは(私は分からない)、あなたがソースをコンパイルし、テキストに戻ってバイナリをobjdumpのしたいことな方法を提供していない場合は、それが価値があるならば。 – Ped7g

答えて

1

TASMのコマンドラインオプション/ laを使用すると、展開されたリストが作成されます。このリストから、上位レベルと下位レベルの展開を確認できます。

OUTPUTMESSAGE MACRO hConsole,stringval 
LOCAL msg 
    .data 
msg db '&stringval',0 
    .code 
    call outputString ,hConsole,OFFSET msg 
ENDM ;OUTPUTMESSAGE 

そして、あなたは、次のソースが展開されているか確認したい:この機能は、たとえば1988年

で初期リリースまでTASMのすべてのバージョンで動作します、あなたは、次のTASMマクロを持っているとしましょう:

OUTPUTMESSAGE hConsole,<This app was assembled with TASM version > 
OUTPUTMESSAGE hConsole,%??version 

(私はバージョン5.4を使用しているように起こった)以下の生成/ラで生産リストファイル:

516      OUTPUTMESSAGE hConsole,<This app was assembled with TASM version > 
1 517 0000018F     .data 
1 518 00000000 54 68 69 73 20 61 70+ ??0000 db 'This app was assembled with TASM version ',0 
    519  70 20 77 61 73 20 61+ 
    520  73 73 65 6D 62 6C 65+ 
    521  64 20 77 69 74 68 20+ 
    522  54 41 53 4D 20 76 65+ 
    523  72 73 69 6F 6E 20 00 
1 524 0000002A     .code 
2 525 0000018F C8 0000 00    ENTERD 00000h,0 
2 526      call outputString ,hConsole,OFFSET ??0000 
3 527 00000193 68 00000000r   PUSH OFFSET ??0000 
3 528 00000198 FF 75 08   PUSH hConsole 
3 529 0000019B E8 FFFFFE9B   CALL outputString 
    530      OUTPUTMESSAGE hConsole,%??version 
1 531 000001A0     .data 
1 532 0000002A 31 32 38 34 00  ??0001 db '1284',0 
1 533 0000002F     .code 
1 534      call outputString ,hConsole,OFFSET ??0001 
2 535 000001A0 68 0000002Ar   PUSH OFFSET ??0001 
2 536 000001A5 FF 75 08   PUSH hConsole 
2 537 000001A8 E8 FFFFFE8E   CALL outputString 

列は[深さ] [行番号] [オフセット] [マシンコード] [ソース]に対応します。残念ながら、[行番号]列は特に便利なわけではありません。下の列について説明しTASM5ユーザガイドからスニップです:

[depth] - indicates the level of nesting of Include files and macros within your 
      listing file. 

[line#] - is the number of the line in the listing file (not including header 
      and title lines). Line numbers are particularly useful when the 
      cross-reference feature of Turbo Assembler, which refers to lines by 
      line number, is used. Be aware that the line numbers in [line#] are 
      not the source module line numbers. For example, if a macro is 
      expanded or a file is included, the line-number field will continue to 
      advance, even though the current line in the source module stays the 
      same. To translate a line number (for example, one that the 
      cross-referencer produced) back to the source file, you must look up 
      the line number in the listing file, and then find that same line (by 
      eye, not by number) in the source file. 

[offset] - is the offset in the current segment of the start of the machine code 
      generated by the associated assembler source line. 

[machine_code] - is the actual sequence of hexadecimal byte and word values that 
       is assembled from the associated assembler source line. 

[source] - is simply the original assembler line, comments and all. Some 
      assembler lines, such as those that contain only comments, don't 
      generate any machine code; these lines have no [offset] or [machine_ 
      code] fields, but do have a line number. 
+0

@byteprtありがとう、どのようにソースを除くすべてをフィルタリングするかについての任意のアイデアですか? – franck

+0

あなたのケースでは、列をオンまたはオフにすると便利ですが、TASM(またはMASM)のリストファイルは柔軟性がありません。上記のようにディレクティブ/マクロのタイプに基づいてこの数値が変動するので、最下位レベルのソースを取得する特定の値に等しい深さの列に依存することもできません。 @ Ped7gが示唆しているように、私はあなたの最良の賭けはソースを得るために結果のモジュールを分解することだけだろうと思う。特定のマクロについて理解が必要な場合は、リストファイルは少なくともその目的に役立ちます。 – byteptr

+0

これは、行にも[machine-code]列に値が含まれているソース行だけを抽出するパーサスクリプトを作成した場合、すべての展開後に最も低いレベルのアセンブリソースだけが得られます後で。この技術は、データと命令の間の切り替え(上記のように)の間で、指示を間違えると確実にオリジナルを再現するために使用することはできません。繰り返しますが、逆アセンブラを使用する必要があるスクエア1に戻っているようです。 – byteptr

関連する問題