So who knows Assembly?

Discussion in 'OT Technology' started by Dysfnctnl85, Oct 1, 2006.

  1. Dysfnctnl85

    Dysfnctnl85 IT/Apple/Rotary/(D)SLR Crew

    Joined:
    Dec 20, 2004
    Messages:
    3,064
    Likes Received:
    0
    Location:
    Fayetteville, Georgia
    Looking for a little bit of advice wrt writing a "simple" Sieve of Eratosthenes solution.

    My question really is, do I need two arrays in order to accomplish the sieve? Is there such thing as "population" in assembly...to initialize the array, I guess.
     
  2. GOGZILLA

    GOGZILLA Double-Uranium Member

    Joined:
    Jan 16, 2003
    Messages:
    10,760
    Likes Received:
    3
    Location:
    Plantation, FL
    what assembly language you using?
     
  3. Dysfnctnl85

    Dysfnctnl85 IT/Apple/Rotary/(D)SLR Crew

    Joined:
    Dec 20, 2004
    Messages:
    3,064
    Likes Received:
    0
    Location:
    Fayetteville, Georgia
    It's for the LC-3...just a few instructions FTW!
     
  4. GOGZILLA

    GOGZILLA Double-Uranium Member

    Joined:
    Jan 16, 2003
    Messages:
    10,760
    Likes Received:
    3
    Location:
    Plantation, FL
    best you can do for populating an array is going to be to do a loop. you could do it with just one array too. each array = i . put 0 in the ones that are eliminated and then print all the ones that arent equal to 0.
     
  5. Dysfnctnl85

    Dysfnctnl85 IT/Apple/Rotary/(D)SLR Crew

    Joined:
    Dec 20, 2004
    Messages:
    3,064
    Likes Received:
    0
    Location:
    Fayetteville, Georgia


    So essentially if I have a pointer, the pointer's index would be equal to the value in the array...

    For an array that would look like 0 1 2 3 4 5 6 7 ... the pointer would be 0 1 2...etc.

    Does that make any sense?
     
  6. GOGZILLA

    GOGZILLA Double-Uranium Member

    Joined:
    Jan 16, 2003
    Messages:
    10,760
    Likes Received:
    3
    Location:
    Plantation, FL
    No im pretty sure you will experience a crash if you try to write to locations 0, 1, 2 etc. Youll have to have a base pointer to a valid writeable address and then use an offset variable that will also double as the value in the array. so itd look something like

    array[base + offset] = offset
     
  7. Dysfnctnl85

    Dysfnctnl85 IT/Apple/Rotary/(D)SLR Crew

    Joined:
    Dec 20, 2004
    Messages:
    3,064
    Likes Received:
    0
    Location:
    Fayetteville, Georgia
    Alright so I need to intialize the array in a way that makes sense.

    I will try using .blkw to set aside some space in memory and then populate the values in a loop.
     
  8. GOGZILLA

    GOGZILLA Double-Uranium Member

    Joined:
    Jan 16, 2003
    Messages:
    10,760
    Likes Received:
    3
    Location:
    Plantation, FL
    if you arent running an OS you dont need to allocate memory you keep track of it yourself, just make sure youre writing to a RAM location whatever that is for LC-3. In other assemblies you would do something like:

    ORG 2000
    put all your variables here

    ORG 2500
    put instructions here

    So youd have 500bytes for variables. Thats how it works for pic assembly and motorola not sure how LC3 goes exactly.
     
  9. Dysfnctnl85

    Dysfnctnl85 IT/Apple/Rotary/(D)SLR Crew

    Joined:
    Dec 20, 2004
    Messages:
    3,064
    Likes Received:
    0
    Location:
    Fayetteville, Georgia
    I finally figured out what I was doing wrong, I just didn't understand the STR command basically.

    I didn't know how I could store something in the address space I had created for the array. At any rate, I got it now! Thanks :)
     

Share This Page