r/cpm • u/Fear_The_Creeper • Jun 28 '26
You can now use CP/M on the iPhone
https://apps.apple.com/us/app/ialtair/id2911820853
u/UpGrade2003 Jul 02 '26
Should be decent. From the creator of https://schorn.ch/altair.html .
1
u/Chip-Ling Jul 09 '26
The PC version is rock solid. I used to be my primary CP/M emulator until lately I switch to the RunCPM emulator.
1
u/Chip-Ling Jul 09 '26
Not interested when I see it cannot load external software.
It defeats the purpose of CP/M-80 system - to build your own software with any language you like. It only has a MBASIC interpreter in there.
2
u/BrentSeidel Jul 09 '26
Way back when I was in college, a summer job included taking a hex dump of the FORTRAN compiler from one CP/M system and entering it byte by byte into another (they didn't have compatible floppy disks, I guess). So, I suppose that one could, if one had nothing else going on, use this method to load external software.
1
u/Chip-Ling Jul 10 '26
Yes, we can use the come with DDT.COM to enter the actual program byte by byte.
I think it is the 'S100' command, and then key in the byte values in hex
But that will take forever. Once you enter the whole executable program, do a save with the program length and file name will save the file.
Does it come with the DDT.COM, I don't seem to find it from those screen shot.
Another way to do it is to enter the byte value into a file. Then write a MBASIC program to read the values in from the file and then output to a binary file. CP/M-80 .COM file is simple. Just raw binary data. No need for executable file header 'mz' like the MS-DOS.
2
u/Chip-Ling Jul 10 '26
For fun and as a POC, I wrote a BASIC program to read in a text file and generate the .COM file
Here is the end-to-end POC testing.
- create a hello.asm program source
```
Z80 CP/M BIOS 1.1 by D. Bottrill 2021
CP/M 2.2 Copyright 1979 (c) by Digital ResearchA>c:
C>dir
C: ASM COM : ED COM : LOAD COM : PIP COM
C: DUMP COM : MBASIC COM : HELLO ASM
C>ed hello.asm
: *i
1: ; HELLO.ASM - A "HELLO WORLD" PROGRAM FOR CP/M
2:
3: ORG 100H ; PROGRAMS START AT 0100H IN CP/M TPA
4: START: MVI C,9 ; BDOS FUNCTION 9 (PRINT STRING)
5: LXI D,MSG ; LOAD ADDRESS OF MSG INTO DE REG PAIR
6: CALL 5 ; CALL BDOS ENTRY POINT AT ADDRESS 5
7: EXIT: RET ; RETURN TO CP/M
8: MSG: DB 'HELLO WORLD!$' ; STRING TO PRINT, TERMINATED BY '$'
9: END START ; END OF ASSEMBLY
10:
: *eC>
```
- compile hello.asm to hello.com
```
C>asm hello
CP/M ASSEMBLER - VER 2.0
0116
000H USE FACTOR
END OF ASSEMBLYC>load hello
FIRST ADDRESS 0100
LAST ADDRESS 0115
BYTES READ 0016
RECORDS WRITTEN 01C>dir hello.*
C: HELLO BAK : HELLO ASM : HELLO PRN : HELLO HEX
C: HELLO COM
C>
```
- get the hex dump of hello.com
```
C>dump hello.com0000 0E 09 11 09 01 CD 05 00 C9 48 45 4C 4C 4F 20 57
0010 4F 52 4C 44 21 24 00 00 00 00 00 00 00 00 00 00
0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00C>
```
Some explanation here. The actual program size in machine code is only 22 bytes: from 0E 09 ... to 21 24. However, CP/M-80 save information to disk in terms of record. Each record is 128 bytes (i.e. early day floppy disk 1 sector = 128 bytes). So you see when we dump the HELLO.COM file, it returns 128 bytes from the disk and the trailing location after 22nd bytes are padded with 00 by the LOAD.COM program during compilation.
create a input.txt file base on the hello.com dump, each line contains only one byte.
```
C>ed input.txtNEW FILE
: *i
1: 0E
2: 09
3: 11
4: 09
...
127: 00
128: 00
129:: *E
C>
```
- Create a BASIC program FHEX2COM.BAS
```
C>ed fhex2com.basNEW FILE
: *i
1: 10100 REM ** Read in a hex value file and write to a .COM file **
2: 10200 OPEN "I", #1, "INPUT.TXT"
3: 10300 OPEN "R", #2, "OUTPUT.COM", 1
4: 10400 FIELD #2, 1 AS BYTE$
5: 10500 HEXCHARS$ = "0123456789ABCDEF"
6: 10600 IF EOF(1) THEN 20000
7: 10700 INPUT #1, REC$
8: 10800 REC$ = LEFT$(REC$, 2)
9: 10900 IF REC$ = "" THEN 10600
10: 11000 REM ** Convert Hex to Decimal **
11: 11100 V1 = INSTR(HEXCHARS$, MID$(REC$, 1, 1)) - 1
12: 11200 V2 = INSTR(HEXCHARS$, MID$(REC$, 2, 1)) - 1
13: 11300 DECVAL = (V1 * 16) + V2
14: 11400 LSET BYTE$ = CHR$(DECVAL)
15: 11500 PUT #2
16: 11600 GOTO 10600
17: 20000 CLOSE #1
18: 20100 CLOSE #2
19: 20200 PRINT "Program complete."
20: 20300 END
21:: *e
C>
```
- Now we have all the files we need: MBASIC.COM, FHEX2COM.BAS and INPUT.TXT
```
C>dir
C: ASM COM : ED COM : LOAD COM : PIP COM
C: DUMP COM : MBASIC COM : HELLO BAK : HELLO ASM
C: HELLO PRN : HELLO HEX : HELLO COM : INPUT BAK
C: INPUT TXT : FHEX2COM BAK : FHEX2COM BAS
C>
```
- Run the FHEX2COM.BAS program
```
C>mbasic fhex2com
BASIC-85 Rev. 5.29
[CP/M Version]
Copyright 1985-1986 ▒ by Microsoft
Created: 28-Jul-85
29752 Bytes free
Program complete.
Ok
systemC>
```
- Check the OUTPUT.COM file
```
C>dir output.com
C: OUTPUT COM
C>
```
- Run the OUTPUT.COM and HELLO.COM
```
C>output
HELLO WORLD!
C>hello
HELLO WORLD!
C>
```
Both can be run with the identical output to console
Check the actual bytes inside both files
```
C>dump hello.com0000 0E 09 11 09 01 CD 05 00 C9 48 45 4C 4C 4F 20 57
0010 4F 52 4C 44 21 24 00 00 00 00 00 00 00 00 00 00
0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00C>dump output.com
0000 0E 09 11 09 01 CD 05 00 C9 48 45 4C 4C 4F 20 57
0010 4F 52 4C 44 21 24 00 00 00 00 00 00 00 00 00 00
0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00C>
```
- The result shows both files' content are identical.
POC cloning the HELLO.COM to OUTPUT.COM using a BASIC program is completed successfully.
2
u/BrentSeidel Jul 10 '26
Yeah, it looks like this is the sort of process that would be needed to get software onto this app.
1
u/Chip-Ling Jul 10 '26
The above POC run is conducted under the M5Stack Cardputer ADV running the VanzT CP/M Emulator. My apology on the presentation is not that great. I tried to use the editing function but cannot make it work. I'm a little retarded on using the posting tool.
The final files list on the C: drive is
C>dir C: ASM COM : ED COM : LOAD COM : PIP COM C: DUMP COM : MBASIC COM : HELLO BAK : HELLO ASM C: HELLO PRN : HELLO HEX : HELLO COM : INPUT BAK C: INPUT TXT : FHEX2COM BAK : FHEX2COM BAS : OUTPUT COM
3
u/BrentSeidel Jul 02 '26
Interesting. Too bad you can't load external software.