สำนักงานราชบัณฑิตยสภา
ซอฟต์แวร์ระบบส� ำหรั บแผงวงจรไมโครคอนโทรลเลอร์เพื่ อการเรี ยนรู้ 166 The Journal of the Royal Institute of Thailand Vol. 38 No. 3 July-Sep 2013 - 21 - ; Page 7 MOV AL,'-' CALL C_OUT CALL BLANK MOV BX,R_AX ;store addr for AX MOV DX,WORD PTR[BX+SI] ;get old reg content via DX CALL H_OUT ;then display it MOV AL,'?' ;ask for a replacement CALL C_OUT CALL GET_NUM ;read new value using DX CMP BH,'0' ;blank data? JZ NUN ;yes, skip the reg MOV BX,R_AX ;store addr for AX MOV WORD PTR[BX+SI],DX ;save new reg content NUN: ADD SI,2 ;go to next reg LOOP I_NEX ;repeat JMP GET_COM ;get new cmnd ; G Command, Go execute user program E_XEC: CALL GET_NUM ;start addr of user prog via DX SUB AX,AX PUSH AX ;set CS=0000H on stack PUSH DX ;set IP=DX on stack CALL CRLF MOV DI,R_AX ;7F00H MOV AX,WORD PTR[DI] ;retrieve reg values saved MOV BX,WORD PTR[DI+2] MOV CX,WORD PTR[DI+4] MOV DX,WORD PTR[DI+6] MOV BP,WORD PTR[DI+8] MOV SI,WORD PTR[DI+10] PUSH BX ;temporarily store BX MOV BX,R_AX MOV DI,WORD PTR[BX+12] POP BX ;retrieve BX RET ;pop stack for IP & CS to execute user prog ; H Command, Help message display H_ELP: LEA SI,H_MSG ;ptr to help msg CALL S_END ;display it JMP GET_COM ; Page 8 ; I Command, Input data from a port P_IN: CALL GET_NUM ;get input port addr via DX CALL CRLF MOV AL,'[' CALL C_OUT IN AL,DX ;read data from input prt CALL HTOA ;display data byte on PC MOV AL,']' CALL C_OUT JMP GET_COM ;get next command ; L Command, Load user prog in HEX file to addr 0400H L_OAD: CALL CRLF MOV BX,0400H ;downloaded prog begins here NXT_REC: MOV SI,C_SUM MOV BYTE PTR[SI],0 ;clear chksm total KOLON: CALL C_IN ;wait for input char in AL CALL C_OUT ;echo it to PC CMP AL,':' JNZ KOLON ;repeat until ':' CALL GET_BYT ;get rec length, 1 byte in AL MOV CL,AL ;transfer it to CL for counting MOV CH,0 CALL GET_WRD ;get load addr, 1 wrd in AX MOV DI,AX ;save it in DI CALL GET_BYT ;get rec type, 1 byte in AL CMP AL,0 JZ DAT_REC ;data record CMP AL,1 JZ EOF_REC ;end-of-file record CMP AL,2 JZ EAD_REC ;extened-addr record CMP AL,3 JZ SAD_REC ;starting-addr record LEA SI,URT ;undef rec type msg ptr CALL S_END JMP GET_COM DAT_REC: CALL GET_BYT ;start getting data bytes MOV BYTE PTR[BX+DI],AL ;and store them
Made with FlippingBook
RkJQdWJsaXNoZXIy NTk0NjM=