Starting from:

$30

CS341-Machine Project 3 Accessing I/O Ports using Assembly Language Solved

The purpose of this assignment is to gain some familiarity with writing C callable functions that do things that can’t be done in C such as accessing I/O ports.

 

I.      Program a UART directly in assembler 

 

Please note that we consider this the old-fashioned way to do this programming! The current way is to use assembler only where it is required. Write an assembler function to read and echo characters. The C driver does the same initial logic determining whether or not the console is a COM port and if so which one, and if not, just return. In the new version, it then goes on to ask the user for the "escape character" that stops the echo loop. This can be CONTROL-A, but it doesn't have to be. The user types the actual character, not its ASCII code or whatever, to specify the escape character. Then the C driver calls the assembler echo function:

 

                  void echo(int comport, unsigned char esc_char)

 

The assembler code does the loop with in and out instructions to do the actual I/O, testing for the special esc_char and returning when it is seen coming from the user. Call your files echo.s and echoc.c. In file echo.script, show:

 

1)     a run with "abc" followed by the esc_char,  

2)     a second run with "abcde<CRxy" followed by the esc_char, and  3) a third run with "abcde<CR<LFxy", then esc_char.  

 

 

 

 

 

 

 

If your keyboard doesn't have a key marked line feed, use <control-J. Since we haven't asked for any special treatment for <CR, the "xy" of the second test should overwrite the "ab", but the <LF should prevent this in the third test.

More products