Skip to content

Data Locations

November 6, 2015

So I noticed that I have a problem as regards memory locations for data. The SDCC compiler seems to explicitly expect you to provide –code-loc and –data-loc values. In my case, i hoped it would just pack the data in before or after the code but no such luck. If I specify –code-loc as 8007 it defaults –data-loc to 8000 which overwrites my program.

I noticed that the sdcc compiler invokes the linker with a “.lk” file which contains the values for code and data locations. I jimmied the file and took out the line “-b _DATA = 0x8000” as below.

-mjwx
-i 1stbigger.ihx
-b _CODE = 0x8007
-b _DATA = 0x8000
-k h:\Program Files\SDCC\bin\..\lib\z80
-l z80
h:\Program Files\SDCC\bin\..\lib\z80\crt0.rel
1stbigger.rel

-e

The result seems to be more or less what I want, it looks like the data segment lines up after the code segment – at least the initialized part of it. Editing that file would be a pretty awkward workaround though.
Here’s the .ihx file

:07 8000 00CDA180CD2280C755
:10 80A1 00 013400 78B1280811B180216D80EDB0 C9 8B
:20 8007 003E81D340C93E80D340C9110000210200397B967A239ED0001318F2CD07802150B9
:20 8027 00C3E5CD1180F1CD0C802150C3E5CD1180F118E82E2E2E2E2E2E2E2E2E312E2E2E28
:208047002E2E2E2E2E2E322E2E2E2E2E2E2E2E2E332E2E2E2E2E2E2E2E2E342E2E2E2E2E4A
:208067002E2E2E2E3500802E2E2E2E2E2E2E2E2E312E2E2E2E2E2E2E2E2E322E2E2E2E2E07
:1A8087002E2E2E2E332E2E2E2E2E2E2E2E2E342E2E2E2E2E2E2E2E2E35004F
:00000001FF

and the disassembly of the 2nd line which is GSINIT initializing global variables
15-11-06 ODA

The comments on the SDCC help forum are not encouraging. https://sourceforge.net/p/sdcc/discussion/1865/thread/4b313096/

I might try for now specifying data-loc as A000 allowing 16K each for code and data then I’ll see if I get smarter as I go along. This seems to work and didn’t make the .ihx file any bigger.

