1. fresh question: dos_interrupt()
- Posted by Alan Tu <ATU5713 at COMPUSERVE.COM> Oct 05, 1998
- 595 views
- Last edited Oct 06, 1998
The constants defined in machine.e for dos_interrupt() don't make sense. = For example, there's no AH, but it seems AH is equivalent to AX in Euphoria. I don't get it. Could someone please help? Alan =
2. Re: fresh question: dos_interrupt()
- Posted by Hawke <mdeland at NWINFO.NET> Oct 05, 1998
- 539 views
- Last edited Oct 06, 1998
Alan Tu wrote: >The constants defined in machine.e...don't make sense. >For example, there's no AH, but it seems AH is >equivalent to AX in Euphoria. well, AH is a part of AX. so in one sense, them being equivalent is kinda true... AX is comprised of a _pair_ of 8 bit 'storage vessels'. as it turns out, 4 bits is a value that is representable by a single hexadecimal value. what this means is that the value of AX will be 4 numerals in length, with each numeral being a value from 0..F and will have a total of 16bits or 4 bytes. examples of values held by AX might be F29Ch, or 374Dh, and so on. The AH part of AX is the high order "byte", and we generally assume that in casual conversation it's the first two numerals(bytes). the AL part of AX is the low order "byte", and it's generally the last two numerals(bytes). the reason the word "byte" is quoted above is that they are really nibbles. they did that just to confuse you :) so AX is therefore: AH AL and in the example above, F29Ch would mean AH was F2 and AL was 9C. if you goto look at this directly, with a debugger of some sort, or a direct memory dump perhaps, the great maker in it's infinite wisdom decided that we would not store things that way internally, and we use byte reordering (aka byte swapping) and all the hexadecimal values are backwards between high order and low order nibbles. does that concern you? in theory, no. but you need to be introduced to that, and you need to be aware of it. if you build a program in this manner, and need to debug it, then as you begin examining real-time outputs of your data being held in memory, you will potentially see this mechanism in action. it's rather disconcerting. if you pull out a value from AX using dos_interrupt, it should (i believe) be properly byte ordered. simply take the first 8 bits, or the first 2 hexadecimal numerals, from the value euphoria tells you AX to be, and that will be AH. the last 8 bits, or the last 2 hexadecimal values, will be AH. and now you can see why the constants AH and AL are not really needed and why they aren't defined. that would be like having a constant holding a real number, but it only holds the numeric part, and having another constant holding the fractional part of that real. kinda goofy, no? why hold only half of a value? hope this helps... --Hawke'
3. Re: fresh question: dos_interrupt()
- Posted by John Worthington <woodmage at EARTHLINK.NET> Oct 06, 1998
- 554 views
Alan Tu wrote: > The constants defined in machine.e for dos_interrupt() don't make sense. > For example, there's no AH, but it seems AH is equivalent to AX in > Euphoria. I don't get it. Could someone please help? Ahah! Something I can understand! <g> AH is IN AX but is not the SAME as AX. Basicly, put it this way, AX = { AH, AL }. What's going on here is that you can adjust both the high and the low byte of AX by referring to AH and AL (in assembly, etc). So,... If you need AH to be (for example) 32 and AL to be (fe) 128, then AX = 32 * 256 + 128. Er, you work it out. If you don't care about AL or want it zero, simply make AX=256*AH. In Euphoric, function makeAX(AH,AL) integer AX AX=256*AH+AL return AX end function myvar1 = makeAX(var1,0) myvar2 = makeAX(var2, var2b) The same goes for BX,CX,DX. BX=BH*256+BL. CX..... etc. Sorry this got so long and hope it helps. ;') \/\/ood/\/\age
4. Re: fresh question: dos_interrupt()
- Posted by Ralf Nieuwenhuijsen <nieuwen at XS4ALL.NL> Oct 06, 1998
- 567 views
>The constants defined in machine.e for dos_interrupt() don't make sense. >For example, there's no AH, but it seems AH is equivalent to AX in >Euphoria. I don't get it. Could someone please help? AH, Stands for Variable: A Part: H(igh) Proccesors have variables (as you might have noticed), you need to set those variable to give an 'argument' to an interrupt call. You have A, B, C, etc. Each of those variables are 2, yes *2* bytes long. If you want to set the HIGH-byte you use AH in ASM for example. To acces the LOW-byte you use AL in ASM for example. To acces both the bytes you can use AX in ASM for example. Euphoria only lets you set all two bytes, however this should be no problem. function make_x (byte low, byte high) return low*256 + high end function For example: integer A function set_high (integer a, integer val) a = and_bits (a, 256*255) a = a + val return a end function function set_low (integer a, integer val) a = and_bits (a, 255) a = a + (val * 256) return a end function So, to set AH of A to 4 do: a = set_high (a, 4) To set AL of A to 8 do: a = set_low (a, 8) To set AX of A to 12 do: a = 12 Did this help ? Ralf nieuwen at xs4all.nl
5. Re: fresh question: dos_interrupt()
- Posted by Matt Z Nunyabidness <matt1278 at JUNO.COM> Oct 06, 1998
- 550 views
The registers AX,BX,CX, and DX are split into these: AH and AL, BH and BL, CH and CL, DH and DL. Specifying a value of 1 for AH won't work, but you can specify a value of 0100 for AX. There also some other registers: DI SI and BP. _________________ When it comes to programming languages, Euphoria is a cut above matt1278 at juno.com Euphoria programmer Webbers: <A HREF="mailto:prezsoft at juno.com">prezsoft at juno.com</A>, president of SoftCo. All virus proggers should die horrible deaths™ ___________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com or call Juno at (800) 654-JUNO [654-5866]
6. Re: fresh question: dos_interrupt()
- Posted by Alan Tu <ATU5713 at COMPUSERVE.COM> Oct 06, 1998
- 545 views
- Last edited Oct 07, 1998
Ralf, Previously, there's been only used...er (clear the throat). Previously, they only used high bytes for Int 21 functions, interestiing. Now they'v= e begun, with Win9x, to have the high bytes equal 71 and the low bytes be 00-whatever. Interesting now they use low order also. --Alan =
7. Re: fresh question: dos_interrupt()
- Posted by Alan Tu <ATU5713 at COMPUSERVE.COM> Oct 06, 1998
- 555 views
- Last edited Oct 07, 1998
John, Thanks a lot. --Alan =
8. Re: fresh question: dos_interrupt()
- Posted by Alan Tu <ATU5713 at COMPUSERVE.COM> Oct 06, 1998
- 534 views
- Last edited Oct 07, 1998
Hiya Hawke! (BTW, learned this expression from you) Thanks. So H is for high and L is for low. All right, I got it. So now= I can relate AH and AL to AX and DH and DL to DX. Great! Boy, this is whe= re I think programming is fun, not that I'm going to home-brew use any DOS interrupt very soon. --Alan =
9. Re: fresh question: dos_interrupt()
- Posted by Hawke <mdeland at NWINFO.NET> Oct 06, 1998
- 533 views
- Last edited Oct 07, 1998
Alan Tu wrote: > Hiya Hawke! (BTW, learned this expression from you) are my bad habits really rubbing off so easily?? =) >So now I can relate AH and AL to AX and DH and DL to DX. and now that you think it's easy, let's mess you all up. *cackle* before you go headlong into asm programming, even via EU and dosinterrupt(), be forewarned that certain registers are (this is a real bad way to put this actually) "reserved" for certain operations. i mean 'reserved' kinda backwards tho. it's not that you cannot use them, as your free to use AX,BX, CX & DX pretty much as you see fit. this last statement has one large caveat all by itself. you need to remember to save the state they were in (ergo data they held) *before* you go running off and fiddlefarting with them or you're likely to be smelling brainfarts soon. with that out the way, i'll define reserved a bit more. certain of these registers are reserved for certain functions. what that means is certain functions expect certain registers to contain data they are looking for. "well, i've noticed that already as interrupt 2xh wants al to be XXh and ah to be XXh" ummmm... that ain't what i mean here. this reserved business gets rather involved and often it's not real well documented. it would be documented in a book showing how to do asm coding. it's not real well documented in lists of interrupts. operations like division expect the divisor to be in one very specific place and the dividend in another very specific place, and that is what i mean by reserved. another example is accessing data held in a variable through a process called 'offsetting'. the B register is reserved for most offset functions (as memory serves... pete?). if you place your divisor in the right place and the dividend in the wrong place, and you call the division function in asm, well... brainfarts, migraines and rampant hair loss are the answers you get. :) we'll talk, mebbe get a subgroup from the list that is real proficient at asm to help you further, if you're interested, as it does go offtopic rather quickly, if not carefull. --Hawke'