19IV. Machine Language ProgrammingVIP Machine CodingFor a complete description of machine languageinstructions, refer to the User Manual for the CDP1802COSMAC Microprocessor MPM201A. YourCOSMAC VIP computer incorporates the followingspecial machine-language input and output instructions:CODE OPERATION696B61626364Turn display on (Bus -> MX,D)Input port byte + MX,D (Optional)Turn display off (MX -> Bus,RX+1)MX(LSD) -> Hex keyboard latch,RX+1MX -> Output port, RX+1 (Optional)MX -> Bus,RX+lOne 64 instruction is always executed by theOperating System. It can also be used in expandedsystems if desired. Instructions 65, 66, 67, 6A, 6C, 6D,6E, and 6F are also available for use in expandedsystems.The External Flag lines are used as follows:FLAGEF1EF2EF3EF4USEGenerated by the video interface(CDPI861)Serial data from cassette playerHex key pressed signalNot used in basic systemEF4 can be used for system expansion. EF3 can alsobe used in expanded systems if no key will be depressedat the same time that an external device is using EF3.EF1 can only be used by an external device when thedisplay is turned off. EF2 should not be used inexpanded systems.The latched Q line output performs several functionsin the COSMAC VIP system. When set, it holds the Qlight on and generates a continuous speaker tone. Ile Qline is also used for serial output data to a cassetterecorder. You can use the Q output line as a controlsignal in an expanded system if you avoid conflicts withits normal functions.You can store a machine language program starting atlocation 0000. It will be executed when you flip theRUN switch up. Initially P=0, X=0, R0=0000, Q=0, andR1=0XFF, where 0X= last page of on-card RAM. (0X =07 in 2048-byte RAM system). The operating systemuses the last 84 bytes of on-card RAM. You shouldavoid using these last 84 RAM bytes when writingmachine language programs. With a 2048-byte RAM,locations 07AC-07FF would be reserved for use by theoperating system. Note that Rl initially contains theaddress of the last on-card RAM byte. Your machinelanguage program can use Rl to determine the amount ofRAM in your system when required.Putting Machine Coding andCHIP-8 Language TogetherThe operating system and the CHIP-8 languageinterpreter use a video display format that is 64 bits wideby 32 bits high. This 256-byte display can easily bemodified by writing your own video refresh interruptroutine as explained in the CDP1861 data sheet providedin Appendix G. Display formats up to 64 bits wide by128 bits high are possible with no hardwaremodification. The 4096-bit picture program in AppendixD uses a machine language refresh interrupt routine thatprovides a format 64 bits wide by 64 bits high.