TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Frank Adam
from: Adam Fitzpatrick
date: 1996-08-12 22:46:14
subject: Regs

Quoting Frank Adam to Adam Fitzpatrick:



FA>Just curious why is REGS a union and not a struct ? It feels like one.. 



AF>It's a union of two structs I think. :) This is because AX is divided

AF>think I've explained this very clearly, but you should be able to

AF>figure it out. 



FA>Of course :-) I think i do know that part of it.



Sorry... :)

 

FA>char* Get_DTA() 

FA>regs.x.ax = 0x2f00;

 

FA>Basicly this is what i was wondering about when i asked the question.

FA>I have a feeling that if i'd access regs.h.al, the union's byteregs 

FA>structure would get filled, than when i access regs.x.ax it would have

FA>to fill the wordregs struct. So if this is for saving bytes, i'd

FA>rather waste the a few bytes and have them in separate structs, and

FA>not in a union.( i think... :) )



No, because they overlap in memory. Changing regs.h.ah will affect the

most significant byte of regs.x.ax, and regs.h.al is the same byte of

memory as the LSB of regs.x.ax.



AF>have a look at the definition of REGS again for something like

AF>regs.h.ah or regs.l.ah. (That'll explain why it's a union I think.)



FA>The byteregs struct holds both the low and high bytes.



Yep, I just couldn't remember what the name of the struct was.



FA>ptr = (char far*) MK_FP((unsigned)sregs.es,(usigned)regs.x.dx);

 

AF>Two problems:

AF>1) It doesn't return ptr.



FA>No it returns seg:off, but that's what MK_FP turns into a ptr.



Actually, there wasn't a return statement at all IIRC.

 

AF>How about (completely untested):

 

[snip]

 

FA>Funny i've had no problems reading that code, but i'd probably never

FA>manage to write it at the present.

FA>The few feeble attempts i've had at assembly were with rather poor 

FA>results, and i guess it did put me off to a large degree.

 

FA>Thanks for that snip,i'll try it. I do use TASM when i have to.

FA>I may have to see if i can get the hang of this assembly thingo, but

FA>chances are i didn't get much better at it since the last time :-)



It might help to lurk in the 80XXX echo. Then again, it might not. :)



... Arachibutyrophobia: fear of peanut butter sticking to roof of mouth.

--- FMailX 1.02
* Origin: Power BBS - +61-2-858-4114 - Files/Games/EchoMail/Internet (3:711/953)
SEEN-BY: 50/99 620/243 623/630 711/401 409 410 413 430 808 809 932 934 946
SEEN-BY: 711/953 963 712/515 713/888 714/906 800/1
@PATH: 711/953 410 808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.