FREEHAFER'S VISUAL C++ VERSION ONE HELP PAGE
THIS WEB SITE IS BY JOHN RICHARD FREEHAFER.
E-MAIL ADDRESS: nfn12346@naples.net
©1998
The following are complete programs for a Visual C++ Version 1.0 compiler:
Use function 0204h interrupt 31h to display vector 1Eh in protected mode.
Use function 2Ch interrupt 21h to get your computer system time.
Use function 43h interrupt 21h to set a file's attributes.
Check to see if you are in a dos protected mode interface.
Use ports and inline assembly to play a song.
Use function 0204h interrupt 31h to display vector 1Eh in protected mode!
// // 0204h GET PROTECTED MODE INTERRUPT VECTOR // PROGRAM USES my_table AND function 0204h int 31h // TO READ VECTOR 1Eh // #include
typedef struct my_table{ unsigned char v0; unsigned char v1; unsigned char v2; unsigned char v3; unsigned char v4; unsigned char v5; unsigned char v6; unsigned char v7; unsigned char v8; unsigned char v9; unsigned char v10; }TABLE; void main(){ // DECLARE AND CLEAR YOUR TABLE. TABLE my_table; my_table.v0 = 0; my_table.v1 = 0; my_table.v2 = 0; my_table.v3 = 0; my_table.v4 = 0; my_table.v5 = 0; my_table.v6 = 0; my_table.v7 = 0; my_table.v8 = 0; my_table.v9 = 0; my_table.v10 = 0; //********************************************************************** // GET PROTECTED MODE INTERRUPT VECTOR __asm{ mov CX, 0 mov DX, 0 mov AX, 0204h // GET PROTECTED MODE INTERRUPT VECTOR mov BL, 1Eh int 31h mov BX, DX // mov CX:DX into ES:BX mov ES, CX // mov CX:DX into ES:BX mov AL, byte ptr ES:[BX] // PUT POINTER TO my_table into ES:BX mov byte ptr my_table.v0, AL mov AL, byte ptr ES:[BX+1] mov byte ptr my_table.v1, AL mov AL, byte ptr ES:[BX+2] mov byte ptr my_table.v2, AL mov AL, byte ptr ES:[BX+3] mov byte ptr my_table.v3, AL mov AL, byte ptr ES:[BX+4] mov byte ptr my_table.v4, AL mov AL, byte ptr ES:[Bx+5] mov byte ptr my_table.v5, AL mov AL, byte ptr ES:[BX+6] mov byte ptr my_table.v6, AL mov AL, byte ptr ES:[BX+7] mov byte ptr my_table.v7, AL mov AL, byte ptr ES:[BX+8] mov byte ptr my_table.v8, AL mov AL, byte ptr ES:[BX+9] mov byte ptr my_table.v9, AL mov AL, byte ptr ES:[BX+10] mov byte ptr my_table.v10, AL } // DISPLAY VALUES AT 1Eh FOR GET PROTECTED MODE INTERRUPT VECTOR printf("\n\n The contents of vector 1Eh are:\n\n"); printf(" I Did Not Bother To Split Bits Here -- Step Rate = %d.\n",my_table.v0); printf(" I Did Not Bother To Split Bits Here -- Head Load Time = %d.\n",my_table.v1); printf(" Motor Off Time = %d.\n",my_table.v2); printf(" Sector Size In Bytes (2 for 512 bytes per sector) = %d.\n",my_table.v3); printf(" Sectors Per Track = %d.\n",my_table.v4); printf(" Size of Gap on Read/Write = %d.\n",my_table.v5); printf(" Length of Data Transfer = %d.\n",my_table.v6); printf(" Size of Gap on Format = %d.\n",my_table.v7); printf(" Fill Byte = %d.\n",my_table.v8); printf(" Head Settle Time = %d.\n",my_table.v9); printf(" Motor Startup Time = %d.\n",my_table.v10); // DISPLAY COPYRIGHT printf("\n\n FREEHAFER'S DISPLAY VECTOR 1Eh IN PROTECTED\n MODE PROGRAM IS TERMINATED! ROAK NOG!\n (c)1999 INNIEA PUBLISHING COMAPNY!");}
Download and try this executable freeware to display vector 1Eh in protected mode!
Use function 2Ch interrupt 21h to get your computer system time!
#include "stdio.h" void main() { char zs1; char zs2; int h = 0, m = 0, s = 0, ch = 0; __asm{ mov AH, 2Ch INT 21h mov BYTE PTR [h], CH //hour mov BYTE PTR [m], CL //minute mov BYTE PTR [s], DH //second } ch = h; if (h == 0) ch = 12; if (h > 12) ch = h - 12; if (m <= 9) zs1 = '0'; if (m > 9) zs1 = ' '; if (s <= 9) zs2 = '0'; if (s > 9) zs2 = ' '; printf ( "Your computer system time is %i:%c%i:%c%i ",ch,zs1,m,zs2,s); if (h < 12) printf ("AM.\n"); if (h >= 12) printf ("PM.\n"); // DISPLAY COPYRIGHT printf("\n\nFREEHAFER'S SYSTEM TIME PROGRAM IS TERMINATED!\nROAK NOG!\n(c)1999 INNIEA PUBLISHING COMPANY!");}
Download and try this executable freeware to display your system time!
Use function 43h interrupt 21h to set a file's attributes!
void main( void ) { // declare variables char path[] = "c:\\temp\\quirk.txt"; int cfa = 0, attcode = 0; char code; //set file to archive if it exists so that it can be overwritten __asm { // open file lea DX, WORD PTR [path] mov AL, 02h // access mode read & write mov AH, 3Dh // open file function int 21h // call interrupt // set file attribute mov CX,0 mov AH, 43h // function for file attributes mov AL, 01h // 00h to get 01h to set file attributes mov CX, 32 // set to archive // 100000b = decimal 1 to set file as read only // decimal 32 = binary 100000 to set file as archive lea DX,WORD PTR [path] //DS:DX = path name made acceptable to visual c++ int 21h // call interrupt mov cfa, CX // CX gives you the file attributes after interrupt call } // create file FILE *CF; CF = fopen (path,"w"); fclose(CF); printf("\n\nThis program created the file c:\\temp\\quirk.txt\n\n"); //input code printf("Enter R/r to make file read only, \nor enter A/a for archive: "); code = getc(stdin); if (code == 'r' || code == 'R') attcode = 1; if (code == 'a' || code == 'A') attcode = 32; //inline assembly __asm { // open file lea DX, WORD PTR [path] mov AL, 02h // access mode read & write mov AH, 3Dh // open file function int 21h // call interrupt // set file attribute mov CX,0 mov AH, 43h // function for file attributes mov AL, 01h // 00h to get 01h to set file attributes mov CX, WORD PTR [attcode] // 100000b = decimal 1 to set file as read only // decimal 32 = binary 100000 to set file as archive lea DX,WORD PTR [path] //DS:DX = path name made acceptable to visual c++ int 21h // call interrupt mov cfa, CX // CX gives you the file attributes after interrupt call // close file mov BX, AX // file handle mov AH, 3Eh // close file int 21h // interrupt call } // output if (cfa == 32) printf("The file c:\\temp\\quirk.txt is archive!"); if (cfa == 1) printf("The file c:\\temp\\quirk.txt is read only!"); // display copyright printf("\n\n(c)1999 INNIEA PUBLISHGIN COMPANY!\nROAK NOG!\n\n");}
Download and try this executable freeware to set a files attribute!
Test to see if you are in a dos protected mode interface!
#include
void main() { int dpmi = 0; __asm{ mov AX, 1686h // test if in DOS PROTECTECD MODE INTERFACE int 2Fh mov WORD PTR [dpmi], AX } printf ( "\n\n This program tests if you are in a\n DOS PROTECTED MODE INTERFACE!\n The following number is zero if true: %i!",dpmi ); printf ( "\n\n (c) 1999 INNIEA PUBLISHING COMPANY!\n ROAK NOG!");}
Download and try this executable freeware to see if you are in a dos protected mode interface!
Use ports and inline assembly to play a song!
// USE PORTS AND INLINE ASSEMBLY TO PLAY SONG // // BIBLIOGRAPHY // // THE REVOLUTIONARY GUIDE TO ASSEMBLY LANGUAGE, // MALJIGIN, IZRAILEVICH, LAVIN, SOPIN, WROX PRESS, // UK, ©1993, page 504. #include "stdio.h"//for printf void main() { printf ( "\n This program plays a song\n written by a tone deaf person!"); int frequ, frequency[30] = {523,587,659,523,420,330,28000,523,999,258,699,784,28800, 100,200,300,400,880,784,699,88,587,880,100,200,30000,40,80,84,19968};//the notes for( int i = 0; i < 30; i++) { frequ = frequency[i]; __asm{ mov di, word ptr [frequ]// copy frequency into destination index register mov bx, 30 // duration in hundredths of seconds goes into base register // copy registers onto stack////////////////////////////////////////////////////////////// push ax push cx push dx push ds push es push si // play tone//////////////////////////////////////////////////////////////////////////// in al,61h // input port B's address 61h into accumulator mov cl,al // copy port B's address in count register or al,3 // turn on speaker and timer by putting 3 or 11 binary into accumulator out 61h,al // and then output from accumulator to port B mov al,0B6h // set for channel 2 by first putting 0B6h into accumulator out 43h,al // and then output command from register to port mov dx,14h // prevents division by zero mov ax,4F38h // divisor of frequency div di // frequency in di is divided by 144F38h out 42h,al // lower byte of result of frequency division is sent to timer port mov al,ah // copy high bits to low bits out 42h,al // higher byte of result of frequency division is sent to timer port // time lapse ////////////////////////////////////////////////////////////////////// mov ax,91 // accumulator contains multiplier mul bx // AX = BX * 91 and result is put in DX:AX since it is a word mov bx,500 // divisor div bx // DX:AX dividend / 500 = result in AX, remainder in DX mov bx,ax // save delay result in BX mov ah,0 // read clock tick function which is incremenyed 18.2 times / second INT 1Ah // read clock interrupt add dx,bx // DX = DX + BX mov bx,dx // DX = BX Loopity: INT 1Ah // begin loop and read clock interrupt cmp dx,bx // compare to see if time passed jne Loopity // end loop in al,61h // read mode of port B mov al,cl // previous mode of port B and al,0FCh // prepare to turn offf speaker out 61h,al // restore original contents to port B to turn speaker off //restore registers/////////////////////////////////////////////////////////////////////// pop si pop es pop ds pop dx pop cx pop ax} } // COPYWRONG printf("\n\n FREEHAFER'S PORT SONG IS TERMINATED!\n ROAK NOG!\n (c)1999 INNIEA PUBLISHING COMPANY!");}
Download and try this executable freeware to play a song using ports and inline assembly!
TOUCH THIS TO GO BACK TO THE HOME PAGE!