Link to home
Start Free TrialLog in
Avatar of hassaanb
hassaanb

asked on

conversion in mc68000 assembly

i can't program this in assembly help needed


Write a subroutine, NUM2STR, to convert a signed integer into characters to be printed with
WRSTR. This subroutine requires a word parameter containing the signed integer and a
memory location where the resulting string should be stored. Use the following algorithm for
the process:
Let A0 point to the first position in the string buffer;
Let D0 be the number to convert;
While (D0 > #0)
{
D1 = D0 mod 10;//can use lsl or rsl and then
D0 = D0 - D1;
D0 = D0 / 10;
D1 = D1 + #48
MOVE.B D1,(A0)+
}
MOVE.B #$00,(A0)+ ; String ends with a NULL




Now the string contains the number IN REVERSE. You will have to write a subroutine to print the buffer contents backwards, or to reverse a string into a new string buffer.

Note: there is no MOD instruction available in the 68000 instruction set.
You can write a loop to figure it out.
 
You can do a DIV instruction, then LSL or LSR the bits in the register to get the remainder, which is stored in the upper 16 bits of the destination register.
 
ASKER CERTIFIED SOLUTION
Avatar of dimitry
dimitry

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mbizup

No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
    Split: dimitry {http:#12804329} & stefan73 {http:#12804934}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

mbizup
EE Cleanup Volunteer