Category Archives: Assembler

Custom prolog and epilog for a function in C++

Traditionally, the compiler is responsible for creating the prolog and epilog of a function. However, custom prolog and epilog code can be written if a function has been declared with the naked attribute. The snippet below demonstrates a naked function with custom prolog and epilog code. __declspec(naked) void foo(){ // Prolog __asm { push ebp [...]

Also posted in C++ | Tagged , , , , , , , , , , , , , , | Leave a comment

Assembling with nasm and disassembling with ndisasm

The following commands demonstrate assembling with nasm and disassembling with ndisasm. $ cat example.s mov eax,0 test eax,eax $ nasm example.s $ ndisasm example 00000000 66B800000000 mov eax,0×0 00000006 6685C0 test eax,eax The first column of the disassembly contains the file offset, the second column contains the opcodes and the third contains the assembly instructions. [...]

Also posted in Bash | Tagged , , , , , , | Leave a comment

(Assembler) PIC Interrupt Context Save and Restore

This code is used to save and restore the context registers of a PIC18F device before executing an interrupt service routine. FSR0 only needs to be saved

Posted in Assembler | Tagged , , , , , | Leave a comment

(Assembler) GCC inline Assembly template

Posted in Assembler | Tagged , , , | Leave a comment

(Assembler) Simple MASM program

This demonstrates a simple “Hello World” style program for 16-bit (DOS) x86 assembly using Microsoft’s free MASM assembler.

Posted in Assembler | Tagged , , , , , | Leave a comment

(Assembler) GCC inline Assembly template

Intel syntax

Posted in Assembler | Tagged , , , , , | Leave a comment

(Assembler) Bootloader FAT12

FASM 1.47

Posted in Assembler | Tagged , , , | Leave a comment

(Assembler) StringDecToValue

Posted in Assembler | Tagged , , , | Leave a comment

(Assembler) StringHexToValue

Posted in Assembler | Tagged , , , | Leave a comment

(Assembler) StringBinToValue

Posted in Assembler | Tagged , , , | Leave a comment