SourceFormatX

Overview

Features

Why Use It

Formatting Show

Integration

Screenshots

Documentation

FAQs & Tips

Update History

Award Gallery

Testimonials

License Policy

CodeMorph

CodeToHtml

8051 Assembly / Asm51 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 8051 Assembly / Asm51 / Asm 51 code formatting example, the purpose of it is to show the power of 8051 Assembly syntax parse engine powered by SourceFormatX 8051 Assembly Code Formatter.

  ;-------------------------------------------------
  ;|                                               |
  ;|      Before 8051 Assembly Code Formatting     |
  ;|                                               |
  ;-------------------------------------------------

      $nomod51
       $include (80c515.mcu)
     $include (mon_sub.inc)

   ; voorbeeld programma

           homeCur equ 02h
  shLfCur                 equ 10h
   shRtCur     equ 14h

  start:call  initlcd
  call cursorof
    call          setbarchars
  bar:   call  cursorup
       mov a,#20h
  call  shwLCDbar
    mov   dptr,#2000
        call ltime
   call  cursorup
                    mov   a,#80h
          call  shwLCDbar
      mov   dptr,#2000
    call ltime
      call  cursorup
    mov   a,#0ffh
  call  shwLCDbar
   mov   dptr,#2000
                call ltime
  jmp   bar

  ; ----------------------------------------------------------
  ; subroutine shwLCDbar - displays een analoge-bar op regel 2
  ; the lengte van de bar is proportioneel met de waarde in de
  ; accumelator.
  ; ----------------------------------------------------------

   push  acc        ; bewaar de binary waarde
    mov    a,#0c0h   ; zet de cursor op begin regel 2
      call   strcom
  mov   a, #2      ; row 2
    mov b, #0      ; locatie 0
      lcall placeCur4  ; place cursor at line 1, position 13

   pop   acc      ; herstel de binary waarde
  mov   b, #LCDwidth ; volle schaal met karakters
    mul      ab ; b heeft de integer
    mov r4, b ; save integer in r4
   mov r6,    b     ; character teller
  mov     r5,   a         ; save fraction in r5

    mov a, r4      ; mov integer part
      mov    r0, #5     ; volle karakter breedte met 5 kolommen
  sBar1:
  jz sBar2 ; geen vol karakter als r4=0
  push acc        ; bewaar teller
   mov    a,r0
      lcall lcddata ; display character
    pop   acc     ; recall count
  dec   acc  ; update count
    sjmp  sBar1         ; repeat
  sBar2:
  mov  a, #LCDwidth
  clr c          ; clear carry flag
    subb a, r6        ; spaces to write
  jz    sBar5  ; skip if 0
    mov   r6, a  ; save in a
   mov   r0, #' ' ; the space character
  sBar3:
  mov a,r0
    lcall lcddata ; display it
   djnz r6,      sBar4 ; repeat
  sBar4:
      ret
    end


  ;-------------------------------------------------
  ;|                                               |
  ;|      After 8051 Assembly Code Formatting      |
  ;|                                               |
  ;-------------------------------------------------

  $nomod51
  $include (80c515.mcu)
  $include (mon_sub.inc)

  ; voorbeeld programma

             homeCur equ 02h
             shLfCur equ 10h
             shRtCur equ 14h

  start:     call    initlcd
             call    cursorof
             call    setbarchars
  bar:       call    cursorup
             mov     A, #20h
             call    shwLCDbar
             mov     DPTR, #2000
             call    ltime
             call    cursorup
             mov     A, #80h
             call    shwLCDbar
             mov     DPTR, #2000
             call    ltime
             call    cursorup
             mov     A, #0ffh
             call    shwLCDbar
             mov     DPTR, #2000
             call    ltime
             jmp     bar

  ; ----------------------------------------------------------
  ; subroutine shwLCDbar - displays een analoge-bar op regel 2
  ; the lengte van de bar is proportioneel met de waarde in de
  ; accumelator.
  ; ----------------------------------------------------------

             push    ACC          ; bewaar de binary waarde
             mov     A, #0c0h     ; zet de cursor op begin regel 2
             call    strcom
             mov     A, #2        ; row 2
             mov     B, #0        ; locatie 0
             lcall   placeCur4    ; place cursor at line 1, position 13

             pop     ACC          ; herstel de binary waarde
             mov     B, #LCDwidth ; volle schaal met karakters
             mul     AB           ; b heeft de integer
             mov     R4, B        ; save integer in r4
             mov     R6, B        ; character teller
             mov     R5, A        ; save fraction in r5

             mov     A, R4        ; mov integer part
             mov     R0, #5       ; volle karakter breedte met 5 kolommen
  sBar1:
             jz      sBar2        ; geen vol karakter als r4=0
             push    ACC          ; bewaar teller
             mov     A, R0
             lcall   lcddata      ; display character
             pop     ACC          ; recall count
             dec     ACC          ; update count
             sjmp    sBar1        ; repeat
  sBar2:
             mov     A, #LCDwidth
             clr     C            ; clear carry flag
             subb    A, R6        ; spaces to write
             jz      sBar5        ; skip if 0
             mov     R6, A        ; save in a
             mov     R0, #' '     ; the space character
  sBar3:
             mov     A, R0
             lcall   lcddata      ; display it
             djnz    R6, sBar4    ; repeat
  sBar4:
             ret

  end

  Don't waste time on formatting 8051 assembly and asm51 code by hand any more!  Try SourceFormatX 8051 Asm Formatter today!