Question

PROGRAMMING ASSIGNMENT: Write a fully-commented program for the HC12 board, including appropriate directives and labels for...

PROGRAMMING ASSIGNMENT:

Write a fully-commented program for the HC12 board, including appropriate directives and labels for memory operands and constants. The program should do the following:

• The program should start execution at address $2000.

• Use directives to create an array of N=20 unsigned 8-bit decimal values: 15,20,14,13,17,9,10,5,18,7,19,8,1,3,4,11,2,6,12,16 stored in contiguous memory at locations start at $1000.

• Sort given numbers in a descending order.

• Store sorted numbers at memory locations starting from $1000. *assembly programming language*

0 0
Add a comment Improve this question Transcribed image text
Answer #1

section   .text
global _start ;must be declared for linker (ld)
Begin:
mov ax, data
mov ds, ax
mov es, ax
mov bx, OFFSET N
mov cx, 20
mov dx, cx
L1:
mov si, 0
mov ax, si
inc ax
mov di, ax
mov dx, cx
L2:
mov al, [bx][si]
cmp al, [bx][di]
jg L4
L3:
inc si
inc di
dec dx
cmp dx, 00
je L1
jg L2
L4:
mov al, [bx][si]
mov ah, [bx][di]
mov [bx][si], ah
mov [bx][di], al
inc si
inc di   
dec dx
cmp dx, 00
je L1
jg L2
Exit:
mov ax, 1000
int 21h
  
_start:   ;tells linker entry point
mov   edx,len ;message length
mov   ecx,msg ;message to write
mov   ebx,1 ;file descriptor (stdout)
mov   eax,4 ;system call number (sys_write)
int   0x80 ;call kernel
  
mov   eax,1 ;system call number (sys_exit)
int   0x80 ;call kernel

section   .data
N times 20 DW 15,20,14,13,17,9,10,5,18,7,19,8,1,3,4,11,2,6,12,16

Add a comment
Know the answer?
Add Answer to:
PROGRAMMING ASSIGNMENT: Write a fully-commented program for the HC12 board, including appropriate directives and labels for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C programming Strictly - Write a program to sort an array of integers via arrays of...

    C programming Strictly - Write a program to sort an array of integers via arrays of pointers to those integers as shown in the figure. Problem 1 (68 points): Write a program to sort an array of integers via arrays of pointers to those integers as shown in the figure. The code should contain the following functions: 1)to randomly generate an array of integer numbers; 2) to allocate memory and build the arrays of pointers as shown in the figure...

  • Please answer using assembly language Easy68k ONLY. I. Write a program called Sorted Primes to a....

    Please answer using assembly language Easy68k ONLY. I. Write a program called Sorted Primes to a. Find out the prime numbers in a method from the following list (15, 16, 17, 23, 2, 32, 3, 31, 13, 19, 12, 9) and push/store them in a stack and then PRINT. (15 points) b. Sort those prime numbers passed by reference (using PEA) to a second method that you found out from the above list in descending order and then PRINT. (20...

  • Write a program in MIPS assembly language that implements the DESCENDING bubble sort algorithm to sort a variable-sized array of signed 32-bit integers

    Write a program in MIPS assembly language that implements the DESCENDING bubble sort algorithm to sort a variable-sized array of signed 32-bit integers (words)that are read from the console. Be reminded that in a descending sort, the integers are sorted from the largest to the smallest. A “special value” 99999 will beused to signify the end of the input sequence. This value is not to be considered part of the input data set. However, any value greater than 99999 that...

  • Write a computer program that prompts the user for one number, n for the number of...

    Write a computer program that prompts the user for one number, n for the number of items in the array to sort, and create and sort 1000 different arrays of this size timing the run to get an average time to sort an array of this size. Then do the following: Initiate a variable running_time to 0 Create a for loop that iterates 1000 times. In the body of the loop, Create an array of n random integers (Make sure...

  • Write a PIC18Fxx2 assembly program that takes the variable A and save into B in inverted the 110010102, then the program finishes with B 010100112-The 1. bit order. For example, if A variable A s...

    Write a PIC18Fxx2 assembly program that takes the variable A and save into B in inverted the 110010102, then the program finishes with B 010100112-The 1. bit order. For example, if A variable A shall preserve the original value at the end of the program execution. The program shall be implemented using any of the loop and shift techniques discussed in class. 2. Write a PIC18Fxx2 assembly program that makes the calculus of the first eigth (8) terms of the...

  • Can someone please help me with this problem? We are using CodeWarrior to write this program...

    Can someone please help me with this problem? We are using CodeWarrior to write this program in assembly language. The array sample contains eight 8-bit signed binary numbers (integers) as shown below. Write a program which stores the negative numbers in the array nelements, computes the sum of the positive numbens to be stored in the variable psum and stores the number of the positive numbers in the variable pnumber. Note that a zero is ther positive nor negative. Your...

  • This assignment is designed to introduce you to using memory, input/output syscalls and if statements a....

    This assignment is designed to introduce you to using memory, input/output syscalls and if statements a. Open the text editor and type in the following. Then save your work as “assign3.asm”. Note that there are 3 words of memory indicated that start at the address 0x10010000. Do not use labels in the data segment. .data .word 0 .word 0 .word 0 .globl main .text main: b. Add the following zero terminated ascii strings (.asciiz) to the data segment right above...

  • 1. Write a program in Assembly language using MIPS instruction set that reads two integer numbers...

    1. Write a program in Assembly language using MIPS instruction set that reads two integer numbers from the user named as start and end number and finds out all the prime numbers between start and end (including start and end). Your program should do the validation of both the numbers as follows: i. start number must be smaller or equal to the end number. ii. Both numbers must be positive. iii. The maximum value for the end number is 10000...

  • For this c++ assignment, Overview write a program that will process two sets of numeric information....

    For this c++ assignment, Overview write a program that will process two sets of numeric information. The information will be needed for later processing, so it will be stored in two arrays that will be displayed, sorted, and displayed (again). One set of numeric information will be read from a file while the other will be randomly generated. The arrays that will be used in the assignment should be declared to hold a maximum of 50 double or float elements....

  • Create a program that performs the following operations: 1. Prompt for and accept a string of...

    Create a program that performs the following operations: 1. Prompt for and accept a string of up to 80 characters from the user. • The memory buffer for this string is created by: buffer: .space 80 #create space for string input The syscall to place input into the buffer looks like: li $v0,8 # code for syscall read_string la $a0, buffer #tell syscall where the buffer is li $a1, 80 # tell syscall how big the buffer is syscall 2....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT