📄 s12sermon2r1.lst
字号:
978 465 a00F96F 8DFF FF cpy #$FFFF ;is it programmed?
979 466 a00F972 2702 beq SciIsrExit ; if not exit
980 467 a00F974 0540 jmp 0,Y ;if programmed the go there.
981 468
982 469 a00F976 4D0C 01 SciIsrExit: bclr SwPullup,mSwPullup ;restore reset state
983 470 a00F979 06F8 D1 jmp Prompt1
984 471 ;* unlike most ISRs, this one does not end in an RTI. If/when we
985 472 ;* return to running the user program, we will re-enable Rx interrupts
986 473
987 474 ;*********************************************************************
988 475 ;* Reset Command - forces a reset - if user pseudo-vector is not blank
989 476 ;* (or some other conditions are met - see ColdStart:) processing will
990 477 ;* start at the user-specified reset pseudo-vector location and the
991 478 ;* user has full control of all write-once registers. Otherwise reset
992 479 ;* causes the bootloader/monitor program to cold start.
993 480 ;*********************************************************************
994 481 a00F97C 8641 ResetCmd: ldaa #RSBCK|!CR2|!CR1|CR0 ;Cop disabled in BDM
995 482 a00F97E 5A3C staa COPCTL ; turn on cop monitor
996 483 a00F980 913C cmpa COPCTL ; load to see if user touched it
997 484 a00F982 2703 beq CopLock ; wait for COP reset
998 485 a00F984 06F8 00 jmp ColdStart ; can't use COP just start over
999 486 a00F987 1410 CopLock: orcc #$10 ; disable interrupts
1000 487 a00F989 20FE bra *
1001 488
1002 489 ;*********************************************************************
1003 490 ;* SWI service routine - trace1 or breakpoint from user code
1004 491 ;* SWI saves user CPU registers on stack and returns to monitor
1005 492 ;* control at a new command prompt.
1006 493 ;* User CPU registers stack frame...
1007 494 ;*
1008 495 ;* +0 UCcr <- SP after SWI stacking and on entry to this ISR
1009 496 ;* +1 UDreg (B:A)
1010 497 ;* +3 UXreg
1011 498 ;* +5 UYreg
1012 499 ;* +7 UPc
1013 500 ;* +9 --- <- User's SP
1014 501 ;*********************************************************************
1015 502 a00F98B 7900 28 Breakpoint: clr DBGC2 ;Bkpct0 cleared to disabled
1016 503 a00F98E 7900 20 clr DBGC1 ;Dbgc1 cleared to disarm DBG
1017 504 a00F991 4DCA 08 bclr flagReg,RunFlag ;run/mon flag = monitor active
1018 505 a00F994 C604 ldab #StatTrace ;set status to Trace (SWI) -> B
1019 506 ;and enter monitor
1020 507
1021 508 ;*********************************************************************
Metrowerks HC12-Assembler
(c) COPYRIGHT METROWERKS 1987-2003
Abs. Rel. Loc Obj. code Source line
---- ---- ------ --------- -----------
1022 509 ;* This is the entrypoint to the monitor from the user application
1023 510 ;* A contains the status value that reflects run status
1024 511 ;*
1025 512 ;* If SP isn't within valid RAM, it can't support the monitor so the
1026 513 ;* monitor is forced to initialize the SP and user registers.
1027 514 ;*********************************************************************
1028 515 ReenterMon:
1029 516 a00F996 8F10 1B cps #LowSPLimit+1 ;check against lower limit
1030 517 a00F999 2518 blo badSP ; note: +1 => A is not pushed yet
1031 518 a00F99B 8F3F F8 cps #HighSPLimit+1 ;check against upper limit
1032 519 a00F99E 2213 bhi badSP
1033 520 a00F9A0 86E0 ldaa #ErrNone ;error code for no errors
1034 521 a00F9A2 16FC 85 jsr PutChar ;send error code
1035 522 a00F9A5 180F tba ;status code from B to A
1036 523 a00F9A7 4FCA 0405 brclr flagReg,TraceFlag,SWIdone ;0 indicates not Trace
1037 524 a00F9AB 4DCA 04 bclr flagReg,TraceFlag ;acknowledge trace flag
1038 525 a00F9AE 8604 ldaa #StatTrace ;status code for Trace1 return
1039 526 a00F9B0 06F8 BB SWIdone: jmp EndPrompt ;send status and >
1040 527 a00F9B3 86E3 badSP: ldaa #ErrSP ;set error code to bad stack pointer
1041 528 a00F9B5 06F8 66 jmp stackInit
1042 529 a00F9B8 4DCA 20 bclr flagReg,ArmFlag ;Save ARM flag
1043 530
1044 531 ;*********************************************************************
1045 532 ;* Erase EE Command - mass
1046 533 ;* erase all EEPROM locations
1047 534 ;*
1048 535 ;* Eeprom erasure assumes no protection. (Mass command will fail)
1049 536 ;*********************************************************************
1050 537 a00F9BB 16FD 2D EraseEECmd: jsr abClr ;abort commands and clear errors
1051 538
1052 539 a00F9BE 4F1C 3026 brclr MEMSIZ0,eep_sw1+eep_sw0,ErsPageErr1 ;Check if device has EEprom
1053 540 a00F9C2 CD04 00 ldy #EEpromStart ; get device eeprom start
1054 541 a00F9C5 6C40 std 0,y ; write to eeprom (latch address)
1055 542 ; data is don't care (but needed)
1056 543
1057 544 a00F9C7 180B 4101 movb #$41,ECMD ;mass erase command
00F9CB 16
1058 545 a00F9CC 180B 8001 movb #CBEIF,ESTAT ;register the command
00F9D0 15
1059 546 a00F9D1 A7 nop ; wait a few cycles for
1060 547 a00F9D2 A7 nop ; command to sync.
1061 548 a00F9D3 A7 nop
1062 549 a00F9D4 B601 15 ChkDoneE: ldaa ESTAT ;wait for CBEIF=CCIF=1 (cmnd done)
1063 550 a00F9D7 2AFB bpl ChkDoneE ;loop if command buffer full (busy)
1064 551 a00F9D9 48 asla ;moves CCIF to MSB (set/clear N bit)
1065 552 a00F9DA 2AF8 bpl ChkDoneE ;loop if CCIF=0 (not done)
1066 553 a00F9DC B601 05 ldaa FSTAT
1067 554 a00F9DF 8430 anda #$30 ;mask all but PVIOL or ACCERR
1068 555 a00F9E1 2605 bne ErsPageErr1 ;back to prompt-flash error
1069 556 a00F9E3 86E0 ldaa #ErrNone ;code for no errors ($E0)
1070 557 a00F9E5 06F8 B1 jmp Prompt ;ready for next command
1071 558
1072 559 a00F9E8 86E9 ErsPageErr1: ldaa #ErrEeErase ;Erase error code ($E9)
1073 560 a00F9EA 06F8 B1 jmp Prompt ;ready for next command
1074 561
1075 562 ;*********************************************************************
1076 563 ;* Erase Command - Use repeated page erase commands to erase all flash
1077 564 ;* except bootloader in protected block at the end of flash, and mass
1078 565 ;* erase all EEPROM locations
1079 566 ;*
1080 567 ;* Eeprom erasure assumes no protection. (Mass command will fail)
1081 568 ;*********************************************************************
1082 569 a00F9ED 16FD 2D EraseAllCmd: jsr abClr ;abort commands and clear errors
1083 570
Metrowerks HC12-Assembler
(c) COPYRIGHT METROWERKS 1987-2003
Abs. Rel. Loc Obj. code Source line
---- ---- ------ --------- -----------
1084 571 a00F9F0 4F1C 301A brclr MEMSIZ0,eep_sw1+eep_sw0,ErsBlk0 ;Check if device has EEprom
1085 572 a00F9F4 CD04 00 ldy #EEpromStart ; get device eeprom start
1086 573 a00F9F7 6C40 std 0,y ; write to eeprom (latch address)
1087 574 ; data is don't care (but needed)
1088 575
1089 576 a00F9F9 180B 4101 movb #MassErase,ECMD ;mass erase command
00F9FD 16
1090 577 a00F9FE 180B 8001 movb #CBEIF,ESTAT ;register the command
00FA02 15
1091 578 a00FA03 A7 nop ; wait a few cycles for
1092 579 a00FA04 A7 nop ; command to sync.
1093 580 a00FA05 A7 nop
1094 581 a00FA06 B601 15 ChkDoneE1: ldaa ESTAT ;wait for CBEIF=CCIF=1 (cmnd done)
1095 582 a00FA09 2AFB bpl ChkDoneE1 ;loop if command buffer full (busy)
1096 583 a00FA0B 48 asla ;moves CCIF to MSB (set/clear N bit)
1097 584 a00FA0C 2AF8 bpl ChkDoneE1 ;loop if CCIF=0 (not done)
1098 585 ;
1099 586 ; erase flash pages from RomStart to start of protected bootloader
1100 587 ; no need to check for errors because we cleared them before EE erase
1101 588 ;
1102 589
1103 590 ErsBlk0: ; sector erase all full blocks
1104 591 a00FA0E C604 ldab #PagesBlk ; Get number of banks/blocks
1105 592 a00FA10 53 decb ; erase all but last
1106 593 a00FA11 6BAF stab 1,-sp ; save counter
1107 594 a00FA13 863F ldaa #$3f ; highest bank
1108 595 a00FA15 1816 sba ; Compute lowest page-1
1109 596 a00FA17 5A30 staa PPAGE ; PPAGE for first 16K page of block 0
1110 597 ; (passed in the A accumulator).
1111 598 a00FA19 7901 03 clr FCNFG ; set block select bits to 0.
1112 599 a00FA1C CE02 00 ErsBlk0Lp: ldx #SectorSize ; select sector size
1113 600 a00FA1F CC40 00 ldd #$4000 ; Window size
1114 601 a00FA22 1810 idiv ; compute total number of sectors
1115 602 a00FA24 B754 tfr x,d ; get number of sectors in B
1116 603 a00FA26 CE80 00 ldx #Window ; point to the start of the PPAGE window.
1117 604 a00FA29 0760 bsr ErsSectors ; go erase the PPAGE window a sector at a time.
1118 605 a00FA2B 7200 30 inc PPAGE ; go to the next PPAGE.
1119 606 a00FA2E 6380 dec 0,sp ; done with all full PPAGE blocks?
1120 607 a00FA30 26EA bne ErsBlk0Lp ; no? then erase more blocks.
1121 608
1122 609 a00FA32 CE02 00 ldx #SectorSize ; select sector size
1123 610 a00FA35 CC38 00 ldd #((BootStart-$c000)) ; get size - protected amount
1124 611 a00FA38 1810 idiv ; compute total number of sectors
1125 612 ; minus the bootblock.
1126 613 a00FA3A B754 tfr x,d ; get number of sectors in B
1127 614 a00FA3C CE80 00 ldx #Window ; point to the start of the PPAGE window.
1128 615 a00FA3F 074A bsr ErsSectors ; go erase the PPAGE window a sector at a time.
1129 616 a00FA41 33 pulb ; remove the page count from the stack.
1130 617
1131 618 ; erase all sectors outside the bootblock.
1132 619 ;
1133 620 ;********************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -