1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Assembly Programming Help

Discussion in 'Scripting & Programming' started by zimbo, Feb 15, 2008.

  1. zimbo
    Honorary Member

    zimbo Petabyte Poster

    5,215
    98
    181
    Wonder if any of you guys know much assembly:

    Just want to clear something up with some work im doing. Im doing a simple ex and i came across something im not sure of.

    Assume: R2 = 50 Memory location 7000 = 8000 and 8000 = 0

    I have the following code:

    Code:
    store R2 @7000
    So first of all @7000 means we looking at Memory location 8000 and R2. In the example provided the output shows the value 50 in 8000. :blink How? Does the store command not follow the traditional sequence:

    Destination, Source

    Should it not be whatever is stored in 8000 be stored into R2? Thus R2 = 0?

    PS does anyone know of a free piece of software that allows me to simulate this - where i can see the registers and memory locations? They gave us SPIMSAL but its rather pathetic!!! :twisted:

    Thanks in advance for the help!
     
    Certifications: B.Sc, MCDST & MCSA
    WIP: M.Sc - Computer Forensics
  2. dmarsh

    dmarsh Terabyte Poster

    3,782
    302
    184
    I've done 80x86 and 68k assembler in the past but it was some time ago !

    Different processors have different instruction sets, mnemonics/op codes and addressing modes. Also some assemblers give you extra features above straight forward opcode translation.

    What type of assembler you learning ? MIPS RS2000 ?

    http://deep3.pkl.net/Files/Source%20Code/SPIM/src/spim.html

    I wonder why they don't just teach you 80x86 and use native tools ?

    http://www.date.uni-paderborn.de/fileadmin/lehre/WS2006-07/TI/Lehrmaterial/mips-assembler.pdf

    There appears to be no store mnemonic, the store commands are on page 6, their addressing mode seems to go source, dest. So I guess its putting contents of register R2 at memory address 7000. Unless the @ is an assembler shorthand for indirect addressing whereby the address at memory location 7000 might be used to 'point' to the address where the register contents will be stored.

    Dave
     
    Certifications: CITP, BSc, HND, SCJP, SCJD, SCWCD, SCBCD, SCEA, N+, Sec+, Proj+, Server+, Linux+, MCTS, MCPD, MCSA, MCITP, CCDH
  3. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    I think I've got a MIPS book at home, so I'll check tonight. It is *many* years since I did assembly on those!

    On the "Destination, Source" part - this depends on the processor, and sometimes on the assembler. Many processors have assemblers that have those two the other way round.

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  4. zimbo
    Honorary Member

    zimbo Petabyte Poster

    5,215
    98
    181
    Thanks for the help guys! Thing is we just given the code and not the processor type.. all the commands in the example follow : Des, Source yet this one is the other way around - thats why i asked if the STORE command and the indirect addressing made this an exception...
     
    Certifications: B.Sc, MCDST & MCSA
    WIP: M.Sc - Computer Forensics
  5. Mathematix

    Mathematix Megabyte Poster

    969
    35
    74
    That code is practically meaningless without knowing precisely what the instruction set is (the processor family and any revisions). From the explanation above I would hazzard a guess that @7000 is a pointer to memory address 8000, and the value contained at memory location 8000 is stored in register R2. See the sequence of events like this:

    Code:
    dw aval 0x0000       ; assume 'aval' is at address decimal 8000 (0x1f40) and contains the value zero.   
                                ; This is the bit for 8000 = 0 (memory address 8000 contains/equals 0)
    dw ptrVal  0x1f40    ; Assume 'ptrVal' is at address decimal 7000 (0x1b58) and contains the hex value for 8000
    
    store R2 [ptrVal]     ; Get the value pointed to be 'ptrVal' and dereference (get the value of) it.
                               ; This represents the [i]store R2 @7000[/i] bit.
    
    This resembles generic asm which wouldn't compile on any chipset, so see it as pseudocode. I hope this clarifies matters.
     
    Certifications: BSc(Hons) Comp Sci, BCS Award of Merit
    WIP: Not doing certs. Computer geek.
  6. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    Hm - looking at my book at home and I se that there is no mnemonic 'store'. Or the use of '@'.

    I've also looked at the docs for SPIMSAL and SAL doesn't have that mnemonic either.

    So there must be something else involved here.

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+

Share This Page

Loading...