Shop OBEX P1 Docs P2 Docs Learn Events
View of the Machine Code ?? — Parallax Forums

View of the Machine Code ??

John KauffmanJohn Kauffman Posts: 653
edited 2006-10-25 14:33 in General Discussion
I am trying to provide for students demos for each step of the programming process.
·
As I understand the process:
SX/B code in .SXB file >> Compiler >> Assembly Code in .SRC file >> Assembler >> Machine Code in ??? file >> load into the EEFlash
·
I can show students the SXB and SRC files. Is there any way to complete the story with a view of the machine code?
·
Specific questions follow:
·
1 ·Does the machine code persist or is it sent straight to the EEFlash?
2 ·If it persists what is the file name, extension and path?
3· I assume if I can open the machine code file it will be a string of 1 & 0s. I also assume it can’t be opened in Notepad. Is there any way to get a peek at that machine code just for the educational purpose of demonstrating what it is that actually goes into the chip?
·
Much thanks.

Comments

  • RsadeikaRsadeika Posts: 3,837
    edited 2006-10-22 15:23
    I do not know if this would help, Run -> Device. At the bottom of the window it shows the hex code for what is contained in the EEFlash.

    Ray
  • metron9metron9 Posts: 1,100
    edited 2006-10-22 16:58
    Use debug instead or RUN, it brings up the code in a code list file, you can cut and paste

    Example: shows SXB command and below the op codes as well as the machine code in hex format


       169                                                   ;' -------------------------------------------------------------------------
       170                                                   ;' Subroutine Declarations
       171                                                   ;' -------------------------------------------------------------------------
       172  =00000042       __Initialize_8255:               ;Initialize_8255 SUB
       173  0042  0010        JMP @Initialize_8255          
            0043  0A5A
       174                  
       175  =00000044       __PortA_8255:                    ;PortA_8255 SUB
       176  0044  0010        JMP @PortA_8255               
            0045  0AB6
       177                  
       178  =00000046       __PortB_8255:                    ;PortB_8255 SUB
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think outside the BOX!
  • PJMontyPJMonty Posts: 983
    edited 2006-10-24 16:50
    John,

    Just to be clear, if you look at the snippet in the previous post by Metron9, the machine code are the numbers following the line number. For example line number 173 is followed by 0042 and 0010, and on the next line below it are 0043 0A5A. These are the machine code values for the assembly source line "JMP @Initialize_8255. Machine code is simply the actual number used by the CPU for a given instruction. They can be expressed in decimal, hex, binary, octal, or whatever. The number base is unimportant.
      Thanks, PeterM
  • YendorYendor Posts: 288
    edited 2006-10-24 18:48
    There's an option under Run-configure to save the obj files.
    Click on "assembler" and check box the "SASM Output" dir.

    Compile the code, and keep the IDE up.
    You can then go to the \SX-Key v3.2\SASM Output directory, and there is the obj file that has the machine code. I use UltraEdit to view it, as it gives the address, as well.
    Also, don't forget flowcharting! [noparse]:o[/noparse])

    [noparse][[/noparse]edit] To clarify, it appears when you compile, and the IDE·deletes the file after you close the IDE...Sneaky, eh?

    Rodney

    Post Edited (Yendor) : 10/25/2006 3:23:46 AM GMT
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2006-10-25 08:33
    When you don't check the "SASM Ouput" box, files like the list and object files go into the directory where the source file is located, and they are not deleted when you close the IDE.

    Instead of showing the students the object file, it might be better to show them the list file, as Metron9 had suggested, as it contains all the information: The assembly instructions, the generated machine code, and the addresses, where the code goes. As Peter had mentioned, the machine code can be found in the third column (1st is the line number in decimal, 2nd is the address in hex, and 3rd is the machine code in hex).

    The sample, Metron9 had posted also nicely shows, how the assembler has generated two instruction codes for each of the JMP @.... instructions, the codes for a PAGE, and a JMP instruction. This is also hepful to understand compound instructions, like MOV fr1, fr2, Here, the assembler generates two instruction codes for MOV w, fr2 and MOV fr1, w.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • YendorYendor Posts: 288
    edited 2006-10-25 14:33
    Gunther, thanks for pointing out what happens when you don't check the "SASM Ouput" box. I likea that better....Guess it pays to read the manual...

    The obj file becomes more relavent when you have to burn your own EPROMS on other uc's. Or at least, it was to me! It should match what's on the window, with what Ray pointed out, I would imagine after the SX is programmed.

    Rodney
Sign In or Register to comment.