Order Now  +1 678 648 4277 

Program a UART in x86 assembly assignment help

The assignment deals with implementing a program to echo the characters read from the serial UART port. The program is to be written in x86 assembly. The program sets the I/O registers for the COM port to read and write the data to be echoed. The program uses a polled approach, testing the line status to determine if the data is ready to send or to read it. To have tasks of this nature completed by an expert, take our x86 assembly assignment help.

Echoing Characters from a Serial UART Port

Solution #------------------------------------------------------------------------------- # echo.s: reads and echoes characters through the serial port # # Author: Adnan # Date: November 12, 2018 #------------------------------------------------------------------------------- .text .globl _echo _echo: pushl %ebx movl 8(%esp), %ebx # get COM port in ebx movl 12(%esp), %ecx # get escape character in ecx leal 4(%ebx), %edx # get modem control address in edx inb %dx, %al # get current char modem control register orb $0x03, %al # set RTS and DTR to 1 outb %al, %dx # set modem control register leal 6(%ebx), %edx # get modem status address in edx waitloop: inb %dx, %al # get current modem status andb $0xb0, %al # leave only DCD, DSR and CTS xorb $0xb0, %al # test the bits to see if all 3 are 1 jnz waitloop # if not all 3 are on, wait mov $0x0, %ah # clear data inloop: leal 5(%ebx), %edx # get line status address in edx inb %dx, %al # get current line status andb $0x01, %al # test data ready bit jz xmit # if no data ready, send movl %ebx, %edx # get data address in edx inb %dx, %al # read received data movb %al, %ah # save received data in ah cmpb %ah, %cl # see if it was a escape char jz endecho # if so, end the echo function leal 5(%ebx), %edx # get line status address in edx xmit: inb %dx, %al # get current line status andb $0x20, %al # test the THRE bit jz inloop # if not set, not available to send, keep waiting cmpb $0x0, %ah # see if there is data to send jz inloop # if no data keep waiting movb %ah, %al # else, output data movl %ebx, %edx # get data address in edx outb %al, %dx movb $0x0, %ah # clear data buffer jmp inloop # continue reading chars endecho: popl %ebx ret