[rc2014-z80] HEX loader... bad and good news

558 views
Skip to first unread message

Filippo Bergamasco

unread,
Jul 8, 2016, 3:59:22 AM7/8/16
to RC201...@googlegroups.com
Dear friends,
I'm working to build a simple hex loader that can be used for everybody like me that cannot afford (yet) an eeprom programmer. What I do is basically the following:

1) Use a simple basic program to load the the hex loader in the upper part of the ram memory. such loader is written in z80 assembly for speed/size reasons

2) use usr() to jump to the hex loader

3) transfer the hex file and store it at correct memory locations (checksums are also properly checked)

4) the hex loader jumps at location 0x8000


I you want to try it, here are the basic steps:

1) Boot the RC2014 to get the basic prompt
2) Paste the following listing

--------------------- 8<  [CUT HERE] ----------------
clear
10 let mb=-2048
20 for l=1 to 69
30 input "";a,b,c,d
31 poke mb, a
32 poke mb+1, b
33 poke mb+2, c
34 poke mb+3, d
35 let mb=mb+4
40 next l
50 poke -32696,195
60 poke -32695,0
70 poke -32694,248
run
243,33,255,255
249,62,150,211
128,243,33,214
248,205,154,248
205,137,248,125
254,58,194,16
248,221,33,0
0,205,164,248
68,77,205,164
248,85,205,164
248,93,205,164
248,125,254,1
40,41,254,0
32,50,205,164
248,125,18,19
11,62,0,176
177,254,0,32
241,62,124,205
126,248,205,164
248,221,125,254
0,32,30,62
42,205,126,248
195,16,248,205
164,248,33,13
249,205,154,248
33,0,128,233
33,249,248,205
154,248,195,122
248,33,3,249
205,154,248,195
122,248,0,195
122,248,245,219
128,203,79,40
250,241,211,129
201,245,219,128
203,71,40,250
219,129,38,0
111,205,126,248
241,201,126,183
200,205,126,248
35,195,154,248
245,213,205,137
248,125,214,48
254,10,56,2
214,7,87,205
137,248,125,214
48,254,10,56
2,214,7,95
203,34,203,34
203,34,203,34
178,209,38,0
111,241,197,6
0,77,221,9
193,201,72,69
88,32,76,79
65,68,69,82
32,98,121,32
70,105,108,105
112,112,111,32
66,101,114,103
97,109,97,115
99,111,10,13
0,10,13,73
78,86,32,84
89,80,0,10
13,66,65,68
32,67,72,75
0,10,13,79
75,0,0,0
print usr(0)
--------------------- 8<  [CUT HERE] ----------------

3) You should see:
HEX LOADER by Filippo Bergamasco

4) Paste your hex file, for example:

--------------------- 8<  [CUT HERE] ----------------

:10800000F321FFFFF9C33E80F5DB80CB4F28FAF167
:10801000D381C9F5DB80CB4728FADB8126006FF1DD
:10802000C97DCD0880C92E00DB80CB47C82E01C991
:10803000C54DED4068C1C9C54C45ED41C1C9ED73A1
:108040002182212382018C001E00CDF58021258212
:10805000018000CD6380CD2581C3D480E5E1ED7B37
:108060002182C95D54E5C50E01CD0681DA858021E6
:10807000060019EBC109AF2B772B77EB7323722323
:10808000CDCA80E1C9E1E1CD8D8023C9E12E09C3CC
:108090009780E1E1E12EFF2600222382C3A280E146
:1080A000E1E121FFFF37C9E1E1E1E121000037C94A
:1080B000E1C97723772377237723772377237723E0
:1080C00077237723772377237723772377237723E0
:1080D0007723C9E911A7821AB7CA5C80E56F260029
:1080E000291947562B5E2BC5E5EBCDD380E1C11096
:1080F000F2E1C35C8078B17B5D54C877130B78B133
:10810000C8E5EDB0E1C979E6F8201579E607281051
:10811000AFCDC6802B2B2B36FE2B2B71210000C937
:1081200021010037C9210A0022AD8221F881CD3515
:1081300081C32B81C97EB7C8CF23C335813E00B42C
:10814000B528273E000118FCCD5B81019CFFCD5B6B
:10815000810EF6CD5B8148C365813C0938FCED4258
:10816000B7C8C36A810938F2ED42C630CF3E00C9B4
:108170007CCD7F817CCD83817DCD7F817D18041F67
:108180001F1F1FF6F027C6A0CE40CFC9CDE8812122
:108190000482CD3581C9CDE88121FF81CD3581C9EA
:1081A000CDE881210982CD3581C9E5CDE881210C59
:1081B00082CD3581E1CD3D813E6DCFC9E5CDE881F0
:1081C000211282CD3581E1CD3D813E6DCFC9CDE813
:1081D00081D1C1E1D5C5CD3D813E3BCFE1CD3D81D2
:1081E0003E48CFE1E5E5E5C93E1BCF3E5BCFC9097F
:1081F000454E4F4C434B000048454C4C4F21003FEF
:1082000032356C003F32356800324A0033383B3536
:108210003B0034383B353B0000258200001B8201C7
:00000001FF

--------------------- 8<  [CUT HERE] ----------------

5) Once loaded you should see a lot of "HELLO" on the screen. That is actually
the program that you've just loded



And now the bad news:

It's hard for me to load a relatively long hex file because sometime I miss some bytes. In general the UART communication is very unreliable. Sometimes I get wrong characters, sometimes I completely miss some of them. We already mentioned this problem in a previous discussion. If you use RC2014 with the keyboard is not a problem but when you want to transfer some data it is quite annoying.
Apparently, the problem is still there even if I add a delay (even a big delay!) between the characters. Sounds like the ACIA chip is not working properly to me.... Any suggestion?


Filippo


Jason Fagan

unread,
Jul 8, 2016, 4:08:06 AM7/8/16
to rc201...@googlegroups.com
Great work Filippo, but like you say there is an issue with pasting over serial, I’ve found that pasting 2-3 lines seems to be the most reliable method so far, but painfully slow. 

Has anyone thought about or implemented a simple audio interface for recording or playback of data?



--
You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+...@googlegroups.com.
To post to this group, send email to rc201...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rc2014-z80/CAK%2B%3DWr9V7U3inZuVga%3DJZWSK%3D%3DgUQSSxpfFK4VyyCtx3E6mObw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Steve Barnett

unread,
Jul 8, 2016, 5:53:31 AM7/8/16
to RC2014-Z80
I hit similar problems with writing interactive loaders in BASIC.

My solution was to encode the data to be loaded in DATA statements. BASIC is much faster at reading the keyboard itself than running a BASIC program to read the keyboard, so dropped input is less of an issue.

This should allow you to get a small machine code loader in place as a "stage 2" loader.

