SourceFormatX

Overview

Features

Why Use It

Formatting Show

Integration

Screenshots

Documentation

FAQs & Tips

Update History

Award Gallery

Testimonials

License Policy

CodeMorph

CodeToHtml

80x86 Assembly / 8086 Asm Source Code Formatting Show


SourceFormatX Code Formatter bases on powerful syntax parse engines so it can beautify and format source code files with omnifarious styles, even these messy source code examples below:

C/C++ Java C# Delphi (Pascal)
PHP JSP ASP JavaScript
Visual Basic VB.NET VBScript HTML Components
80x86 ASM 8051 ASM CORBA IDL


This is an extreme 80x86 Assembly / x86 Asm / 8086 ASM code formatting example, the purpose of it is to show the power of 80x86 Assembly / x86 Asm syntax parse engine powered by SourceFormatX 80x86 Assembly Code Formatter.

  ;-------------------------------------------------
  ;|                                               |
  ;|     Before 80x86 Assembly Code Formatting     |
  ;|                                               |
  ;-------------------------------------------------

  .386
  .MODEL FLAT,STDCALL

    include  windows.inc
       INCLUDE user32.inc
   Include       kernel32.inc
     incLUDE    gdi32.inc

  .datA
    ClassName DB "SimpleWinClass",0
   AppName db "Bezier Splines",0

  .cODE
  start:
  INvoke    GetModuleHandle,         NULL
   mov  hInstance, eax
  	  inVOKE         GetCommandLine
    INVOKE WinMain,   hInstance, NULL, CommandLine,  SW_SHOWDEFAULT
  INvoke     ExitProcess,     eax

  WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:SDWORD
  LOCAL  wc:WNDCLASSEX
  	local        msg:MSG
   Local  hwnd:HWND

  @main: Mov   wc.cbSize,     SIZEOF WNDCLASSEX
  mov            wc.style,  CS_HREDRAW or CS_VREDRAW
  	mov wc.lpfnWndProc,   OFFSET WndProc
     mov       wc.cbClsExtra,  NULL
   Mov   wc.cbWndExtra, NULL
              push      hInstance
      pop      wc.hInstance
  	MOV wc.hbrBackground,COLOR_WINDOW+1
  	 mov         wc.lpszMenuName,NULL
  	mov   wc.lpszClassName,OFFSET ClassName
        invoke LoadIcon,NULL,IDI_APPLICATION
  	MOV   wc.hIcon,eax
          mov   wc.hIconSm,0
      invoke   LoadCursor,NULL,IDC_ARROW
  	mOV wc.hCursor,   eax
  invoke RegisterClassEx, addr wc ; create window
    INVOKE CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
  WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
  CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\
  hInst,NULL
    mov       hwnd,eax
      INVoke ShowWindow, hwnd,SW_SHOWNORMAL
   INVOKE UpdateWindow, hwnd
  .whiLE TRUE ; loop
          Invoke        GetMessage, addr msg,NULL,0,0
    .BREAK .IF (!eax)
      INVOKE    TranslateMessage, Addr msg
  INVOKE    DispatchMessage,    ADDR msg
                .ENDW ; end loop
   mov  eax,msg.wParam
             ret
  WinMain ENDP

  SetupOpenGL PROC hWnd
  LoCAL pfd:PIXELFORMATDESCRIPTOR
  LOCAL pixformat:DWORD
   invoke GetDC,  hWnd
      mov hdc,        EAX
  ZeroMemory pfd,   sizeof(PIXELFORMATDESCRIPTOR)
  
  .IF eax == 2
  mov     pfd.nSize,  sizeof(PIXELFORMATDESCRIPTOR)
   mov     pfd.nVersion,1
       .ELSE
     MOV   pfd.dwFlags, PFD_SUPPORT_OPENGL OR PFD_DOUBLEBUFFER OR PFD_DRAW_TO_WINDOW
   mov   pfd.dwLayerMask,   PFD_MAIN_PLANE
       MOV      pfd.iPixelType,     PFD_TYPE_RGBA
  .ENDIF

   mov    pfd.cColorBits,  16
  mov        pfd.cDepthBits, 16
   Mov         pfd.cAccumBits,            0
   mov pfd.cStencilBits,  0
      invoke          ChoosePixelFormat,  hdc, addr pfd
               mov  pixformat,   Eax
   invoke      SetPixelFormat,hdc,pixformat,ADDR pfd

  ; position viewer
   _glMatrixMode GL_MODELVIEW
          _glTranslatef 0.0f,      0.0f,-2.0f

         ; position light
   INVOKE glLightfv,     GL_LIGHT0,GL_POSITION,   ADDR lightPos
     _glEnable GL_LIGHTING
  _glEnable GL_LIGHT0
            _glEnable GL_DEPTH_TEST
      _glShadeModel GL_SMOOTH
             ret
  SetupOpenGL ENDP

  end start


  ;-------------------------------------------------
  ;|                                               |
  ;|     After 80x86 Assembly Code Formatting      |
  ;|                                               |
  ;-------------------------------------------------

  .386
  .model flat, stdcall

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

  .data
  ClassName  db "SimpleWinClass", 0
  AppName    db "Bezier Splines", 0

  .code
  start:
             invoke GetModuleHandle, NULL
             mov    hInstance, EAX
             invoke GetCommandLine
             invoke WinMain, hInstance, NULL, CommandLine, SW_SHOWDEFAULT
             invoke ExitProcess, EAX

  ;--------------------------------------------------------------------------

  WinMain proc hInst:HINSTANCE, hPrevInst:HINSTANCE, CmdLine:LPSTR, CmdShow:SDWORD
             local       wc:WNDCLASSEX
             local       msg:MSG
             local       hwnd:HWND

  @main:     mov         wc.cbSize, sizeof WNDCLASSEX
             mov         wc.style, CS_HREDRAW or CS_VREDRAW
             mov         wc.lpfnWndProc, offset WndProc
             mov         wc.cbClsExtra, NULL
             mov         wc.cbWndExtra, NULL
             push        hInstance
             pop         wc.hInstance
             mov         wc.hbrBackground, COLOR_WINDOW+1
             mov         wc.lpszMenuName, NULL
             mov         wc.lpszClassName, offset ClassName
             invoke      LoadIcon, NULL, IDI_APPLICATION
             mov         wc.hIcon, EAX
             mov         wc.hIconSm, 0
             invoke      LoadCursor, NULL, IDC_ARROW
             mov         wc.hCursor, EAX
             invoke      RegisterClassEx, addr wc                              ; create window
             invoke      CreateWindowEx, NULL, addr ClassName, addr AppName, \
                         WS_OVERLAPPEDWINDOW , CW_USEDEFAULT, \
                         CW_USEDEFAULT       , CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, \
                         hInst               , NULL
             mov         hwnd, EAX
             invoke      ShowWindow, hwnd, SW_SHOWNORMAL
             invoke      UpdateWindow, hwnd
             .while      TRUE                                                  ; loop
                         invoke              GetMessage, addr msg, NULL, 0, 0
                         .break              .if (!EAX)
                         invoke              TranslateMessage, addr msg
                         invoke              DispatchMessage, addr msg
             .endw       ; end loop
             mov         EAX, msg.wParam
             ret
  WinMain endp

  ;--------------------------------------------------------------------------

  SetupOpenGL proc hWnd
      local       pfd:PIXELFORMATDESCRIPTOR
      local       pixformat:DWORD
      invoke      GetDC, hWnd
      mov         hdc, EAX
      ZeroMemory  pfd, sizeof(PIXELFORMATDESCRIPTOR)

      .if         EAX == 2
                  mov       pfd.nSize, sizeof(PIXELFORMATDESCRIPTOR)
                  mov       pfd.nVersion, 1
      .else
                  mov       pfd.dwFlags, PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER or PFD_DRAW_TO_WINDOW
                  mov       pfd.dwLayerMask, PFD_MAIN_PLANE
                  mov       pfd.iPixelType, PFD_TYPE_RGBA
      .endif

      mov         pfd.cColorBits, 16
      mov         pfd.cDepthBits, 16
      mov         pfd.cAccumBits, 0
      mov         pfd.cStencilBits, 0
      invoke      ChoosePixelFormat, hdc, addr pfd
      mov         pixformat, EAX
      invoke      SetPixelFormat, hdc, pixformat, addr pfd

      ; position viewer
      _glMatrixMode GL_MODELVIEW
      _glTranslatef 0.0f, 0.0f, -2.0f

      ; position light
      invoke        glLightfv, GL_LIGHT0, GL_POSITION, addr lightPos
      _glEnable     GL_LIGHTING
      _glEnable     GL_LIGHT0
      _glEnable     GL_DEPTH_TEST
      _glShadeModel GL_SMOOTH
      ret
  SetupOpenGL endp

  end start

  Don't waste time on formatting x86 assembly source code by hand any more!  Download SourceFormatX Code Formatter Now!