Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Assembly Expert

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.

Assembly, Programming

  • Category:- Assembly
  • Reference No.:- M91869795
  • Price:- $50

Priced at Now at $50, Verified Solution

Have any Question?


Related Questions in Assembly

Really need to find a correct answer to this questionwrite

Really need to find a correct answer to this question: Write a MIPS assembly program that can search for a number that is entered by a user in an array with 20 integer number. Make sure it also prints the index of the ar ...

Task 1using masm sdk write an assembly language program

TASK 1 Using MASM SDK, write an assembly language program which converts an integer inputted via the console to binary. Your program should be well commented and well formatted. TASK 2 Using MASM SDK, write an assembly l ...

Question a sequence string of one-byte ascii characters is

Question : A sequence (string) of one-byte ASCII characters is stored at memory location $600 onward. A second sequence of equal length is stored at memory location $700 onward. Each sequence ends with the character $0 ( ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As