HEX BOOT Loader

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
crazygray
Member
Member
Posts: 73
Joined: Sat Nov 03, 2007 10:17 am
Location: Toky,Japan

HEX BOOT Loader

Post by crazygray »

I have been trying out assembly lately and I pretty much stink but I am able to program in a hex editor for some reason better than with assembly. How reasonable would it be to write a bootloader just from the hex opcodes?
Imagine if a creature came from a 4 dimensional world, would he think you to be flat?
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

If you find hex opcodes easier and quicker to program in and debug than asm, why not? Makes me think that your username is apt, though :wink:

Cheers,
Adam
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Post by inflater »

rofl :lol: Do you want to write direct machine code?
Sorry for insulting your person, but you didn't even knew to build a BAT file for nasm... :)
But anything can be done, maybe I'm just wrong.

Regards
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post by XCHG »

You shouldn't code in hex because if you do, people will die all around the world. :shock:
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Post by 01000101 »

lol, if you have the time, patience, and skill... go for it. It would be some hardcore control over your OS if you know how to do it right.
User avatar
Zacariaz
Member
Member
Posts: 1069
Joined: Tue May 22, 2007 2:36 pm
Contact:

Post by Zacariaz »

Ive allways wanted to try that aproach. Controling the ones and zeros directly is just cool!
I dont have the patience though...

Anyway, i agree that it is probably a very bad aproach, cool though it would be.
This was supposed to be a cool signature...
LordMage
Member
Member
Posts: 115
Joined: Sat Sep 22, 2007 7:26 am
Contact:

Post by LordMage »

Isn't ASM just a readable version of the machine code/ hexcode? and if so how in the world do you figure it is easier to remember 0110 0101 0101 1011 = 655B = MOV Al, 11 (NOT REAL VALUES) but the point is that you have to do the translation in your head or on paper so aside from learning a few things about your particular ASM compiler I don't see how hexcode could possible be easier than ASM. Please enlighten me


NOTE: I realise that I don't know the opcodes that corrispond to the ASM commands and am not really sure whether it is 8, 16, or 32 bits for each command but I know that x86 from Art of Assembly uses an 8bit opcode with an 8bit information portion attached. so my example could be completely wrong but the question is still a valid one.
Getting back in the game.
User avatar
AndrewAPrice
Member
Member
Posts: 2309
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

AJ wrote:If you find hex opcodes easier and quicker to program in and debug than asm, why not? Makes me think that your username is apt, though :wink:

Cheers,
Adam
If you could work manually and efficiently with opcodes, then it would be the easiest system to debug! You'd just have to print a hex layout of a section of the memory!
My OS is Perception.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post by Brendan »

Hi,

When I was a teenager, I used to program in decimal bytes for 6502 machine code - not because I wanted to, but because I didn't have a choice.
If you could work manually and efficiently with opcodes, then it would be the easiest system to debug! You'd just have to print a hex layout of a section of the memory!
If you can work efficiently with hex bytes, then it'll still be a code maintenance nightmare - something as simple as inserting a few instructions into existing code would involve searching for all CALL, JMP and branch instructions and adjusting the target addresses, and possibly even adjusting all memory accesses in (what would normally be) the ".data" section.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
AndrewAPrice
Member
Member
Posts: 2309
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

Brendan wrote:If you can work efficiently with hex bytes, then it'll still be a code maintenance nightmare - something as simple as inserting a few instructions into existing code would involve searching for all CALL, JMP and branch instructions and adjusting the target addresses, and possibly even adjusting all memory accesses in (what would normally be) the ".data" section.
You'd have to plan out your entire program on paper, then write the entire program leaving a place holder for your address locations and coming back to fill them in once you are done.

It might work for something small like a boot loader, but for anything more complex it'd just be pointless.
My OS is Perception.
User avatar
JackScott
Member
Member
Posts: 1036
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Mastodon: https://aus.social/@jackscottau
Matrix: @JackScottAU:matrix.org
GitHub: https://github.com/JackScottAU
Contact:

Post by JackScott »

Which basically just involves writing the program in assembly, and assembling it by hand. I've done that, and it does beg the question "Why not just use the assembler?".
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post by Brendan »

Hi,
Yayyak wrote:Which basically just involves writing the program in assembly, and assembling it by hand. I've done that, and it does beg the question "Why not just use the assembler?".
For me, the code looked (very roughly) like:

Code: Select all

10 DATA 12, 15, 213, 203, 34, 103, 130, 102, 96, 21
20 DATA 92, 43, 123, 141, 205, 12, 15, 20, 4

100 for i = 0 to 18
110 read a;
120 poke 49152+i, a
130 next
140 sys 49152
150 exit
Quite simply, there wasn't any assembler.

Of course after messing about with little bitmap editors, simple games, etc (in "assembly assisted BASIC") the first serious piece of software I wrote was an assembler.. ;)


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post by JAAman »

i have done that... wrote a section in ASM, then translated it into hex -- its quite fun actually, and after a while, you find patters which give incite into the instruction-set design

quite enjoyable, although quite time-consuming also...
exkor
Member
Member
Posts: 111
Joined: Wed May 23, 2007 9:38 pm

Post by exkor »

I guess the only real use of machine language would be self modified code. Disassembler would most likely have troubles showing you correct code. But you'll need permission to write to code section.

Does anybody know any ways of hiding writes to code section? so that human has troubles seeing it?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post by Brendan »

Hi,
exkor wrote:Does anybody know any ways of hiding writes to code section? so that human has troubles seeing it?
A human that single steps through your code (e.g. using Bochs debugger) is omniscient - they see everything you could possibly do. Resistance is futile. All your base are belong to us. :lol:


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply