From: "Rylan" Newsgroups: comp.os.msdos.djgpp Subject: Real Mode Intel to Protected Mode AT&T Date: Tue, 4 Aug 1998 19:03:25 +0200 Organization: The South African Internet Exchange Lines: 139 Message-ID: <6q7f86$dh5$1@news2.saix.net> Reply-To: "Rylan" NNTP-Posting-Host: pc25-01-p15.saix.net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Hi! I'm trying to do an interesting little experiment to convert a small real mode assembler demo to protected mode inline AT&T syntax for DJGPP. It is a small "fire" demo of gray smoke moving upward from the middle of the screen with a very realistic smoke effect. Here is the Intel program that does the effect (looks like TASM): .MODEL TINY .386 .CODE .STARTUP push 0a000h pop es push es pop ds mov al,13h int 10h mov dx,3c8h xor ax,ax out dx,al inc dx DAC_loop: out dx,al out dx,al out dx,al inc ax jnz DAC_loop MainLoop: mov si,320 mov ch,7dh ; cx=0, 320*100=0x7D00, so ch=0x7D push si ; to be re-cycled later push cx smoothloop: lodsb ; thanx to Chaos for reminding me this! mov bl,[si] add ax,bx mov bl,[si+319] add ax,bx mov bl,[si-2] add ax,bx shr ax,2 mov [si-321],al loop smoothloop pop di ; re-cycle time! pop cx randline: mul word ptr [di] ; what a way to make random numbers! inc ax ; why is 'inc ah' 2bytes but 'inc ax' 1byte?? stosw dec di ; must try to get rid of this byte... loop randline MOV AH,1 INT 16h ; key-press test Jz MainLoop ;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Bye: mov ax,3 int 10h ret END The AT&T & C equivalent works fine (including setting up the palette) but then something goes wrong. I only get a stationary line of fire in the middle of the screen. I do not include the whole program (for reasons of brevity) since the rest of it works fine (a selector for video ram, etc. etc.) The problem must lie here somewhere: (The mainloop section) __asm__ __volatile__ (" movw _global_selector,%%es movw _global_selector,%%fs movl $0xA0000,%%edi movl $0aA0000,%%esi mainloop: movw $320,%%si movb $0x7d,%%ch pushw %%si pushw %%cx smoothloop: lodsb movb %%fs:(%%esi),%%bl addw %%ax,%%bx movb %%fs:319(%%esi),%%bl addw %%ax,%%bx movb %%fs:-2(%%esi),%%bl addw %%ax,%%bx shrw $2,%%ax movb %%fs:-321(%%esi),%%al loop smoothloop popw %%di popw %%cx randline: mulw (%%edi) incw %%ax stosw decw %%di loop randline jmp mainloop " : : : "ax","bx","cx","memory" ); Note that I use FS as an override, since trying to use DS GPF's me out each time. FS then references as FS:ESI (instead of DS:ESI) and EDI of course automatically references ES:EDI (the video selector for video RAM). Can anybody tell me where I made a mistake? Some selector:offset mistake somewhere? Any help will be gladly appreciated - please reply by mail if at all possible. Anybody else interested in this kind of conversion stuff? (BTW - I did this with NASM (Real TASM to Prot NASM) and it worked fine - just interested in the AT&T side of things) Again, fanx! -- Spawned By Rylan Is truth beauty or beauty truth?