; ; SumtreeC.asm ; ; Program that implements a tree that sums integers ; ; 2-6-2008 ; ; This program reads the number from the DOWN and RIGHT ports, adds them ; and sends the result to the UP port. ; ; Port0 (U) ; Port1 (L) ; Port2 (R) ; Port3 (D) ; ;Set-up reset vector ORG 00H LJMP RESET ;--------------------------------------------------------------- P0 EQU 80H P1 EQU 90H P2 EQU 0A0H P3 EQU 0B0H UP EQU 80H LEFT EQU 90H RIGHT EQU 0A0H DOWN EQU 0B0H ACC EQU 0E0H B EQU 0F0H SP EQU 081H ;--------------------------------------------------------------- ; RAM MEMORY MAP ; ; 30h-4Fh : spare ; ; 50h-FFh : stack ;--------------------------------------------------------------- ; STACK EQU 050h ;-------------------------------------------------------------- ;Main program ORG 0100H RESET: MOV SP,#STACK NOP NOP NOP NOP NOP MOV A,DOWN ;read DOWN port MOV B,A MOV A,RIGHT ;read RIGHT port ADD A,B MOV UP,A ;Write UP port HALT: SJMP HALT ;-------------------------------------------------------------- END