Subject Computer Science Assembly Language Programming

Question

Sorter
You are responsible to write an assembly function to perform sorting of a list of integer key values. This function can sort either in ascending or descending order. You will use the bubble sort algorithm for this function. This function will use the C function signature but everything within this function should be assembly code using the ASM block similar to the assembly example shown in class.

Program Specification:

int sorter ( int* list, int count, int opcode );

list – the starting address of the list of integers to be sorted

count – total number of integers in the list

opcode -

1. Ascending
2. Descending


Binary Search
You are responsible to write an assembly function to perform searching of a list of names in stored in ascending order. This function will use the binary search algorithm. The names could be stored in mixed case. Therefore your assembly function must do the comparison in a case insensitive manner. This function will use the C function signature but everything within this function should be assembly code using the ASM block similar to the assembly example shown in class.

Program Specification:

int b_search (char list[100][20], int count, char* token);

list – the starting address of the list of names to be searched

count – total number of names in the list

token – name to be search in the list

This function returns the position of the token in the list (starting with 1). If the name is not found, then it returns 0. When it returns 0, print a message on the console.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <io.h>


int sorter ( int *list, int count, int opcode )
{
int wasswap; //flag to indicate if there was a swap in loop execution
int i; // loop counter

_asm
{
mov wasswap, 1 ; set wasswap to true to enter loop
whileLoop: ; main loop
cmp wasswap, 0 ; check if there was a swap
je endWhileLoop ; exit loop if there were no swap

mov eax, count ; move count to reg
sub eax, 1 ; decrement reg with 1
mov count, eax ; count = count - 1

mov wasswap, 0 ; set wasswap to false before the checks start

mov i, 0 ; set i to 0, start checking loop
forLoop:
mov eax, count ; move count to reg to compare with i...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Assisting Tutor

Related Homework Solutions

Assembly Language Problems
Homework Solution
$25.00
Assembly Language
Programming
Computer Science
Strings
Macros
Characters
Procedures
Addresses
Numbers
Stack
Algorithms
Structures
Conversion
Registers
Binary Values
Input
Output
MIPS and Assembly Exercises
Homework Solution
$25.00
MIPS
Asm
Sum
Integer
Code
Registers
Formula
Non-Iterative
Computer Science
Assembly Language Programming
Assembly Language Problems
Homework Solution
$50.00
Programming
Computer Science
Assembly Language
Characters
Calendars
Video Mode
Variables
Keyboard Navigation
Commands
Raid Simulation Program Using Assembly Language
Homework Solution
$150.00
Assembly Language
Programming
Computer Science
Algorithms
Strings
Files
XOR
Commands
Input
Output
Bytes
System Kernel
Loop Counter
Pointers
Memory
Variables
Get help from a qualified tutor
Live Chats