asm-brush

asm-brush is small WordPress plugin I wrote and dedicated to the dinosaurs (like me) who still use and want to share assembly language source code. It is a brush designed to work with the SyntaxHighlighter Evolved WordPress plugin (written by Viper), itself based on the SyntaxHighlighter JavaScript package by Alex Gorbatchev. To be able to use this brush, you will need the asm-brush as well as the SyntaxHighlighter Evolved plugins installed.

To highlight your assembly language code, simply wrap it between these tags:

 1 

or

 1 

The brush detects and applies different styles to the following elements:

  • Registers
  • Assembly language user instructions
  • Assembly language system instructions
  • FPU instructions
  • Multimedia instructions
  • MASM specific directives & instructions
  • Numbers (decimal and hexadecimal)
  • IDA (The Interactive Disassembler) labels style

The styles are easily customizable by editing the CSS file (style.css).

You can download asm-brush at the WordPress Plugin Directory

Example N°1 : a MASM source

.386
.model flat,stdcall
option casemap:none

include     windows.inc
include     user32.inc
include     kernel32.inc

includelib  user32.lib
includelib  kernel32.lib

.data

message     db  'Hello friends!', 13, 10
            db  'This is an autotyping example.', 0
app         db  'notepad.exe', 0
wndclass    db  'Notepad', 0
childclass  db  'Edit', 0

.data?

handle      dd  ?

.code

start:
    invoke  WinExec, ADDR app, SW_SHOW
    invoke  FindWindow, ADDR wndclass, 0
    invoke  FindWindowEx, eax, 0, ADDR childclass, 0
    mov     handle, eax
    mov     edx, OFFSET message
@lb_start:
    movzx   eax,BYTE PTR [edx]
    test    eax,eax
    jz      @lb_end
    push    edx
    invoke  SendMessage, handle, WM_CHAR, eax, 0
    invoke  Sleep, 200
    pop     edx
    inc     edx
    jmp     @lb_start
@lb_end:
    invoke  ExitProcess, 0

    END     start

Example N°2 : an IDA disassembly

.text:00402C9D sub_402C9D      proc near
.text:00402C9D arg_0           = dword ptr  8
.text:00402C9D arg_4           = dword ptr  0Ch
.text:00402C9D arg_8           = dword ptr  10h
.text:00402C9D arg_C           = dword ptr  14h
.text:00402C9D arg_10          = dword ptr  18h
.text:00402C9D arg_14          = dword ptr  1Ch
.text:00402C9D arg_18          = dword ptr  20h
.text:00402C9D
.text:00402C9D                 push    ebp
.text:00402C9E                 mov     ebp, esp
.text:00402CA0                 push    [esp+arg_18]    ; int
.text:00402CA4                 push    [ebp+arg_14]    ; int
.text:00402CA7                 push    [ebp+arg_10]    ; wchar_t *
.text:00402CAA                 push    [ebp+arg_C]     ; int
.text:00402CAD                 push    [ebp+arg_8]     ; int
.text:00402CB0                 push    [ebp+arg_4]     ; int
.text:00402CB3                 push    [ebp+arg_0]     ; int
.text:00402CB6                 call    sub_402CC6
.text:00402CBB                 add     esp, 1Ch
.text:00402CBE                 cmp     eax, 1
.text:00402CC1                 sbb     eax, eax
.text:00402CC3                 pop     ebp
.text:00402CC4                 inc     eax
.text:00402CC5                 retn
.text:00402CC5 sub_402C9D      endp

Example N°3 : another IDA disassembly

.text:00402F9B
.text:00402F9B loc_402F9B: ; CODE XREF: sub_402F74+A
.text:00402F9B                 mov     eax, [ebp+arg_8]
.text:00402F9E                 push    eax
.text:00402F9F                 mov     ax, [ebp+arg_4]
.text:00402FA3                 shr     ax, 1
.text:00402FA6                 push    eax
.text:00402FA7                 push    [ebp+lpMultiByteStr]
.text:00402FAA                 call    sub_402EE2
.text:00402FAF                 add     esp, 0Ch
.text:00402FB2                 test    eax, eax
.text:00402FB4                 mov     eax, 0
.text:00402FB9                 jz      short loc_402FC0
.text:00402FBB
.text:00402FBB loc_402FBB: ; CODE XREF: sub_402F74+21
.text:00402FBB                 mov     eax, 1
.text:00402FC0
.text:00402FC0 loc_402FC0: ; CODE XREF: sub_402F74+25
.text:00402FC0                 pop     ebp
.text:00402FC1                 retn
.text:00402FC1 sub_402F74      endp

Frequently Asked Questions

  • Will the brush work with other processors?
    Processors have in common some mnemonics, so yes it will, but not everything will be highlighted like with the x86 instruction set, you need to add your particular instructions set to the brush.
  • How can I add instructions to the brush?
    By editing the shBrushAsm.js file.

Not on WordPress?

I’m really sorry for you! no seriously, if you are not a WordPress user, you can download the asm-brush JavaScript file and use it with the original SyntaxHighlighter JavaScript package by Alex Gorbatchev. For the styles, you can either add the plugin styles to the package (please see below) or modify the brush file and stick to Alex’s orginal styles.

/* Registers */
.syntaxhighlighter .registers
{ color: #ff8000; font-weight: normal !important; }

/* User Instructions */
.syntaxhighlighter .usr_inst
{ color: #ff0080; font-weight: normal !important; }

/* System Instructions */
.syntaxhighlighter .sys_inst
{ color: #0000ff; font-weight: normal !important; }

/* FPU Instructions */
.syntaxhighlighter .fpu_inst
{ color: #ff8040; font-weight: normal !important; }

/* Multimedia Instructions */
.syntaxhighlighter .mul_inst
{ color: #cbd601; font-weight: normal !important; }

/* Masm Specific */
.syntaxhighlighter .masm_spc
{ color: #0080c0; font-weight: normal !important; }

/* Numbers */
.syntaxhighlighter .numbers
{ color: #8000ff; font-weight: normal !important; }

/* IDA labels */
.syntaxhighlighter .labels
{ color: blue; font-weight: normal !important; }

/* Strings */
.syntaxhighlighter .asmstring
{ color: #b0002d; font-weight: normal !important; }

{ 4 comments… read them below or add one }

cheap air max ltd December 10, 2012 at 00:35

Great site. Lots of useful information here.
I’m sending it to some friends ans additionally sharing in delicious. And obviously, thanks to your effort!

Reply

DWORD January 3, 2013 at 19:24

Thanks for the plugin – I think your post has some typos on it regarding the tags.
 
[code lang="assembly"]
// code
[/code]

Reply

gucci 財布 April 21, 2013 at 04:36

。ほぼすべてのブ
ランドのアイテム
、腕時計、スニー
カー、サングラス
やバッグのそれである
が、信憑性のペーパーが付
属して、慎重
に物事が “ちょうどグッチのように ‘好きと言う小さな版画を探す必要があります。あなたが正しいことを利用したい場合は、 “グッ
チに触発さ ‘これはメーカーがあなたが購入している製品が本物か偽物ではないこと、これらの罰金版画を通して警告していることを意味しています。

Reply

naprawa sterowników pomp wtryskowych November 16, 2013 at 19:53

Hello there! This post could not be written any better!

Reading through this post reminds me of my old room mate!

He always kept chatting about this. I will forward this page to him.
Fairly certain he will have a good read. Thank you for sharing!

Reply

Leave a Comment

{ 1 trackback }