-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Writing a new driver in assembly #66
Comments
There's clearly an assembler bug, but there should already be makefile support for llvm-based assembler programs --- just drop a .S file into Try changing the section name from |
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:
And the rest is fixed to $0200 and beyond. |
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:
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 |
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. |
That all sounds utterly bizarre. I wonder if something's changed upstream? |
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. |
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:
Here you can see the reference to the strategy routine is relocated. But if I put it in .data:
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:
vs
But I noticed this: Driver description in .data:
Driver description in .rodata:
Notice that the second to last section is smaller in .data compared to .rodata. |
Hi,
I started working on tty80/screen80 for the Atari. I want it as a loadable driver, but I'm stumbling upon a few problems.
First I started in "asm.com" assembly, but noticed I could not create the needed jump table. .byte <label-1 and .byte >label-1 did not work correctly. The 13 entries for screen:
The 3 entries for tty:
The third one here is tty_conout, so that crashes heavily ;) See https://github.com/ivop/cpm65/blob/tty80/apps/a8tty80.asm
Adding an extra dummy byte to the table only works if it is equal to the last one before. Adding .byte 0 messes things up and adds both zeroes to the end of the second table.
So, I tried doing it with clang instead. Added a makefile rule to compile .S instead of .c to .o, link to .com was there already, but somehow the resulting cpm65 binary is not relocated correctly. When the code runs, it is as if it was loaded at $0200 instead of higher up ($0c00 on the XL/XE, $1d00 on the 400/800).
which should be JSR $0C04 (jmp BDOS). See https://github.com/ivop/cpm65/blob/tty80-2/apps/a8tty80.S
I checked the invocations of llvm with the -v flag, and it seems identical to the C version, except for calling cc1as. But there's a relocation flag there, too.
Anyway, I'm stuck. I could do it all in mads, which I know pretty well, but I'd prefer to use the cpm65 tools.
Regards,
Ivo
The text was updated successfully, but these errors were encountered: