homework 5 solutions

# homework 5 solutions - Homework Sol#5 org \$0100 ST...

This preview shows page 1. Sign up to view the full content.

org \$0100 ST LDS #\$00FF CLR TEMP SET TEMP TO ZERO LDY #\$0008 NEED TO LOOP EIGHT TIMES LP JSR INCHAR GO GET THE INPUT CHAR CMPA #\$31 GO SEE IF IT'S A ONE BEQ OK CMPA #\$30 GO SEE IF IT'S A ZERO BEQ OK BRA LP INVALID INPUT OK JSR OUTA GO ECHO THE CHARACTER SUBA #\$30 GO MAKE 0 OR 1 LDAB TEMP GO GET THE NUMBER SO FAR LSLB SHIFT IT TO THE LEFT ABA ADD THE NEW BIT TO TEMP STAA TEMP BUT IF BACK INTO TEMP DEY BNE LP DO IT EIGHT TIMES LDAA TEMP GO PUT IT IN THE AREG EQ BRA EQ INCHAR PSHB THIS ROUTINE INPUTS ONE CHAR IN A REG RCHR1 LDAB \$102E GO SEE IF THE RECEIVE BUFFER IS EMPTY ANDB #\$20 BEQ RCHR1 LDAA \$102F SOURCE INPUT CHARACTER IN THE A REG PULB RTS OUTA PSHB THIS ROUTINE OUTPUTS ONE CHAR IN A REG WCHR1 LDAB \$102E GO SEE IF THE TRANSMIT BUFFER IS EMPTY ANDB #\$80 BEQ WCHR1 STAA \$102F GO WRITE THE CHAR PULB RTS CRLF LDAA #\$0D JSR OUTA LDAA #\$0A JSR OUTA GO WRITE THE LINE FEED AND CARRIAGE RETURN RTS TEMP FCB 00 End _______________________________________________________________ org \$0100 ST LDS #\$00FF LDY #\$0008 NEED TO LOOP EIGHT TIMES LP LSLA PUT BITS INTO CARRY BCS PRINT1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Ask a homework question - tutors are online