My full solution was a python script on the host PC whose output is sent to the serial port. It takes a binary file and an address, sends a loader program with the binary encoded in DATA statements and runs it. It puts a .01 second delay between characters and a 0.1 second delay between lines (processing a line of input takes BASIC a while.

This script actually takes a list of commands - load file at address or execute code at address. This lets me drive it from a Makefile for a fairly hassle free RC2014 dev environment.

I'll try and post source code later.

Steve Barnett

unread,
Jul 8, 2016, 5:56:51 AM7/8/16
to RC2014-Z80
Apologies, what I said above didn't account for corrupt characters, only dropped characters.

I've not encountered the corrupt characters issue yet. :(

Filippo Bergamasco

unread,
Jul 8, 2016, 5:57:52 AM7/8/16
to rc201...@googlegroups.com
It's exactly what I do, I have two stages. There is no BASIC involved, I mean, the first stage (the basic one) is successful 99% of the time. The problem is when I start upload the big hex file that is processed with my (assembly-written) hex loader.
 
It's not a matter of how fast I upload the bytes. Even if i put a 0.5 sec delay between each bytes it can happen that data gets corrupted in some way. 




--
You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+...@googlegroups.com.
To post to this group, send an email to rc201...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rc2014-z80/7d777ad7-a672-42e3-ba8a-3d173ff3f49d%40googlegroups.com.

David Pucknell

unread,
Jul 8, 2016, 8:27:56 AM7/8/16
to RC2014-Z80, RC201...@googlegroups.com
I have changed the basic program so that saves the cut and paste issues. May be of some use to some people. 

Just cut and paste the whole lot.

--- CUT --- 

new
clear
10 let mb=-2048
20 for l=1 to 69
25 read a,b,c,d
26 rem print l*10 + 9000,a,b,c,d
31 poke mb, a
32 poke mb+1, b
33 poke mb+2, c
34 poke mb+3, d
35 let mb=mb+4
40 next l
50 poke -32696,195
60 poke -32695,0
70 poke -32694,248
100 print usr(0)


9010 data 243,33,255,255
9020 data 249,62,150,211
9030 data 128,243,33,214
9040 data 248,205,154,248
9050 data 205,137,248,125
9060 data 254,58,194,16
9070 data 248,221,33,0
9080 data 0,205,164,248
9090 data 68,77,205,164
9100 data 248,85,205,164
9110 data 248,93,205,164
9120 data 248,125,254,1
9130 data 40,41,254,0
9140 data 32,50,205,164
9150 data 248,125,18,19
9160 data 11,62,0,176
9170 data 177,254,0,32
9180 data 241,62,124,205
9190 data 126,248,205,164
9200 data 248,221,125,254
9210 data 0,32,30,62
9220 data 42,205,126,248
9230 data 195,16,248,205
9240 data 164,248,33,13
9250 data 249,205,154,248
9260 data 33,0,128,233
9270 data 33,249,248,205
9280 data 154,248,195,122
9290 data 248,33,3,249
9300 data 205,154,248,195
9310 data 122,248,0,195
9320 data 122,248,245,219
9330 data 128,203,79,40
9340 data 250,241,211,129
9350 data 201,245,219,128
9360 data 203,71,40,250
9370 data 219,129,38,0
9380 data 111,205,126,248
9390 data 241,201,126,183
9400 data 200,205,126,248
9410 data 35,195,154,248
9420 data 245,213,205,137
9430 data 248,125,214,48
9440 data 254,10,56,2
9450 data 214,7,87,205
9460 data 137,248,125,214
9470 data 48,254,10,56
9480 data 2,214,7,95
9490 data 203,34,203,34
9500 data 203,34,203,34
9510 data 178,209,38,0
9520 data 111,241,197,6
9530 data 0,77,221,9
9540 data 193,201,72,69
9550 data 88,32,76,79
9560 data 65,68,69,82
9570 data 32,98,121,32
9580 data 70,105,108,105
9590 data 112,112,111,32
9600 data 66,101,114,103
9610 data 97,109,97,115
9620 data 99,111,10,13
9630 data 0,10,13,73
9640 data 78,86,32,84
9650 data 89,80,0,10
9660 data 13,66,65,68
9670 data 32,67,72,75
9680 data 0,10,13,79
9690 data 75,0,0,0

run


 ---- END ---

Spencer Owen

unread,
Jul 8, 2016, 8:40:48 AM7/8/16
to rc201...@googlegroups.com
Hey Filippo,

Good work on the hex loader :-)

I have given it a try this morning and the hex loader works great!  So many HELLO scrolling across my screen :-)

Like the others, I find that if I copy & paste from PuTTY via a FTDI cable, it tends to miss a lot.

However, I use a BBC Micro:bit for storing programs from a PC and playing them back in to the RC2014.  This code has a 10ms delay at the end of each line and it works perfectly.  If I remove the 10ms delay then it mainly works ok, although it sometimes failed on uploading the hex in to the hex loader.

I have got some slower crystals that run the RC2014 at 3.6864Mhz, which is a baudrate of 57600.  I figured that if it ran slower it would be more reliable - but I got almost exactly the same results with the PuTTY/FTDI test.  (The Micro:bit doesn't support 57600, so I couldn't test wit that).

i know the 68B50 interface is pretty crude and doesn't have much in the way of a buffer.  The fact that this is an obsolete product isn't ideal either, so there are a couple of other UART / ACIA chips that I'm looking in to.

