Writing an assembler

new topic     » topic index » view thread      » older message » newer message

Well, I got a mad idea about writing an assembler (one to create exe files) in
Eu. However, tricky stuff like mod r/m aside, there is one point I really cannot
wrap my head around. Suppose you have:

jz l9
...
jz l8
....
jz l1
...
l1:
....
l8:
...
l9:
...
jmp l5

Now l9,8,7... are forward references so you'd be wise to assume they will need a
4-byte offset. Either at l1 or on a second pass, you figure the jz l1 can be a
one-byte offset, which may mean (3rd pass would be OK) that jz l2 can too.

My question is how do you keep track of where all these bytes are going to be?
When you "shrink" jz l1 (or 6), how/when do you modify that final jmp l5?

I think/hope this is a generic problem-solving question:
How do you 'move' multiple things like this at once?
Or, just being told exactly what info I really need to keep might make 1p drop.

I guess a similar question is that if I have say:
"some that some that some that"
and I have {6,16,26}, if I replace "that" with "x", somewhere I shall want those
indexes changed to {6,13,20}. [I may replace instances in any order and consider
that those numbers may be dispersed a bit more, and there may well be literally
many thousands of such inter/independent effects].

Hoping for a hint,
Pete

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu