Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Finish the program by writing assembly code to compare x and y. Light up LED if x < y. In order to compare two operands,

Finish the program by writing assembly code to compare x and y. Light up LED if x < y. In order to compare two operands, we need to understand the following instruction, CMP. CMP src, dst V: 1, arithmetic overflow 0, otherwise N: 1, src > dst 0, src <= dst Z: 1, src=dst=0 0, otherwise C: 1, carry from MSB result 0, if not This CMP instruction will set the bits in SR according the relation of the operands. The most relevant results for our comparison purpose are stored in N. When the source is larger, the bit N will be set. There are program flow control instructions such as JZ(JEQ), JNZ (JNE), JC, NC, JN, JGE, JL, and JMP. Since our comparison will result in setting the bit N if the first number is larger, we can only use JN (Note that the N in JNZ, JNE, and JNC, means not). Run your program for the following settings: 1) x = 0x01, y = 0x02 2) x = 0x02, y = 0x02 3) x = 0x03, y = 0x02

----------------------------------------- this what i have so far:

#include "msp430.h" ; #define controlled include file

NAME main ; module name

PUBLIC main ; make the main label vissible ; outside this module ORG 0FFFEh DC16 init ; set reset vector to 'init' label

RSEG CSTACK ; pre-declaration of segment RSEG DATA16_HEAP ; start the heap segment z DW 1234h ; place a variable as a tag RSEG DATA16_N ; start data segment x DW 01h ; define global variable x y DW 02h ;define global variable y RSEG CODE ; place program in 'CODE' segment

init: MOV #SFE(CSTACK), SP ; set up stack main: NOP ; main program // MOV.W #WDTPW+WDTHOLD,&WDTCTL ; Stop watchdog timer CMP.b x, y JN skip skip: BIS.B #01h, P1OUT ; Toggle Red LED on MSP430F

push #1234 JMP $ ; jump to current location '$' ; (endless loop) END

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

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

More Books

Students also viewed these Databases questions