.title by Grant Beattie, Class 2C ;************************************************************************** ;* Sample.asm * ;* * ;* The purpose of this program is to demonstrate source file page layout * ;* and basic AS6811 assembler syntax. * ;************************************************************************** ; 1. The program performs an additive checksum over the EPROM range ; (C000-FFFF) and places the result in the two lowest bytes of ; internal RAM. ; 2. An additive checksum is simply an unsigned addition of all of the ; bytes into a 16-bit result. ; 3. As each byte is read and summed into the 16-bit result, it's value ; appears on the LED display. ; ;.------------------------------------------------------------------------. ;| EQUATES SECTION | ;`------------------------------------------------------------------------' LED = 0x9000 ;2-digit LED display. EPROMSTART = 0xC000 ;Lowest EPROM address. EPROMEND = 0xFFFF ;Highest EPROM address. ;.------------------------------------------------------------------------. ;| MAIN | ;`------------------------------------------------------------------------' .AREA Sample (ABS) .MODULE Sample .ORG 0xC000 Main: ldd #0 ;Initialize the RAM checksum variable. std Checksum ldy #EPROMSTART ;Set pointer to start of test area. Summing: ldab ,y ;Read one byte from test area and stab LED ;echo it to the LED and put a copy stab ByteVariable ; of it in RAM also. ldx Checksum abx ;Add the byte to the total. stx Checksum iny ;Point to the next location. cpy #EPROMEND+1 ;All done? bne Summing ; No, continue with next location. bra . ; Yes done, endless loop. .page ;.------------------------------------------------------------------------. ;| CONSTANT DATA | ;`------------------------------------------------------------------------' DumbTable: .db 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 Copyright: .ascii "Copyright (c) 1995 by the person that wrote it. " .asciz "Hands off." ;.------------------------------------------------------------------------. ;| VARIABLES | ;`------------------------------------------------------------------------' .org 0x0000 ;Variables must be somewhere in RAM Checksum: .ds 2 ;Holds the final result. ByteVariable: .ds 1 ;The byte is placed here during the ;addition process so that the RAM ;does not get lonely. ;.------------------------------------------------------------------------. ;| RESET VECTOR | ;`------------------------------------------------------------------------' .org 0xFFFE ;Place the reset vector so that .DW Main ;we can run this from power-up. ; ^ ^ ^ (Column settings for this example.) ; 15 22 35 IF YOU USE THE IDE SET THE TAB CHAR ; OFF SO THAT IT USES SPACES INSTEAD!