summaryrefslogtreecommitdiff
path: root/HW1/Sources/cmpen472hw1_McDonnell.asm
blob: 31da9647311d589836421cf14ef758718845956d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
**********************************************************************************************
*
* Title: Star Fill (In Memory) Homework #1
*
* Objective: CMPEN472 Homework #1 demonstration program. Fill 225 bytes of memory with '*'.
*
* Revision: V1.0
*
* Date: Jan. 22, 2025
*
* Programmer: Jacob McDonnell
*
* Company: The Pennsylvania State Universtiy
* Electrical Engineering and Computer Science
*
* Algorithm: While Loop demo of HCS12 Assembly
*
* Register Use: A accumulator: character to be placed in memory
*               B accumulator: counter of filled memory locations
*               X register:    pointer to memory location to fill
*
* Memory use: RAM locations $3000 to $30E1
*
* Input: No input, data and parameters are hard coded.
*
* Output: Memory locations $3000 to $30E1 are filled with '*' character.
*
* Observation: This program is designed for instruction purpose.
* This program can be a template for other loop based code.
*
* Comments: This program is developed and simulated using CodeWarrior Development Software.
*
**********************************************************************************************
* Parameter Declaration Section
*
* Export Symbols
        xdef     pgstart ; export 'pgstart' symbol
        absentry pgstart ; for assembly entry point
* Symbols and Macros
porta   equ     $0000    ; i/o port address
portb   equ     $0001
ddra    equ     $0002
ddrb    equ     $0003
**********************************************************************************************
* Data Section
*
        org     $3000    ; reserved memory starting address
here    ds.b    $e1      ; 225 memory locations reserved
count   dc.b    $e1      ; constant counter for stars = 225
*
**********************************************************************************************
* Program Section
*
        org     $3100    ; Program Start Address in RAM
pgstart ldaa    #'*'     ; Load '*' into accumulator A
        ldab    count    ; Load count of stars into B
        ldx     #here    ; Load address pointer into X
loop    staa    0,x      ; Put a start at this memory location
        inx              ; Go to the next memory location
        decb             ; Decrement the counter
        bne     loop     ; Loop if not done
done    bra     done     ; Task finished
        end              ; Last line of a file