Skip to content

Instantly share code, notes, and snippets.

@allbinmani
Last active March 2, 2017 07:13
Show Gist options
  • Save allbinmani/08de96702b4d49d6ba5855934f8b8192 to your computer and use it in GitHub Desktop.
Save allbinmani/08de96702b4d49d6ba5855934f8b8192 to your computer and use it in GitHub Desktop.
============= start.S ======================
.global start
.text
start:
lea.l _DemoBase(PC),a0
lea.l (PC,_DemoBase),a1
lea.l (_DemoBase,PC),a2
lea.l _DemoBase,a0
lea.l _DemoBaseEnd(PC),a3
lea.l _DemoBaseEnd,a4
lea.l start(PC),a5
lea.l start,a6
rts
============== demobase.S ===================
.global _DemoBaseEnd
.global _DemoBase
.text
_DemoBase = .
.space 32,0x77
_DemoBaseEnd = .
============= link.mri ========================
OUTPUT_FORMAT("amiga")
OUTPUT_ARCH(m68k)
ENTRY(start)
SECTIONS
{
.text :
{
___machtype = ABSOLUTE(0x0);
__stext = .;
start.o(.text);
__stend = .;
*(.text)
. = ALIGN(0x08);
__ecode = .;
__etext = .;
___text_size = ABSOLUTE(__etext - __stext);
}
. = ALIGN(0x08);
.data :
{
__sdata = .;
CONSTRUCTORS
*(.data)
__edata = .;
___data_size = ABSOLUTE(__edata - __sdata);
}
. = ALIGN(0x08);
.bss :
{
__bss_start = .;
*(.bss)
*(COMMON)
__end = . ;
___bss_size = ABSOLUTE(__end - __bss_start);
}
.data_chip :
{
*(.data_chip)
}
.bss_chip :
{
*(.bss_chip)
}
}
============= build ========================
# m68k-amigaos-as -v
GNU assembler version 2.8.1 (m68k-amigaos)
# m68k-amigaos-ld -v
GNU ld version 2.8.1 (with BFD 2.8.1)
# m68k-amigaos-as -sc --bitwise-or -D --defsym GAS=1 -o star.o start.S
# m68k-amigaos-as -sc --bitwise-or -D --defsym GAS=1 -o demobase.o demobase.S
# m68k-amigaos-ld -T link.mri --verbose -mamiga_bss -o demo start.o demobase.o
============ objdump =========================
src/demo: file format amiga
src/demo
architecture: m68k:68000, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000058 00000000 00000000 00000024 2**2
CONTENTS, ALLOC, LOAD, RELOC, CODE
1 .data 00000000 00000000 00000000 00000120 2**2
CONTENTS, ALLOC, LOAD, DATA
SYMBOL TABLE:
00000058 g .text 0000 00 __etext
00000038 g .text 0000 00 _DemoBase
00000000 g .text 0000 00 __stext
00000000 g .text 0000 00 start
00000058 g .text 0000 00 __ecode
00000038 g .text 0000 00 __stend
00000058 g .text 0000 00 _DemoBaseEnd
00000000 g .data 0001 00 __edata
00000000 g .data 0001 00 __sdata
Disassembly of section .text:
00000000 <__stext>:
0: 41fb 0170 0000 lea %pc@(36 <__stext+36>),%a0
6: 0034
8: 43fb 0170 0000 lea %pc@(36 <__stext+36>),%a1
e: 002c
10: 45fb 0170 0000 lea %pc@(36 <__stext+36>),%a2
16: 0024
18: 41f9 0000 0038 lea 38 <_DemoBase>,%a0
1a: reloc32 .text
1e: 47fb 0170 0000 lea %pc@(56 <_DemoBase+1e>),%a3
24: 0036
26: 49f9 0000 0058 lea 58 <_DemoBaseEnd>,%a4
28: reloc32 .text
2c: 4bfa ffd2 lea 0 <__stext>,%fp
30: 4dfa ffce lea 0 <__stext>,%a6
34: 4e75 rts
...
00000038 <_DemoBase>:
38: 7777 073567
3a: 7777 073567
3c: 7777 073567
3e: 7777 073567
40: 7777 073567
42: 7777 073567
44: 7777 073567
46: 7777 073567
48: 7777 073567
4a: 7777 073567
4c: 7777 073567
4e: 7777 073567
50: 7777 073567
52: 7777 073567
54: 7777 073567
56: 7777 073567
=================== hexdump ===================
start.o:
0000000: 0002 0107 0000 0038 0000 0000 0000 0000 .......8........
0000010: 0000 0030 0000 0000 0000 0030 0000 0000 ...0.......0....
0000020: 41fb 0170 ffff fffe 43fb 0170 ffff fff6 A..p....C..p....
0000030: 45fb 0170 ffff ffee 41f9 0000 0000 47fb E..p....A.....G.
0000040: 0170 ffff ffe0 49f9 0000 0000 4bfa ffd2 .p....I.....K...
0000050: 4dfa ffce 4e75 0000 0000 001a 0000 0250 M...Nu.........P
0000060: 0000 0028 0000 0350 0000 0004 0000 02d0 ...(...P........
0000070: 0000 000c 0000 02d0 0000 0014 0000 02d0 ................
0000080: 0000 0022 0000 03d0 0000 0004 0200 0000 ..."............
0000090: 0000 0001 0000 0008 0500 0000 0000 0000 ................
00000a0: 0000 000e 0100 0000 0000 0000 0000 0018 ................
00000b0: 0100 0000 0000 0000 0000 0025 4741 5300 ...........%GAS.
00000c0: 7374 6172 7400 5f44 656d 6f42 6173 6500 start._DemoBase.
00000d0: 5f44 656d 6f42 6173 6545 6e64 00 _DemoBaseEnd.
demobase.o:
0000000: 0002 0107 0000 0020 0000 0000 0000 0000 ....... ........
0000010: 0000 009c 0000 0000 0000 0000 0000 0000 ................
0000020: 7777 7777 7777 7777 7777 7777 7777 7777 wwwwwwwwwwwwwwww
0000030: 7777 7777 7777 7777 7777 7777 7777 7777 wwwwwwwwwwwwwwww
0000040: 0000 0004 0200 0000 0000 0001 0000 0008 ................
0000050: 0200 0000 0000 0000 0000 0010 0200 0000 ................
0000060: 0000 0004 0000 001c 0200 0000 0000 0008 ................
0000070: 0000 0028 0200 0000 0000 000c 0000 0034 ...(...........4
0000080: 0200 0000 0000 0010 0000 0043 0200 0000 ...........C....
0000090: 0000 0014 0000 004f 0200 0000 0000 0018 .......O........
00000a0: 0000 005d 0200 0000 0000 001a 0000 006b ...]...........k
00000b0: 0200 0000 0000 001c 0000 0079 0200 0000 ...........y....
00000c0: 0000 001e 0000 0085 0500 0000 0000 0020 ...............
00000d0: 0000 0092 0500 0000 0000 0000 0000 009c ................
00000e0: 4741 5300 4442 4f5f 5642 5200 4442 4f5f GAS.DBO_VBR.DBO_
00000f0: 5379 7342 6173 6500 4442 4f5f 444f 5342 SysBase.DBO_DOSB
0000100: 6173 6500 4442 4f5f 4766 7842 6173 6500 ase.DBO_GfxBase.
0000110: 4442 4f5f 6f6c 6443 6f70 496e 6974 0044 DBO_oldCopInit.D
0000120: 424f 5f6f 6c64 5669 6577 0044 424f 5f6f BO_oldView.DBO_o
0000130: 6c64 494e 5445 4e41 0044 424f 5f6f 6c64 ldINTENA.DBO_old
0000140: 444d 4143 4f4e 0044 424f 5f6f 6c64 4144 DMACON.DBO_oldAD
0000150: 4b43 4f4e 0044 424f 5f44 425f 5369 7a65 KCON.DBO_DB_Size
0000160: 005f 4465 6d6f 4261 7365 456e 6400 5f44 ._DemoBaseEnd._D
0000170: 656d 6f42 6173 6500 emoBase.
demo:
0000000: 0000 03f3 0000 0000 0000 0002 0000 0000 ................
0000010: 0000 0001 0000 0016 0000 0000 0000 03e9 ................
0000020: 0000 0016 41fb 0170 0000 0034 43fb 0170 ....A..p...4C..p
0000030: 0000 002c 45fb 0170 0000 0024 41f9 0000 ...,E..p...$A...
0000040: 0038 47fb 0170 0000 0036 49f9 0000 0058 .8G..p...6I....X
0000050: 4bfa ffd2 4dfa ffce 4e75 0000 7777 7777 K...M...Nu..wwww
0000060: 7777 7777 7777 7777 7777 7777 7777 7777 wwwwwwwwwwwwwwww
0000070: 7777 7777 7777 7777 7777 7777 0000 03ec wwwwwwwwwwww....
0000080: 0000 0002 0000 0000 0000 001a 0000 0028 ...............(
0000090: 0000 0000 0000 03f0 0000 0002 5f5f 6574 ............__et
00000a0: 6578 7400 0000 0058 0000 0003 5f44 656d ext....X...._Dem
00000b0: 6f42 6173 6500 0000 0000 0038 0000 0002 oBase......8....
00000c0: 5f5f 7374 6578 7400 0000 0000 0000 0002 __stext.........
00000d0: 7374 6172 7400 0000 0000 0000 0000 0002 start...........
00000e0: 5f5f 6563 6f64 6500 0000 0058 0000 0002 __ecode....X....
00000f0: 5f5f 7374 656e 6400 0000 0038 0000 0003 __stend....8....
0000100: 5f44 656d 6f42 6173 6545 6e64 0000 0058 _DemoBaseEnd...X
0000110: 0000 0000 0000 03f2 0000 03ea 0000 0000 ................
0000120: 0000 03f0 0000 0002 5f5f 6564 6174 6100 ........__edata.
0000130: 0000 0000 0000 0002 5f5f 7364 6174 6100 ........__sdata.
0000140: 0000 0000 0000 0000 0000 03f2 ............
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment