Question
BELOW IS THE ORIGINAL CODE: ; export symbols XDEF Entry, _Startup ; export 'Entry' symbol ABSENTRY Entry ; for absolute assembly: mark this as application
BELOW IS THE ORIGINAL CODE:
; export symbols XDEF Entry, _Startup ; export 'Entry' symbol ABSENTRY Entry ; for absolute assembly: mark this as application entry point
; Include derivative-specific definitions INCLUDE 'derivative.inc'
ROMStart EQU $4000 ; absolute address to place my code/constant data
; variable/data section
ORG RAMStart ; Insert here your data definition. Counter DS.W 1 FiboRes DS.W 1
; code section ORG ROMStart ******************************
LCD_DAT EQU PORTB ;LCD data port, bits - PB7,...,PB0 LCD_CNTR EQU PTJ ;LCD control port, bits - PE7(RS),PE4(E) LCD_E EQU $80 ;LCD E-signal pin LCD_RS EQU $40 ;LCD RS-signal pin
; Variable/data section ORG $3850 TEN_THOUS RMB 1 ;10,000 digit THOUSANDS RMB 1 ;1,000 digit HUNDREDS RMB 1 ;100 digit TENS RMB 1 ;10 digit UNITS RMB 1 ;1 digit NO_BLANK RMB 1 ;Used in leading zero blanking by BCD2ASC ADDATA RMB 8 ;storage for RAM registers to conatin the results BCD_SPARE RMB 1 ;extra space for string terminator and decimal point.
; Code section ORG $4000 Entry: _Startup:
LDS #$4000 ;initialize the stack pointer JSR initAD ;initialize ATD converter JSR initLCD ;initialize LCD JSR clrLCD ;clear LCD & home cursor
LDX #msg1 ;display msg1 JSR putsLCD ;" LDAA #$C0 ;move LCD cursor to the 2nd row JSR cmd2LCD LDX #msg2 ;display msg2 JSR putsLCD ;" lbl MOVB #$90,ATDCTL5 ;r.just., unsign., sing.conv., mult., ch0, start conv. BRCLR ATDSTAT0,$80,* ;wait until the conversion sequence is complete LDAA ATDDR4L ;load the ch4 result into AccA ATDDR4L $0099 LDAB #39 ;AccB = 39 #39 #$27 MUL ;AccD = 1st result x 39 ADDD #600 ;AccD = 1st result x 39 + 600 #600 #$258 JSR int2BCD JSR BCD2ASC LDAA #$8C ;move LCD cursor to the 1st row, end of msg1 JSR cmd2LCD ; "
LDAA TEN_THOUS ;output the TEN_THOUS ASCII character JSR putcLCD ; "
;... same for THOUSANDS, . and HUNDREDS LDAA THOUSANDS ;output the THOUSANDS ASCII character JSR putcLCD ; " LDAA #46 JSR putcLCD LDAA HUNDREDS ;output the TEN_THOUS ASCII character JSR putcLCD ; "
LDAA TENS ;output the TENS ASCII character JSR putcLCD ; "
LDAA #$CA ;move LCD cursor to the 2nd row, end of msg2 JSR cmd2LCD ;
BRCLR PORTAD0,#%00000100,bowON LDAA #$31 ; output 1 if bow sw OFF BRA bowOFF bowON LDAA #$30 ; output 0 if bow sw ON bowOFF JSR putcLCD
LDAA #$20 ;output a space character in ASCII JSR putcLCD BRCLR PORTAD0,#%00001000,sternON LDAA #$31 BRA sternOFF ;output 1 if stern sw OFF sternON LDAA #$30 ; output 0 if stern sw ON sternOFF JSR putcLCD
JMP lbl
msg1 dc.b "Battery volt",0 msg2 dc.b "Sw status",0
; Subroutine section ******************************
******************************
int2BCD XGDX ; Save the binary number into .X LDAA #0 ;Clear the BCD_BUFFER STAA TEN_THOUS STAA THOUSANDS STAA HUNDREDS STAA TENS STAA UNITS STAA BCD_SPARE STAA BCD_SPARE+1 * CPX #0 ;Check for a zero input BEQ CON_EXIT ; and if so, exit * XGDX ;Not zero, get the binary number back to .D as dividend LDX #10 ;Setup 10 (Decimal!) as the divisor
IDIV ;Divide: Quotient is now in .X, remainder in .D STAB UNITS ;Store remainder
CPX #0 ; If quotient is zero, BEQ CON_EXIT ; then exit * XGDX ;else swap first quotient back into .D LDX #10 ; and setup for another divide by 10
IDIV STAB TENS CPX #0 BEQ CON_EXIT * XGDX ;Swap quotient back into .D LDX #10 ;and setup for another divide by 10
IDIV STAB HUNDREDS CPX #0 BEQ CON_EXIT * XGDX ;Swap quotient back into .D LDX #10 ;and setup for another divide by 10
IDIV STAB THOUSANDS CPX #0 BEQ CON_EXIT * XGDX ; Swap quotient back into .D LDX #10 ;and setup for another divide by 10
IDIV STAB TEN_THOUS * CON_EXIT RTS ;Were done the conversion
BCD2ASC LDAA #0 ;Initialize the blanking flag STAA NO_BLANK * C_TTHOU LDAA TEN_THOUS ;Check the ten_thousands digit ORAA NO_BLANK BNE NOT_BLANK1 * ISBLANK1 LDAA #' ' ;Its blank STAA TEN_THOUS ;so store a space BRA C_THOU ;and check the thousands digit * NOT_BLANK1 LDAA TEN_THOUS ;Get the ten_thousands digit ORAA #$30 ;Convert to ascii STAA TEN_THOUS LDAA #$1 ;Signal that we have seen a non-blank digit STAA NO_BLANK * C_THOU LDAA THOUSANDS ;Check the thousands digit for blankness ORAA NO_BLANK ;If its blank and no-blank is still zero BNE NOT_BLANK2 * ISBLANK2 LDAA #' ' ;Thousands digit is blank STAA THOUSANDS ;so store a space BRA C_HUNS ;and check the hundreds digit * NOT_BLANK2 LDAA THOUSANDS ;(similar to ten_thousands case) ORAA #$30 STAA THOUSANDS LDAA #$1 STAA NO_BLANK * C_HUNS LDAA HUNDREDS ;Check the hundreds digit for blankness ORAA NO_BLANK ;If its blank and no-blank is still zero BNE NOT_BLANK3 * ISBLANK3 LDAA #' ' ;Hundreds digit is blank STAA HUNDREDS ;so store a space BRA C_TENS ;and check the tens digit * NOT_BLANK3 LDAA HUNDREDS ;(similar to ten_thousands case) ORAA #$30 STAA HUNDREDS LDAA #$1 STAA NO_BLANK * C_TENS LDAA TENS ;Check the tens digit for blankness ORAA NO_BLANK ;If its blank and no-blank is still zero BNE NOT_BLANK4 * ISBLANK4 LDAA #' ' ;Tens digit is blank STAA TENS ;so store a space BRA C_UNITS ;and check the units digit * NOT_BLANK4 LDAA TENS ;(similar to ten_thousands case) ORAA #$30 STAA TENS * C_UNITS LDAA UNITS ;No blank check necessary, convert to ascii. ORAA #$30 STAA UNITS * RTS ;Were done
initAD MOVB #$C0,ATDCTL2 ;power up AD, select fast flag clear JSR del_50us ;wait for 50 us
MOVB #$00,ATDCTL3 ;8 conversions in a sequence MOVB #$85,ATDCTL4 ;res=8, conv-clks=2, prescal=12 BSET ATDDIEN,$0C ;configure pins AN03,AN02 as digital inputs RTS
; Interrupt vectors
SWI
++++++++++++++++++++++++++++++
I NEED TO DO THE FOLLOWING:
1. display the Battery Voltage in the first line of eebot lcd
2. erase after 2 secs
3. display SW Status in the first line of lcd
4. erase after 2 secs.
This 4 steps should happen in a sequence.
I need it in less than half hour! Please help me!! Thank you
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started