Page 1 of 3

HEX BOOT Loader

Posted: Tue Nov 06, 2007 10:10 am
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?

Posted: Tue Nov 06, 2007 10:21 am
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

Posted: Tue Nov 06, 2007 1:19 pm
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

Posted: Tue Nov 06, 2007 3:04 pm
by XCHG
You shouldn't code in hex because if you do, people will die all around the world. :shock:

Posted: Tue Nov 06, 2007 11:42 pm
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.

Posted: Tue Nov 06, 2007 11:52 pm
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.

Posted: Tue Nov 06, 2007 11:55 pm
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.

Posted: Wed Nov 07, 2007 12:31 am
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!

Posted: Wed Nov 07, 2007 1:39 am
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

Posted: Wed Nov 07, 2007 1:58 am
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.

Posted: Wed Nov 07, 2007 2:03 am
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?".

Posted: Wed Nov 07, 2007 2:16 am
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

Posted: Wed Nov 07, 2007 12:21 pm
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...

Posted: Wed Nov 07, 2007 4:37 pm
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?

Posted: Wed Nov 07, 2007 6:48 pm
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