Page 1 of 6
Issue with as86/ld86 and ORG
Posted: Sat Aug 22, 2009 9:30 am
by myk
Hello All,
Hoping someone could help me out here. I'm trying to get some romable code working for an old computer I built. I've got two assembly files but I'm having some issues with the ORG command. My first assembly file is start.s, it will eventually setup all of the segment registers and do other hardware init stuff. I'd like for it to start at 0x0000 in my ROM. My other file is resetvec.s which is just a reset vector jump to the code in the first file at 0x0000. I've also got main.c that I link in to make sure I can throw some C in there. The code is as follows:
start.s
Code: Select all
.ORG 0x0000
.globl _main
entry start
start:
MOV AX, 0x0000 ;SYSRAM
MOV DS, AX ;initialize segments
MOV SS, AX ;RAM is both the stack and the data segment
;MOV AX, 0x0100 ;OFFSET top_of_stack ;initialize the stack pointer
MOV SP, AX
MOV DX, _main
JMP DX
resetvec.s
Code: Select all
ORG 0xFFF0
entry reset
reset:
JMP 0xF000:0x0000
main.c
To build:
Code: Select all
bcc -c main.c
as86 -o start.o start.s
as86 -o resetvec.o resetvec.s
ld86 -d -M -o project.bin start.o main.o resetvec.o
The output of the -M from ld86 is
Code: Select all
start start 0 00000000 A N
main _main 0 00000010 R
resetvec reset 0 0000fff0 A N
From what I think the ORG statement in resetvec.s should do is make sure that the following code starts at 0xFFF0, however everything gets offset by the codesize of start.s and main.c, so instead of starting at 0xFFF0, it starts at 0x10014.
Does anyone know of a way to get this to work like I'd like, resetvec.s starting at 0xFFF0?
If I cannot figure this out, I could always assemble my start.s with resetvec.s's code and then copy my compiled code into a predefined section of the .bin file, but I'd rather do this properly.
Thanks!
Re: Issue with as86/ld86 and ORG
Posted: Sat Aug 22, 2009 9:46 am
by earlz
you built your own computer with custom ROM? I'm sorry, what is your platform? I've never heard of anyone being able to get ROM into an x86 machine.. (also, sounds interesting, maybe I'd like to do that myself.. )
Re: Issue with as86/ld86 and ORG
Posted: Sat Aug 22, 2009 10:04 am
by myk
Yes, it's an 8086 with 64k of EPROM and 64k SRAM. All wire wrapped and hand assembled and designed. Previously I was using A86 and dos to write code for it. I wrote a 3k line "OS" in assembly for it back in college. I've recently wanted to work on it again and get some C code going on it. I'm in the process of building EPROM emulators for rapid development, I've got the hardware about 70% there and the software about 60% for the emulators.
The A86 assembler handled the ORG statements like I think they should be handled, but AS86/LD86 is not being nice to me (or I'm just not using them properly).
Re: Issue with as86/ld86 and ORG
Posted: Sat Aug 22, 2009 10:42 am
by Combuster
I'd more likely expect a custom rombios for bochs...
In any case, ORG was never meant to tell whatever linker where to put it. You can tell an advanced linker like GNU LD to place things at certain locations in the output binary. You'd have to find the ld86 equivalent of linker scripts if you want to continue using that linker as it is.
Your best bet is to construct an utility that computes the binary size, add zeros to make it 0xFFF0 bytes, then append a binary file containing the jump instruction. (in essence, you'd make your own specialized linker)
Re: Issue with as86/ld86 and ORG
Posted: Sat Aug 22, 2009 10:48 am
by myk
Gotcha, that's kinda what I was expecting. Making a perl script to insert a jump at the right location is rather trivial, I'll go that route. I don't believe ld86 has the ability to use linker scripts or anything like that, so I'm out of luck in that sense... custom script here we come!
By the way, I still have the old schematic files and asm files from my school project if anyone wants to take a look. I'm pretty sure the asm is the complete code (it should build) but I don't think the schematics are 100% (wouldn't take much to fix them though).
Re: Issue with as86/ld86 and ORG
Posted: Sat Aug 22, 2009 11:09 am
by earlz
myk wrote:Yes, it's an 8086 with 64k of EPROM and 64k SRAM. All wire wrapped and hand assembled and designed. Previously I was using A86 and dos to write code for it. I wrote a 3k line "OS" in assembly for it back in college. I've recently wanted to work on it again and get some C code going on it. I'm in the process of building EPROM emulators for rapid development, I've got the hardware about 70% there and the software about 60% for the emulators.
The A86 assembler handled the ORG statements like I think they should be handled, but AS86/LD86 is not being nice to me (or I'm just not using them properly).
If your meaning you wish to simulate your "computer" on a PC, I have an old project called x86Lib which simulates only the 8086(and a bit of 8186 last I checked) processor, and then you add in your own peripherals to get it to do anything useful. That might help you as adding just a ROM and RAM and simple IO is trivial for the project..
and I would like to see your schematics.. also, how much did it cost for you to build it? I don't have many electronic things, just a solder gun and the basics like resistors and transistors and capacitors and LEDs. I don't have any chip holders or actual chips.. and what difficulty would you say this project is? (I'm still new to soldering)
Re: Issue with as86/ld86 and ORG
Posted: Sat Aug 22, 2009 11:30 am
by myk
My intentions are not to simulate but actually run this on the metal, however I'd love to take a look at your simulator.
If I have some time today I'll upload everything to my google code account and post back here. This project was for a junior and senior level computer architecture class when I was getting my Comp Eng degree a few years back. If you have a very low level understanding of the 8086 and how memory and what not works, it's not terribly difficult. I believe I spent close to 300 hours my second semester of my Jr year designing, building, and programming this board.
I would really like to post this stuff online and write up tutorials and guides on how it works if people are interested. I believe there is a lot of knowledge there that is just not easy to find on the internet.
The total parts cost was around 200-300 dollars and you only need very basic tools to put it together, wire wrap wire, wrap tool, soldering iron, solder, and a looooooot of time.
Re: Issue with as86/ld86 and ORG
Posted: Sat Aug 22, 2009 11:43 am
by earlz
myk wrote:My intentions are not to simulate but actually run this on the metal, however I'd love to take a look at your simulator.
If I have some time today I'll upload everything to my google code account and post back here. This project was for a junior and senior level computer architecture class when I was getting my Comp Eng degree a few years back. If you have a very low level understanding of the 8086 and how memory and what not works, it's not terribly difficult. I believe I spent close to 300 hours my second semester of my Jr year designing, building, and programming this board.
I would really like to post this stuff online and write up tutorials and guides on how it works if people are interested. I believe there is a lot of knowledge there that is just not easy to find on the internet.
The total parts cost was around 200-300 dollars and you only need very basic tools to put it together, wire wrap wire, wrap tool, soldering iron, solder, and a looooooot of time.
For my simulator, just look for it on SF, I would download the SVN version and not the release and then use the MP branch or whatever it was..
Could you maybe upload a pic of this machine?
And tutorials would be great. I'm afraid I would probably have to practice with a few other projects before getting up to this though.. (also, I'd need a bit more cash lol)
Re: Issue with as86/ld86 and ORG
Posted: Sat Aug 22, 2009 11:56 am
by f2
There's a topic on flat assembler board about ROM programming:
http://board.flatassembler.net/topic.php?t=9181.
This may be useful. And it will be easier to make a ROM with Fasm, instead of as86/ld86.
Re: Issue with as86/ld86 and ORG
Posted: Sat Aug 22, 2009 12:20 pm
by myk
Thanks to the flat asm link!
Here is a video of the board:
http://www.youtube.com/watch?v=bhv8hGZ2fSQ
Re: Issue with as86/ld86 and ORG
Posted: Sat Aug 22, 2009 4:06 pm
by earlz
IS it possible to plug that into PCI or ISA or something as a coprocessor?
Also, youtube is not a portable data source lol(do you know how painful it is to watch youtube through a VNC? )
Re: Issue with as86/ld86 and ORG
Posted: Sat Aug 22, 2009 6:19 pm
by myk
Nope, it is completely stand alone.
lol sorry, that's all I have online at the minute.
Re: Issue with as86/ld86 and ORG
Posted: Sat Aug 22, 2009 9:22 pm
by myk
Ok, just upped my schematics, code, and reports to here:
http://code.google.com/p/romulatoravr/s ... riginalASM
I have no idea how complete this code is, the last changes I found were April 26th, 2006. I tried to upload all the code I could find in order of date that it was edited, starting from April 2nd to April 26th. I unfortunately skipped a few days from the 7th to the 26th. I upped the reports I could find, they should explain the code and the hardware. The schematics were generated from a program called Orcad Schematic Capture. I'm pretty sure the schematics are incomplete, but it should be enough to get you started and to learn from. Also there are some pretty terrible spelling mistakes (interupt vs interrupt) so please ignore those
Let me know if you guys find this stuff interesting or have any questions! I might be able to dig up some more stuff if you like it. Also, the text for the class was Barry Brey's The Intel Microprocessors. I love this book, it explains everything and has detailed schematics and code examples. I have two copies and have read it front to back.
Edit: Also, the coding is pretty terrible. This was the first time I had written anything substantial in ASM and it was pretty much learning as you go.
Re: Issue with as86/ld86 and ORG
Posted: Wed Aug 26, 2009 5:52 am
by jal
myk wrote:Yes, it's an 8086 with 64k of EPROM and 64k SRAM. All wire wrapped and hand assembled and designed.
Heh, that's massively cool. Wish I could do that. What other hardware have you added (especially PIC, PIT and stuff), what bus does it use?
JAL
Re: Issue with as86/ld86 and ORG
Posted: Wed Aug 26, 2009 1:22 pm
by Owen
"What bus does it use?"
I'd guess, given that it's based upon the 8086, that it would use the 8086 bus...