Basic assembly language questions

Discussion in 'Assembly Language Programming (ALP) Forum' started by Shafqat, Nov 28, 2008.

  1. Shafqat

    Shafqat New Member

    Joined:
    Nov 27, 2008
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I just exposed myself to assembly language a few days ago so these questions might seem dumb but please bear with me :)


    1) What does dc.b mean? It is used in the code in this context:

    dc.b "Enter your name." , CR, LF

    Does dc.b mean define constant.byte? If so how is this sentence a byte?


    2) What does org mean?


    Any help would be highly appreciated.

    Thanks
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    You don't say what processor and assembler you're using so it could mean anything. Different processors use different languages, and different assemblers for each processor implement the language slightly differently, so for the answer to mean anything it has to be in the context of a specific processor (or processor family) and assembler.

    So it's entirely possible that dc.b means define constant byte, or possibly bytes, and that the particular assembler you're using allows you to define a series of bytes rather than making you do dc.b 'E' dc.b 'n' dc.b 't' etc, which would be really tedious.

    org again depends on the processor and assembler, but often it's short for "origin" and defines what address the program should be compiled to.
     
  3. Shafqat

    Shafqat New Member

    Joined:
    Nov 27, 2008
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Thanks, I'm using Coldfire 5307 processor

    One more question:

    What is the difference between data and address register?

    The way I understand it is data register stores data like integers etc. and address register stores addresses.

    But then what does the foll. code mean:

    move.1 D1, -(A7)

    move #9, D1

    jsr print_out

    move.l (A7)+, D1

    Print_out is a subroutine in the code among several other subroutines and I notice that the code in intalics marks the near end and beginning of every subroutine. What does it mean?

    Thanks
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Data and address registers are essentially the same thing; both store numbers, but some instructions will only work on data registers and some only on address registers. In general you should use data registers to store data and address registers to store addresses, but you can crossover if necessary. If you're doing pointer arithmetic you could use both types.

    move.l d1, -(A7) moves the contents of D1 to the memory location pointed to by A7-4 (or possibly A7-1; I'd have to RTFM to be sure, but A7-4 makes more sense than A7-1)
    move #9,D1 sets D1 to 9
    jsr calls a function - I don't know what that does
    move.l (A7)+,d1 moves the contents of memory location pointed to by A7 to D1, and increases A7 by 4 (or 1).

    So A7 is probably being used as a stack for safe storage of whatever is in D1, and the references to -(A7) and (A7)+ are equivalent to push and pop instructions in other processors. It's a long time since I looked at 68000 programming (Amiga days...sigh...) but I have a vague idea that A7 is generally used as the processor stack pointer. If that's the case then jsr probably modifies A7 too; it'll push the return address onto the stack.
     
  5. Shafqat

    Shafqat New Member

    Joined:
    Nov 27, 2008
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Another question:

    What is the difference between A1 and (A1) ?
     
  6. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    A1 is the register, (A1) is the memory location pointed to by A1. So if A1 contains 1000 and D1 contains 50, move D1,A1 sets A1 to 50, but move d1,(a1) sets memory location 1000 to 50 and doesn't change A1 itself.
     
  7. Shafqat

    Shafqat New Member

    Joined:
    Nov 27, 2008
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Sorry I'm being slow but is this what you mean:

    move D1, A1 implies A1 is now not pointing to memory location 1000 but instead is pointing to memory location containing 50

    move D1, (A1) implies memory location 1000 is set to contain 50.

    is 1000 the address or the contents?

    Thanks
     
  8. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    > move D1, A1 implies A1 is now not pointing to memory location 1000
    correct.

    > but instead is pointing to memory location containing 50
    No, A1 is now pointing to memory location 50

    > move D1, (A1) implies memory location 1000 is set to contain 50. is 1000 the address or the contents?

    Memory location/address 1000 contains the value/has contents 50. There is a 50 stored at address 1000.

    move 50,d1
    move 1000,a1
    move d1,(a1) // stores 50 at 1000

    move 1000,d1
    move 50,a1
    move d1,(a1) // stores 1000 at 50

    move 1000,d1
    move d1,a1
    move d1,(a1) // stores 1000 at 1000

    Probably the best bet is to download an emulator and watch how memory is affected by simple code examples like the above. If you restrict all values to, say, less than 25, and the emulator has RAM at addresses 0-25, then you should be able to keep track of everything without taking up too much screen space or getting confused scrolling from one area to another trying to find the value.
     
  9. Shafqat

    Shafqat New Member

    Joined:
    Nov 27, 2008
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Sounds like a good idea, will do that. Thanks.
     
  10. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Since Coldfire 5307 is based on the 68000 chip this may be of interest: http://www.easy68k.com/
    It's something I keep meaning to try out but time shortages have prevented it so far.
     
  11. yas

    yas New Member

    Joined:
    Jan 24, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Sorry i'm newbie here and like to learn.I had a problem here can anyone give a code/solution for this problem,i had try but fail.

    8085

    Question:
    Connect a DIP switch to port B and 7 segment(common Cathode) to port C.Write a program to read input from DIP switch connected to port B and display them on each segment of the 7 segment as show below:

    DIP SWITCH 7 segment
    0000 - all segments off
    0001 - segment A on,others off
    0010 - segment B on,others off
    0011 - segment C on, others off
    0100 - segment D on,others off
    0101 - segment E on, others off
    0110 - segment F on,others off
    0111 - segment G on, others off
    1000 - segment DP on,others off
    1001 - all segment on
     
  12. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Could you start your own thread rather than hijacking someone else's thread?
     
  13. yas

    yas New Member

    Joined:
    Jan 24, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    sorry for my stupidity
     
  14. rahulkspzr

    rahulkspzr New Member

    Joined:
    Dec 25, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    The org means the beginning location in RAM.That is the location from which the code writing is beginning.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice