Pasting a hex file into SCM

99 views
Skip to first unread message

Rob Hunter

unread,
Oct 26, 2022, 6:20:45 AM10/26/22
to retro-comp
Hi, all. I have successfully built a SC516 card and I can communicate with the SCM using either minicom or screen on my macbook. I can enter a BASIC program and run it so all is well there.

I have created a small  hello world program in assembly language:

----------

org 8000h

C_WRITESTR equ 0x06     ; API function to print a $ terminated string

        ld de, Hello_TXT        ; Load the address of the Hello_TXT label into DE

        ld c, C_WRITESTR        ; C must contain BDOS function number

        RST 0x30

        ret                     ; Return to the SCM

Hello_TXT: db 0x0D,0x0A,"Hello World!",0x0D,0x0A,"$"    ; The $ terminated string to be printed


-------

The assembler output:

z88dk-z80asm -v ./hwZ80.asm -b -l                     

Predefined constant: __CPU_Z80__ = 1

Predefined constant: __CPU_ZILOG__ = 1

Predefined constant: __FLOAT_GENMATH__ = 1

Assembling 'hwZ80.asm' to 'hwZ80.o'

Reading 'hwZ80.asm' = 'hwZ80.asm'

Writing object file 'hwZ80.o'

Module 'hwZ80' size: 24 bytes


Code size: 24 bytes ($8000 to $8017)

Creating binary './hwZ80.bin'


Then using appmake I create an Intel HEX file.

z88dk-appmake  +hex -b ./hw.bin -o hw.hex --org 0x8000

----------

The resulting HEX output is:

:100000001107800E06F7C90D0A48656C6C6F205702

:080010006F726C64210D0A24DB

:00000001FF

----------


My problem is with pasting bytes from a HEX code generated by the z88dk assembler. If I paste into screen using the rightclick 'paste' menu option or use minicoms 'paste file' option I get this

Small Computer Monitor - Z50Bus/Z80                                                                               

                                                                                                                  

*:0009ED0D866:8057602200F                                                                                         

Bad command 


-------


Can someone please tell me what I am doing wrong?

regards,

Rob



Steve Cousins

unread,
Oct 26, 2022, 7:44:06 AM10/26/22
to retro-comp
Hi Rob,

Your HEX file seems to be the problem.

This is your HEX file:

:100000001107800E06F7C90D0A48656C6C6F205702
:080010006F726C64210D0A24DB
:00000001FF

This is my HEX file:

:108000001107800E06F7C90A0A48656C6C6F205785
:108010006F726C64210D0A24FFFFFFFFFFFFFFFF5B
:00000001FF

Note that my first lines start ":108000" where yours start ":100000".

The first two bytes after the colon are the number of bytes of data in the line (eg. 10)
The next 4 are the start address (eg. 8000 for the first line and 8010 for the second line)

Your file loads to address 0x0000, not 0x8000.

The data bytes looks correct in your file.

You can ignore the extra FF values in my file.

One little point about your code: SCM strings are terminated with a null, not a '$'.

Here is my listing file:

                    0001  
                    0002              .PROC Z80           ;SCWorkshop select processor
                    0003              .HEXBYTES 0x10      ;SCWorkshop Intel Hex output format
                    0004  
                    0005  
                    0006              .ORG  0x8000
                    0007  
8000: 11 07 80      0008              LD  DE,Hello
8003: 0E 06         0009              LD  C,6
8005: F7            0010              RST 0x30
8006: C9            0011              RET
                    0012  
8007: 0A 0A 48 65   0013  Hello:      .DB 0x0A,0x0A,"Hello World!",0x0D,0x0A,"$"
800B: 6C 6C ...     0013  
                    0014  


If you edit your HEX file to include the correct addresses I think you will be able to download it okay.

Steve


Douglas Miller

unread,
Oct 26, 2022, 8:08:25 AM10/26/22
to retro-comp
Note that all digits in a HEX file are hexadecimal, so the length field "10" actually means 16 bytes represented (32 digits of data). Also note that the last two digits on each line are a checksum, and so you can't alter (edit) an existing HEX file without recomputing the checksum. Better to just get the assembler/source to correctly produce the desired/correct HEX file.

Rob Hunter

unread,
Oct 26, 2022, 9:10:29 AM10/26/22
to retro-comp
Hello Steven and thanks for taking the time to reply. I'm going to install the SCM IDE is windows and try what you have done. I did however paste your hex bytes:
:108000001107800E06F7C90A0A48656C6C6F205785
:108010006F726C64210D0A24FFFFFFFFFFFFFFFF5B
:00000001FF

 into the SCM app and I got. 

----

*2"52

Bad command

*

------

So I'm afraid that didn't work either. I'm assuming your checksum is correct as Douglas mentioned.
regards,
Rob

Steve Cousins

unread,
Oct 26, 2022, 9:38:37 AM10/26/22
to retro-comp
Hi Rob,

The reason the code did not produce "Hello World!" is that I assembled your code including the '$' terminator. When a null terminator is used the code runs correctly.

Here is the corrected HEX file:

:108000001107800E06F7C90A0A48656C6C6F205785
:108010006F726C64210D0A00FFFFFFFFFFFFFFFF7F
:00000001FF



Here is the terminal output:

Small Computer Monitor - Z50Bus/Z80
*Ready

*
*g8000


Hello World!
*


Here is the source code:


            .PROC Z80           ;SCWorkshop select processor
            .HEXBYTES 0x10      ;SCWorkshop Intel Hex output format

            .ORG  0x8000

            LD  DE,Hello
            LD  C,6
            RST 0x30
            RET

Hello:      .DB 0x0A,0x0A,"Hello World!",0x0D,0x0A,0



Steve

Rob Hunter

unread,
Oct 26, 2022, 10:01:53 AM10/26/22
to retro-comp
Hi Steve,


I tried pasting your hex code below and I get 

Small Computer Monitor - Z50Bus/Z80                                            

*2"52 


Might I ask which terminal program you are using to paste the bytes over?

regards,

Rob

Rob Hunter

unread,
Oct 26, 2022, 10:34:52 AM10/26/22
to retro-comp
Hi, I have retried using you hex code via Minicom with Ubuntu and it works. The issue would appear to be with the z88dk toolchain and/or its usage under macOS.
If I power cycle the card and then first fill 0x8000 with 20 NULL bytes, verify using dump to verify I only see NOPS and then try to load my hexcode for my source code the SCM says ok but if I dump 0x8000 onwards the bytes are still null.
If I do the same with your hexcode I can dump 0x8000 and see your bytes and the ' Hello World' message is displayed.
Reply all
Reply to author
Forward
0 new messages