Download Using MON12 Utility Functions for I/O in EECS 388: Computer Systems and Assembly Language and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity! 1 EECS 388: Computer Systems and Assembly Language Lab 7: Using MON12 Utility Subroutines for I/O MON12 Utility Functions Below are the descriptions of some of the utility functions, taken from the MON12 manual included with the Axiom CD (Documents/Mon12man.pdf). UPCASE If character in accumulator A is lower case alpha, convert to upper case. OUTA Output accumulator A ASCII character. OUTlBYT Convert binary byte at address in index register X to two ASCII characters and output. Returns address in index register X pointing to next byte. OUTCRLF Output ASCII carriage return followed by a line feed. OUTSTRG Output string of ASCII bytes pointed to by address in index register X until character is an end of transmission ($04). OUTSTRGO Same as OUTSTRG except leading carriage return and line feed is skipped. INCHAR Input ASCII character to accumulator A and echo back. This routine loops until character is actually received. MON12 Service Routine Jump Table Below is a table of the MON12 utility functions and their addresses, taken from the CMLS12DP256 manual (Documents\manuals\CMLS12DP256man.pdf on the Axiom CD). It’s also available in the “references” section of the class website. ADDRESS ff10 MAIN ; warm start ff13 BPCLR ; clear breakpoint table ff16 RPRINT ; display user registers ff19 HEXBIN ; convert ascii hex char to binary ff1c BUFFARG ; build hex argument from buffer ff1f TERMARG ; read hex argument from terminal ff22 CHGBYT ; modify memory byte at address in x ff25 JMP CHGWORD ; modify memory word at address in x ff28 READBUFF ; read character from buffer ff2b INCBUFF ; increment buffer pointer ff2e DECBUFF ; decrement buffer pointer ff31 WSKIP ; find non-whitespace char in buffer ff34 CHKABRT ; check for abort from terminal ff37 JMP UPCASE ; convert to upper case ff3a WCHEK ; check for white space ff3d DCHEK ; check for delimeter ff40 ONSCI0 ; initialize i/o device ff43 INPUT ; low level input routine ff46 OUTPUT ; low level output routine ff49 OUTLHLF ; display top 4 bits as hex digit ff4c OUTRHLF ; display bottom 4 bits as hex digit 2 ff4f OUTA ; output ascii character in A ff52 OUT1BYT ; display the hex value of byte at X ff55 OUT1BSP ; out1byt followed by space ff58 OUT2BSP ; display 2 hex bytes (word) at x and a space ff5b OUTCRLF ; carriage return, line feed to terminal ff5e OUTSTRG ; display string at X (term with $04) ff61 OUTSTRG0 ; outstrg with no initial carr ret ff64 INCHAR ; wait for and input a char from term ff67 VECINIT ; initialize RAM vector table Examples: To use a utility function, simply do a JSR to the memory address. For example, to output an ASCII character that’s in accumulator A, you can use the following code. It’s considered good form to label your functions, rather than just jumping to the memory locations. OUTA equ $FF4F ldaa #$67 ;Load A with a lowercase “g.” jsr OUTA ;Print “g” to the monitor. Ex1. Prompting the user: Define your message text using FCC, and call the OUTSTRG function. OUTSTRG equ $FF5E EOT equ $04 ldx #FIRST org $4000 jsr OUTSTRG ;Print the string until EOT. swi org $6000 FIRST fcc 'Enter first number:' fcb #EOT Ex2. Reading a character from the keyboard: Define INCHAR with the correct address, similarly to the previous example. This function waits for the user to enter a character, and then stores it in accumulator A. jsr INCHAR ;Take in a character Accumulator A now has the ASCII value of the character.