For this lab you will create a basic io inputoutput library


For this lab, you will create a Basic I/O (input/output) Library of subroutines. There are 7 subroutines in this library, 4 of which you must write. The lowest level routines have been provided for you and are in the file BasicIO.asm. They are:

GetChar - get a character from the keyboard, echo to the display and return it in reg al. - Note: if a linefeed (LF) is received (Enter key), a carriage return (CR) will also be echoed.

PutChar - display a character passed in reg al.

The higher level routines which you will write call the above routines. They are:

GetStr - read a string from the keyboard and place it at the address passed in register AX

           Note: you must delimit this string by placing a ‘$’ at the end

GetNum - read an unsigned 16-bit decimal number (<65535) from the keyboard and return it in register AX. -

Note: for now, you do not need to do any error checking - this means that you have to be careful when testing!

PutStr - display a string – address is passed in the AX reg -

Note: string passed must be delimited with a ‘$’

PutLine - display a string (address in AX) and also print CR/LF -

Note: this routine is written for you – it calls

PutStr first PutNum - display a 16 bit signed number passed in the AX reg -

Note: you did this in Lab 2 – you get to re-use code!

Note that since you will be using the AL or AX register to pass and return parameters, you do not save this register inside each subroutine. You must push (and pop) all other registers you use in each subroutine, however.

Be careful with labels since all of the subroutines will be in a single file. You cannot have a duplicate label. Use the convention shown in the subroutines given. Notice that each subroutine has 2 capital letters in the title and these letters are unique. For example, for the GetChar routine, these characters are GC. Precede every label inside this routine with GC (notice GCWait). In this way, you will not have any duplicate labels. You should also remember that the assembler is NOT case sensitive – we only use uppercase letters to improve the documentation. It is good practice to use a capital letter to begin every label.

Once again we will test these subroutines by writing a Main routine during the main lab. This routine will be more complicated; however, as we will display some interesting messages.

Prelab Deliverables:

1. Some or all of the assembly code for the subroutines in basicio.asm In this Lab you will write a Main program to test the Basic I/O subroutine you wrote for the PreLab. You will test your knowledge of program structure and gain more experience in assembly language coding and debugging.

Upon arrival, show your pre-lab deliverables to the TA so that your pre-lab mark is recorded. Like basicio.asm, you will be required to keep and submit one intermediate version of the main program. See Submission details at the bottom.

You should first assemble your subroutines to make sure you have no obvious errors in your code. The Main program is slightly more complicated and you need to think about the I/O process. First of all, for most applications you do not call the low level routines GetChar and PutChar. They are used by the higher level I/O subroutines that you wrote for reading and writing strings and numbers.

Secondly, you cannot just call an input routine like GetStr or GetNum on its own. Think carefully about what would happen. Let’s say at some point in your program you want to read a number from the keyboard and place it in a memory location. Consider the following code fragment:

MyNum: dw

Main: … …

call GetNum

mov MyNum1, ax 

This code will assemble and run and when you enter a number and press ‘Enter’ it will store the number at location MyNum. However, how does the person running the program know when to enter a number, or whether to enter a number or a string? When subroutine GetNum is called it will simply wait for input from the keyboard. But the program gives no indication that it is waiting for input! The simple answer is that you must always first write a string to the screen asking for the kind of input you want the user to enter, then call the appropriate input routine. So, our revised program should look like this:

Prompt1: db ‘Enter a number less than 65536: $’

MyNum: dw

Main:

 …-----------

-----------

Mov ax, Prompt1

Call PutStr

call GetNum

mov MyNum1, ax

Now when the program runs it first prints a message asking for a number and then waits for input. Try this out – if you have written your routines correctly, I think you will like the way this works. Don’t try to test all of your subroutines all at once. If something goes wrong, you may not know where the problem is. Call each subroutine on its own several times to make sure it is working before testing the next. What you submit should allow the TAs to enter their own numbers and strings in order to test the code. The extensiveness of your testing will make up part of your final mark.

Solution Preview :

Prepared by a verified Expert
Assembly Language: For this lab you will create a basic io inputoutput library
Reference No:- TGS01490183

Now Priced at $50 (50% Discount)

Recommended (91%)

Rated (4.3/5)