[Update - I just checked in to a couple more things, and it turns out that I didn't have flow control enabled in PuTTY!  With this on, the entire BASIC program that David just posted does copy & paste perfectly.  I am getting BAD CHK errors when I copy & paste the HELLO code though]

Spencer

Filippo Bergamasco

unread,
Jul 8, 2016, 10:43:47 AM7/8/16
to rc201...@googlegroups.com
You mean hardware or software flow control?


Jason Fagan

unread,
Jul 8, 2016, 11:11:04 AM7/8/16
to rc201...@googlegroups.com
I wrote a small Python script to load the data with ~10ms delay between each line and Filippos’ code works like a charm.

Dave P

unread,
Jul 8, 2016, 12:11:48 PM7/8/16
to RC2014-Z80, RC201...@googlegroups.com
Just a bit of Clarity for everyone. 

5 REM Start address 63488 in hex F800
10 let mb=&HF800

100 poke mb,&H3e
110 poke mb+1,&H48
120 poke mb+2,&Hcf
130 poke mb+3,&Hc9

8049 rem 8049 REM JP start address (c3 00 f8) jp f800
8050 poke -32696,&HC3
8060 poke -32695,&H00
8070 poke -32694,&Hf8
9100 print usr(0)
run


It just prints "H" ... But as you can see we already have the hex in the basic.

DAVE

Filippo Bergamasco

unread,
Jul 8, 2016, 12:17:17 PM7/8/16
to rc201...@googlegroups.com
Sorry Dave I don't get it...
If you mean "2 stage loader is not needed since I can encode an hex as sequence of basic pokes".. yes, you are right, but for a long hex it will just become a huge listing. Also, I need to compute the checksum at every line which is quite difficult in basic

Filippo


--
You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+...@googlegroups.com.
To post to this group, send email to rc201...@googlegroups.com.

Dave P

unread,
Jul 8, 2016, 1:10:23 PM7/8/16
to RC2014-Z80, RC201...@googlegroups.com
Sorry that is not what I ment. 

I was suggesting that maybe we could utilise this somehow. I think you are right a two stage process. 

Filippo Bergamasco

unread,
Jul 8, 2016, 3:17:11 PM7/8/16
to rc201...@googlegroups.com
Gentlemen,
I think I've figured out how to make the communication reliable. The problem was that I thought  the ACIA chip had some sort of buffer in it. So... I just polled for bytes in a loop while computing the checksum and storing everything in memory at the right place.

But... the chip actually has just 1 byte buffer so you can either be extremely fast at reading those data or you will eventually end up missing bytes. By reading che original basic source (in particular the initialisation part) I've seen that there is already a circular buffer implemented to store the incoming serial data that is received on demand via interrupts. So... to let it short, I take advantage of that routines in my hex loader and now is much much better!

Unfortunately I haven't got the hardware with me right now... can anybody of you test this for me? I'm so curious to see if it properly works.

The new BASIC code to paste is the following:


------- 8<  ------

clear
10 let mb=-2048
20 for l=1 to 65
30 input "";a,b,c,d
31 poke mb, a
32 poke mb+1, b
33 poke mb+2, c
34 poke mb+3, d
35 let mb=mb+4
40 next l
50 poke -32696,195
60 poke -32695,0
70 poke -32694,248
run
33,255,255,249
62,3,211,128
62,150,211,128
251,33,200,248
205,140,248,205
135,248,125,254
58,194,19,248
221,33,0,0
205,150,248,68
77,205,150,248
85,205,150,248
93,205,150,248
125,254,1,40
36,254,0,32
45,205,150,248
125,18,19,11
62,0,176,177
254,0,32,241
205,150,248,221
125,254,0,32
30,62,42,205
124,248,195,19
248,205,150,248
33,255,248,205
140,248,33,128
128,233,33,235
248,205,140,248
195,120,248,33
245,248,205,140
248,195,120,248
0,195,120,248
245,219,128,203
79,40,250,241
211,129,201,245
215,111,241,201
126,183,200,205
124,248,35,195
140,248,245,213
205,135,248,125
214,48,254,10
56,2,214,7
87,205,135,248
125,214,48,254
10,56,2,214
7,95,203,34
203,34,203,34
203,34,178,209
38,0,111,241
197,6,0,77
221,9,193,201
72,69,88,32
76,79,65,68
69,82,32,98
121,32,70,105
108,105,112,112
111,32,66,101
114,103,97,109
97,115,99,111
10,13,0,10
13,73,78,86
32,84,89,80
0,10,13,66
65,68,32,67
72,75,0,10
13,79,75,0
print usr(0)

---- 8<--------------

Whereas you can try to load my super funny ( :P ) snake game from the attached hex file (note that is different from the previous version as it has been relocated at a different memory address).

A 10ms delay between each byte should be more than enough for a reliable upload.

Thank you for your help and suggestions :)

Filippo




On Fri, Jul 8, 2016 at 7:10 PM, Dave P <dpuc...@gmail.com> wrote:
Sorry that is not what I ment. 

I was suggesting that maybe we could utilise this somehow. I think you are right a two stage process. 

--
You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+...@googlegroups.com.
To post to this group, send email to rc201...@googlegroups.com.
snake.hex

Spencer Owen

unread,
Jul 8, 2016, 9:03:43 PM7/8/16
to rc201...@googlegroups.com
Ok, bad news, good news, bad news;

I couldn't get your new program to copy & paste in without errors :-(

However, modifying Daves program with your new data values did copy & paste in just fine.  And, from there, I could could copy & paste the Snake.hex file in and Snake runs! :-)

Sadly, though, I am no good at Snake when I'm drunk :-(  

Here's the code I used to get the new Hex Loader working;

------- 8<  ------

new
clear
10 let mb=-2048
20 for l=1 to 65
25 read a,b,c,d
26 rem print l*10 + 9000,a,b,c,d
31 poke mb, a
32 poke mb+1, b
33 poke mb+2, c
34 poke mb+3, d
35 let mb=mb+4
40 next l
50 poke -32696,195
60 poke -32695,0
70 poke -32694,248
100 print usr(0)
9010 data 33,255,255,249
9020 data 62,3,211,128
9030 data 62,150,211,128
9040 data 251,33,200,248
9050 data 205,140,248,205
9060 data 135,248,125,254
9070 data 58,194,19,248
9080 data 221,33,0,0
9090 data 205,150,248,68
9100 data 77,205,150,248
9110 data 85,205,150,248
9120 data 93,205,150,248
9130 data 125,254,1,40
9140 data 36,254,0,32
9150 data 45,205,150,248
9160 data 125,18,19,11
9170 data 62,0,176,177
9180 data 254,0,32,241
9190 data 205,150,248,221
9200 data 125,254,0,32
9210 data 30,62,42,205
9220 data 124,248,195,19
9230 data 248,205,150,248
9240 data 33,255,248,205
9250 data 140,248,33,128
9260 data 128,233,33,235
9270 data 248,205,140,248
9280 data 195,120,248,33
9290 data 245,248,205,140
9300 data 248,195,120,248
9310 data 0,195,120,248
9320 data 245,219,128,203
9330 data 79,40,250,241
9340 data 211,129,201,245
9350 data 215,111,241,201
9360 data 126,183,200,205
9370 data 124,248,35,195
9380 data 140,248,245,213
9390 data 205,135,248,125
9400 data 214,48,254,10
9410 data 56,2,214,7
9420 data 87,205,135,248
9430 data 125,214,48,254
9440 data 10,56,2,214
9450 data 7,95,203,34
9460 data 203,34,203,34
9470 data 203,34,178,209
9480 data 38,0,111,241
9490 data 197,6,0,77
9500 data 221,9,193,201
9510 data 72,69,88,32
9520 data 76,79,65,68
9530 data 69,82,32,98
9540 data 121,32,70,105
9550 data 108,105,112,112
9560 data 111,32,66,101
9570 data 114,103,97,109
9580 data 97,115,99,111
9590 data 10,13,0,10
9600 data 13,73,78,86
9610 data 32,84,89,80
9620 data 0,10,13,66
9630 data 65,68,32,67
9640 data 72,75,0,10
9650 data 13,79,75,0


Filippo Bergamasco

unread,
Jul 9, 2016, 2:28:59 AM7/9/16
to rc201...@googlegroups.com
Wow that's great!! Thank you for your test.
I'll modify the python script pushing the hex loader code using the approach proposed by Dave. But first, I have to read what that "data" keyword does :P