#include <stdio.h>
unsigned char port40=0x80; //output port 40 with bit 7 reserved for serial input
char dsfiller[17];
char filler[]=".........1.........2.........3.........4.........5";
void setledon(){
__asm
 ld a,#129
 out (64),a
__endasm ;
}
void setledoff(){
__asm
 ld a,#0x80
 out (64),a
__endasm ;
}
void delay(unsigned int howlong){
	unsigned int i;
	for (i=0;i<howlong;i++){
		__asm nop __endasm;
	}
}
void main(){
	dsfiller[0]='1'; dsfiller[1]=0;
	filler[0]='*';
	printf("\ndsfiller=%s, filler=%s\n",dsfiller,filler);
	dsfiller[0]=getchar();
	while(1){
		setledon();
		delay(50000);
		setledoff();
		delay(50000);
	}
}
:07800000CD848CCD2280C766
:108C840001340078B128081111A021508CEDB0C92D
:208007003E81D340C93E80D340C9110000210200397B967A239ED0001318F22100A0363156
:208027002336002112A0362A115F80E52100A0E5D5CDD78021060039F9CD09817D3200A03A
:20804700CD07802150C3E5CD1180F1CD0C802150C3E5CD1180F118E80A647366696C6C65AF
:20806700723D25732C2066696C6C65723D25730A002E2E2E2E2E2E2E2E2E312E2E2E2E2E54
:208087002E2E2E2E322E2E2E2E2E2E2E2E2E332E2E2E2E2E2E2E2E2E342E2E2E2E2E2E2E0A
:0480A7002E2E350044
:208C5000802E2E2E2E2E2E2E2E2E312E2E2E2E2E2E2E2E2E322E2E2E2E2E2E2E2E2E332EE6
:148C70002E2E2E2E2E2E2E2E342E2E2E2E2E2E2E2E2E350079
:2080AB00210200397EF533CDF48033C9210400394E2346C5210400394E2346C5210000E5BC
:2080CB0021AB80E5CD1F82F1F1F1F1C921040039E5210400394E2346C5210000E521AB80FA
:2080EB00E5CD1F82F1F1F1F1C9210200397EFE0AC205813E0DCDE90F3E0ACDE90FC9CDDDDB
:20810B000F6FC9FD210200FD39FD7E00C630673E399430147CC60767FD210300FD39FDCBC1
:20812B00004628047CC62067FD210600FD39FD4E00FD4601C5E533210700397E23666FCD8F
:20814B00408CF133C9DDE5DD210000DD39DD7E0407070707E60F57DD6E08DD6609E5DD6EEF
:20816B0006DD6607E5DD7E05F533D533CD0E8121060039F9DD7E04E60F57DD6E08DD660930
:20818B00E5DD6E06DD6607E5DD7E05F533D533CD0E8121060039F9DDE1C9DDE5DD210000E3
:2081AB00DD3921F9FF39F9DD5E04DD5605D521030039EB010400EDB0D1210400194D44DDA0
:2081CB0036F9200A87DD77FFDD7EFDCB07E601DD77FEDD7EFFDDB6FE02F5F1DDCBFA26DD86
:2081EB00CBFB16DDCBFC16DDCBFD160A67DD960638097CDD960602DDCBFAC6DD7EF9C6FF80
:20820B00DD77F9B720BD21010039010400EDB0DDF9DDE1C9DDE5DD210000DD3921CAFF391F
:20822B00F9DD36E800DD36E900210A0039DD75F9DD74FA21050039DD75E6DD74E7210A004F
:20824B0039DD75ECDD74EDDD7EECC604DD77F6DD7EEDCE00DD77F7DD6E08DD66095623DDAD
:20826B007508DD7409DD72F87AB7CA2A8CDD7EF8D625C2078CDD36DC00DD36E100DD36E0AB
:20828B0000DD36DF00DD36DE00DD36DD00DD36DB00DD36DA00DD36D200DD36FD00DD36D14C
:2082AB00FFDD7E08DD77EADD7E09DD77EBDD6EEADD66EB7EDD77FEDD34EA2003DD34EBDD46
:2082CB007EEADD7708DD7EEBDD7709DD7EFED6252023DD6E06DD6607E5DD7EFEF533DD6E49
:2082EB0004DD6605CD408CF133DD34E8C26282DD34E9C36282DD66FE7CD630383B3E3994E9
:20830B003836DD7ED13C201CDD7EFD4F87878187DD77FFDD86FEC6D0DD77FDB7208FDD366F
:20832B00E1011889DD6ED14D292909297DDD86FEC6D0DD77D1C3B882DD7EFED62E200EDDC4
:20834B007ED13CC2B882DD36D100C3B882DD6EFE7DD661380F3E7A95380ADDCBFEAEDD3670
:20836B00D9011804DD36D900DD7EFED620CA1284DD7EFED62BCA0B84DD7EFED62D287ADDD3
:20838B007EFED642CA1984DD7EFED643CA2784DD7EFED644CA3C86DD7EFED646CA5886DDF7
:2083AB007EFED648CAB882DD7EFED649CA3C86DD7EFED64ACAB882DD7EFED64C2857DD7E3E
:2083CB00FED64FCA4686DD7EFED650CA9385DD7EFED653CA7184DD7EFED654CAB882DD7E55
:2083EB00FED655CA4C86DD7EFED658CA5286DD7EFED65ACAB882C35E86DD36DC01C3B88263
:20840B00DD36E001C3B882DD36DF01C3B882DD36DD01C3B882DD36DB01C3B882DDCBDD46CB
:20842B002811DD6E0ADD660B23DD750ADD740B2B561813DD6E0ADD660B2323DD750ADD7438
:20844B000B2B2B562366DD6E06DD6607E5D533DD6E04DD6605CD408CF133DD34E8C288862C
:20846B00DD34E9C38886210A0039DD75EADD74EBDD6E0ADD660B2323DD750ADD740B2B2B53
:20848B005E2356DD6EEADD66EB732372D5CD418CF15DDD7ED13C2003DD73D1DDCBDC46203C
:2084AB00467BDD96FD3040DD7EFD93DD77FFDD4EE8DD46E9DD66FFDD35FF7CB7281DC5D54E
:2084CB00DD6E06DD6607E53E20F533DD6E04DD6605CD408CF133D1C10318D9DD71E8DD702E
:2084EB00E9DD7EFFDD77FDDD56D1DD4EE8DD46E9DD6EEADD66EB7E23666F7EDD77FFB72831
:20850B004A6215AF94E21585EE80F25685C5D5DD6E06DD6607E5DD7EFFF533DD6E04DD6667
:20852B0005CD408CF133D1C103DD6EEADD66EB7E23666F23DD75FBDD74FCDD6EEADD66EBE0
:20854B00DD7EFB7723DD7EFC7718A5DD71E8DD70E9DDCBDC46CA88867BDD96FDD28886DDDF
:20856B007EFD935F631D7CB7CA7F86C5D5DD6E06DD6607E53E20F533DD6E04DD6605CD40BD
:20858B008CF133D1C10318DC210A0039EBDD6E0ADD660B2323DD750ADD740B2B2B4E23469A
:2085AB007912137812DD6E06DD6607E53E30F533DD6E04DD6605CD408CF133DD5EE8DD56C8
:2085CB00E913D5DD6E06DD6607E53E78F533DD6E04DD6605CD408CF133D113210B0039467E
:2085EB00D5DD6E06DD6607E5DD6E04DD6605E5DD7ED9F533C533CD508121060039F9D11370
:20860B0013DD6EF9DD66FA46D5DD6E06DD6607E5DD6E04DD6605E5DD7ED9F533C533CD5033
:20862B008121060039F9D11313DD73E8DD72E9184CDD36DE01DD36D20A1842DD36D208184A
:20864B003CDD36D20A1836DD36D2101830DD36DA01182ADD6E06DD6607E5DD7EFEF533DD4B
:20866B006E04DD6605CD408CF133DD34E8200EDD34E91809DD71E8DD70E9DD73FDDDCBDAFB
:20868B0046CA4A87210A0039DD75FBDD74FCDD7E0AC604DD77EADD7E0BCE00DD77EBDD7EB5
:2086AB00EADD770ADD7EEBDD770BDD7EEAC6FCDD77EADD7EEBCEFFDD77EBDD5EEADD56EBE8
:2086CB0021180039EB010400EDB0DD5EFBDD56FC21180039010400EDB0210A0039DD75E27F
:2086EB00DD74E3DD6EE2DD66E3363523368CDD7EE8DD77FBDD7EE9DD77FCDD6EE2DD66E31F
:20870B005E23564B4203DD6EE2DD66E37123701A67B7CA6282DD4E06DD4607C5E533DD6E27
:20872B0004DD6605CD408CF133DD34FB2003DD34FCDD7EFBDD77E8DD7EFCDD77E918BBDD13
:20874B007ED2B7CA6282DD7EE6DD77E2DD7EE7DD77E3DDCBDD46CAF687210A0039DD75FBA6
:20876B00DD74FCDD7E0AC601DD77EADD7E0BCE00DD77EBDD7EEADD770ADD7EEBDD770BDD9F
:20878B006EEADD66EB2BDD75EADD74EBDD6EEADD66EB7EDD77FFDD77EEDD7EFF179FDD77CB
:2087AB00EFDD77F0DD77F1DD5EFBDD56FC21240039010400EDB0DDCBDE46C2F588DD5EFB70
:2087CB00DD56FC21240039EB010400EDB0DD36EF00DD36F000DD36F100DD5EFBDD56FC21C5
:2087EB00240039010400EDB0C3F588DDCBDB462858210A0039DD75EEDD74EFDD7E0AC604D3
:20880B00DD77FBDD7E0BCE00DD77FCDD7EFBDD770ADD7EFCDD770BDD7EFBC6FCDD77FBDDCC
:20882B007EFCCEFFDD77FCDD5EFBDD56FC21280039EB010400EDB0DD5EEEDD56EF2128008E
:20884B0039010400EDB0C3F588210A0039DD75F2DD74F3DD7E0AC602DD77EEDD7E0BCE0063
:20886B00DD77EFDD7EEEDD770ADD7EEFDD770BDD7EEEC6FEDD77EEDD7EEFCEFFDD77EFDDD4
:20888B007EEEDD77EEDD7EEFDD77EFDD6EEEDD66EF7EDD77EE237EDD77EFDD7EEEDD77EEF8
:2088AB00DD7EEFDD77EF179FDD77F0DD77F1DD5EF2DD56F321240039010400EDB0DDCBDEE8
:2088CB00462027DD5EF2DD56F321240039EB010400EDB0DD36F000DD36F100DD5EF2DD563B
:2088EB00F321240039010400EDB0DDCBDE46284A210A0039DD75F2DD74F3EB21240039EBDC
:20890B00010400EDB0DDCBF17E282BDD6EF2DD66F35E2356234E2346AF935F3E009A573E0E
:20892B0000994F3E009847DD6EF2DD66F3732372237123701804DD36DE00DD36D301DD4E66
:20894B00E2DD46E3DD36D000210E00393600DD5EECDD56EDC5DD7ED2F533D5CDA581F13356
:20896B00C1DDCBD3462023DD6EF6DD66F77E07070707E6F057DD6EF6DD66F77E07070707D0
:20898B00E60FB2570AB2020B1808DD6EF6DD66F77E02DD34D0DD7ED3EE01DD77D3DD6EEC8E
:2089AB00DD66ED5E235623237E2B66B4B2B32098DD71F2DD70F3DD7ED0DD77EEDD7EFDB783
:2089CB002004DD36FD01DDCBE1462054DDCBDC46204EDD7EEE3CDD77E2DD7EE8DD77FBDDB2
:2089EB007EE9DD77FCDD56FDDD7EE2923023D5DD6E06DD6607E53E20F533DD6E04DD6605F1
:208A0B00CD408CF133D1DD34FB2003DD34FC1518D7DD7EFBDD77E8DD7EFCDD77E9DD72FD0B
:208A2B00DDCBDE462823DD6E06DD6607E53E2DF533DD6E04DD6605CD408CF133DD34E82094
:208A4B0003DD34E9DD35FD1856DD7EEEB72850DDCBE0462823DD6E06DD6607E53E2BF533EF
:208A6B00DD6E04DD6605CD408CF133DD34E82003DD34E9DD35FD1827DDCBDF462821DD6ED2
:208A8B0006DD6607E53E20F533DD6E04DD6605CD408CF133DD34E82003DD34E9DD35FDDDBA
:208AAB00CBDC46204FDD7EE8DD77E2DD7EE9DD77E3DD7EFDDD77FBDD66FBDD35FBDD7EEE20
:208ACB0094304ADDCBE1462806DD36FF301804DD36FF20DD6E06DD6607E5DD7EFFF533DD11
:208AEB006E04DD6605CD408CF133DD34E220C8DD34E318C3DD7EEEDD96FD300BDD7EFDDD21
:208B0B0096EEDD77FF1818DD36FF001812DD7EE2DD77E8DD7EE3DD77E9DD7EFBDD77FFDD8D
:208B2B007EF2DD77F2DD7EF3DD77F3DD7EE8DD77E2DD7EE9DD77E3DD7EEEDD77EEDD66EE2F
:208B4B00DD35EE7CB7286ADD7ED3EE01DD77D3DDCBD346201EDD34F22003DD34F3DD6EF29B
:208B6B00DD66F37E07070707E60FDD6EF6DD66F7771810DD6EF2DD66F37EE60FDD6EF6DD07
:208B8B0066F777DD6EF6DD66F756DD6E06DD6607E5DD6E04DD6605E5DD7ED9F533D533CDF8
:208BAB000E8121060039F9DD34E22091DD34E3188CDD7EE2DD77E8DD7EE3DD77E9DDCBDC0E
:208BCB0046CA6282DD5EE2DD56E3DD7EFFDD77F2DD66F2DD35F27CB7CA6282D5DD6E06DDA6
:208BEB006607E53E20F533DD6E04DD6605CD408CF133D113DD73E8DD72E918D4DD6E06DDD0
:208C0B006607E5DD7EF8F533DD6E04DD6605CD408CF133DD34E8C26282DD34E9C36282DD0B
:208C2B006EE8DD66E9DDF9DDE1C93C4E4F20464C4F41543E00E9C1E1E5C5AF474FEDB12164
:058C4B00FFFFED42C92E
:00000001FF
Advertisements

From → Olduino/Z

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: