Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 6th, 2005, 12:21 AM   #1
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 403
Rep Power: 3 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
Question Assembly without a compiler

OK, I'm not new to the world of programming or anything, but I am new to the Intel x86 assembly language. I've programmed in C, Java, Javascript, PHP, VisualBasic, etc. All these languages don't particularly interest me for one MAJOR reason: You're trusting someone else's code to write your code. The experience I have with assembly programming relates primarily to the PICmicro processors. These are actually microcontrollers which are used in development of mechatronic devices (mechanical engineering is my profession). However, the PICs instruction set only has 14 opcodes. Therefore, it's relatively easy to understand and comprehend. Furthermore, there is no such thing as segmentation or paging or the other stuff that the x86 can do. It operates basically like this: put the instruction somewhere in the memory of the microcontroller and it does it (whatever particular function it is one of the 14 opcodes possess).

Regarding the x86 I have a pretty good understanding of all the "primary" registers (the ones that do most of the application execution). However, registers which control the "behind the scenes" operations are what I do not understand (such as the various task registers and control registers). Or rather, I don't understand how it is the segment descriptors are placed into memory. Or for that matter, how it is I actually get a program to physically execute itself (I don't mean by double-clicking an exe or something). So apparently I don't understand much, or rather I want to understand exactly what it is a particular compiler does (the popular NASM, FASM, MASM, or TASM for instance).

So let's set the problem up.

I want to create an assembly program which meets the following requirements:
1 - The program will display a white pixel at the upper left hand corner of the screen with a black background (resolution isn't important).
2 - The program must be written so as not to incorporate any BIOS, DOS, Windows, Linux, etc. functions, or interrupts (I want to know EXPLICITLY what every line of code does).
3 - The program must be written without the benefit of one of the various assemblers out there. I don't need the actual binary. I can translate the instructions myself, but I don't want a compiler to take the liberty of doing things for me.

Finally, yes I realize this is ridiculous to most of you, actually writing down 1's and 0's and going through all this "needless" work. Well please refrain from replying if that's all you have to say. I'm interested in achieving something and in this particularly explicit way. The end purpose if you must know is that I'm curious as to how to implement a very elementary operating system similar to DOS or how to construct a BIOS for the x86.

So, if anyone can tell me where to start conceptually, or actually tell me what should be my first opcode I would appreciate it. Again allow me to emphasize there is no usage of include files or prebuilt functions or anything, I EXCLUSIVELY want to use the opcodes made available by the processor, and to have TOTAL control over what the application has done, where it resides in memory, and why it resides in that particular place in memory.

Thanks for any help.
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote
Old Sep 6th, 2005, 5:57 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Quote:
All these languages don't particularly interest me for one MAJOR reason: You're trusting someone else's code to write your code.
That's just silly. One could extend that mode of thinking to even more asinine lengths with no problem at all. If you ran the rest of your life like that, you certainly wouldn't be on line at a forum.

If you just WANT to know how to write every last iota of code, nothing wrong with that. I would suggest you get a microprocessor kit, appropriate compiler/linker/locator, maybe even a ROM blower, and have at it.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Sep 6th, 2005, 8:25 AM   #3
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 3 Polyphemus_ is on a distinguished road
LOL how would you write those 1's and 0's without a third-party editor?
Polyphemus_ is offline   Reply With Quote
Old Sep 6th, 2005, 9:14 AM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
You can actually set up your equipment where you use toggle switches to set up the address, set up the binary pattern (data or instruction) to go there, clock it in, move to the next address, and so on. The microworld was not born with BIOSes, OSes, editors, and compilers. People developed them as tools. It distinguishes man from most (not all) animals in that he uses tools. That's why the REASON given by the OP is ludicrous. The GOAL is not.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Sep 6th, 2005, 9:35 AM   #5
Dizzutch
Professional Programmer
 
Dizzutch's Avatar
 
Join Date: Dec 2004
Location: Worcester, MA
Posts: 441
Rep Power: 4 Dizzutch is on a distinguished road
Send a message via ICQ to Dizzutch Send a message via AIM to Dizzutch Send a message via MSN to Dizzutch Send a message via Yahoo to Dizzutch
I think it's good to understand how other peoples software do certain things, I don't however see it neccesary to re-re-re-re-reinvent the wheel for the 50th time around. Unless one has great ideas as to how to improve on existing code, I see no reason to write it again yourself, that's just wasting time. Even large corporations use other peoples code, even Microsoft's Domain Controllers are built on BIND, Linux is based upon UNIX...etc, etc...
__________________
naked pictures of you | PFO F@H stats
Dizzutch is offline   Reply With Quote
Old Sep 6th, 2005, 5:14 PM   #6
Scorpions4ever
Programmer
 
Join Date: Jun 2005
Posts: 86
Rep Power: 4 Scorpions4ever is on a distinguished road
I have written a few programs using the DOS copy command. Something like:
C:\> copy con reboot.com
<alt>205 ^Y <enter>
^Z<enter>

Ah, the good ol' days.
Scorpions4ever is offline   Reply With Quote
Old Sep 6th, 2005, 10:00 PM   #7
iignotus
Professional Programmer
 
iignotus's Avatar
 
Join Date: Apr 2005
Location: Nowhere Special
Posts: 466
Rep Power: 4 iignotus is on a distinguished road
Send a message via AIM to iignotus
Quote:
I have written a few programs using the DOS copy command. Something like:
C:\> copy con reboot.com
<alt>205 ^Y <enter>
^Z<enter>

Ah, the good ol' days.
But you see, that's just stupid! You're trusting the copy command to put those codes into a file! Someone else wrote 'copy' -- how can you trust it?!

What you really should do is set the bits yourself with and electric controller attatched to the hard drive :p
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[ 
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;}
iignotus is offline   Reply With Quote
Old Sep 6th, 2005, 10:15 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
What's even worse, you can't drive. Someone else built the car. How can you trust the wheels, much less the carburetor? Shoot, you can't even walk unless you do it barefoot. How can you trust those shoes build by some stupid person to protect you from thorns? You can't even make your own shoes, unless you grow your own cows. Stupid rancher wouldn't know what SHE was doing! I mean, she lost 10% of her calf crop to a blizzard, because SHE couldn't trust the stupid weatherman.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Sep 6th, 2005, 10:16 PM   #9
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 403
Rep Power: 3 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
Alright, well perhaps the question mark icon at the top didn't exactly specify what I meant. I'm not interested in being critiqued on WHY I'm doing this, whether it be a waste of time or unreasonable to the rest of you. I came here to humbly ask for help and assistance, perhaps this was the wrong place to do that. It's a waste of time yes, it's asinine sure, thank you for your opinions.

Now can someone tell me how to structure a program that will boot itself up from a floppy, without using any of the BIOS or DOS interrupts or gates? All it has to do is display a pixel or a character or anything against a background of some different color. Do I have to place the descriptor for the segments, will placing these descriptors somewhere in memory somehow override other more important code, how do I get the program to execute, etc.?

Again, I realize I'm wasting my time, I realize my reasons are unreasonable, but if you have the time to tell me that I would much rather you spend it helping me solve the problem rather than telling me why not to do so. However, if you feel obligated to let me know how oblivious and mistaken I am please post somewhere else.
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote
Old Sep 6th, 2005, 10:26 PM   #10
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
When you power on the system, it HAS no code, other than the BIOS. If you don't want to use the BIOS, you have to write your own and put it into memory by one mechanism or another. I'm perfectly serious about the use of switches. It's how we booted small systems prior to the advent of ROM and such. I mean, you can't even read a freakin' paper tape without a small set of code to drive it. If you read my first response, you'll see that I said your goal wasn't asinine -- your REASON was. It's also apparent you don't yet have the knowledge to pull this off. You are very unlikely to get it here, though it's possible someone would spend scads of hours bringing you up to speed. You really need to do quite a bit more research so as not to totally bog down a teacher/mentor, should you find one.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:55 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC