Comments (7)
There's clearly an assembler bug, but there should already be makefile support for llvm-based assembler programs --- just drop a .S file into apps
and it should work. I'm doing that in https://github.com/davidgiven/cpm65/pull/67/files#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52 and it's working.
Try changing the section name from .text.driver
to .text
? That's the only thing I can see which is different. The linker script should pick up all .text.*
sections, however. The other thing it's worth doing is pushing the binary through OBJDUMP.COM
, which will show you precisely where all the relocations are.
from cpm65.
I have changed the Makefile back again and it now assembles with the already present rules.
But it still doesn't work. The only relocations done are in the beginning:
Output from OBJDUMP:
ZP: 02 TPA: 03 ZPRELO: 008d TPARELO: 008f
0000 02 . ill
0001 03 . ill
0002 8d 00 4c ..L sta 4c00
TPARELO 0003
0005 00 . brk
0006 00 . brk
0007 20 0b 00 .. jsr 000b
TPARELO 0009
000a 60 ` rts
000b 4c 30 00 L0. jmp 0030
TPARELO 000d
And the rest is fixed to $0200 and beyond.
from cpm65.
I recompiled and installed the latest llvm-mos and llvm-mos-sdk (my version was from May), but I still have the same results as mentioned in my previous post, except that objdump does not work correctly anymore. That also happens with the beeb, vic-20 and the apple 2 port. It prints everything on the same line, as if only CR works, but LF doesn't.
Edit: the same happens with stat.c. It seems that the latest version of llvm-mos does not handle \r\n correctly.
Edit2: replacing crlf() by print("\015\012"); does not work either, but cpm_conout(13); cpm_conout(10); does!
Edit3:
static char dat[] = { 13, 10, 0 };
// print(dat);
for (int i=0; i<2; i++)
cpm_conout(dat[i]);
print(dat) does not work, the for loop does. The current llvm-mos seems b0rked.
Edit4: and I cannot install the latest mos-sdk with the compiler from May because of mos-clang: error: the clang compiler does not support '-mcpu=mos65el02'
from cpm65.
Anyway, I have it working now with the May version of the compiler and SDK. I had to place the tables and banner explicitly in the data segment. sigh... ;)
Edit: it was more complicated, the defdriver macro switches to the .data segment, so I had to switch back .text for code.
Edit2: still not entirely working. Somehow the devices output is messed up now.
Edit3: devices output is correct now, too. Had to reserve ZP for jmpdispatch. Finally I can start working on the driver itself and stop edit-bombing you ;-) There is still something different from what happens in the bios code. Tables and the driver description have to be in .text (not .data) otherwise the pointers are not relocated. The bios code has the driver description in .data.
from cpm65.
That all sounds utterly bizarre. I wonder if something's changed upstream? llvm-objdump -dr
ought to show the ELF relocations (look in .obj
)...
from cpm65.
Yeah, strange things are happening. With the May compiler, stuff in .data is not relocated (i.e. pointers). I suppose compiling C didn't trigger that somehow, and the bios code is linked to a fixed address. I worked around it by putting stuff in .text instead.
The current HEAD llvm-mos compiler doesn't handle passing string pointers correctly (see stat above). Not sure if it's a cpm65 backend problem or llvm-mos regressed in general. Haven't looked into it in more detail as I was finally motivated to do the 80-columns driver, so I did that. Now I want to finish porting atari8080 and write the 130XE overlay loader.
from cpm65.
Okay, I looked into it a bit further, and it seems it is specifically .data that does not get converted from elf to bin. If I put the driver description in .rodata, it works correctly:
038f 19 00 00 ... ora 0000, y
TPARELO 0390
0392 00 . brk
0393 53 S ill
0394 43 C ill
0395 52 45 RE eor (45)
0397 45 4e EN eor 4e
0399 38 8 sec
039a 30 00 0. bmi 039c
Here you can see the reference to the strategy routine is relocated.
But if I put it in .data:
03af 19 02 00 ... ora 0002, y
03b2 00 . brk
03b3 53 S ill
03b4 43 C ill
03b5 52 45 RE eor (45)
03b7 45 4e EN eor 4e
03b9 38 8 sec
03ba 30 00 0. bmi 03bc
it is not.
I don't see any difference in the relocation tables in the .elf files other than the fact that they are in .data or .rodata:
RELOCATION RECORDS FOR [.rodata]:
OFFSET TYPE VALUE
0000058f R_MOS_ADDR16 drv_screen80_strat
vs
RELOCATION RECORDS FOR [.data]:
OFFSET TYPE VALUE
000005bb R_MOS_ADDR16 drv_screen80_strat
But I noticed this:
Driver description in .data:
.obj/a8tty80drv.com.elf: file format elf32-mos
Program Header:
LOAD off 0x000000b4 vaddr 0x00000200 paddr 0x00000200 align 2**0
filesz 0x00000628 memsz 0x00000628 flags rwx
UNKNOWN off 0x000006dc vaddr 0x00000000 paddr 0x00000000 align 2**2
filesz 0x00000a74 memsz 0x0000018c flags r--
UNKNOWN off 0x00001150 vaddr 0x00000000 paddr 0x00000000 align 2**2
filesz 0x00000e70 memsz 0x00000e70 flags r--
Driver description in .rodata:
.obj/a8tty80drv.com.elf: file format elf32-mos
Program Header:
LOAD off 0x000000b4 vaddr 0x00000200 paddr 0x00000200 align 2**0
filesz 0x00000628 memsz 0x00000628 flags rwx
UNKNOWN off 0x000006dc vaddr 0x00000000 paddr 0x00000000 align 2**2
filesz 0x00000a80 memsz 0x00000198 flags r--
UNKNOWN off 0x0000115c vaddr 0x00000000 paddr 0x00000000 align 2**2
filesz 0x00000e70 memsz 0x00000e70 flags r--
Notice that the second to last section is smaller in .data compared to .rodata.
from cpm65.
Related Issues (20)
- VT52 waiting for valid escape sequence HOT 1
- Reusing a static FCB for several file operations HOT 3
- "REN"-like command for changing user ID HOT 2
- Multiple drive support HOT 6
- Older Apple ][ support HOT 4
- Arrow-key constants HOT 2
- cpm.h header file needed HOT 2
- munmap_chunk(): invalid pointer HOT 4
- Suggestion: have the CCP zero out the bss for transient commands
- Thoughts on sound, timer, and joystick drivers
- request: o65 6502 binary relocation format
- Cursor behaviour HOT 3
- Dependency on a certain version of llvm-mos HOT 1
- Failing to assemble .COMs on macOS (13.6) HOT 2
- Listing multiple lines in BEdit does not work
- ccp internal "ren" does not work HOT 2
- Build for Apple II 3.5" as well HOT 2
- Saving files with BEDIT on the Atari doesn't work HOT 3
- Updates to lib6502 breaks objdump HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpm65.