Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #1334

Re: View assembly output for C code

Newsgroups comp.sys.apple2.programmer
Date 2014-10-04 09:31 -0700
References <32d7a2e8-1e78-4ac5-9fd5-130038fc1f8b@googlegroups.com> <m0p1lm$5q3$1@dont-email.me>
Message-ID <b3aa63ab-fe67-4b78-b167-e20b9fd577d4@googlegroups.com> (permalink)
Subject Re: View assembly output for C code
From AppleIIGSMarc <appleiigsmarc@gmail.com>

Show all headers | View raw


On Saturday, October 4, 2014 7:53:36 AM UTC-7, Kelvin Sherlock wrote:
> Disassemble the intermediate (.A) object files.  They're also OMF so 
> 
> dumpobj or orca/disassembler can handle them.
> 
> 
> 
> #pragma lint -1
> 
> #pragma optimize -1
> 
> 
> 
> #include <stdio.h>
> 
> 
> 
> int main(int argc, char **argv)
> 
> {
> 
>   puts("hello, world!");
> 
>   return 0;
> 
> }
> 
> 
> 
> Segment name  : main
> 
> 
> 
> 00003F 000000 |          LONGA ON
> 
> 00003F 000000 |          LONGI ON
> 
> 00003F 000000 | main     START
> 
> 00003F 000000 |          PHA
> 
> 000041 000001 |          TSC
> 
> 000042 000002 |          PHD
> 
> 000043 000003 |          TCD
> 
> 000044 000004 |          PEA   ((main+$00000023)|$FFFFFFF0)
> 
> 000053 000007 |          PEA   (main+$00000023)
> 
> 00005D 00000A |          JSL   puts
> 
> 000068 00000E |          STZ   $01
> 
> 00006B 000010 |          LDA   $04
> 
> 00006D 000012 |          STA   $0A
> 
> 00006F 000014 |          LDA   $03
> 
> 000071 000016 |          STA   $09
> 
> 000073 000018 |          LDY   $01
> 
> 000075 00001A |          PLD
> 
> 000076 00001B |          TSC
> 
> 000077 00001C |          CLC
> 
> 000078 00001D |          ADC   #$0008
> 
> 00007B 000020 |          TCS
> 
> 00007C 000021 |          TYA
> 
> 00007D 000022 |          RTL
> 
> 00007E 000023 |          PLA
> 
> 000080 000024 |          ADC   $6C
> 
> 000082 000026 |          JMP   ($2C6F)
> 
> 000085 000029 |          JSR   $6F77
> 
> 000088 00002C |          ADC   ($6C)
> 
> 00008A 00002E |          STZ   $21
> 
> 00008C 000030 |          BRK   ???
> 
> 00008E 000032 |
> 
> 00008F 000032 |          END
> 
> 
> 
> 
> 
> 
> 
> On 2014-10-01 02:07:35 +0000, AppleIIGSMarc said:
> 
> 
> 
> > I was wondering if anyone had any useful advice on how best to view the 
> 
> > assembly code that Orca/C generates for any given function.  There 
> 
> > doesn't appear to be a compiler option to output the generated assembly 
> 
> > code, so I currently only know of two ways to view it.  First is to 
> 
> > compile the code with an asm 'brk' statement placed in front of the 
> 
> > code I'd like to examine and then use GSBug to look at it.  This means 
> 
> > I must recompile each time I want to examine a different chunk of code. 
> 
> >  The other is to run my program through the Orca/Disassembler which 
> 
> > lets me see everything at once, but pretty much merges all the code 
> 
> > into one gigantic listing.
> 
> > 
> 
> > Neither method really allows me to easily see the start and end of 
> 
> > individual functions.  I realize this may be as good as it gets, but I 
> 
> > figured it couldn't hurt to ask and see if anyone knew of a better way 
> 
> > or had any tips on how to make it easier.
> 
> > 
> 
> > Thanks!

Thanks!  That worked perfectly with Orca's GUI disassembler and is exactly what I needed.  Each function shows up separately under the Segments menu and labels and global variables show up in the code.  I guess it's still a little buggy (the computer locks up if I try to open a particular .a file), but it's still extremely useful.  

Thanks for the help,
Marc

Back to comp.sys.apple2.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

View assembly output for C code AppleIIGSMarc <appleiigsmarc@gmail.com> - 2014-09-30 19:07 -0700
  Re: View assembly output for C code Kelvin Sherlock <email@domain.com> - 2014-10-04 10:53 -0400
    Re: View assembly output for C code AppleIIGSMarc <appleiigsmarc@gmail.com> - 2014-10-04 09:31 -0700
      Re: View assembly output for C code AppleIIGSMarc <appleiigsmarc@gmail.com> - 2014-10-04 17:33 -0700
        Re: View assembly output for C code Antoine Vignau <antoine.vignau@laposte.net> - 2014-10-05 03:55 -0700
        Re: View assembly output for C code Michael J. Mahon <mjmahon@aol.com> - 2014-10-05 17:19 -0500
          Re: Learning Assembly Language markpmlim@yahoo.com.sg - 2014-10-05 18:26 -0700
          Re: View assembly output for C code "Bill Buckels" <bbuckels@mts.net> - 2014-10-05 20:29 -0500
            Re: View assembly output for C code Michael J. Mahon <mjmahon@aol.com> - 2014-10-05 23:10 -0500
              Re: View assembly output for C code "Bill Buckels" <bbuckels@mts.net> - 2014-10-06 04:45 -0500
                Re: View assembly output for C code AppleIIGSMarc <appleiigsmarc@gmail.com> - 2014-10-13 11:22 -0700
                Re: View assembly output for C code Antoine Vignau <antoine.vignau@laposte.net> - 2014-10-14 13:08 -0700
                Re: View assembly output for C code AppleIIGSMarc <appleiigsmarc@gmail.com> - 2014-10-14 17:29 -0700
                Re: View assembly output for C code Antoine Vignau <antoine.vignau@laposte.net> - 2014-10-14 22:38 -0700

csiph-web