Now that I can test what I do on the real hardware, more games and goodies will follow :D



Dave P

unread,
Jul 9, 2016, 3:22:01 AM7/9/16
to RC2014-Z80, RC201...@googlegroups.com
Just to confirm this is much better! 

I have everything working with two cut and pastes. 


Dave P

unread,
Jul 10, 2016, 9:36:10 AM7/10/16
to RC2014-Z80, RC201...@googlegroups.com
More notes.... 

Please correct me if I am wrong as I am working this out on my own.

Start of Ram = 32768 8000h
RAM used by BASIC and serial buffers = 336 150h
Free Ram Left = 32432 7eb0h

Add some buffers and string space. 

That leaves the min free memory top to be 33187 81a3h

You need a basic loader so would not not be able to use that as you will need space for that. 

So if you allow a total of 2K for the Serial +  Basic work space + Basic program area (1691 bytes) and make RAMTOP 34817 

That leave 31k free for Machine code between address A000h to FFFFh 

I need to take in to account the stack too..

Yes?






Dave Pucknell

unread,
Jul 10, 2016, 9:40:39 AM7/10/16
to RC2014-Z80
Correction. Leaves 30K.

On 10/07/16 14:36, Dave P wrote:
More notes.... 

Please correct me if I am wrong as I am working this out on my own.

Start of Ram = 32768 8000h
RAM used by BASIC and serial buffers = 336 150h
Free Ram Left = 32432 7eb0h

Add some buffers and string space. 

That leaves the min free memory top to be 33187 81a3h

You need a basic loader so would not not be able to use that as you will need space for that. 

So if you allow a total of 2K for the Serial +  Basic work space + Basic program area (1691 bytes) and make RAMTOP 34817 

That leave 30k free for Machine code between address A000h to FFFFh 

I need to take in to account the stack too..

Yes?






--
You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+...@googlegroups.com.
To post to this group, send email to rc201...@googlegroups.com.

Filippo Bergamasco

unread,
Jul 10, 2016, 10:19:25 AM7/10/16
to rc201...@googlegroups.com
I haven't checked the details but I think I have a little bit more than that. Currently my asm-based hex loader weights 260bytes that can be loaded at the upper part of the memory just before the stack. even if we consider another 100 bytes of stack (more than enough) this leaves more than 32279 bytes if I load the hex file from 0x8080.
Anyway... you are right that more or less you have 30k to play with... Unfortunately... it will be very slow to load 30k of data :P



Dave P

unread,
Jul 10, 2016, 3:27:50 PM7/10/16
to RC2014-Z80
SLOW? I think if we wanted speed we may have made the wrong choice.. 





On Sunday, 10 July 2016 15:19:25 UTC+1, Filippo Bergamasco wrote:
I haven't checked the details but I think I have a little bit more than that. Currently my asm-based hex loader weights 260bytes that can be loaded at the upper part of the memory just before the stack. even if we consider another 100 bytes of stack (more than enough) this leaves more than 32279 bytes if I load the hex file from 0x8080.
Anyway... you are right that more or less you have 30k to play with... Unfortunately... it will be very slow to load 30k of data :P


On Sun, Jul 10, 2016 at 3:40 PM, Dave Pucknell <dpuc...@gmail.com> wrote:
Correction. Leaves 30K.

On 10/07/16 14:36, Dave P wrote:
More notes.... 

Please correct me if I am wrong as I am working this out on my own.

Start of Ram = 32768 8000h
RAM used by BASIC and serial buffers = 336 150h
Free Ram Left = 32432 7eb0h

Add some buffers and string space. 

That leaves the min free memory top to be 33187 81a3h

You need a basic loader so would not not be able to use that as you will need space for that. 

So if you allow a total of 2K for the Serial +  Basic work space + Basic program area (1691 bytes) and make RAMTOP 34817 

That leave 30k free for Machine code between address A000h to FFFFh 

I need to take in to account the stack too..

Yes?






--
You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+unsubscribe@googlegroups.com.

To post to this group, send email to rc201...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rc2014-z80/b0efc318-2fca-47d2-a768-561ab1a14700%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+unsubscribe@googlegroups.com.

To post to this group, send email to rc201...@googlegroups.com.

Dave P

unread,
Jul 11, 2016, 10:00:27 AM7/11/16
to RC2014-Z80, RC201...@googlegroups.com
I have been playing with the hex loader and making it more readable and flexible. (I hope)

new
clear

10 REM Created by Filippo Bergamasco and modified by DaveP for the RC2014
20 REM Version 0.01
30 Print "Loading Data"
40 let mb=&Hf800
50 print "Start Address:",hex$(mb)
60 REM Go to READ Subroutine.
70 GOSUB 1000
80 print "End Address:",hex$(mb-1)

90 REM Change Pointer for USR
100 GOSUB 1100

110 REM RUN THE CODE!
120 print usr(0)
130 END
 
1000 REM Routine to load Data
1010 REM Needs var mb set to start location20 read a
1020 read a
1030 if a>255 then RETURN
1040 rem print HEX$(mb),a
1050 poke mb, a
1060 let mb=mb+1
1070 goto 1020

1100 REM    Location of pointer &H8049
1110 print "Change Jump Location"
1120 let mb=&H8048
1130 REM    JP start address (c3 00 f8) jp f800
1140 poke mb,&Hc3
1150 poke mb+1,&H00
1160 poke mb+2,&Hf8
1170 RETURN
 
9010 data 33,255,255,249,62,3,211,128,62,150,211,128
9040 data 251,33,200,248,205,140,248,205,135,248,125,254
9070 data 58,194,19,248,221,33,0,0,205,150,248,68
9100 data 77,205,150,248,85,205,150,248,93,205,150,248
9130 data 125,254,1,40,36,254,0,32,45,205,150,248
9160 data 125,18,19,11,62,0,176,177,254,0,32,241
9190 data 205,150,248,221,125,254,0,32,30,62,42,205
9220 data 124,248,195,19,248,205,150,248,33,255,248,205
9250 data 140,248,33,128,128,233,33,235,248,205,140,248
9280 data 195,120,248,33,245,248,205,140,248,195,120,248
9310 data 0,195,120,248,245,219,128,203,79,40,250,241
9340 data 211,129,201,245,215,111,241,201,126,183,200,205
9370 data 124,248,35,195,140,248,245,213,205,135,248,125
9400 data 214,48,254,10,56,2,214,7,87,205,135,248
9430 data 125,214,48,254,10,56,2,214,7,95,203,34
9460 data 203,34,203,34,203,34,178,209,38,0,111,241
9490 data 197,6,0,77,221,9,193,201,72,69,88,32
9520 data 76,79,65,68,69,82,32,98,121,32,70,105
9550 data 108,105,112,112,111,32,66,101,114,103,97,109
9580 data 97,115,99,111,10,13,0,10,13,73,78,86
9610 data 32,84,89,80,0,10,13,66,65,68,32,67
9640 data 72,75,0,10,13,79,75,0
9900 REM THIS IS THE END MARKER
9900 data    999

