Question

In: Computer Science

HCS12 Assembly Language: 1. Write a program to convert a decimal number stored at memory location...

HCS12 Assembly Language:

1. Write a program to convert a decimal number stored at memory location $1010 into a binary number. Store the result in memory location $2000

Solutions

Expert Solution

Step(1). Basic idea of Decimal to binary conversion

Let consider Decimal number have five Digits

If Decimal Is = N1 N2 N3 N4 N5

(Where N1 is Most Significent Number)

Then Binary is = ((((N1x 10) + N2) x 10 + N3) x 10 + N4) x 10 + N5

Step(2). HCS12 program to convert a decimal number stored at memory location $1010 into a binary number. Store the result in memory location $2000

; processing N1

ldaa $1010 ; A = N1 (the most significant digit)

ldab #10   ; B = 10

mul ; operation (1) D = N1 x 10

std $2000 ; store the result in $2000

; processing N2

ldab $1011 ; B = N2

clra ; A = 0 so D = A:B = 00: N2

addd $2000 ;operation (2) d = [$2000]+D = (N1 x 10) + N2

; process N3

ldy #10 ; Y = 10\

emul ; Y:D = D x Y operation (3)

std $2000 ; d = ((N1 x 10) + N2) x 10

ldab $1012 ; B = N3

clra ; A = 0 so D = A:B = 00: N3

addd $2000 ; operation (4) d = ((N1 x 10) + N2) x 10 + N3

; process N4

ldy #10 ; Y = 10

emul ; Y:D = D x Y operation 5

std $2000 ; d = (((N1 x 10) + N2) x 10 + N3) x 10

ldab $1013 ; B = N3

clra ; A = 0 so D = A:B = 00: N4

addd $2000 ;operation (6) d = ((((N1 x 10) + N2) x 10 + N3) x 10) + N4

; process N5

ldy #10 ; Y = 10

emul ; Y:D = D x Y operation (7)

std $2000   ;  d = (((((N1 x 10) + N2) x 10 + N3) x 10) + N4)x 10

ldab $1014   ; B = N5

clra ; A = 0 so D = A:B = 00: N5

addd $2000 ; operation (8) d = ((((((N1 x 10) + N2) x 10 + N3) x 10) + N4)x 10 ) + N5

I Hope it will Helpfull............


Related Solutions

Write a MIPS Assembly Language program which runs interactively to convert between decimal, binary, and hexadecimal....
Write a MIPS Assembly Language program which runs interactively to convert between decimal, binary, and hexadecimal. 1. Request input data type. 2. Request input data. 3. Request output data type. 4. Output the data. Use any algorithm
Write a program in MIPS assembly language to convert an ASCII number string containing positive and...
Write a program in MIPS assembly language to convert an ASCII number string containing positive and negative integer decimal strings, to an integer. Your program should expect register $a0 to hold the address of a nullterminated string containing some combination of the digits 0 through 9. Your program should compute the integer value equivalent to this string of digits, then place the number in register $v0. If a non-digit character appears anywhere in the string, your program should stop with...
write a assembly language program to convert GRAY to BCD code in 8051
write a assembly language program to convert GRAY to BCD code in 8051
Write a RARS assembly language program to solve the following: For a set of integers stored...
Write a RARS assembly language program to solve the following: For a set of integers stored in an array, calculate the sum of the positive numbers and the sum of the negative numbers, storing the results into memory. In the data segment of the program, define an array consisting of 25 integers (words) that are a mix of positive and negative values. You can select any values you wish but try to create a balance of positive and negative numbers....
Write an Intel 8085 assembly program to find the largest of N numbers stored in memory...
Write an Intel 8085 assembly program to find the largest of N numbers stored in memory using the algorithm below. Hand trace (execute) the program showing the changes made to all affected registers and memory locations. Max = a(1) For i = n to N If max < a(i) then max = a(i) Next i
Write a program to convert the input numbers to another number system. 1. Decimal to Binary...
Write a program to convert the input numbers to another number system. 1. Decimal to Binary 2. Binary to Decimal 3. Hexadecimal to Decimal 4. Decimal to Hexadecimal 5. Binary to Hexadecimal 6. Hexadecimal to Binary The user will type in the input number as following: Binary number : up to 8 bits Hexadecimal number: up to 2 bytes Decimal number: Less than 256 As a result, print out the output after the conversion with their input numbers. The program...
using Emulator Write an Assembly program that will produce all divisors for a 1-digit decimal number....
using Emulator Write an Assembly program that will produce all divisors for a 1-digit decimal number. For example, if the number is 6, then the outputs will be 1,2,3,6 which are the divisors of 6. show me the output
Write an assembly language program for 8085 microprocessor to read consecutive memory locations from 2000 to...
Write an assembly language program for 8085 microprocessor to read consecutive memory locations from 2000 to 2FFF & transfer to 4000 to 4FFF
Write an assembly language program that repeatedly prompts the user to enter signed decimal integer numbers....
Write an assembly language program that repeatedly prompts the user to enter signed decimal integer numbers. The program should be run from the command prompt, output a text prompt to the screen, and then wait for the user to type in a number followed by the Enter key. (The legitimate range of user input values is any signed integer that can be represented in 32 bits.) After each number is entered, the program should determine and display the following information...
Write a Java program to convert decimal (integer) numbers into their octal number (integer) equivalents. The...
Write a Java program to convert decimal (integer) numbers into their octal number (integer) equivalents. The input to the program will be a single non-negative integer number. If the number is less than or equal to 2097151, convert the number to its octal equivalent. If the number is larger than 2097151, output the phrase “UNABLE TO CONVERT” and quit the program. The output of your program will always be a 7-digit octal number with no spaces between any of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT