13.1 asm/dasm

There are two rsc scripts that emulate 'rasm' to assemble and disassemble single opcodes for multiple architectures from the command line.

$ rsc asm 'mov eax,33'
b8 21 00 00 00 

$ rsc dasm 'b8 21 00 00 00'
   0:   b8 21 00 00 00          mov    $0x21,%eax

If you pay attention to the output you'll notice that it's AT&T syntax and the formatting is the objdump one. Looking the scripts will make you understand that it's using 'gas' and 'nasm' for assembling and objdump for disassembling.

Compare this with rasm:

$ rasm 'mov eax,33'
b8 21 00 00 00 
$ rasm -d 'b8 21 00 00 00'
mov eax, 0x21

When encoding branch instructions (jumps or calls) it is important to define the offset where this instruction will live. The reason for this is because the assembler will encode relative branch instructions which are shorter or address-dependant. This is defined using the '-s' flag.

$ rasm -s 0x8047000 'jmp 0x8048000'
e9 fb 0f 00 00 
$ rasm  'jmp 0x8048000'
e9 fb 7f 04 08 
$ rasm -s 0x8049000 'jmp 0x8048000'
e9 fb ef ff ff