Legacy apps in Windows/OS X was Re: Old MS-DOS & Win Software
Patrick Finnegan
pat at computer-refuge.org
Wed Dec 7 23:21:28 CST 2005
Chuck Guzis declared on Wednesday 07 December 2005 21:32:
> On 12/7/2005 at 9:03 PM Patrick Finnegan wrote:
> >Chuck Guzis declared on Wednesday 07 December 2005 20:26:
> >> keeping things like the DAA instruction intact and supporting a
> >> bunch of do-nothing instructions like MOV DL,DL.
> >
> >FYI, that most certainly doesn't just "do nothing." It updates the
> > flags based on the contents of the DL register, and you could do a
> > conditional jump based on the results.
>
> With all due respect, I suggest that you review your X86 instructions
> and their effect on flags. Try running this little bit of code under
> your favorite debugger (DEBUG is fine) and have a gander at the flags
> register:
>
> xor ax,ax
> mov dl,-1
> mov dl,dl
> int 3
I'll admit it's been a while since I've bother to do much x86 assembly,
but I don't doubt you're right. I think I might have been thinking more
of "and dl, dl", which I'm pretty sure ought to update the flags.
Pretty much any assembly language has useless constructs like that,
though, just because it makes the instruction set easier to implement
(and sometimes, compilers easier to write).
For example, in RISC architectures, register 0 is generally fixed to read
0. When you would normally do stuff like:
mov r1,r2
you can also do
mov r0,r2
or even
mov r0, r0
(using syntax there the matching intel syntax
> Now, if your point of view held, the condition code should show a
> nonzero negative (signed) value. In fact, they show a zero positive
> value (i.e. the results of the XOR AX,AX). In fact, moves, be they
> register to memory, register to register or memory to register or
> memory to memory do not affect condition code bits. Else why have a
> nutty instruction like JCXZ? You coiuld just MOV CX,CX and jumpt on
> the zero result...
Sure there's a reason. JCXZ is one instruction, and (probably) uses up
less code space than the other. You could "AND CX,CX" and do a JZ
afterwards to do the same thing.
> >> Consider on Windows XP that you can still run the following code:
> >>
> >> mov cl,9
> >> mov dx,offset HWMes
> >> call 5
> >> mov cl,0
> >> call 5
> >
> >Huh? Do you mean this?
> >
> >MOV AH, 9
> >MOV DX, HWMes
> >INT 21h
> >MOV AH, 0
> >INT 21h
>
> Nope, I mean what I said--try it.
I don't have a Windows system to try it on. I could probably find
something running DOS (or OS/2) to try it on, assuming DEBUG is
installed on the machine... I vaguely remember the PCB "jump to DOS"
vector, but never used it when I wrote code (for the same reason I never
used an FCB to touch files.. probably just too young :).
Pat
--
Purdue University ITAP/RCAC --- http://www.rcac.purdue.edu/
The Computer Refuge --- http://computer-refuge.org
More information about the cctalk
mailing list