; PEP-8 example -- addition.

START:   CHARO   10,i
         ;
         LDA     A,d
         ADDA    0x5555,i
         STA     C,d
         DECO    C,d
         CHARO   ',',i
         CHARO   10,i
         ;
         LDA     A,d
         ADDA    B,d
         STA     D,d
         DECO    D,d
         ;
         STOP

A:       .WORD   0x1111 
B:       .WORD   0x2222
C:       .WORD   0x3333
D:       .WORD   0x4444
         .END

;;; Program to compute quotient and remainder for 1009 / 77.

LOOP:    LDA     REM,d       ; PROCESS:  subtract DIV repeatedly.
         CPA     DIV,d       ; Can we subtract again?
         BRLT    DONE        ; No.  (REM is smaller than DIV)

         SUBA    DIV,d       ; Subtract DIV from Remainder 
         STA     REM,d
         LDA     Q,d         ; Add 1 to quotient
         ADDA    1,i
         STA     Q,d
         BR      LOOP

DONE:    DECO    Q,d         ; OUTPUT:  Quotient & Remainder
         CHARO   10,i        ; NEWLINE
         DECO    REM,d
         CHARO   10,i        ; NEWLINE
         STOP

NUMBER:  .WORD   1009        ; Numerator
REM:     .WORD   1009        ; Remainder
DIV:     .WORD   77          ; Denominator
Q:       .WORD   0           ; Quotient = number of loops

         .END
See also:
  • pep/div1.pep
  • pep/div2-io.pep
  • pep/div3-debug.pep