Write an arduino c function called strlen that determines


Do NOT use any C string library functions.

1. Assume the 8250 UART (the same UART as used in PCs) is connected to an ATmega2560 single board computer mapped as external data memory with a start address of FCC0 Hex. Write the following Arduino C language functions.

For those who are interested, the data memory map for the 2560 is shown in the Atmega2560 data manual - External Memory with Sector Select.

ASSUME THE 8250 UART IS ALREADY INITIALIZED (so you do not need to write UARTinit()).

a. kbhit(void): - will examine the RDA status bit and return a true (non-zero value) if RDA is true, otherwise it will return a false (0 value).
b. getchar(void): - will read one character from the serial port and return it.c.
c. putchar(char vname): - will write the character vname to the serial port as soon as TBE is true.

2. Write an Arduino C language function printstr(*unsigned char str0) which will print out a NULL terminated ASCII string using the serial I/O functions defined in Question 1 above. The input pointer str0 points to the first element of the string to be printed.

3. Write an ARDUINO C function called strlen() that determines the length of a null-terminated ASCII string. Pass a 16-bit address pointer to the first element of the string to the function. Return the length, excluding the null byte.

4. Write an ARDUINO C function to create a fixed length destination string by copying a source string and truncating or padding with spaces as needed. Pass three variables to the function: 1) the length of the output string, 2) a 16-bit address pointer to the first element of the source string, and 3) a 16-bit address pointer to the first element of the destination string. The function does not return any value.

5. Write an ARDUINO C function to compare two character strings and determine whether one is less than, greater than, or equal to the other. Assume the strings are null-terminated. Pass a 16-bit address pointer to the first element of the first string, and a 16-bit address pointer to the first element of the second string. Return -1 if the first is less than the second, return 0 if the strings are equivalent, and return + 1 if the first is greater than the second.

Attachment:- selection.rar

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write an arduino c function called strlen that determines
Reference No:- TGS01229170

Expected delivery within 24 Hours