Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an assembly program for the following tasks: PROGRAMMING ASSIGNMENT (2): Write an assembly program for the Dragon 12 HCS12 board to perform as specified

Write an assembly program for the following tasks:

image text in transcribed

image text in transcribed

PROGRAMMING ASSIGNMENT (2): Write an assembly program for the Dragon 12 HCS12 board to perform as specified below and name it Lab3_2.asm. Include overall general comments explaining sections of your code as related to the program requirements, and also include comments explaining what each instruction does specifically. If necessary, you may use memory locations from $1000 as temporary data memory for your calculations. Even though the debugger loads all the registers with zeros on startup, your program must not assume they are initialized - initialize them yourself as needed in the program; this is good general programming practice. The program should do the following steps: 1. Store the following array of six decimal byte values: 61, 220, 47, 188, 121 and 26 into contiguous memory at locations $1000-$1005, respectively. Do not use directives. Use mostly immediate addressing and pre/post-increment/decrement Indexed addressing in this step. In the next tasks we will refer to this array as 'Array'. 2. To avoid triggering overflow when adding byte numbers, the numbers can be extended to words and then added. Use this idea to add the first two bytes in Array and store this word at memory location $1010 (called Suml), assuming the numbers are unsigned. Use mostly extended addressing in this step. Hint: clear a word register, add the first byte to the register, and add the second byte to the summation (stored in 16-bit register). Store the result word in $1010. 3. Add the hex word value $3245 to the byte at the memory address $1004 and then add the result with the byte at the address $1005. Assume the numbers are unsigned. Store the final result (a word) at memory location $1012 (called Sum2). 4. Subtract the first byte of Array from the second byte of Array and store the result at $1014 (called Diff). Note: Diff is byte. 5. Interpret the bytes stored in Array as signed numbers and repeat task 2. Extend the first byte in Array to a signed word and store it in a temporary memory location, then extend the second byte in Array to a signed word and add it to the first number, and store the result (a word) at memory location $1016 (called Sum3). PROGRAMMING ASSIGNMENT (2): Write an assembly program for the Dragon 12 HCS12 board to perform as specified below and name it Lab3_2.asm. Include overall general comments explaining sections of your code as related to the program requirements, and also include comments explaining what each instruction does specifically. If necessary, you may use memory locations from $1000 as temporary data memory for your calculations. Even though the debugger loads all the registers with zeros on startup, your program must not assume they are initialized - initialize them yourself as needed in the program; this is good general programming practice. The program should do the following steps: 1. Store the following array of six decimal byte values: 61, 220, 47, 188, 121 and 26 into contiguous memory at locations $1000-$1005, respectively. Do not use directives. Use mostly immediate addressing and pre/post-increment/decrement Indexed addressing in this step. In the next tasks we will refer to this array as 'Array'. 2. To avoid triggering overflow when adding byte numbers, the numbers can be extended to words and then added. Use this idea to add the first two bytes in Array and store this word at memory location $1010 (called Suml), assuming the numbers are unsigned. Use mostly extended addressing in this step. Hint: clear a word register, add the first byte to the register, and add the second byte to the summation (stored in 16-bit register). Store the result word in $1010. 3. Add the hex word value $3245 to the byte at the memory address $1004 and then add the result with the byte at the address $1005. Assume the numbers are unsigned. Store the final result (a word) at memory location $1012 (called Sum2). 4. Subtract the first byte of Array from the second byte of Array and store the result at $1014 (called Diff). Note: Diff is byte. 5. Interpret the bytes stored in Array as signed numbers and repeat task 2. Extend the first byte in Array to a signed word and store it in a temporary memory location, then extend the second byte in Array to a signed word and add it to the first number, and store the result (a word) at memory location $1016 (called Sum3)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

Students also viewed these Databases questions