@@ -142,6 +142,8 @@ static int mouseopt_enabled;
142142
143143static __dpmi_raddr int0_vec ;
144144static int int0_wa ;
145+ static __dpmi_paddr int75_vec ;
146+ static int int75_wa ;
145147
146148/*
147149 * Command parser defines/variables
@@ -243,6 +245,7 @@ static void perform_popd(const char *arg);
243245static void perform_prompt (const char * arg );
244246static void perform_pushd (const char * arg );
245247static void perform_r200fix (const char * arg );
248+ static void perform_divzfix (const char * arg );
246249static void perform_rd (const char * arg );
247250static void perform_rename (const char * arg );
248251static void perform_shift (const char * arg );
@@ -303,6 +306,7 @@ struct built_in_cmd cmd_table[] =
303306 {"prompt" , perform_prompt , "" , "customize prompt string" },
304307 {"pushd" , perform_pushd , "" , "push cwd to stack and cd" },
305308 {"r200fix" , perform_r200fix , "" , "runtime error 200 fix" },
309+ {"divzfix" , perform_divzfix , "" , "division by zero fix" },
306310 {"rd" , perform_rd , "" , "remove directory" },
307311 {"rmdir" , perform_rd , "" , "remove directory" },
308312 {"rename" , perform_rename , "" , "rename with wildcards" },
@@ -3065,6 +3069,15 @@ static int is_HMA_enabled(void)
30653069 return !!(r .h .dh & 0x10 );
30663070 }
30673071
3072+ static void activate_int75_handling (void )
3073+ {
3074+ __dpmi_paddr pa ;
3075+
3076+ pa .selector = _my_cs ();
3077+ pa .offset32 = (uintptr_t )my_int75_handler ;
3078+ __dpmi_set_protected_mode_interrupt_vector (0x75 , & pa );
3079+ }
3080+
30683081static void perform_external_cmd (int call , int lh , char * ext_cmd )
30693082 {
30703083 finddata_t ff ;
@@ -3231,6 +3244,7 @@ static void perform_external_cmd(int call, int lh, char *ext_cmd)
32313244#ifdef __DJGPP__
32323245 __djgpp_exception_toggle ();
32333246#endif
3247+ activate_int75_handling ();
32343248 set_env_seg ();
32353249 /* prepend command tail with space */
32363250 alen = strlen (cmd_args );
@@ -3709,6 +3723,21 @@ static void perform_r200fix(const char *arg)
37093723 int0_wa = 0 ;
37103724 }
37113725
3726+ static void perform_divzfix (const char * arg )
3727+ {
3728+ if (!* arg )
3729+ {
3730+ cprintf ("divzfix: command name missing\r\n" );
3731+ reset_batfile_call_stack ();
3732+ return ;
3733+ }
3734+ shift_cmdline ();
3735+
3736+ int75_wa = 1 ;
3737+ perform_external_cmd (false, false, cmd );
3738+ int75_wa = 0 ;
3739+ }
3740+
37123741static void perform_rd (const char * arg )
37133742 {
37143743 while (* cmd_switch ) // skip switches
@@ -4705,6 +4734,20 @@ void do_int0(void)
47054734 __dpmi_set_real_mode_interrupt_vector (0 , & int0_vec );
47064735}
47074736
4737+ static void setup_int75_handling (void )
4738+ {
4739+ __djgpp_exception_toggle ();
4740+ __dpmi_get_protected_mode_interrupt_vector (0x75 , & int75_vec );
4741+ __djgpp_exception_toggle ();
4742+ _prev75_eip = int75_vec .offset32 ;
4743+ _prev75_cs = int75_vec .selector ;
4744+ }
4745+
4746+ int do_int75 (void )
4747+ {
4748+ return int75_wa ;
4749+ }
4750+
47084751int main (int argc , const char * argv [], const char * envp [])
47094752 {
47104753 int a ;
@@ -4729,6 +4772,7 @@ int main(int argc, const char *argv[], const char *envp[])
47294772 _osmajor = 7 ; // fake _osmajor to enable extended functionality
47304773 setup_break_handling ();
47314774 setup_int0_handling ();
4775+ setup_int75_handling ();
47324776
47334777 // unbuffer stdin and stdout
47344778 setbuf (stdin , NULL );
0 commit comments