9999 END
run



Is this any clearer? 

Key points I wanted to make clear was
 Memory addresses. (I cant think in twos compliment) Lets use hex as that is clearer. 
 Can be used to load any length code no need to work it out before hand. Just end the data with a number greater than 255.

Open to comments!


Filippo Bergamasco

unread,
Jul 11, 2016, 10:07:11 AM7/11/16
to rc201...@googlegroups.com
I like it a lot!

I'm in the process or refactor a bit the whole build environment of the stuff I did so that one can easily choose between a ram only model (to be used with the hexloader) or rom/ram model to be directly burned in an eeprom. Once ready I'll commit everything in the official RC2014 repository (ready soon!) together with your basic loader :)

Cheers!
Filippo


--
You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+...@googlegroups.com.

To post to this group, send email to rc201...@googlegroups.com.

Dave P

unread,
Jul 13, 2016, 5:58:36 AM7/13/16
to RC2014-Z80, RC201...@googlegroups.com
New and Improved version. I when I mean improved I mean SLOWER. 


10 REM Created by Filippo Bergamasco and modified by DaveP for RC2014
20 REM Version 0.02

30 Print "Loading Data"
40 let mb=&Hf800
50 print "Start Address:",hex$(mb)
60 REM Go to READ Subroutine.
70 GOSUB 1000
80 print "End Address:",hex$(mb-1)


90 REM Change Pointer for USR
100 GOSUB 1100


110 REM RUN THE CODE!
120 print usr(0)
130 END
 
1000 REM Routine to load Data
1010 REM Needs var mb set to start location
1020 read H$


1024 GOSUB 9000
1026 rem PRINT A;

1030 if a>255 then RETURN
1040 rem print HEX$(A)

1050 poke mb, a
1060 let mb=mb+1
1070 goto 1020


1100 REM    Location of pointer &H8049
1110 print "Change Jump Location"
1120 let mb=&H8048
1130 REM    JP start address (c3 00 f8) jp f800
1140 poke mb,&Hc3
1150 poke mb+1,&H00
1160 poke mb+2,&Hf8
1170 RETURN






9000 REM HEX TO DECIMAL CONVERTER
9010 REM NEEDS H$ AS INPUT HEX
9020 REM OUTPUTS A AS DECIMAL


9050 A=0:D=1
9060 FOR P=LEN(H$)-1 TO 0 STEP -1
9070 C=ASC(MID$(H$,D,1))
9080 D=D+1
9090 IF(C>=48)*(C<=57) THEN C=C-48:GOTO 9130
9100 IF(C>=65)*(C<=70) THEN C=C-55:GOTO 9130


9110 PRINT "PRINT ERROR IN ";H$
9120 END


9130 A=A+C*16^P
9140 NEXT
9150 RETURN






9501 DATA "21","FF","FF","F9","3E","3","D3","80","3E","96"
9502 DATA "D3","80","FB","21","C8","F8","CD","8C","F8","CD"
9503 DATA "87","F8","7D","FE","3A","C2","13","F8","DD","21"
9504 DATA "0","0","CD","96","F8","44","4D","CD","96","F8"
9505 DATA "55","CD","96","F8","5D","CD","96","F8","7D","FE"
9506 DATA "1","28","24","FE","0","20","2D","CD","96","F8"
9507 DATA "7D","12","13","B","3E","0","B0","B1","FE","0"
9508 DATA "20","F1","CD","96","F8","DD","7D","FE","0","20"
9509 DATA "1E","3E","2A","CD","7C","F8","C3","13","F8","CD"
9510 DATA "96","F8","21","FF","F8","CD","8C","F8","21","80"
9511 DATA "80","E9","21","EB","F8","CD","8C","F8","C3","78"
9512 DATA "F8","21","F5","F8","CD","8C","F8","C3","78","F8"
9513 DATA "0","C3","78","F8","F5","DB","80","CB","4F","28"
9514 DATA "FA","F1","D3","81","C9","F5","D7","6F","F1","C9"
9515 DATA "7E","B7","C8","CD","7C","F8","23","C3","8C","F8"
9516 DATA "F5","D5","CD","87","F8","7D","D6","30","FE","A"
9517 DATA "38","2","D6","7","57","CD","87","F8","7D","D6"
9518 DATA "30","FE","A","38","2","D6","7","5F","CB","22"
9519 DATA "CB","22","CB","22","CB","22","B2","D1","26","0"
9520 DATA "6F","F1","C5","6","0","4D","DD","9","C1","C9"
9521 DATA "48","45","58","20","4C","4F","41","44","45","52"
9522 DATA "20","62","79","20","46","69","6C","69","70","70"
9523 DATA "6F","20","42","65","72","67","61","6D","61","73"
9524 DATA "63","6F","A","D","0","A","D","49","4E","56"
9525 DATA "20","54","59","50","0","A","D","42","41","44"
9526 DATA "20","43","48","4B","0","A","D","4F","4B"


9699 DATA "FFFF"

Scott Lawrence

