Author Topic: From linux patch to rom  (Read 18700 times)

Offline gabiz_ro

  • Jr. Member
  • *
  • Posts: 3
From linux patch to rom
« on: February 11, 2010, 09:14:05 PM »
I want to make one of this two patches to mbr or this one in asm then to assemble in bin format to insert in bios as pci option rom.
But I can't,I don't know anything about programming.
Always getting errors parser,instruction expected.
Who can help me to solve this?
Who can spend few minutes to make this for me?
Thanks.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: From linux patch to rom
« Reply #1 on: February 13, 2010, 05:05:17 PM »
Of the two patches you mention, one is for Gas and the other for C, so Nasm isn't going to help you. Can you find an already-patched version of the code where you found the patches? If you had patched and assembled/compiled code, would you know what to do with it? I usually encourage people to "do the experiment", but messing with mbr/bios, you can render the machine inoperable if you screw up. Unless it's a "scratch" machine, I'd say "forget it!"... or at least get knowledgeable help (probably where you found the patches).

Best,
Frank


Offline gabiz_ro

  • Jr. Member
  • *
  • Posts: 3
Re: From linux patch to rom
« Reply #2 on: February 14, 2010, 04:22:52 AM »
Thank you for response.
Is not a risk for me to mess bios or mbr,even then I can easy fix them.
Problem is I don't know anything about programming like I say.
And I need to build a pci option rom to insert in my bios,this module will write at some addresses in ram to enable some functions of hardware.
I found similar things,but I cant figure out how it works and is more complicated that what I need.
I also search for a sample code but can't find one,maybe is too simple to be explained.I'm dizzy now between ax,bx.eax mov,too many address format 08000fa90h , 0X8000fa90 .
In the end let's say I want to write value 40 at address 0x8000fa90 can somebody provide me a sample (example,pattern,model) how to do this?
And in case,can I replicate that code few times inside asm file for different addresses?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: From linux patch to rom
« Reply #3 on: February 14, 2010, 12:47:26 PM »
Well, yeah... if you just say "mov [0x8000fa80], 40", Nasm will complain "operation size not specified". We'd need to say "mov byte [0x8000fa90], 40",  or "mov word [0x8000fa90], 40" (unlikely, but possible), or "mov dword [0x8000fa90], 40", depending on what you wanted to do. But neither of your patches are for Nasm - different syntax. I think, for Gas, you'd want "movl $40, (0x8000fa90)". Really not a Nasm question. (and not a "beginner" question, for sure!) (and that "40" probably wants to be "0x40", dunno...)

If you want to learn enough programming to do it, we can help you get started, but it's going to be a long road. And in the end, you'll probably still need advice from someone who's done it. I wish I could help you more, but this is like "I want to do brain surgery, but I don't know anything about medicine". Seems that way to me, anyway...

Best,
Frank


Offline gabiz_ro

  • Jr. Member
  • *
  • Posts: 3
Re: From linux patch to rom
« Reply #4 on: February 14, 2010, 01:23:34 PM »
Let's say forget about this patches.

"mov byte [0x8000fa90], 40" will write 40 hex value to 0x8000fa90 address?
Thats all?
All I want was to write some values at some address in ram.
Still errors: word data exceeds bounds.
I'll spend some few more times but in the end I think just to abandon this,is too much to learn for such a simple need and I don't have time now.
Thank you for responses.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: From linux patch to rom
« Reply #5 on: February 14, 2010, 02:54:56 PM »
40 would be decimal value 40. 0x40 would be hex value. 40h is hex also, but stick with 0x40 - it's more widely used.

The warning (error?) about "word value exceeds bounds" suggests you're not telling Nasm "bits 32", so it's trying to squeeze your address into 16-bits.

If all you need is to put some values at some addresses, there isn't "that much" to learn, provided you know what values and what addresses. Probably not going to do "that much" for you either. But maybe...

I hate to discourage you, but the best thing might be to let it go. Depends on how bad you need it, I guess...

Best,
Frank