ORG $7510 THERM DC.L 0 ; reserve and clear space for temperature ORG $7520 LENNOX DC.L 0 ; reserve and clear space for on/off ORG $6000 START MOVE.B #78,D1 ; put 78 degrees as thermostat setting MOVE.B #85,THERM ; put 85 degrees as current temperature MOVE.L #50,D7 ; set the loop counter TLOOP BSR AIRCTRL BSR STATUS ; show status BSR DELAY1 ; wait for a little time TST.B LENNOX ; nudge temperature depending on AC status BNE COOLIT ADDI.B #1,THERM ; increase by 1 degree BRA NEXT COOLIT SUBI.B #1,THERM ; decrease by 1 degree NEXT SUBQ.W #1,D7 BGT TLOOP ; loop a bunch of times TRAP #9 ORG $6100 AIRCTRL MOVEM.L D0/D1,-(A7) ; AIRCTRL is main thermostat function MOVE.B THERM,D0 ; get current temperature ADDQ.B #2,D1 ; convert setting to upper limit CMP.B D1,D0 ; too hot? BGE TURNON ; turn unit on SUBQ.B #4,D1 ; convert setting to lower limit CMP.B D1,D0 ; too cold? BLE TURNOFF ; turn unit off BRA AIRDONE TURNON MOVE.B #1,LENNOX ; set on/off port to on BRA AIRDONE TURNOFF MOVE.B #0,LENNOX ; set on/off port to off AIRDONE MOVEM.L (A7)+,D0/D1 RTS ORG $6200 STATUS MOVEM.L D0/A3,-(A7) ; STATUS prints temperature and AC on or off LEA.L MSGTEMP,A3 ; set a3 to display "temperature" TRAP #3 ; print it CLR.L D0 ; clear upper bytes MOVE.B TEMP,D0 ; get temperature as byte BSR TOSTR ; print the temperature MOVE.B LENNOX,D0 ; get the air conditioner status BEQ SAYOFF ; is it off? LEA.L MSGON,A3 ; set a3 to display "air is on" TRAP #3 MOVEM.L (A7)+,D0/A3 RTS SAYOFF LEA.L MSGOFF,A3 TRAP #3 MOVEM.L (A7)+,D0/A3 RTS ORG $6300 MSGTEMP DC.B ' temperature is ' DC.B 0 MSGON DC.B ' airconditioner is on' DC.B 13,0 MSGOFF DC.B ' airconditioner is off' DC.B 13,0,0 ORG $6400 DELAY1 MOVEM.L D0-D2,-(A7) ; DELAY1 should use up a second of time MOVE.L #30000,D0 ; choose to get 1 second, but depends on PC speed DLOOP MOVE.L #455,D1 ; do some arbitrary divide to eat up time MOVE.L #39,D2 DIVS D2,D1 SUB.L #1,D0 BGT DLOOP MOVEM.L (A7)+,D0-D2 RTS ORG $7000 TOSTR MOVEM.L D0/A3,-(A7) ; TOSTR prints value in D0 as text LEA.L SDATA,A3 SLOOP TST.L D0 ; while not zero BEQ SDONE DIVU #10,D0 ; next decimal character SWAP D0 ; get remainder ADDI.B #'0',D0 ; make it ascii MOVE.B D0,-(A3) ; output to string CLR.B D0 ; zero out the remainder SWAP D0 ; restore value BRA SLOOP SDONE TRAP #3 MOVEM.L (A7)+,D0/A3 RTS DS.B 8 ; space for tostr output SDATA DC.B 13 ; newline at end DC.B 0 ; null termination END