Pl2 EXOS 2.DOC
Jump to navigation
Jump to search
------------------------------ EXERCISES No. 2 ON THE FUNCTIONS OF GEMDOS, BIOS and XBIOS ------------------------------ Here are some exercises that will force you (finally!) to PROGRAM with your assembler. Remember to use the macro instructions we created in the previous chapter and which are in the file: MACROS.L These exercises aim to familiarize you with the functions of GEMDOS, BIOS, and XBIOS, as well as the instructions of the 68000. Good luck. The solutions are present in the file: CORRIG_2.DOC ----------------------------------- 1) Exercise no.1: ---------------- Write a MACRO instruction whose purpose is to save the data and address registers on the system stack and name it 'SAVE'. Write the complementary MACRO instruction that will reload the data and address registers with the values pushed by the macro 'SAVE'. You will name this macro: 'RESTORE'. Those who cannot do it within 10 seconds did not read the course on the 68000 instructions correctly... 2) Exercise no.2: ---------------- Create a 1-parameter MACRO instruction whose goal is to display in HEXADECIMAL the contents of the parameter (Long-Word). Name this macro instruction: 'HEXA' Indications: ------------ .A HEXA digit is represented by 4 bits .Use rotation or shift instructions to reach all the bits of the parameter you will need. .To keep a defined number of BITS in a register, mask the bits to keep with the AND instruction. (For example, AND #%111,dn masks bits 0,1 and 2 of dn) .The ascii code of '0' is $30 .The ascii code of 'A' is $37+$A 3) Exercise no.3: ---------------- Create a 1-parameter MACRO instruction whose goal is to display in BINARY the contents of the parameter (Long-Word). Name this macro instruction: 'BINARY' Indications: ------------ .Use shift and rotation instructions as well as the appropriate conditional branching instructions. 4) Exercise no.4: ---------------- Create a program whose purpose is to FORMAT the floppy disk (80 tracks, 9 sectors per track, interleave=1) The program will display a warning message and ask for a confirmation before formatting. In case of error, the program should display the error code in DECIMAL. Indications: ------------ .Use the FLOPFMT function of GEMDOS .Some parameters will have to vary... (track number) .To display a number in DECIMAL, consider using the DIVU instruction (after having changed the sign of the number to process because it is negative!) to search for the tens digit, the units digit. (if you can't do it in decimal, then use your BINARY or HEXA macro) .The ascii code of 0 is $30 .Reserve a lot of memory with SETBLOCK (as 'STACK'): at least 20000 bytes... (The size of the PRG will not be affected in any case, so don't skimp on your 512 KB of RAM...) .The BUFFER address for FLOPFMT must be EVEN, don't forget! 5) Exercise no.5: ---------------- Create a program that allows to play the sounds that are defined in the PROSOUND.DAT file (which you will integrate at the end of your listing in the DATA segment). The FUNCTION keys (F1 to F10) will serve as a keyboard and if another key is pressed, the program must stop. Indications: .Think about searching for the SCANCODEs of the function keys. As you do not know them yet, you will have to make a small program which displays them to you. (Ultra simple, use the HEXA macro and display the return code of 'WAIT' for example: just press the function keys so that their scancode appears...) .Replay the sounds with the DOSOUND macro (Gemdos) .Reserve a lot of memory for SETBLOCK (as 'STACK') 6) Exercise no.6: ---------------- Create a program that displays the floppy disk directory. Indications: .Use the SEARCH and SEARCH_NEXT functions of Gemdos. .The DTA buffer must be located at an EVEN address, don't forget! .Reserve a lot of space for SETBLOCK (as 'STACK') -------------------- I understand that these exercises may pose certain problems for you, if you don't progress, look at the listings corresponding to the exercise that you can't do and try to rewrite it. Look at the solution only at the last resort... PIECHOCKI Laurent 8, impasse Bellevue CORRECTIONS in the file: CORRIG_2.DOC ------------------------------------------------------------- 57980 TENTELING
Back to ASM_Tutorial