;FILENAME: UNIT13.TXT ; ; ASSEMBLY LANGUAGE COURSE, UNIT 13 ; By Don Stoner Revision: 2008.07.02 ; ; This is a simple monitor program to ; enable the display and editing of ; memory locations, as well as the ; execution of simple programs that ; are entered into memory. ; ORG 100h ; Code Starts at 100h ; ; Start memory pointer at 1000h ; Operations will work on this ; memory location until the ; pointer in SI is cahnged. ; MOV SI,1000h ; LOOP_BACK: ; Loop back to here ; CALL CRLF_OUT ;New line ; ; Display memory address and ; its contents. ; ;Get memory MOV AX,SI ;address MOV AL,AH CALL HEX_OUT ;Show MSB (AH) MOV AX,SI CALL HEX_OUT ;Show LSB (AL) CALL SPACE_OUT ;Space ; ; ;Get memory MOV AL,[SI] ;contents CALL HEX_OUT ;Show them CALL SPACE_OUT ;Space ; ; Next, fetch a key to tell ; the monitor what to do: ; CALL ASCII_IN ;Read key to AL CALL ASCII_OUT ;Echo it ; ; Select operation depending ; on which key was pressed: ;------------------------------ ; These operations use ; the pointer in SI: ; ; Set memory contents? "=" ; CMP AL,"=" ;Set mem =to? JNZ NTSET CALL HEX_IN ;Get hex in DL MOV [SI],DL ;then to memory JMP LOOP_BACK ;loaction NTSET: ; ; Execute code at SI "." ; CMP AL,"." ;. -> Run code JNZ NTEXEC ; ; This calls whatever hex code ; you have entered, beginning ; from the address in the SI ; pointer: ; CALL SI ;Execute code ; ; Your code must end with a ; RET command (0C3h) to tell ; the computer to return to ; the code following the CALL. ; You might try loading AL with ; 55h (code: 0B0h 55h) or SI ; with 1234h (0BEh 34h 12h) ; (the LSB comes comes first). ; ;Drop down to CALL CRLF_OUT ;the next line CALL HEX_OUT ;and show AL ;so we can see JMP LOOP_BACK ;what happened. NTEXEC: ;------------------------------ ; These operations change ; the pointer in SI: ; ; Advance pointer? "+" ? ; CMP AL,"+" ;Advance? JNE NTADV INC SI ;Point to next JMP LOOP_BACK ;memory byte NTADV: ; ; Backup pointer? "-" ? ; CMP AL,"-" ;Back? JNE NTBAK DEC SI ;Point to last JMP LOOP_BACK ;memory byte NTBAK: ; ; Set memory pointer "*" ; CMP AL,"*" ;* -> Set addr. JNZ NTMEM CALL HEX_IN ;Get hex in DX MOV SI,DX ;then to memory JMP LOOP_BACK ;address NTMEM: ;------------------------------ ; Other operations: ; ; Escape? (1Bh) ; CMP AL,1Bh ;(Escape key) JNZ NTESC INT 20h ;just return to DOS NTESC: ; ; Key not recognized ; CALL SPACE_OUT ;Output hex CALL HEX_OUT ;key code JMP LOOP_BACK ;(for debug) ;-------------------------------------- %INCLUDE "UNIT11.ASM" ;(Subroutines)