สำนักงานราชบัณฑิตยสภา
ซอฟต์แวร์ระบบส� ำหรั บแผงวงจรไมโครคอนโทรลเลอร์เพื่ อการเรี ยนรู้ 164 The Journal of the Royal Institute of Thailand Vol. 38 No. 3 July-Sep 2013 - 19 - ; Page 3 POP AX ;get brkpt offset from stack MOV SI,BR_IP ;store addr for brkpt IP MOV WORD PTR[SI],AX ;save brkpt IP POP AX ;get brkpt segment from stack MOV SI,BR_CS ;store addr for brkpt CS MOV WORD PTR[SI],AX ;save brkpt CS POP AX ;decrement SP MOV DX,WORD PTR[SI] ;display addr of brkpt CALL H_OUT ;in CS:IP format MOV AL,':' CALL C_OUT MOV DI,BR_IP MOV DX,WORD PTR[DI] DEC DX ;decrement brkpt IP CALL H_OUT MOV AL,']' CALL C_OUT MOV DI,B_MMA ;addr for brkpt in main mem MOV SI,WORD PTR[DI] ;restore user code at brkpt MOV DI,OP_KODE ;addr for replaced opcode MOV AL,BYTE PTR[DI] MOV BYTE PTR[SI],AL MOV DI,BR_STAT ;store addr for brkpt status MOV BYTE PTR[DI],0 ;clear brkpt status JMP GET_COM ;get next command ; normal entry point (via INT 95H), this routine falls into GET_COM RE_STRT: CALL ENVIR ;save/display environment LEA SI,RENTER ;display re-entry message (with '[') CALL S_END POP AX ;get exit IP from stack MOV BX,BR_IP ;store addr for brkpt IP MOV WORD PTR[BX],AX ;save brkpt IP POP AX ;get exit CS from stack MOV BX,BR_CS ;store addr for brkpt CS MOV WORD PTR[BX],AX ;save brkpt CS POP AX ;dec IP by popping stack MOV DX,WORD PTR[BX] ;display exit addr CALL H_OUT ;in CS:IP format MOV AL,':' ; Page 4 CALL C_OUT MOV BX,BR_IP MOV DX,WORD PTR[BX] SUB DX,2 ;brkpt IP-2 CALL H_OUT MOV AL,']' CALL C_OUT ; command recognizer GET_COM: CALL CRLF ;start new line on PC MOV AL,'>' ;prepare command prompt CALL C_OUT ;and send it to PC CALL C_IN ;get cmnd letter (in AL) from PC CALL C_OUT ;echo it to PC CALL CH_CASE ;capitalize the letter CMP AL,13 ;if CR, get new cmnd JZ GET_COM MOV CX,NUM_COM ;init cntr to no. commands (=14) MOV SI,0 ;init table ptr C_TEST: CMP AL,COMS[SI] ;check cmnd char w/ table item JZ CHK_SN ;find match ADD SI,2 ;not match, move ahead LOOP C_TEST ;repeat test CALL ERROR ;find no match, send message JMP GET_COM ;start all over again CHK_SN: CALL C_IN ;<cr>/<sp> expected as next char CMP AL,13 ;<cr>? JZ DO_JMP ;yes, so xcute cmnd CALL C_OUT ;echo char to PC CMP AL,20H ;<sp>? JZ DO_JMP ;yes, so xcute cmnd CALL ERROR ;undefined char JMP GET_COM ;start all over again DO_JMP: JMP J_UMPS[SI] ;use jump table ; ********** COMMAND ROUTINES ********** ; B Command, set Breakpoint
Made with FlippingBook
RkJQdWJsaXNoZXIy NTk0NjM=