Close

CC65 Toolchain for OSI C1P

A project log for OSI SD Card Operating System (OSISDOS)

Ohio Scientific / UK101 SD Card based Operating System under Multicomp FPGA Computer

land-boardscomland-boards.com 07/29/2020 at 11:310 Comments

I want to write the OS for the SD Card (OSISDOS) in C so it can be ported to other hardware platforms.

I tried to get the CC65 Assembler to work in a previous log and gave up. Let's try again. Here's the doc page (Ohio Scientific-specific information for cc65). From the page:

References

Added bin folder of cc65 to PATH env vars.

Using Command line:

cl65 --start-addr 0x300 -Wl -D,__HIMEM__=$2000,-D,__STACKSIZE__=$0200 -t osic1p -o OSISDOS.o OSISDOS.c

 Create a list file:

cl65 --start-addr 0x300 -Wl -D,__HIMEM__=$2000,-D,__STACKSIZE__=$0200 -t osic1p -l osidos.lst OSISDOS.c

No errors 

Looking at command line options

--start-addr 0x300 = Set the default start address

-Wl = Pass options directly to the linker. 
This may be used to pass options that aren't directly supported by cl65. 
Several options may be separated by commas; the commas are replaced by spaces 
when passing them to the linker.

-D,__HIMEM__=$2000, = Define a preprocessor symbol - 16K High Memory

-D,__STACKSIZE__=$0200  = Define a preprocessor symbol - 512 byte stack

-t  osic1p = Set the target system - ISI C1P target

Change format

"..\..\..\..\..\PC Tools\srecord\srec_cat.exe" OSISDOS -bin -of 0x300 -o OSISDOS.c1p -os -esa=0x300

Output looks like:

.0300/A2
FF
9A
D8
A9
00
A2
...

Very nice!

Except this doesn't match the list file. Disassemble the object file using retroassembler disassemble function:

"C:\Users\HPz420\Documents\GitHub\Doug Gilliland\Retro-Computers\6502\RetroAssembler\retroassembler.exe" -d -D=0x0300 OSISDOS.o OSISDOS.DIS

The top of the file looks like:

$0300 a2 ff      ldx #$ff
$0302 9a         txs
$0303 d8         cld
$0304 a9 00      lda #$00
$0306 a2 20      ldx #$20
$0308 85 02      sta $02
$030a 86 03      stx $03
$030c 20 9b 05   jsr $059b
$030f 20 1b 03   jsr $031b
$0312 20 27 03   jsr $0327
$0315 20 c1 04   jsr $04c1
$0318 4c 00 ff   jmp $ff00
$031b a0 00      ldy #$00
$031d f0 07      beq $0326
$031f a9 27      lda #$27
$0321 a2 03      ldx #$03
$0323 4c be 05   jmp $05be
$0326 60         rts

It's definitely 6502 code. Is that C1P startup code? The list file from cl65 has:

000000r 1                   .forceimport    __STARTUP__
000000r 1                   .export        _main
000000r 1                   .export        _setLBA0
000000r 1                   .export        _setLBA1

Disappointing that the cl65 listing file does not contain all of the code that is created.

Create a map file using the line:

cl65 --start-addr 0x300 -Wl -D,__HIMEM__=$2000,-D,__STACKSIZE__=$0200 -t osic1p -m OSISDOS.map -o OSISDOS.o OSISDOS.c

 Table shows where main() starts:

Exports list by name:
---------------------
__BSS_RUN__               0005E3 RLA    __BSS_SIZE__              000000 REA    
__CONSTRUCTOR_COUNT__     000000 REA    __CONSTRUCTOR_TABLE__     000327 RLA    
__DESTRUCTOR_COUNT__      000000 REA    __DESTRUCTOR_TABLE__      0005BE RLA    
__MAIN_SIZE__             001B00 REA    __MAIN_START__            000300 RLA    
__STACKSIZE__             000200 REA    __STARTUP__               000001 REA    
_main                     000327 RLA    addysp                    0004B4 RLA    
boolne                    00051E RLA    boolult                   00053D RLA    
decsp1                    0004CD RLA    decsp4                    0004D6 RLA    
donelib                   0004C1 RLA    incax1                    0004E3 RLA    
incsp1                    0004EA RLA    incsp2                    0004F9 RLA    
incsp4                    000507 RLA    initlib                   00031B RLA    
ldauidx                   00050C RLA    ldaxysp                   000517 RLA    
ptr1                      00000A RLZ    pusha                     00054E RLA    
pushax                    000564 RLA    regsave                   000006 RLZ    
sp                        000002 RLZ    staspidx                  00057A RLA    
staxysp                   000592 RLA    tmp1                      000012 RLZ    
zerobss                   00059B RLA    

 main() is at 0x0327. The code at 0x0327 is:

$0327 a2 00      ldx #$00
$0329 a9 00      lda #$00
$032b 8d 05 f0   sta $f005
$032e a9 00      lda #$00
$0330 20 41 03   jsr $0341
$0333 a9 00      lda #$00
$0335 20 51 03   jsr $0351

 This does nicely match the main() code is the .lst file from cl65:

000000r 1  A2 00        	ldx     #$00
000002r 1  A9 00        	lda     #$00
000004r 1  8D 05 F0     	sta     $F005
000007r 1  A9 00        	lda     #$00
000009r 1  20 rr rr     	jsr     _setLBA0
00000Cr 1  A9 00        	lda     #$00
00000Er 1  20 rr rr     	jsr     _setLBA1
000011r 1  A9 00        	lda     #$00
000013r 1  20 rr rr     	jsr     _setLBA2
000016r 1  20 rr rr     	jsr     _readBlock
000019r 1  60           	rts

 A more detailed map file can be created using the command line:

cl65 --start-addr 0x300 -Wl -D,__HIMEM__=$2000,-D,__STACKSIZE__=$0200 -t osic1p -vm -m OSISDOS.map -o OSISDOS.o OSISDOS.c

I will debug the code in another log.

Discussions