unread,
Jul 14, 2016, 12:06:15 PM7/14/16
to rc201...@googlegroups.com
I've never used the USR() function before, can you confirm this for me? :
(I looked around through NASCOM BASIC pdfs but couldn't really get the answers...)

When USR( 0 ) is called, the BASIC interpreter will jump to address $8048 and continue execution there, so what you've done is replaced the 3 bytes that start at that address with a JP to 0xF800

eg:
.org 0x8048
    jp 0xF800

(Where does the parameter passed in, '0' in this example) end up?  If i wanted to use this parameter, what address is it stored in?

F800 is a safe place to put a chunk of code, (as long as you tell BASIC this when you start: it will ask "Memory Top?" and you type... what?)

So the basic procedure that you're doing above is:

1. start up basic leaving off some space atop memory at $F800
2. the basic program runs, copying the program in the DATA block to $F800 thru (wherever it ends)
3. call USR( 0 )
4. BASIC interperter calls USR function with parameter 0, which does a jump to our code block at $F800
5. our machine language block runs.

-s


--
You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+...@googlegroups.com.
To post to this group, send email to rc201...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Scott Lawrence
yor...@gmail.com

Dave Pucknell

unread,
Jul 14, 2016, 12:12:58 PM7/14/16
to rc201...@googlegroups.com
You are correct in all counts. 

Write a simple test like

LD A,’S’
RST 08
RET

4 Bytes.. And prints S on the screen.

I have been sort of mapping the memory and setting the RAMTOP (Memory top at start) and also using CLEAR. Not for public consumption yet.

DAVE


Scott Lawrence

unread,
Jul 14, 2016, 12:36:01 PM7/14/16
to rc201...@googlegroups.com
Excellent.  Okay, so help me fill in the blanks here by doing this super-distilled small example based off of yours above...

If i were to write a simple routine that printed out to the terminal whatever parameter were passed in, to print out the text "Hi!", the pieces needed:

10 REM install the USR handler
20 GOSUB 100

30 REM Call it
40 USR( 72 )
50 USR( 105 )
60 USR( 33 )
70 END

100 GOSUB 200
110 GOSUB 300
120 RETURN

100 REM Copy code from DATA to F800
... (code here from the prvious examples to copy the data in to 0xF800 and above)
    a combination of READ from DATA and POKE to F800+index
199 RETURN

200 REM install the USR handler (from your code)
210 REM    Location of pointer &H8049
220 print "Change Jump Location"
230 let mb=&H8048
240 REM    JP start address (c3 00 f8) jp f800
250 poke mb,&Hc3
260 poke mb+1,&H00
270 poke mb+2,&Hf8
280 RETURN

1000 REM Data block
... code is assembled binary list from this asm:

.define USERPARAM  0x????
.org 0xF800
MyUser:
    LD a, #USERPARAM
    RST 08
    RET


What is the value of USERPARAM?  

-s




For more options, visit https://groups.google.com/d/optout.



--
Scott Lawrence
yor...@gmail.com

Dave Pucknell

unread,
Jul 14, 2016, 1:05:43 PM7/14/16
to rc201...@googlegroups.com
Right I think you need to take a small step to get the concepts......

A good test is the following....

9000                          .ORG   09000h  
9000   3E 48                  LD   a,'H'   ; Contents of HL into A
9002   CF                     RST   08h   ; Call the output routine.
9003   C9                     RET   ; Stop!

So only 4 bytes. And not dependent on memory location.

3E 48 CF C9

So if we take the loader and use this small bit of code...
Look at line.... 9501 ..... !!!!

9501 DATA "3E","48","CF","C9"


9699 DATA "FFFF"


Now Run..

You should get the output...

Loading Data
Start Address:              F800
End Address:  F803
Change Jump Location
H 0
Ok

See that H .. We did that! We put the value 48h in the A register then called the output routine (RST 08) and then exited...

Now what you want to do is something a bit more advanced......

            .ORG    09000h ; For RC2014 40960

START:             
                   
            LD      hl,line1 ; Load the address of the string into HL
            CALL    printline ; Fire up the print routine!
            RET     ; Return to basic

PRINTLINE:         
            LD      a,(hl) ; Contents of HL into A
            CP      00 ; Check for End of String
            JP      z,printend ;   If found jump to print end.
            RST     08
            INC     hl ; Add one to HL
            JP      printline ; LOOP!

PRINTEND:          
            RET     ; Stop!

LINE1:             
            DB      "Lets start this thing",13,00



This does the same as before starting at the beginning of the string getting one character, looping and printing out all the sting one by one. the 13 is a return and the 00 is the end marker.

Hex for you...

F800 21 13 F8 CD| 07 F8 C9 7E
F808 FE 00 CA 12| F8 CF 23 C3
F810 07 F8 C9 4C| 65 74 73 20
F818 73 74 61 72| 74 20 74 68
F820 69 73 20 74| 68 69 6E 67

Dave...

(If you want we can Skype and I can share screen.)

Scott Lawrence

unread,
Jul 14, 2016, 1:25:17 PM7/14/16
to rc201...@googlegroups.com
Thanks.  I'm actually at work waiting for compiles right now. 

I understand the Z80-asm side of things, and I understand the BASIC side of things, but the interactions between the two are completely new to me...  The two things that I don't yet know:

1. I know that in order to have space to copy the program in to, you need to adjust that when you start BASIC... when it asks the memory top question, you need to enter a value there, and not just hit return.  for the above example, what do you enter there?

2. How do you get the parameter passed in from the BASIC USR() call?  I assume that's stashed away in some memory address somewhere.... where is that?

-s


For more options, visit https://groups.google.com/d/optout.



--
Scott Lawrence
yor...@gmail.com

DaveP

unread,
Jul 14, 2016, 1:30:03 PM7/14/16
to RC2014-Z80
1) You don't need to reserve not for this example. All I do i leave it blank. 

2) As for parameters inside the USR(). Not got a clue yet. 

DAVE

Dave Pucknell

unread,
Jul 14, 2016, 3:13:12 PM7/14/16
to RC2014-Z80

> 2) As for parameters inside the USR(). Not got a clue yet.
>
I do now....

USR(x) Where x is the RETURN value. It is not a parameter to pass (like
in C)



let test=usr(1)

Lets start this thing

Ok
print test
1
Ok
let test=usr(2)

Lets start this thing

Ok
print test
2
Ok


DAVE

Filippo Bergamasco

unread,
Jul 14, 2016, 3:41:37 PM7/14/16
to rc201...@googlegroups.com
And what is the intended usage of that?

- Filippo
> --
> You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+...@googlegroups.com.
> To post to this group, send an email to rc201...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/rc2014-z80/5787E446.8030302%40gmail.com.

Niels Moseley

unread,
Jul 14, 2016, 3:47:01 PM7/14/16
to rc201...@googlegroups.com
That doesn't feel correct.

I suspect the parameter is put in one of the registers. My guess would be the A register. A return parameter is most likely returned in the same way; via the A register. Thus, If your code doesn't touch the A register, the return value will be equal to the USR parameter.

I can't check it as I'm travelling this week and only have a phone :-/

Regards,
Niels
> --
> You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+...@googlegroups.com.
> To post to this group, send an email to rc201...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/rc2014-z80/5787E446.8030302%40gmail.com.

Scott Lawrence

unread,
Jul 14, 2016, 3:56:39 PM7/14/16
to rc201...@googlegroups.com
Ok. Found it

Section Appendix D

- Looks like it pushes 16 bytes of stack space for general use.
- Call the function DEINT to get the parameter to register pair DE
- do your work
- Return value goes into register pair AB (which is weird to me... why not BC?)
- Call ABPASS
- ret

In the NASCOM BASIC source, 
        ORG     0E000H

START:  JP      STARTB          ; Jump for restart jump
STARTB: DI                      ; No interrupts
        LD      IX,0            ; Flag cold start
        JP      CSTART          ; Jump to initialise

        DW      DEINT           ; Get integer -32768 to 32767
        DW      ABPASS          ; Return integer in AB
The NASCOM manual actually says to call the function whose high and low bytes are at those specific locations... so to extrapolate....
or in ours (32k RAM version) (I have two copies of the BASIC source, one starts at 0x0150, one starts at 0x100...)

.ORG 00150H
COLD: JP STARTB ; Jump for cold start
WARM: JP WARMST ; Jump for warm start
STARTB:
LD IX,0 ; Flag cold start
JP CSTART ; Jump to initialise
.WORD DEINT ; Get integer -32768 to 32767
.WORD ABPASS ; Return integer in AB

