--------------- FIDO MESSAGE AREA==> TOPIC: 145 ASSEMBLY LANG. Ref: EAE00016Date: 06/10/97 From: DENIS BOYLES Time: 05:02am \/To: BARRY BLOCK (Read 2 times) Subj: CLEARING SCREENS Hi Barry! BB> Hello all, I asked for a timer routine with better resolution than BB> 1/18 sec. In the meantime I rewrote the program and renamed it to A couple of thoughts. You could program the timer itself to a faster resolution than 1/18 for the duration of your program. The only catch is hat your system time will go warp speed! :) Another thought is to use one of the BIOS services in the CASETTE interrupt. There's a couple of millisecond timer functions that use the RTC and are available on 286+ machines. One function is a WAIT one, that will wait the specified number of milliseconds. The other is a WATCHDOG timer that will set a flag in the BIOS DATA segment when the time is up. Look under interrupt 15h (CASETTE) for the WAIT / WATCHDOG TIMER functions. (they might be microsecond counters or milli, can't remember) BB> something more appropriate. Anyone want to share a screen clearing BB> routine? Sure! When I come up with something :) ... * * * time passes * * * ...ok, I've got something, that wasn't too long now was it. :) =========================================================================== ;-=] SLOTCLR.ASM [=- Public Domain 1997 by Denis Boyles ; ;Arrowsoft Assembler (MASM v3.0) | VAL Linker (.COM) | MS-DOS v6.20 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; This program will clear the default 80x25 DOS screen in a kinda slot ; machine fashion. That is, each character is "rolled" down to a space ; character, kinda like how the slots roll. ; ; Things to do: 1) I assumed that characters < space will not be on the ; screen. So I suppose that could be added and checked for. ; ; 2) Add color support? The color attributes are not changed, ; only the ASCII codes. Therefore they retain whatever ; attributes were there to start with. ; ; 3) Make it video mode/card independent. PRG SEGMENT ASSUME CS:PRG ORG 100h ;-=] main [=--------------------------------------------------------------- ; Clears the 80x25 text screen using a "slot machine" method. That is, ; decreasing the ASCII values in memory until they become spaces. main PROC mov AX,0B800h ;Setup DS to point to the color text mov DS,AX ;RAM segment. M0: xor DX,DX ;zero out DX as space counter xor SI,SI ;zero out SI as offset index mov CX,2000 ;we'll loop 80x25 times checking M1: cmp byte ptr [SI],' ' ;is the current byte a space? jne M4 ;no, then assume above and check. M2: inc DX ;otherwise increment out space counter cmp DX,2000 ;have 2000 spaces been counted? je M5 ;yes, then screen clear, quit program M3: ;no then... add SI,02h ;increment offset by 2,skipping color loop M1 ;and loop back up to M1 for one screen call WaitRetrace ;pause between pages to show effect jmp M0 ;keep looping until screen all spaces M4: dec byte ptr [SI] ;decrement ASCII value jmp M3 ;and move on to the next character M5: ret ;back to DOS main ENDP ;-=] WaitRetrace [=-------------------------------------------------------- ; This waits for a complete vertical retrace of the screen before returning ; to the caller. This is two fold; it provides a "delay" and makes it CPU ; independent. WaitRetrace PROC mov DX,03DAh ;DX = CGA Status Port to read from WR0: ;flush out current retrace in AL,DX ;input status byte from port test AL,8 ;test retrace bit jnz WR0 ;keep looping while 1 to flush WR1: ;wait for retrace start in AL,DX test AL,8 jz WR1 ;keep looping while retrace is 0 ret WaitRetrace ENDP PRG ENDS END main =========================================================================== Cheers, Denis Boyles ___ Blue Wave/QWK v2.12 --- 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: EAE00017Date: 06/10/97 From: DENIS BOYLES Time: 05:02am \/To: PAUL WANKADIA (Read 2 times) Subj: DEBUG MM> With any Microsoft operating system, there comes a mega though hacking MM> utility called DEBUG.COM or DEBUG.EXE - this uncanny tool allows you PW> The best part is trying to get it to look at 386+ instructions MS-DOS's DEBUG program only supports 808x instructions, but checkout the DEBUG in OpenDOS! It also supports 386+ instructions and even Pentium instructions and everything else in between! The only downside is you can't actually see the registers in the R listing, only the standard 808x ones. However you can assemble and dis-assemble the code and even modify the registers with R. ie: A mov EAX,ABCD1234 R EAX EAX ABCD1234 : Since OpenDOS is really Novell DOS, I imagine Novell DOS / DR-DOS has the same capabilities. Cheers, Denis Boyles ___ Blue Wave/QWK v2.12 --- 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: EAE00018Date: 06/10/97 From: DENIS BOYLES Time: 05:02am \/To: PAUL WANKADIA (Read 2 times) Subj: DJGPP, GCC ET AL PW> myself a binary image when I compile. Unfortunately, I now get a PW> strange byte thrown into my code, namely 0x66. According to one of the PW> files with Ralfie's list, it's some kind of prefix for 386+ to specify Yep, it's a 386+ prefix that would allow DWORD sized chunks of memory to be moved instead of WORD sized. (Possibly other things as well) ie: REP MOVSD ;mov a DWORD chunk on a 386 Could be done as: db 66h ;386 prefix REP MOVSW ;to 8x code to move a DWORD chunk PW> memory-size or something. Does anyone know how to get rid of it? It DJGPP Is a 386 C compiler isn't it? As such I doubt you'll be able to get rid of it. Unless you can over-ride 386 code generation and use 808x code generation instead. Cheers, Denis Boyles ___ Blue Wave/QWK v2.12 --- 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: EAE00019Date: 06/10/97 From: DENIS BOYLES Time: 05:02am \/To: BARRY BLOCK (Read 2 times) Subj: INT 2E TEST Hi Barry, BB> I didn't like what Debug did with your int2etst.dbg (512 bytes), BB> so I had A86 assemble it. 17 bytes. QEMM took exception. Not debug's fault really, just my own. I intentionaly put a large save count so I wouldn't have to count it! :) Anyway... BB> Tried without QEMM and got your results. Ahh good. Now you see what I mean by the registers being toasted. The hard part is that some shells/DOSs seem to save them for you. Such as OpenDOS, it returned from the call ok and so it would seem with 4DOS. Only MS-DOS seems to crash everything, since that's the bottom line I guess play it safe and save them. Cheers, Denis Boyles ___ Blue Wave/QWK v2.12 --- 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: EAE00020Date: 06/10/97 From: DENIS BOYLES Time: 05:02am \/To: DAVID SIMAL (Read 2 times) Subj: INTERRUPT 6 Bonjour David, DS> Can someone help me understand how works the CPU DS> generated interrupts 06 & 07 (INVALID OPCODE & NO PROCESSOR DS> EXTENSION AVAILIBLE), I heard that it is possible to Don't know about 7, but I know a bit about 6. When the CPU encounters an instruction it doesn't support or understand it calls this interrupt. By hooking your own code there, you can provide a safe mechanism to reset the machine when such instructions are encountered. The "invalid instruction" dialog that pops up sometimes in Windows when your DOS session crashes. or the GPF or when EMM386 takes a hit and offers to reboot your machine. DS> emulate other instructions/processor using those DS> interrupts, for example, when reprogramming int 06, it is Hmm, just theorizing here, but when the int is called it will be pointing to the "instruction". So, if your handler looked at this instruction, you could perform some action based on it. Thus you could create your own special CPU instructions. Cheers, Denis Boyles ___ Blue Wave/QWK v2.12 --- 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: EAE00021Date: 06/10/97 From: DENIS BOYLES Time: 05:02am \/To: PAUL WANKADIA (Read 2 times) Subj: INVALID OPCODES PW> Does anyone know what happens when the CPU comes across an opcode PW> that it doesn't understand? For example, what happens if a 386 tries PW> to run a 486 or a Pentium opcode? The CPU will issue an interrupt #6 (invalid opcode) where a handler can act on it properly. For example, you might pop up a dialog informing of the condition and offer to reboot the PC. Here's an example: This program installs a handler for interrupt #6 that displays a message and reboots the computer. =========================================================================== ;-=] BADOP.ASM [=- Public Domain 1997 by Denis Boyles ; ;Arrowsoft Assembler (MASM v3.0) | VAL Linker (.COM) | MS-DOS v6.20 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; This is a sample program demonstrating the CPU's "invalid opcode" ; interrupt. (#6) A handler is installed for the interrupt that issues a ; warning dialog and then reboots the computer. This is triggered by putting ; in some DB directives with invalid code to execute. ; ; The "invalid" code used is 0F, 0B which does the job on my 386 computer. ; ; Tested and worked in real mode and in protected/V86 mode under HIMEM.SYS nd ; EMM386.EXE. Windows however intercepted the interrupt itself to display ; it's own dialog message. Therefore, run this program in a strict DOS ; environment, NOT Windows. PRG SEGMENT ASSUME CS:PRG,DS:PRG ORG 100h ENTRY: jmp main msg db 13,10,7,"SYSTEM ERROR: Invalid Opcode",13,10,10 db "An invalid CPU instruction has been executed. The",13,10 db "system has become unstable!",13,10,10 db "Press any key to reboot.$" ;-=] main [=--------------------------------------------------------------- ; Installs the invalid opcode handler and then issues some invalid ; instructions to trigger the interrupt. main PROC mov AX,2506h ;DOS - Set Vector [Interrupt #6] mov DX,offset InvalidOpcode ;DS:DX -> New Handler int 21h ;CALL DOS to install handler dw 0B0Fh ;inavlid opcodes? does it on my 386 main ENDP ;picked up from within the ECHO. ;-=] InvalidOpcode [=------------------------------------------------------ ; The custom handler for the invalid opcode interrupt. Which is called ; by the CPU when an invalid instruction is encountered. Here a dialog ; displayed about the situation and the machine is rebooted. InvalidOpcode PROC mov AH,09h ;DOS - Print String mov DX,offset msg ;DS:DX -> ASCID string to print int 21h ;CALL DOS to print dialog xor AH,AH ;KEYBOARD - Read Keyboard int 16h pushf ;push flags on stack mov AX,0FFFFh ;push FFFF onto stack push AX xor AX,AX ;push 0000 onto stack push AX iret ;so the IRET will boot the computer InvalidOpcode ENDP PRG ENDS END main =========================================================================== This worked on my 386 in real mode, and in protected mode under HIMEM.SYS nd EMM386.EXE. Windows however installed it's own handler that over-rode mine, popping up it's own dialog. Cheers, Denis Boyles ___ Blue Wave/QWK v2.12 --- Maximus/2 3.01 * Origin: Frog Hollow Port Moody BC 604-469-0264/0284 (1:153/290)