Professional Documents
Culture Documents
Table 1.2
; Export Symbols
XDEF _Startup, main
; we export both '_Startup' and 'main' as symbols. Either can
; be referenced in the linker .prm file or from C/C++ later on
XREF __SEG_END_SSTACK ; symbol defined by the linker for the end of the stack
; variable/data section
MY_ZEROPAGE: SECTION SHORT ; Insert here your data definition
; code section
MyCode: SECTION
main:
_Startup:
LDHX #__SEG_END_SSTACK ; stack pointer initialized
TXS
CLI ; interrupts enabled
mainLoop:
LDA #18 ;loads 18 in A
STA FirstOperand ;stores a into FirstOperand
PSHA ;A pushes on stack
LDA #8 ;load const value 8 in A
PSHA ;push A on stack
STA SecondOperand ;store A in SecondOperand
CLRA ;clears A
STA Sum ;stores in sum
STA Difference ;store A into Difference
JMP mainLoop
sum:
PSHA ;push A on stack
CLRA ; clear A
LDA 5, SP ;load 5th value from stak on A
ADD 4, SP ;add A with 4th value from stack
STA 4, SP ;store A in 4th position in stack
PULA ;pull from stack on A
RTS ;return to routine called from
difference:
CLRA ;clear A
LDA 5, SP ;load 5th value in A
PSHA ;push
LDA 5, SP ;load value 4th position from stack in A
NEGA ;turn A in 2nd compliment store in A
PSHA ;push A on stack
JSR sum ;return to routine called from
PULA ;pull top value from stack in A
STA 5, SP ;store A onto 5th position in stack
PULA ;pull top value from stack in A
PULA ;pull top value from stack in A
RTS ;return to routine called from