so to call DEINT, call the function whose address is at 0x015D, 0x15E
to call ABPASS, call the function whose address isat 0x015F, 0x160

for our ROM:

DEINT = 0x0A07
ABPASS = 0x117D

so your asm usr code:

myUsr:
    call DEINT
    ; do something with DE
    ; store result in AB
    call ABPASS
    ret

I can't confirm right now, but this seems to be reasonable...

The document also says that if you don't call these, the USR() BASIC function will return whatever was passed in.

-s


--
You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+...@googlegroups.com.
To post to this group, send an email to rc201...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rc2014-z80/5787E446.8030302%40gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Scott Lawrence
yor...@gmail.com

N.A. Moseley

unread,
Jul 14, 2016, 4:09:13 PM7/14/16
to rc201...@googlegroups.com

Great stuff! Thanks for digging into this!

Niels.

Filippo Bergamasco

unread,
Jul 14, 2016, 4:18:00 PM7/14/16
to rc201...@googlegroups.com
AB is really weird but what you said looks correct :) nice job!

- Filippo

DaveP

unread,
Jul 16, 2016, 5:47:56 AM7/16/16
to RC2014-Z80, RC201...@googlegroups.com
What are people using to create the hex files?

I am using http://www.asm80.com/ and having some issues.

I start with some test code.

<code>
            .ORG    09000h 
            LD      a,'H' ; Contents of HL into A
            RST     08h ; Call the output routine.
            RET     ; Stop!
</code>

I "Poke" the code manually and it works. 

<code>
3E 4A CF C9
</code>

I try to load the hex that ASM80 produced and it crashes and restarts.

<code>
:059000007ACF7BCFC90F
:00000001FF
</code>

I am guessing ASM80 does not produce the right HEX format. Any one have any ideas? Or a better way?

DAVE

Filippo Bergamasco

unread,
Jul 16, 2016, 7:29:36 AM7/16/16
to rc201...@googlegroups.com
I use Intel hex for 3 reasons:
1) is a more compact representation than binary (you need 2 bytes for each encoded byte instead of 3)
2) the checksum is included so I can check if the data transfer was good
3) there are plenty of tools to convert from binary to hex

Your test crashes since my loader always jumps to 0x8080 after the upload. 
The sources are here:



- Filippo
--
You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+...@googlegroups.com.
To post to this group, send email to rc201...@googlegroups.com.

corrado...@gmail.com

unread,
Oct 3, 2016, 7:08:03 AM10/3/16
to RC2014-Z80, RC201...@googlegroups.com

Hi Filippo,
I have read many of the your posts... You are great!
Now, before to buy RC2014, I'm trying it on z80-machine

At the moment I'm be able to:

./bin/rc2014

Z80 System Emulator
 v3.1.1 February 2016
   2016 Scott Lawrence
   2016 Duncan McGreggor
   1994-1995 CodeGen, Inc
   1986-1988 Parag Patel

Starting up...

 '?' for help                                                                                                                                                                                                                               
 'g' to execute Z80                                                                                                                                                                                                                         
 ctrl-'-' to break                                                                                                                                                                                                                          
                                                                                                                                                                                                                                            
Emulation of the RC2014 system                                                                                                                                                                                                              
    version 1.00  2016-07-13                                                                                                                                                                                                                
  RC2014 by Spencer Owen                                                                                                                                                                                                                    
  SBC by Grant Searle!!!                                                                                                                                                                                                                    
  Emu by Scott Lawrence                                                                                                                                                                                                                     
                                                                                                                                                                                                                                            
Mem region 0: 0x0000 - 0x1fff (ROM) ROMs/basic.32.rom: 8192 bytes                                                                                                                                                                           
Mem region 1: 0x8000 - 0xffff (ram)                                                                                                                                                                                                         
                                                                                                                                                                                                                                            
Z80 SBC By Grant Searle                                                                                                                                                                                                                     
                                                                                                                                                                                                                                            
Memory top?                                                                                                                                                                                                                                 
Z80 BASIC Ver 4.7b                                                                                                                                                                                                                          
Copyright (C) 1978 by Microsoft                                                                                                                                                                                                             
32382 Bytes free
Ok

Then I'm trying to load your simple inetlHex:

10 REM Created by Filippo Bergamasco and modified by DaveP for the RC2014
...
9999 END
run


Loading Data
Start Address:              F800
End Address:  F903
Change Jump Location
HEX LOADER by Filippo Bergamasco

Now I paste your .hex code:

:10800000F321FFFFF9C33E80F5DB80CB4F28FAF167
:10801000D381C9F5DB80CB4728FADB8126006FF1DD
:10802000C97DCD0880C92E00DB80CB47C82E01C991
:10803000C54DED4068C1C9C54C45ED41C1C9ED73A1
:108040002182212382018C001E00CDF58021258212
:10805000018000CD6380CD2581C3D480E5E1ED7B37
:108060002182C95D54E5C50E01CD0681DA858021E6
:10807000060019EBC109AF2B772B77EB7323722323
:10808000CDCA80E1C9E1E1CD8D8023C9E12E09C3CC
:108090009780E1E1E12EFF2600222382C3A280E146
:1080A000E1E121FFFF37C9E1E1E1E121000037C94A
:1080B000E1C97723772377237723772377237723E0
:1080C00077237723772377237723772377237723E0
:1080D0007723C9E911A7821AB7CA5C80E56F260029
:1080E000291947562B5E2BC5E5EBCDD380E1C11096
:1080F000F2E1C35C8078B17B5D54C877130B78B133
:10810000C8E5EDB0E1C979E6F8201579E607281051
:10811000AFCDC6802B2B2B36FE2B2B71210000C937
:1081200021010037C9210A0022AD8221F881CD3515
:1081300081C32B81C97EB7C8CF23C335813E00B42C
:10814000B528273E000118FCCD5B81019CFFCD5B6B
:10815000810EF6CD5B8148C365813C0938FCED4258
:10816000B7C8C36A810938F2ED42C630CF3E00C9B4
:108170007CCD7F817CCD83817DCD7F817D18041F67
:108180001F1F1FF6F027C6A0CE40CFC9CDE8812122
:108190000482CD3581C9CDE88121FF81CD3581C9EA
:1081A000CDE881210982CD3581C9E5CDE881210C59
:1081B00082CD3581E1CD3D813E6DCFC9E5CDE881F0
:1081C000211282CD3581E1CD3D813E6DCFC9CDE813
:1081D00081D1C1E1D5C5CD3D813E3BCFE1CD3D81D2
:1081E0003E48CFE1E5E5E5C93E1BCF3E5BCFC9097F
:1081F000454E4F4C434B000048454C4C4F21003FEF
:1082000032356C003F32356800324A0033383B3536
:108210003B0034383B353B0000258200001B8201C7
:00000001FF


 but I receive the following errror:

