Prev: masm linking from console
Next: NASM HelloWorld - DOS
From: santosh on 20 Jul 2007 08:44 //\\\\o//\\\\annabee wrote: > P� Fri, 20 Jul 2007 14:05:06 +0200, skrev Phil Carmody > <thefatphil_demunged(a)yahoo.co.uk>: > >> Herbert Kleebauer <klee(a)unibwm.de> writes: >>> case 0x05: {la[--j] = la[j] / la[j+1]; break;} >> >> That's the line that c.l.c needs to see. >> It'll be feeding time at the zoo! > > Agree, no human should dirty its mind going to the zoo at clc Try not to become an assembler bigot, Wannabee.
From: Frank Kotler on 20 Jul 2007 10:26 Rod Pemberton wrote: > "Rod Pemberton" <do_not_have(a)nowhere.cmm> wrote in message > news:f7pn9f$rp0$1(a)aioe.org... > >>"Frank Kotler" <fbkotler(a)verizon.net> wrote in message >>news:EdHni.5682$bP4.2953(a)trndny01... >> >>>I'll have more to say about Herbert's example. My usual M.O. is to >>>disassemble his executable into Nasmese, and work from there. This gives >>>*ugly* results. This example is so beautifully formatted and commented >>>that it deserves better than that! A "hand translation" will be tedious, >>>but I think it may be worth it. Not immediately. Herbert speaks a >>>strange language, but he does beautiful work! >>> > > > Earlier HK stated: > > >>Most of the code is stolen from Frank >>(hope he doesn't mind, at least now he gets the code back >>in a readably assembler syntax). > > > Sorry, missed the self congratulatory remark, Frank! It appears that it's > your code... :-) Not really. I guess Herbert has gotten some ideas about "xauthority" from my code, since his machine doesn't require authorization, but he's cleaned it up and improved it considerably. Herbert was the one who came up with the *name* of the socket we're connecting to, which I wouldn't have found in a million years. He's been in the lead ever since. I've got "Nasm versions" of several of his demos, some of which do things differently - perhaps "better". I may have figured out some things that helped him, but this is *not* "my code". If it were, I wouldn't be having so much trouble "translating" it back to Nasm! :) I *said* that, right in the first place, but I guess that was the message my browser ate... My best effort so far is "hello world", the "putimage" stuff is entirely Herbert's. I want to get it working - I plugged in a webcam... hoping to get some clues to help John... no dice - Linux does it entirely differently - but I *think* what I'm getting from the camera is 24-bit color. Haven't had any luck displaying it in a "framebuffer device", so I'm hoping X will work out easier. (fat chance) Usually, I translate Herbert's ideas "roughly" into Nasm, but for this one I'm attempting a "literal" translation. It isn't going well. Issues with what lindela will do with uninitiallized data, and what nasm will/won't do, I think. Maybe other mistranslation issues, as well. I think I can work it out, but right now I'm getting SIGBUS. Other evidence that I'm "doin' it wrong" is that Herbert's executable is 1484 bytes, and mine is 216812... Despite that, I think I'm closin' in on it. I've also got a varient that *doesn't* attempt to include the executable header - justs links with ld "normally". That one doesn't crash, but no output. That's on the back burner - I wanna do it "like lindela" this time. Meanwhile, maybe some of this stuff will help: http://mysite.verizon.net/fbkotler/hkstuf.tar.bz2 (an executable of lindela that "works here", the source renamed to lowercase, doc, source and executable of Herbert's latest - 85k) Best, Frank
From: Frank Kotler on 20 Jul 2007 11:18 santosh wrote: > //\\\\o//\\\\annabee wrote: > > >>P� Fri, 20 Jul 2007 14:05:06 +0200, skrev Phil Carmody >><thefatphil_demunged(a)yahoo.co.uk>: >> >> >>>Herbert Kleebauer <klee(a)unibwm.de> writes: >>> >>>> case 0x05: {la[--j] = la[j] / la[j+1]; break;} >>> >>>That's the line that c.l.c needs to see. >>>It'll be feeding time at the zoo! >> >>Agree, no human should dirty its mind going to the zoo at clc > > > Try not to become an assembler bigot, Wannabee. Is it okay if we're, like, really *glad* we're asm-heads, though? :) case 0x05: {la[--j] = la[j] / la[j+1]; break;} "la" is supposed to be "long", right? Is that the same as "int"? Assuming we're dealing with 32-bit quantities, "j" in ecx: mov ebx, [la + ecx + 4] mov eax, [la + ecx] cdq idiv ebx sub ecx, 4 mov [la + ecx], eax jmp end_of_switch_block If that isn't what it's supposed to do, code it so it *does* do what it's supposed to do. Cut out the middleman! I'm scared to try to find out what gcc really makes of it - too hard to find in the ".s" file! I'm even more scared to find out what part of an assembler this is! The thing works, no matter what c.l.c. may think of it. (fun to get 'em going, sometimes... shall we crosspost? :) Best, Frank
From: santosh on 20 Jul 2007 11:42 Frank Kotler wrote: > santosh wrote: >> //\\\\o//\\\\annabee wrote: >> >> >>>P� Fri, 20 Jul 2007 14:05:06 +0200, skrev Phil Carmody >>><thefatphil_demunged(a)yahoo.co.uk>: >>> >>> >>>>Herbert Kleebauer <klee(a)unibwm.de> writes: >>>> >>>>> case 0x05: {la[--j] = la[j] / la[j+1]; break;} >>>> >>>>That's the line that c.l.c needs to see. >>>>It'll be feeding time at the zoo! >>> >>>Agree, no human should dirty its mind going to the zoo at clc >> >> >> Try not to become an assembler bigot, Wannabee. > > Is it okay if we're, like, really *glad* we're asm-heads, though? :) Sure! > case 0x05: {la[--j] = la[j] / la[j+1]; break;} > > "la" is supposed to be "long", right? I don't know. "la" is the name Herbert's given to an array or pointer. What it's type is can be known only when we see the appropriate declaration. Let me check windela.c with grep. Yea, it's indeed an array of long objects. > Is that the same as "int"? No. int is meant to most closely correspond to the natural word size of the implementation. It has to be at least 16 value bits. long has to be at least 32 value bits. So, depending on the implementation long and int may or may not "map" to the same machine-level type. For example on an 8086, int will easily map to the general purpose registers, but long will have to "simulated" by using two registers. > Assuming we're dealing with 32-bit quantities, "j" in ecx: > > mov ebx, [la + ecx + 4] > mov eax, [la + ecx] > cdq > idiv ebx > sub ecx, 4 > mov [la + ecx], eax > jmp end_of_switch_block > > If that isn't what it's supposed to do, code it so it *does* do what > it's supposed to do. Cut out the middleman! Not necessary to cut out the "middleman" and tie yourself to a single CPU. With slight modification Herbert's statement can be perfectly defined C: case 0x05: { la[j-1] = la[j] / la[j+1]; j--; break; } > I'm scared to try to find out what gcc really makes of it - too hard to > find in the ".s" file! I'm even more scared to find out what part of an > assembler this is! The thing works, no matter what c.l.c. may think of > it. (fun to get 'em going, sometimes... shall we crosspost? :) Sure, the the construct may work in a particular instance. But the crux of the matter is, by violating C's semantic rules, we are opening the door for unpredictable behaviour. Do we really want that, especially when the fix is trivial? The compiler is free to evaluate expressions between two sequence points in any way it wants to. From what I understand from the regulars in c.l.c, this was added to allow the compiler to schedule the machine instructions that the construct breaks down into, in the most efficient way possible for the target machine, i.e. to allow it to perform instruction scheduling. As long as the final outcome of the construct is as expected, the compiler is free to do what it wants behind the scenes.
From: Phil Carmody on 20 Jul 2007 12:15
santosh <santosh.k83(a)gmail.com> writes: > //\\\\o//\\\\annabee wrote: > > > P� Fri, 20 Jul 2007 14:05:06 +0200, skrev Phil Carmody > > <thefatphil_demunged(a)yahoo.co.uk>: > > > >> Herbert Kleebauer <klee(a)unibwm.de> writes: > >>> case 0x05: {la[--j] = la[j] / la[j+1]; break;} > >> > >> That's the line that c.l.c needs to see. > >> It'll be feeding time at the zoo! > > > > Agree, no human should dirty its mind going to the zoo at clc > > Try not to become an assembler bigot, Wannabee. Oh come on!?!??! I miss Scott Nudds's outbreaks. Hmm, or did I mean outbursts? Phil -- "Home taping is killing big business profits. We left this side blank so you can help." -- Dead Kennedys, written upon the B-side of tapes of /In God We Trust, Inc./. |