#include 9sequate.asm #include 9sfunc.h #include 9srva.h ;========================================================================= ;Sets up baudrates and control registers and receives data input from user ;========================================================================= org RAM lds #STACK movb #$01,$d0 ;Baudrate register high movb #$38,$d1 ; baudrate low movb #$e4,$d2 ; d2 Sets control register - see pg 15 - 17 of lab book for reasoning movb #$ec,$d3 ; d3 for CR 2 get ldx getchar ; Stores the address of the getchar function in x jsr 0,x ; indirect addressing to starts the getchar function ldx putchar ; displays the character I just input to the screen jsr 0,x ; now character I input is in Acc B. ;========================================================================= ;ensures our data input is valid (from 0-9) ;========================================================================= cmpb #$2f ; (too low) ble bad ; Branch to dead loop if we're outside our range cmpb #$3a ; (too high) bge bad ; If not in our range, branch to invalid character loop bra tran bad ldd #strb ; Loads our string for printf with what we want ldx printf ; indirect addressing for printf command jsr 0,x leas 2,sp ; clean printf parameter off stack bra get ; back strb fcc " Character out of range " ; intend for kermit0 db $d,$a,0 ; cr, lf and terminator ;======================================================================== ;To be used to transmit to smart mode gps ;======================================================================== tran subb #$30 ; subtract $30, converts from ascii to hex movb #$02,$d5 ;set Tx direction to output brclr $d4,#$80,* ; poll TDRE to let us input data movb #$21,$d7 ;! into DRL brclr $d4,#$80,* ;poll TDRE until DRL is empty movb #$47,$d7 ;G into DRL brclr $d4,#$80,* movb #$50,$d7 ;P into DRL brclr $d4,#$80,* movb #$53,$d7 ;S into DRL brclr $d4,#$80,* stab $d7 ;========================================================================= ;sets program up for receiving data ;========================================================================= brclr $d4,#$40,* ;polls until transmission complete movb #$00,$d5 ;set Tx direction to input ;========================================================================= ;Selects which program we want to use for displaying the received information ;========================================================================= cmpb #$00 ; input = 0 bgt sk0 ; skip code for gps type display ;========================= ;gps type (2 bytes) ;========================= brclr $d4,#$20,* ; poll until data register is full (ie, entire byte received) ; when full, d4 bit 5 flag goes up ldaa $d7 ; loads data from data input register to accumulator b ldaa #$00 brclr $d4,#$20,* ; slight error, ! is displayed unless I discard the first byte ldab $d7 ; overwrite the ! with the new data pshd brclr $d4,#$20,* ldab $d7 pshd ldd #str0 ldx printf jsr 0,x leas 2,sp b0 lbra get str0 fcc " %2u (hardware): %2u (firmware) GPS type " db $d,$a,0 sk0 cmpb #$01 ; input = 1 bgt sk1 ; skip code for valid data string ;========================= ;validity of data string (1 byte) ;========================= brclr $d4,#$20,* ; poll until data register is full (ie, entire byte received) ; when full, d4 bit 5 flag goes up ldaa $d7 ; loads data from data input register to accumulator b brclr $d4,#$20,* ; slight error, ! is displayed unless I discard the first byte ldab $d7 ; overwrite the ! with the new data cmpb #$00 ble no ldd #str1 ldx printf jsr 0,x leas 2,sp b1 lbra b0 str1 fcc " Valid Data " db $d,$a,0 no ldd #str1n ldx printf jsr 0,x leas 2,sp bra b1 str1n fcc " Invalid Data " db $d,$a,0 sk1 cmpb #$02 ; input = 2 bgt sk2 ; bypass code for number of satellites ;========================= ;number of satellites (1 byte) ;========================= brclr $d4,#$20,* ; poll until data register is full (ie, entire byte received) ; when full, d4 bit 5 flag goes up ldaa $d7 ; loads data from data input register to accumulator b brclr $d4,#$20,* ; slight error, ! is displayed unless I discard the first byte ldab $d7 ; overwrite the ! with the new data ldaa #$00 ; load Acc A with 0's so printf command only reads the pshd ; significant data ldd #str2 ldx printf jsr 0,x leas 2,sp b2 lbra b1 str2 fcc " %u Satellites acquired " db $d,$a,0 sk2 cmpb #$03 ; input = 3 bgt sk3 ; bypass code for time ;========================= ;time (3 bytes) ;========================= brclr $d4,#$20,* ; poll until data register is full (ie, entire byte received) ; when full, d4 bit 5 flag goes up ldaa $d7 ; loads data from data input register to accumulator b brclr $d4,#$20,* ; slight error, ! is displayed unless I discard the first byte ldaa #$00 ; overwrite the ! with 0's in accumulator A ;printf command accesses 2 bytes from the stack, whereas the information sent from the ;chip is 3 individual bytes, not intended to be combined together. We want to access just the ;desired byte (we put it into Acc. B) and not combine it with anything fromm Acc. A. ; brclr $d4,#$20,* movb $d7,hrs ; load data from received data registed into Acc B. brclr $d4,#$20,* movb $d7,min brclr $d4,#$20,* ldab $d7 pshd ldab min pshd ldab hrs pshd ldd #str3 ldx printf jsr 0,x leas 6,sp b3 lbra b2 str3 fcc " The current atomic time is %.2u:%.2u:%.2u GMT " db $d,$a,0 hrs rmb 1 min rmb 1 sk3 cmpb #$04 ; input = 4 bgt sk4 ; bypass code for date ;========================= ;date (3 bytes) ;========================= brclr $d4,#$20,* ; poll until data register is full (ie, entire byte received) ; when full, d4 bit 5 flag goes up ldaa $d7 ; loads data from data input register to accumulator b brclr $d4,#$20,* ; slight error, ! is displayed unless I discard the first byte ldaa #$00 ; overwrite the ! with 0's in accumulator A ;printf command accesses 2 bytes from the stack, whereas the information sent from the ;chip is 3 individual bytes, not intended to be combined together. We want to access just the ;desired byte (we put it into Acc. B) and not combine it with anything fromm Acc. A. ; brclr $d4,#$20,* movb $d7,mon ; load data from received data registed into Acc B. brclr $d4,#$20,* movb $d7,day brclr $d4,#$20,* ldab $d7 pshd ldab day pshd ldab mon pshd ldd #str4 ldx printf jsr 0,x leas 6,sp b4 lbra b3 str4 fcc " Today's date is %.2u/%.2u/20%.2u (Day/Month/Year) " db $d,$a,0 mon rmb 1 day rmb 1 sk4 cmpb #$05 ; input = 5 bgt sk5 ; skip code for latitude display ;========================================================================= ;Latitude (5 bytes) ;========================================================================= brclr $d4,#$20,* ; poll until data register is full (ie, entire byte received) ; when full, d4 bit 5 flag goes up ldaa $d7 ; loads data from data input register to accumulator b brclr $d4,#$20,* ; slight error, ! is displayed unless I discard the first byte ldaa #$00 ; overwrite the ! with the new data brclr $d4,#$20,* ldab $d7 stab deg brclr $d4,#$20,* ldab $d7 stab mint brclr $d4,#$20,* ldaa $d7 brclr $d4,#$20,* ldab $d7 std fm brclr $d4,#$20,* ldaa #$00 ldab $d7 cmpb #$00 ble north ldab #$53 bra lat north ldab #$4e lat pshd ldd fm pshd ldaa #$00 ldab mint pshd ldab deg pshd ldd #str5 ldx printf jsr 0,x b5 lbra b4 str5 fcc " Latitude %u* %u.%04u' %c " db $d,$a,0 deg rmb 1 mint rmb 1 fm rmb 2 sk5 cmpb #$06 ; input = 6 bgt sk6 ; skip code for longitude display ;========================================================================= ; Longitude (5 bytes) ;========================================================================= brclr $d4,#$20,* ; poll until data register is full (ie, entire byte received) ; when full, d4 bit 5 flag goes up ldaa $d7 ; loads data from data input register to accumulator b brclr $d4,#$20,* ; slight error, ! is displayed unless I discard the first byte ldaa #$00 ; overwrite the ! with the new data brclr $d4,#$20,* ldab $d7 stab deg2 brclr $d4,#$20,* ldab $d7 stab min2 brclr $d4,#$20,* ldaa $d7 brclr $d4,#$20,* ldab $d7 std fm2 brclr $d4,#$20,* ldaa #$00 ldab $d7 cmpb #$00 ble east ldab #$57 bra dis east ldab #$45 dis pshd ldd fm2 pshd ldaa #$00 ldab min2 pshd ldab deg2 pshd ldd #str6 ldx printf jsr 0,x b6 lbra b5 str6 fcc " Longitude %u* %u.%04u' %c " db $d,$a,0 deg2 rmb 1 min2 rmb 1 fm2 rmb 2 sk6 cmpb #$07 ; input = 7 bgt sk7 ; skip code for altitude display ;========================= ;altitude (2 bytes) ;========================= balt brclr $d4,#$20,* ; poll until data register is full (ie, entire byte received) ; when full, d4 bit 5 flag goes up ldaa $d7 ; loads data from data input register to accumulator b brclr $d4,#$20,* ; slight error, ! is displayed unless I discard the first byte ldaa $d7 ; overwrite the ! with the new data brclr $d4,#$20,* ldab $d7 pshd ldd #str7 ldx printf jsr 0,x leas 2,sp b7 lbra b6 str7 fcc " Current altitude %u E-1 m " db $d,$a,0 sk7 cmpb #$08 ; input = 8 bgt sk8 ; send to code for velocity display ;========================= ;velocity (2 bytes) ;========================= brclr $d4,#$20,* ; poll until data register is full (ie, entire byte received) ; when full, d4 bit 5 flag goes up ldaa $d7 ; loads data from data input register to accumulator b brclr $d4,#$20,* ; slight error, ! is displayed unless I discard the first byte ldaa $d7 ; overwrite the ! with the new data brclr $d4,#$20,* ldab $d7 pshd ldd #str8 ldx printf jsr 0,x leas 2,sp b8 lbra b7 str8 fcc " Current speed is %u E-1 knots " db $d,$a,0 ; if none of the above, codes for heading ;========================= ;Heading (2 bytes) ;========================= sk8 brclr $d4,#$20,* ; poll until data register is full (ie, entire byte received) ; when full, d4 bit 5 flag goes up ldaa $d7 ; loads data from data input register to accumulator b brclr $d4,#$20,* ; slight error, ! is displayed unless I discard the first byte ldaa $d7 ; overwrite the ! with the new data brclr $d4,#$20,* ldab $d7 pshd ldd #str9 ldx printf jsr 0,x leas 2,sp bra b8 str9 fcc " %u E-1 degrees (heading) " db $d,$a,0