Illegal instruction 0x7D at PC=0xF84C

:10" not recognized81E1CD3D813E6DCFC9CDE8137
EMU:

Could you help me to understand why?

Do you suggest me an assembler program to generate .hex (intelHEX) code for RC2014?

Thanks.
Corrado.


















Il giorno venerdì 8 luglio 2016 09:59:22 UTC+2, Filippo Bergamasco ha scritto:
Dear friends,
I'm working to build a simple hex loader that can be used for everybody like me that cannot afford (yet) an eeprom programmer. What I do is basically the following:

1) Use a simple basic program to load the the hex loader in the upper part of the ram memory. such loader is written in z80 assembly for speed/size reasons

2) use usr() to jump to the hex loader

3) transfer the hex file and store it at correct memory locations (checksums are also properly checked)

4) the hex loader jumps at location 0x8000


I you want to try it, here are the basic steps:

1) Boot the RC2014 to get the basic prompt
2) Paste the following listing

--------------------- 8<  [CUT HERE] ----------------
clear
10 let mb=-2048
20 for l=1 to 69
30 input "";a,b,c,d
31 poke mb, a
32 poke mb+1, b
33 poke mb+2, c
34 poke mb+3, d
35 let mb=mb+4
40 next l
50 poke -32696,195
60 poke -32695,0
70 poke -32694,248
run
243,33,255,255
249,62,150,211
128,243,33,214
248,205,154,248
205,137,248,125
254,58,194,16
248,221,33,0
0,205,164,248
68,77,205,164
248,85,205,164
248,93,205,164
248,125,254,1
40,41,254,0
32,50,205,164
248,125,18,19
11,62,0,176
177,254,0,32
241,62,124,205
126,248,205,164
248,221,125,254
0,32,30,62
42,205,126,248
195,16,248,205
164,248,33,13
249,205,154,248
33,0,128,233
33,249,248,205
154,248,195,122
248,33,3,249
205,154,248,195
122,248,0,195
122,248,245,219
128,203,79,40
250,241,211,129
201,245,219,128
203,71,40,250
219,129,38,0
111,205,126,248
241,201,126,183
200,205,126,248
35,195,154,248
245,213,205,137
248,125,214,48
254,10,56,2
214,7,87,205
137,248,125,214
48,254,10,56
2,214,7,95
203,34,203,34
203,34,203,34
178,209,38,0
111,241,197,6
0,77,221,9
193,201,72,69
88,32,76,79
65,68,69,82
32,98,121,32
70,105,108,105
112,112,111,32
66,101,114,103
97,109,97,115
99,111,10,13
0,10,13,73
78,86,32,84
89,80,0,10
13,66,65,68
32,67,72,75
0,10,13,79
75,0,0,0
print usr(0)
--------------------- 8<  [CUT HERE] ----------------

3) You should see:
HEX LOADER by Filippo Bergamasco

4) Paste your hex file, for example:

--------------------- 8<  [CUT HERE] ----------------

:10800000F321FFFFF9C33E80F5DB80CB4F28FAF167
:10801000D381C9F5DB80CB4728FADB8126006FF1DD
:10802000C97DCD0880C92E00DB80CB47C82E01C991
:10803000C54DED4068C1C9C54C45ED41C1C9ED73A1
:108040002182212382018C001E00CDF58021258212
:10805000018000CD6380CD2581C3D480E5E1ED7B37
:108060002182C95D54E5C50E01CD0681DA858021E6
:10807000060019EBC109AF2B772B77EB7323722323
:10808000CDCA80E1C9E1E1CD8D8023C9E12E09C3CC
:108090009780E1E1E12EFF2600222382C3A280E146
:1080A000E1E121FFFF37C9E1E1E1E121000037C94A
:1080B000E1C97723772377237723772377237723E0
:1080C00077237723772377237723772377237723E0
:1080D0007723C9E911A7821AB7CA5C80E56F260029
:1080E000291947562B5E2BC5E5EBCDD380E1C11096
:1080F000F2E1C35C8078B17B5D54C877130B78B133
:10810000C8E5EDB0E1C979E6F8201579E607281051
:10811000AFCDC6802B2B2B36FE2B2B71210000C937
:1081200021010037C9210A0022AD8221F881CD3515
:1081300081C32B81C97EB7C8CF23C335813E00B42C
:10814000B528273E000118FCCD5B81019CFFCD5B6B
:10815000810EF6CD5B8148C365813C0938FCED4258
:10816000B7C8C36A810938F2ED42C630CF3E00C9B4
:108170007CCD7F817CCD83817DCD7F817D18041F67
:108180001F1F1FF6F027C6A0CE40CFC9CDE8812122
:108190000482CD3581C9CDE88121FF81CD3581C9EA
:1081A000CDE881210982CD3581C9E5CDE881210C59
:1081B00082CD3581E1CD3D813E6DCFC9E5CDE881F0
:1081C000211282CD3581E1CD3D813E6DCFC9CDE813
:1081D00081D1C1E1D5C5CD3D813E3BCFE1CD3D81D2
:1081E0003E48CFE1E5E5E5C93E1BCF3E5BCFC9097F
:1081F000454E4F4C434B000048454C4C4F21003FEF
:1082000032356C003F32356800324A0033383B3536
:108210003B0034383B353B0000258200001B8201C7
:00000001FF

--------------------- 8<  [CUT HERE] ----------------

5) Once loaded you should see a lot of "HELLO" on the screen. That is actually
the program that you've just loded



And now the bad news:

It's hard for me to load a relatively long hex file because sometime I miss some bytes. In general the UART communication is very unreliable. Sometimes I get wrong characters, sometimes I completely miss some of them. We already mentioned this problem in a previous discussion. If you use RC2014 with the keyboard is not a problem but when you want to transfer some data it is quite annoying.
Apparently, the problem is still there even if I add a delay (even a big delay!) between the characters. Sounds like the ACIA chip is not working properly to me.... Any suggestion?


Filippo


Scott Lawrence

unread,
Feb 21, 2017, 10:28:00 PM2/21/17
to rc201...@googlegroups.com
Filippo: would you mind if i copied your hex loader.bas and the loader.asm into my project? It's the missing piece to make my boot stuff work... I'll likely copy your asm code and extend it to work with my filesystem io stuff, but i just want to get your permission to include it within my project. (with all the proper credits of course.)

-s

--
You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+unsubscribe@googlegroups.com.

To post to this group, send email to rc201...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Scott Lawrence
yor...@gmail.com

Scott Lawrence

unread,
Feb 22, 2017, 2:32:13 PM2/22/17
to rc201...@googlegroups.com
Nevermind. I forgot i wrote my own version with a .LST file to BASIC converter... it's even in my own repository... hah! 


--
Scott Lawrence
yor...@gmail.com
Reply all
Reply to author
Forward
0 new messages