Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6748887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:37:16+00:00 2026-05-26T12:37:16+00:00

So I am creating an assembly language for the following: X = 5 Y

  • 0

So I am creating an assembly language for the following:

 X = 5
 Y = 7
 FOR I = 1 TO 9
    Y = Y + I
    IF T(I) = J(I) + X THEN J(I) = T(I) * 4 - Y
               ELSE J(I) = J(I) - T(I) 
END_FOR

and keep recieving a

"Address Error: Instruction at  418 accessing address  44f
Execution halted"

The code I have so far is:

    ORG $400

    MOVEA   #T,A0
    MOVEA   #J,A1
    MOVE.B  #1,D0       //D0 is a counter to hold I
    MOVE    #5,D1       //X = 5
    MOVE    #7,D2       //Y = 7
NEXT    
    ADD D0,D2       //Y = Y + I
    MOVE    (A0),D3     
    MOVE    (A1),D4
    MOVE    D4,D5       //D5 is a temp copy of J(I)
    MOVE    D5,D1
    CMP D5,D3       //IF T(I) = J(I) + X
    BNE ELSE
    SUB D2,D3
    MULU    #4,D3
    MOVE    D3,(A1)     
    BRA END_LOOP
ELSE    
    SUB D3,D4       //J(I) = J(I) - T(i)
    MOVE    D4,(A1)
END_LOOP
    ADDA    #2,A0       //POINT TO NEXT ELEMENT IN T
    ADDA    #2,A1       //POINT TO NEXT ELEMENT IN J
    ADD #1,D0
    CMP #9,D0
    BNE NEXT
    MOVE.B  #4,D0
    TRAP    #15     //; halt simulator

* Variables and Strings
T   DC.B    6,2,5,4,9,7,3,1,0
J   DC.B    5,7,1,9,2,5,6,6,1

    END $400        //; last line of source

What am I overlooking?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:37:17+00:00Added an answer on May 26, 2026 at 12:37 pm

    It’ll execute without any errors (not sure if it does the right calculations but that’s up to you since it’s homework) if you change all your MOVE,ADD,SUB,CMP to MOVE.B, ADD.B, SUB.B, CMP.B. I’m assuming .B since your variables are declared DC.B. Even if you’re not getting errors you should specify the size. Note the main ones that need changing are the MOVEs that access memory, for the reasons below, but they should all really be specified.

    Anyway the error occurred at: MOVE (A1),D4. If you trace through and look at the registers you’ll see the similar instruction before that (MOVE (A0),D3) was reading a WORD rather than a BYTE into D3: D3=00000602. It read the first two bytes from T into D3. MOVE (A1),D4 also wants to read a WORD, this time from J.

    However, since you told the assembler to DC.B, it aligned the memory so that you can access your arrays as BYTEs as opposed to WORDs. Since your MOVE instructions and such were defaulting to MOVE.W, you could also change DC.B to DC.W, and the error would go away. Don’t do that though, just showing you how and why the error occurs, you should specify the sizes as I mentioned above.

    Also take note that with instructions like MULU, if you only want to multiply single BYTEs together you should make sure that the higher BYTEs of your register(s) are zeroed out, since it multiplies together at least a WORD from each operand. Since you haven’t moved anything more than a BYTE into D3 the higher BYTEs are all 0 anyway.

    Another thing, END $400 should usually be something like END START, ie:

        ORG $1000
    START:
    ...
    END START
    

    EDIT: Just thought I’d point out (if it wasn’t already obvious) that you should fix your increment of A0 and A1, ie. read JustinP’s answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using windows 7 for learning assembly language.I am using NASM for creating
What are some important practices to follow when creating a .NET assembly that is
Creating a view with following code. - (void)loadView { paintView=[[UIView alloc]initWithFrame:CGRectMake(0, 50, 320, 430)];
Creating a google map with store locations within 50 miles of user entered address.
I am in the process of creating a .NET assembly that will be registered
See title. Reflection.Emit seems to be more about creating a new dynamic assembly, not
Can I delete the DLL-File C:\PATH\TO\DLL\FILE.DLL after creating an assembly with CREATE ASSEMBLY MyAssemblyName
I am creating a .NET assembly. I want to have 2 different versions of
I am creating an assembly with packaging=war . I need to include few of
I'm creating a custom WCF service for deployment inside SharePoint 2010 following the instructions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.