🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #7277

Re: byte vs word movs

#7277
From: Duncan Murdoch
Date: Sun, 23 Jun 1991 21:20
50 lines
2620 bytes
In article <k88Z44w164w@bluemoon.uucp> andy@bluemoon.uucp (Andy Vaught) writes:
>dmurdoch@watstat.waterloo.edu (Duncan Murdoch) writes:
>
>> In article <ysyw42w164w@bluemoon.uucp> andy@bluemoon.uucp (Andy Vaught) write
>> >storm@cs.mcgill.ca (Marc WANDSCHNEIDER) writes:
>> >> SECTOR    DB 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
>> ...
>> >> MOV  DX, SECTOR[BX]
>> What does it do?  The instruction looks ambiguous to me, since DX is word
>> sized and SECTOR[BX] is byte sized.  Does TASM move a word (i.e 0B0A if
>> BX=0)?  That's probably not what was intended...
> 
>Since the author specified the DX register, the assembler should, IMHO, 
>generate a word move without complaint. "SECTOR" is only an offset into a 
>memory location. Although "bytes" were specified, this is an artifact of 
>the assembler and its rigid (rabid?) typechecking. 

If we didn't want to type SECTOR as a byte, we could have put a colon after
it, and it would be an offset into a memory location.

>The whole thing is a 
>matter of taste- I feel that assembler (like C) should let you do weird 
>things without complaint.

I agree that it's a matter of taste, but I still think that the original
instruction was ambiguous.  You seem to be saying the data size in 
instructions like

  MOV dest,source

should be the same as the size of the register involved.  This doesn't help
with a case like

  MOV DX,AL

(which I hope you'll agree shouldn't assemble).  I guess we're lucky that
Intel never lets you make two memory references in the same instruction,
or we'd have another special case to work out.  It seems to give a cleaner
language definition to say that the source and destination must be the same
size, and then allow typecasts like

  MOV DX, WORD PTR SECTOR[BX]

for the cases where you want to do weird things.

Duncan Murdoch
dmurdoch@watstat.waterloo.edu

P.S.  I bet the original poster, whose name I've lost, really did intend
to get 000A in DX in the example above!
Technical Details
Message-ID: <1991Jun23.212037.19949@maytag.waterloo.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!spool.mu.edu!news.cs.indiana.edu!maytag!watstat.waterloo.edu!dmurdoch
References: <1991Jun22.170522.3008@maytag.waterloo.edu> <k88Z44w164w@bluemoon.uucp>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!spool.mu.edu!news.cs.indiana.edu!maytag!watstat.waterloo.edu!dmurdoch
From: dmurdoch@watstat.waterloo.edu (Duncan Murdoch)
Newsgroups: comp.os.msdos.programmer
Subject: Re: byte vs word movs
Message-ID: <1991Jun23.212037.19949@maytag.waterloo.edu>
Date: 23 Jun 91 21:20:37 GMT
Article-I.D.: maytag.1991Jun23.212037.19949
References: <1991Jun22.170522.3008@maytag.waterloo.edu> <k88Z44w164w@bluemoon.uucp>
Sender: news@maytag.waterloo.edu (News Owner)
Organization: University of Waterloo
Lines: 50