Problem 1 Write a subroutine not a program in 68000 assembly

Problem #1- Write a subroutine (not a program) in 68000 assembly language that will count the number of 1 bits in a sequential series of bytes between two memory locations. The starting and ending memory locations are passed into the subroutines as 32-bit addresses in registers A0 and A1, and the number of bits are returned in register D7 as a 32-bit long word.

The bytes should be counted from the starting address up to, but not including, the ending address. It is not necessary to check that the addresses are correctly specified. You may assume that the address in register A0 is at least two bytes less than the address in register A1.

Solution

Subroutines

                     STMFD      sp!, {A0-A1,lr}                                                                ; save registe   rs

                      LDR             A0, [sp, #8+20]                                                          ; load address parameter

                       LDR           A1, [sp, #4+20]                                                            ; load length parameter

                      LDR            A2, [sp, #0+20]                                                           ; load value parameter

                     MOV             D7, #0                                                                        ; count = 0;

wh1             CMP              D7, A1                                                                         ; while (count < length)   

                    BHS              endwh1                                                                     ; {

                   STR               A2, [A0, D7, LSL #2]                                         ; Memory.Word[address] = value;

                   ADD               D7, #1                                                             ; count = count + 1;

                   Bwh1                                                                                     ; }

endwh1      LDMFD            sp!, {A0-D7,pc}                                                ; restore registers

Problem #1- Write a subroutine (not a program) in 68000 assembly language that will count the number of 1 bits in a sequential series of bytes between two memor

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site