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 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 mips assembly language program that asks the user to enter an unsigned number and...
Write a mips assembly language program that asks the user to enter an unsigned number and read it. Then swap the bits at odd positions with those at even positions and display the resulting number. For example, if the user enters the number 9, which has binary representation of 1001, then bit 0 is swapped with bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program should display 6.
( Assembly Language ) Write a program that computes the 7th fibonacci number. The fibonacci sequence...
( Assembly Language ) Write a program that computes the 7th fibonacci number. The fibonacci sequence - 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, … what is the initialization of a, b, and d? - a b d 1 ? ? 1 2 ? ? 1 3 1 1 2 4 1 2 3 5 2 3 5 6 3 5 8 7 5 8 13 wrong initialization - a b d 1 0 1 1 2...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT