Set cycles to specific xt/at/386/486/586 speed.

Here you can discuss the development of patches.

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby Qbix » 2008-11-07 @ 12:53

typo on my part.
example => examine
Water flows down the stream
How to ask questions the smart way!
User avatar
Qbix
DOSBox Author
 
Posts: 10438
Joined: 2002-11-27 @ 14:50
Location: Fryslan

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby wd » 2008-11-07 @ 13:18

I'll take your word on the first

It does what Qbix says, that is accounting for multiple NOTs.


second isn't the same, but same result.

No the result is for example not the same for args:="X Y=" at that point.
Though i don't know if "X Y=" would equal "X=" for msdos, but it could
be if the algorithm checks for a pre-space argument and a post-= argument.
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-07 @ 14:52

Yep, I had tested later. In case it was misconstrued, I wasn't being snarky.

Nope on the second, they handle "X Y=" the same.
For both stripspaces and while loop:
before args= '==="X Y=" goto pass1'
after args= '==="X Y=" goto pass1'

Doing set var=X Y= in DOS 5.0 results in nothing being set, not var, x, or y.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-07 @ 18:36

Alright new patch. Merged his first two changes and added handling of quotes on the left side, it just needed an additional stripword on the first word. set3.diff is cleaned up, set3dirty.diff has logging and his unused changes in comments.

To summarize, the first change actually does something and does something DOS 5.0 does, second you can change to if you prefer, it's in the patch, but either way, third, even if it didn't crash, doesn't do anything constructive, doesn't do what DOS 5.0 does. Perhaps ask him where he got idea DOS 5.0 adds a space at the end to just the right side string, testing says otherwise, set and if evaluation. Fourth, breaks functionality, contrary to DOS 5.0 again.
You do not have the required permissions to view the files attached to this post.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby etil » 2008-11-10 @ 10:32

First, I have to apologize for my bad english.

I think that `if' command patch on sf needs explanation. I am sorry if am in the wrong.

The patch does not improve `if' command, has two goal: bug fix and error messages. It behaves like msdos and does not break any functionality (at least I think it).

Write briefly because speak broken English. Use some batch snippets rather. The examples are not from real batch files. They are very simple and silly in some cases.

Code: Select all
-   StripSpaces(args);
+//   StripSpaces(args);
+
+   // ignore all characters until =
+   while(*args && (*args != '='))
+      args++;
+

Ignoring all characters after last non-space character and before '='.

set var=a b

if %var% == "" echo true!
result in msdos: no echo/error
result in dosbox cvs: syntax error message

if %var% == a echo true!
result in msdos: echoing true!
result in dosbox cvs: syntax error message

Code: Select all
-   char* woord2 = StripWord(args);
+//   char* woord2 = StripWord(args);
+
+   char* woord2 = args;
+   // Word is until space
+   while(*args && !isspace(*reinterpret_cast<unsigned char*>(args)))
+      args++;
+   if (*args) *args++ = 0;

Words are enclosed in spaces. It seems that msdos does not use double-quotes.

set var=a b

if "%var%" == "" echo true!
result in msdos: no echo/error
result in dosbox cvs: syntax error message

if "%var%" == "a b" echo true!
result in msdos: Bad command or file name error message
result in dosbox cvs: syntax error message

if "%var%" == "a echo true!
result in msdos: echoing true!
result in dosbox cvs: syntax error message

I think that code above is a bug fix.
This code snippet works wrong in current cvs if the batch file is called without command line parameter.
Code: Select all
set DRIVE=%1
if not "%1"=="" goto :copy
set DRIVE=c:
:copy


multiple NOTs
Code: Select all
-   if (strncasecmp(args,"NOT ",4) ==0) {
+   while (strncasecmp(args,"NOT ",4) ==0) {
       args += 4;   //skip text
       //skip more spaces
       StripSpaces(args);
-      has_not = true;
+      has_not = !has_not;
    }

Probably this modification is unnecessary but msdos works in this way.

if not not a == a echo true!
result in msdos: echoing true!
result in dosbox cvs: syntax error message
etil
Newbie
 
Posts: 17
Joined: 2007-2-15 @ 15:15

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-10 @ 12:25

Everything but "%var%" == "a/a is handled in set3.diff patch. Patch doesn't give an error message for "%var%" == "a b" but that's easily added.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby etil » 2008-11-10 @ 13:58

continuation

Code: Select all
+
+   // Check parameters
+   if (!*word || !*woord2 || (strcasecmp(word,"NOT")==0)) {
+      SyntaxError();
+      return;
+   }
+

Probably this modification is unnecessary. It prints syntax error messages mainly.

expression (!*word):

set var=

if == a echo true!
result in msdos: syntax error message
result in dosbox cvs: no echo/error

if %var% == a echo true!
result in msdos: syntax error message
result in dosbox cvs: no echo/error

if not %var% == a echo true!
result in msdos: syntax error message
result in dosbox cvs: echoing true!

expression (!*woord2):

if a ==
result in msdos: syntax error message
result in dosbox cvs: no error

expression (strcasecmp(word,"NOT")==0):

set var=not
if %var%== "" echo true!
result in msdos: syntax error message
result in dosbox cvs: no echo/error

Code: Select all
+   // 2nd word must terminated with space in msdos 5.0 but command line is trimmed in dosbox
+/*   else {
+      SyntaxError();
+      return;
+   }
+*/

This modification is for completeness only, prints syntax error message.
It is commented out because works wrong in dosbox.

if a == a<space><end-of-line>
result in msdos: no error
result in dosbox cvs: no error

if a == a<end-of-line>
result in msdos: syntax error message
result in dosbox cvs: no error


To summarize, it works correctly, fixes a bug, does not break any functionality, can check variables with spaces against emptyness. But is not constructive, does not improve`if' command and can not compare two variables containing spaces. At least in my opinion.
Last edited by etil on 2008-11-12 @ 15:35, edited 1 time in total.
etil
Newbie
 
Posts: 17
Joined: 2007-2-15 @ 15:15

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-10 @ 14:29

This: // 2nd word must terminated with space in msdos 5.0 but command line is trimmed in dosbox

is not correct.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby etil » 2008-11-10 @ 15:24

Do not understand. Why?

No matter. It is not relevant and commented out.
etil
Newbie
 
Posts: 17
Joined: 2007-2-15 @ 15:15

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby MiniMax » 2008-11-10 @ 15:41

etil wrote:Do not understand. Why?

No matter. It is not relevant and commented out.


Doesn't matter? If there is one thing that I hate more than lack of comments, it is misleading comments. If there are no comments, then you read the code and hopefully you can understand what is going on. But if the comments say one thing, and your own understanding of the code says otherwise, who do YOU trust? I tend to trust the person writing the code (and the comments) and it takes me a really long time before I can convince myself that the comments are wrong, and my understanding is correct. And that time is wasted time.
DOSBox 0.73 ReadMe | DOSBox Wiki | DOSBox 60 seconds guide | How to ask questions
_________________
Lenovo M58p | Core 2 Quad Q8400 @ 2.66 GHz | Radeon R7 240 | LG HL-DT-ST DVDRAM GH40N | Win 10 Pro
User avatar
MiniMax
Moderator
 
Posts: 5128
Joined: 2004-1-18 @ 04:15
Location: Stockholm, Sweden, Europe, Earth Interests: Old games & young women

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-10 @ 15:47

Not referring to the commented out else, but the code that adds a space to the end of the second string. One, DOS 5.0 doesn't do that, two, that makes strings always not match. I'm curious what makes you believe DOS 5.0 does such.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby etil » 2008-11-10 @ 16:10

I apologize.
etil
Newbie
 
Posts: 17
Joined: 2007-2-15 @ 15:15

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby etil » 2008-11-10 @ 16:29

Maybe there are wrong phrases in the comment. I speak broken English.

I tested 2 totally wrong line in msdos 5.0:

if a == a<end-of-line>
There is no space between word `a' and end of line.
Msdos prints syntax error message.

if a == a<space><end-of-line>
There is 1 space between word `a' and end of line.
Msdos prints nothing.

Think that the code does not break string compare. Please give an example.
etil
Newbie
 
Posts: 17
Joined: 2007-2-15 @ 15:15

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-10 @ 17:44

test.bat:
Code: Select all
@echo off

rem var set to "a" no trailing space
set var=a
echo var set as "%var%"

set match=not equal
echo test if "a"=="a"
if "%var%"=="a" set match=equal
echo %match%

set match=not equal
echo test if "a"=="a "
if "%var%"=="a " set match=equal
echo %match%

rem var set to "a " with trailing space
set var=a
echo var set as "%var%"

set match=not equal
echo test if "a "=="a"
if "%var%"=="a" set match=equal
echo %match%

set match=not equal
echo test if "a "=="a  "
if "%var%"=="a  " set match=equal
echo %match%

set match=not equal
echo test if "a "=="a "
if "%var%"=="a " set match=equal
echo %match%


output of test.bat from DOS 5.0:
A:\>test
var set as "a"
test if "a"=="a"
equal
test if "a"=="a "
not equal
var set as "a "
test if "a "=="a"
not equal
test if "a "=="a "
Bad command or file name
not equal
test if "a "=="a "
Bad command or file name
not equal
A:\>

This shows that set and if don't append a space, and if won't compare a variable with a trailing space to a string with a trailing space.

Take the first if compare of "a"=="a", it correctly compares as equal.
Applying your code of adding a space to the end of just the second string, it would evaluate to not equal. All strings will not match for the same reason, they'll all be off by one character; the space added at the end.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-10 @ 20:55

test.bat revealed trailing spaces weren't being passed to the first string, fixed that, dos 5.0 only errors when first and second string have trailing space(s), changed to that behavior, and added the missing error output(not the same as DOS 5.0, but SyntaxError().)

With this, DOSBox behaves the same as DOS 5.0 running test.bat.
You do not have the required permissions to view the files attached to this post.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-11 @ 01:59

Hmm, set4.diff breaks setcpu bat files.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby etil » 2008-11-12 @ 15:25

I'm sorry. Misunderstood your posts.

You are right. It is an error to add a space to the second string.
I'll delete the misleading comment.
etil
Newbie
 
Posts: 17
Joined: 2007-2-15 @ 15:15

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-14 @ 19:09

So.. still at the correct things so setcpu works bit. The issue is passing spaces. The correct or clean fix is to hunt down any and all spots that are relying on spaces not being there and correcting the handling, or hackish way of not fixing all those spots, instead avoiding them/it by keep passing trimmed input to all but that requires handling spaces(if and set.) I've tried the hackish way first but unfortunately the incorrect handling makes use of set so have to dig further.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby ih8registrations » 2008-11-15 @ 16:35

Yay, simple solution:) Replacing trim with stripspaces does the trick.

Added cleaned up batch info(got rid of some spaces and added some info for 486 & 586.)
You do not have the required permissions to view the files attached to this post.
ih8registrations
Oldbie
 
Posts: 931
Joined: 2003-7-25 @ 17:20

Re: Set cycles to specific xt/at/386/486/586 speed.

Postby Flying Nosehair » 2009-5-17 @ 05:22

It's funny. When I run, say, at.bat, all I get is a message that says, "AT@Mhz", and no change in the speed happens. I have version 0.72.
Flying Nosehair
Newbie
 
Posts: 14
Joined: 2009-5-02 @ 03:14

PreviousNext

Return to DOSBox Patches

Who is online

Users browsing this forum: No registered users and 1 guest