--------------- FIDO MESSAGE AREA==> TOPIC: 145 ASSEMBLY LANG. Ref: E3T00014Date: 03/21/97 From: DENIS BOYLES Time: 05:05pm \/To: KEVIN BARROW (Read 2 times) Subj: Master Environment - cod ;SETHELLO.ASM - Public Domain by Denis Boyles ; ! Arrowsoft Assembler (MASM v3.0) ; ? Demonstrate interrupt 2Eh method of finding the Master ; Environment. ; * Appends to ME so you'll need adequate space (22 bytes extra) ; Also uses ANSI codes for illustration, need an ANSI driver PRG SEGMENT ASSUME CS:PRG,DS:PRG ORG 0100h main PROC mov AX,352Eh ;DOS - get interrupt vector (for 2Eh) int 21h ;call DOS to get the vector address mov ES,ES:[2Ch] ;set ES to `master' environment? xor DI,DI ;zero out destination index M0: ;walk environment loop cmp word ptr ES:[DI],0000h ;0,0 marks the end of the environment jz M1 ;if found, move on to next part inc DI ;otherwise, increment DI for next byte jmp M0 ;and keep looping until 0,0 found M1: inc DI ;point to THE last byte of environment mov SI,offset string ;DS:SI -> the test string to write mov CX,22 ;which is 22 bytes long in size rep movsb ;append it into the environment mov AX,4C00h ;DOS - terminate program with code (0) int 21h ;call DOS to terminate program main ENDP ;test string uses ANSI codes! string db 27,"[7mHello, World",27,"[0m",0,0 PRG ENDS END main * OLX 2.1 TD * Chicken heads are the chief food of captive alligators. --- Maximus/2 3.01 * Origin: Frog Hollow Port Moody BC 604-469-0264/0284 (1:153/290) --------------- FIDO MESSAGE AREA==> TOPIC: 145 ASSEMBLY LANG. Ref: E3T00015Date: 03/21/97 From: DENIS BOYLES Time: 05:05pm \/To: KEVIN BARROW (Read 2 times) Subj: Master Environment - tex [re-posted] Hey Kevin! KB>MH> MH>> Modifying the DOS master environment is risky. KB>MH> There's no officiall KB>MH> MH>> documented way of doing it. For starters, you could try the COMMAND.COM interrupt 2Eh back door method. I used this `trick' to find the master environment in my EMEM program. KB> DS> The MS-DOS Developers Guide, Waite Group ISBN 0-672-22630-8, has the KB> DS> steps required to walk back through the MCB's (Memory Control Blocks) DOSREF33 mentions walking the PSPs as another way of finding the master environment. Anyway, let me get back to the interrupt 2Eh thing... KB>Hmm, Well I am one Broke boy, could you Post some code so that I KB>could "disect" it and learn about how to do it the cheap way =) In due time, in due time, but first a little theory, ya ya, I know, BORING right... :) The theory goes like this... When COMMAND.COM is loaded, it hooks itself into several interrupts. One of these interrupts is 2Eh, the `back door', which allows for command execution and addition. This allows programs like DOSKEY and STACKER's REDIRECTOR to work their magic. By finding the segment address of this vector, you will hopefully find COMMAND.COM. Then use the special properties of a COM program to find the PSP and then COMMAND.COM's environment. Once you've done this, you have basically found the `master environment'! As they say, there is no `official' way of finding the master environment, so to each his own. I've tried the 2Eh method on my computer with PC-DOS v4.01, MS-DOS v6.20 and even 4DOS v5.51? and it worked! Ok, now onto the demo code, :) the following is the classic `Hello, World' program with a twist. Instead of printing to the screen, the text is printed into the master environment. To further illustrate the technique, the text contains ANSI codes! (a simple reversed video sequence) [The text is appended to the environment, so make sure you have enough space to safely accomodate it. You'll also need an ANSI driver installed for the illustrative effect.] First, build the program into a COM file and then execute it. Now type the SET command. You should see your environment settings, plus a reversed video Hello, World message! [PS: program code follows in seperate message] BTW: The environment consists of a bunch of NULL terminated strings, like in C. That is, each entry in the environment ends with a value of 0. The end of the environment is marked by a single NULL string. ie: PATH=C:\DOS PROMPT=$P$G Looks like so: PATH=C:\DOS,0 <- NULL terminated string PROMPT=$P$G,0 <- NULL terminated string 0 <- NULL terminated string, end of environment Cheers, Denis Boyles * OLX 2.1 TD * This tagline stolen by Off-Line Xpress! --- Maximus/2 3.01 * Origin: Frog Hollow Port Moody BC 604-469-0264/0284 (1:153/290) --------------- FIDO MESSAGE AREA==> TOPIC: 145 ASSEMBLY LANG. Ref: E3T00016Date: 03/18/97 From: DENIS BOYLES Time: 06:46pm \/To: NICK COONS (Read 2 times) Subj: MOV using same register. Hi Nick! NC> Would using the following instruction: NC> mov bx, [bx] NC> ...actually do what it looks like it would do? That is, move the NC>contents of the memory location pointed to by ds:bx into bx? Can I use a NC>segment override here (es)? You've answered your own question, :) for that's exactly what it will do. Since DS is the assumed default register and BX can be used as an index this will: o fetch the WORD located at DS:[BX] o then store it into BX overwriting the original value You can also use a segment override, like you normally would with other statements. ie: mov BX,ES:[BX] Cheers, Denis Boyles * OLX 2.1 TD * Back Up My Hard Drive? I Can't Find The Reverse Switch! --- Maximus/2 3.01 * Origin: Frog Hollow Port Moody BC 604-469-0264/0284 (1:153/290) --------------- FIDO MESSAGE AREA==> TOPIC: 145 ASSEMBLY LANG. Ref: E3T00017Date: 03/22/97 From: DENIS BOYLES Time: 03:48pm \/To: MORTEN PERRIARD (Read 2 times) Subj: Moving Memory via FPU? Hello Morten, MP> PVH>> animated objects in games, do they just redraw them with REP MOVSW MP> AT> In the most cases, yes. But there are some other MP> AT> methods like DMA (the old one) and the FPU. MP>Is it possible to copy graphics to video-memory faster with the FPU, than wit MP>REP MOVSD? I know I can move 64 bit (or even 80bit) at once I haven't programmed the FPU, but last time I checked it was a (F)loating (P)oint (U)unit. The renamed math coprocessor that speeds up various math operartions. What does that have to do with moving chunks of memory around? Cheers, Denis Boyles * OLX 2.1 TD * MSI - Bringing it all together in '92 --- Maximus/2 3.01 * Origin: Frog Hollow Port Moody BC 604-469-0264/0284 (1:153/290) --------------- FIDO MESSAGE AREA==> TOPIC: 145 ASSEMBLY LANG. Ref: E3T00018Date: 03/22/97 From: DENIS BOYLES Time: 03:48pm \/To: ANTON TOKAR (Read 2 times) Subj: Moving Memory via FPU? Hello Anton, MP> PVH>> animated objects in games, do they just redraw them with REP MOVSW MP> AT> In the most cases, yes. But there are some other MP> AT> methods like DMA (the old one) and the FPU. MP>Is it possible to copy graphics to video-memory faster with the FPU, than wit MP>REP MOVSD? I know I can move 64 bit (or even 80bit) at once I haven't programmed the FPU, but last time I checked it was a (F)loating (P)oint (U)unit. The renamed math coprocessor that speeds up various math operartions. What does that have to do with moving chunks of memory around? Cheers, Denis Boyles * OLX 2.1 TD * MSI - Bringing it all together in '92 --- Maximus/2 3.01 * Origin: Frog Hollow Port Moody BC 604-469-0264/0284 (1:153/290) --------------- FIDO MESSAGE AREA==> TOPIC: 145 ASSEMBLY LANG. Ref: E3T00019Date: 03/22/97 From: BENJAMIN L MCGEE Time: 02:37pm \/To: ALL (Read 2 times) Subj: BP upon entry How is BP defined upon entry to a DOS program? I continue to get the value 091Ch, is that significant? thanx *The road to success is always under construction blm --- FLAME v1.1 * Origin: Purgatoire BBS, 719-846-0140, Trinidad, CO, V.34 (1:15/7) --------------- FIDO MESSAGE AREA==> TOPIC: 145 ASSEMBLY LANG. Ref: E3T00020Date: 03/21/97 From: MARTIJN VAN DE STREEK Time: 06:22pm \/To: IAN MOOTE (Read 2 times) Subj: Gs Hi Ian, Long ago, on Tue 18 Mar 1997, Ian wrote to Nick: IM> Yeah, sure. So's A86, Welfare, and Medicare. It's all those IM> money trees that the liberals planted... IM> Fido is not free. At least not for those of us that have to IM> pay for it. The only thing I pay for fido is the phone bills :) Martijn --- * Origin: Main acticity - coding coders. (2:283/507.4) --------------- FIDO MESSAGE AREA==> TOPIC: 145 ASSEMBLY LANG. Ref: E3T00021Date: 03/22/97 From: STEVEN READ Time: 04:46pm \/To: NICK COONS (Read 2 times) Subj: Delays Nick, NC> ================================================================ NC> Packet: PC-OHIO NC> Date: 03-15-97 (15:26) Number: 11366 NC> From: NICK COONS Refer#: NONE NC> To: JOHN GARDENIERS Recvd: NO NC> Subj: DELAYS Conf: (708) 80XXX-F NC> ---------------------------------------------------------------- NC> > Programmers rule number one: Never assume that there's any NC> > consistency in the way things are implemented on different NC> > CPUs or computer systems. To do so will often cause problems. ;-) NC> The person in here that told me this said, when I asked, "Does NC> NOP take any clock cycles?", "Yes, it takes one clock cycle." ****************************************************************** For the 80xxx series CPUs Taken from the Turbo Assembler Quick Reference Guide (TASM 4.0) Opcode Instruction Clocks Description --------------------------------------------------------------- 486 386 286 86 --- --- --- --- 90 NOP 1 3 3 3 No operation