Re: A (mild-mannered) defense of RosAsm
From: Frank Kotler (fbkotler_at_comcast.net)
Date: 03/04/04
- Next message: Annie: "Re: The Great Debate V. What have changed ?"
- Previous message: Jim Carlock: "Re: A (mild-mannered) defense of RosAsm Rocks !!!"
- In reply to: RoWsRaIrTiEo : "Re: A (mild-mannered) defense of RosAsm"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 04 Mar 2004 21:28:59 GMT
RoWsRaIrTiEo wrote:
> On Mon, 23 Feb 2004 03:38:12 GMT, Frank Kotler <fbkotler@comcast.net>
> wrote:
>
>
>> call putz
>>.get_command:
>> mov esi, PromptString
>> call putz
>>.reget:
>> call getc
>> or al, 20h
>
>
> Why here al = al | 20h
Forces the character to lowercase. This isn't a valid "tolower" - there
are a lot of characters that *don't* want to be altered. Really should
check for "A - Z", but in this particular case we're only interested in
characters that *can* be forced to lowercase, so I used that "cheap and
dirty" trick.
> What are the values that Getc returns for "->" "<-" "\|/" "/|\"
> (arrows)?
Dunno. I may have made a mistake by posting Windows code - I'm quite
clueless in Windows, and not really too interested in learning it. In
Linux, I think the arrow keys (and function keys, etc.) return "ESC"
(1Bh) the first time, and have other characters available after that. I
haven't actually looked into it with the exact "getc" I posted, but with
some code that performs a similar "diddle" on stdin, I can identify the
"interesting" keys in 4 bytes (eax), although some keystrokes return
*more* than 4 bytes (I allocate an 8-byte buffer - that *seems* to
handle everything).
Recently, I've been trying to figure out how the X windows system
handles those keys. As with Windows, it's different than reading stdin
in console mode. I think I'm beginning to figure it out - enough to
identify the arrow keys, at least.
If I were going to do it for Windows "subsystem:console" code, I'd start
by "instrumenting" getc to display everything that is returned by
ReadFile. The way dos does it it to return zero, and return "M", "H",
etc. (for the arrow keys) on the second call. Windows console might be
similar - or maybe not... It probably isn't too hard to figure out. Or
you *could* RTFM, if all else fails :)
I can give you a hand with it, if you need help (I don't think you do),
but I'm kinda "in the X zone" lately... in more ways than one :)
>> push byte STDIN
>
> this push -10 like byte?
Yeah. "push byte -10" *stores* the "-10" as a byte - but the byte is
"sign extended" (the most significant bit of the byte is propagated
through the high bits) to a dword, which is pushed. You can't actually
push a single byte onto the stack - no such instruction!
> Where is the error if there i write: push dword -10
No error, it's just longer (and *may* be faster - intuitively, not
having to sign-extend the byte would seem to be faster than doing it,
but this may not be true).
"push dword -10"
00000016 68F6FFFFFF push dword 0xfffffff6
"push byte -10"
0000001B 6AF6 push byte -0xa
In either case, the full dword goes on the stack. Some assemblers
(RosAsm among them) automatically use the shorter form if it'll fit. The
Original Authors of Nasm, in their Infinite Wisdom, decreed that just
"push -10" should generate the long form. I can't imagine that they
found the calculation too complex (Nasm returns an error on "push byte
100h", and a warning on "push byte 0FFh", so it *does* know...), it was
a deliberate decision - possibly not the best one ever they ever made...
You can override this rather "dumb" behavior with the "-O" switch. I
usually don't use the "-O" switch, preferring to write "byte" where
appropriate, so my code will assemble the same with or without the "-O"
switch (using the "-O" switch to "test myself" - it often picks up
places I've missed). In the case of "named constants" like STDIN - and
there are a ton of them in typical Windows code - you might not "know"
without looking it up whether "WQ_ADJUST_LANTHANUM_FLUX_DENSITY" is
within signed-byte range or not. This is where using the "-O" switch -
or the behavior of "other assemblers" - is a big advantage!
There are enough instances of "push 0" in typical Windows code that it
*does* make a difference (although it isn't a very big deal).
Best,
Frank
- Next message: Annie: "Re: The Great Debate V. What have changed ?"
- Previous message: Jim Carlock: "Re: A (mild-mannered) defense of RosAsm Rocks !!!"
- In reply to: RoWsRaIrTiEo : "Re: A (mild-mannered) defense of RosAsm"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|