dumping ground
Ascii chart

Start and end
* program starts at address 1000
START ORG $1000
* code
* code
* stops execution
STOP #$2000
* or
end SIMHALT
* subroutines
* var definitions
* ends program
END STARTData moving
* stores 123 in d1
move.b #123,d1Data manipulation
* adds 123 to d1
add.b #123,d1Tasks (text example)
* note first you need to load in d0 the task number
* task num 14 displays null terminated string at A1
move #14,d0
* loads address of varName (string) into A1
lea varName,a1
* activates the task
trap #15
* load task 3 into d0
* displays the contents of d1 as a number
move #3,d0
trap #15Var definitions
* define storage - reserves memory for var
* note the 2 in the value
varName ds.b 2
* define constant - places data in memory
varName dc.b 'this is a sting',0Branching
branch if
BCC Branch Carry Clear - Branch if the C-flag is 0.
BCS Branch Carry Set - Branch if the C-flag is 1.
BEQ Branch EQual - Branch if the Z-flag is 1.
BNE Branch Not Equal - Branch if the Z-flag is 0.
BGE Branch Greater or Equal - Branch if N and V are equal.
BGT Branch Greater Than - Branch if N and V are equal and Z=0.
BHI Branch HIgher than - Branch if both C and Z are 0.
BLE Branch Less or Equal - Branch if Z=1 or if N and V are different.
BLS Branch Lower or Same - Branch if C=1 or Z=1.
BLT Branch Less Than - Branch if N and V are different.
BMI Branch MInus - Branch if N=1.
BPL Branch PLus - Branch if N=0.
BVC Branch V Clear - Branch if V=0
BVS Branch V Set - Branch if V=1.
BRA BRanch Always

* this will compair the numbers, by setting the flags accordingly
* note takes any operand
cmp #10,#12
* compair here -- i have put a drop down menu with all branch ifs
bra branchName
* --- branch example ---
branchName:
* code
* codeSubroutines
New line example
* push a1 and d0
subName movem.l d0/a1,-(a7)
* set task number
move #14,d0
* string for new line definded at bottom
lea newLineVar,a1
* executes task
trap #15
* restores registers
movem.l (a7)+,d0/a1
* returns from the subroutine
rts* sub header example
* movem.l moves all the selected registers to memory
subName movem.l d0-d6/a1-a6,-(a7)
* code
* code
* code
* restores all registers from memory
movem.l (a7)+,d0-d6/a1-a6
* returns from subroutine
rtsRandom Number Generator
* trap code #8 returns time in 100ths of a sec from midnight
* result is stored in d1.l
move.b #8,d0
trap #15
* performs AND operation bit for bit
* in this case prevents a overflow
and.l #$5FFFFF,d1
* DIVides d1 / 100 -- first nibble is remainder second is intager
divu #100,d1
* swaps the first and second nibbles so the remainder is second
swap d1
* adds a number between 1 and 8, only used because its fast
addq.w #1,d1
* d2 = d1
move d1,d2