6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 7:53 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Loading code into Py65
PostPosted: Thu Mar 03, 2016 6:08 pm 
Offline

Joined: Thu Mar 03, 2016 5:48 pm
Posts: 2
I'm new to 6502 assembly programming. I'm fresh off the "Easy 6502" tutorial. I'd like to experiment using Py65. I noticed that assembling to an object file produces extra bits that I don't understand.

Here's my code and assembler output.

jeffl@ubuntu:/tmp$ cat main.s
LDA #$80
STA $01
ADC $01
jeffl@ubuntu:/tmp$ ~/development/cc65/bin/ca65 main.s -o main.o

I think my problem is that I don't understand the object format. I'm looking for "a9 80 85 01 65 01". It appears in the hex dump below but not as I expect.

jeffl@ubuntu:/tmp$ xxd main.o
0000000: 557a 6e61 1100 0000 6000 0000 0900 0000 Uzna....`.......
0000010: 6900 0000 0700 0000 7000 0000 4f00 0000 i.......p...O...
0000020: bf00 0000 0100 0000 c000 0000 0100 0000 ................
0000030: c100 0000 0200 0000 c400 0000 1000 0000 ................
0000040: d400 0000 4b00 0000 1f01 0000 0100 0000 ....K...........
0000050: c300 0000 0100 0000 2001 0000 0100 0000 ........ .......
0000060: 0202 0240 96f6 e1b6 0501 0107 6fd8 5619 ...@........o.V.
0000070: 0618 0000 0004 0006 0102 0300 02a9 8001 ................
0000080: 0000 0285 0101 0100 0265 0101 0206 0000 .........e......
0000090: 0005 0000 0102 0006 0000 0006 0000 0102 ................
00000a0: 0006 0000 0007 0000 0102 0006 0000 0008 ................
00000b0: 0000 0101 0006 0000 0009 0000 0102 0000 ................
00000c0: 0000 0000 0301 0000 0000 0200 0000 0003 ................
00000d0: 0000 0000 0a00 066d 6169 6e2e 7318 6361 .......main.s.ca
00000e0: 3635 2056 322e 3135 202d 2047 6974 2036 65 V2.15 - Git 6
00000f0: 3039 3538 6630 052e 7369 7a65 0443 4f44 0958f0..size.COD
0000100: 4506 524f 4441 5441 0342 5353 0444 4154 E.RODATA.BSS.DAT
0000110: 4108 5a45 524f 5041 4745 044e 554c 4c00 A.ZEROPAGE.NULL.
0000120: 00 .
jeffl@ubuntu:/tmp$

How can I produce code using the cc65 toolchain that will work as input files to Py65?


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 03, 2016 6:25 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
For a starting point, please have a look at this thread:
viewtopic.php?f=2&t=2455


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 03, 2016 6:52 pm 
Offline

Joined: Thu Mar 03, 2016 5:48 pm
Posts: 2
Thanks, Big Ed.

I see that defining the base address and linking the object file produces an executable that I can load into py65.

jeffl@ubuntu:/tmp$ ~/development/cc65/bin/ca65 main.s -D BASE=0x8000
jeffl@ubuntu:/tmp$ ~/development/cc65/bin/cl65 main.o --target none --start-addr 0x8000 -o main.bin

(py65-venv)jeffl@ubuntu:~/development/py65-venv/bin$ ./py65mon -l /tmp/main.bin
Wrote +6 bytes from $0000 to $0005

PC AC XR YR SP NV-BDIZC
6502: 0000 00 00 00 ff 00110000

Py65 Monitor

PC AC XR YR SP NV-BDIZC
6502: 0000 00 00 00 ff 00110000
.mem $00:$10
0000: a9 80 85 01 65 01 00 00 00 00 00 00 00 00 00 00 00

PC AC XR YR SP NV-BDIZC
6502: 0000 00 00 00 ff 00110000
.

I have much to learn. :)


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 03, 2016 7:52 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Oh, welcome, by the way!

cc65 is very capable, with the basic idea of separately compiled sources with symbolic addresses which are later linked into an executable. Fortunately it can also be used simply!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 71 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: