Subversion Repositories SvarDOS

Rev

Rev 1892 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1892 Rev 1893
Line 15... Line 15...
15
 
15
 
16
#include "trim.h"
16
#include "trim.h"
17
#include "helpers.h"
17
#include "helpers.h"
18
 
18
 
19
 
19
 
-
 
20
 
-
 
21
/* outputs a NUL-terminated string to stdout */
-
 
22
void output(const char *s) {
-
 
23
  _asm {
-
 
24
    push ds
-
 
25
    push es
-
 
26
    /* get length of s into CX */
-
 
27
    mov ax, 0x4000 /* ah=DOS "write to file" and AL=0 for NUL matching */
-
 
28
    lds dx, s      /* set DS:DX to string (required for later) */
-
 
29
    push ds
-
 
30
    pop es         /* make sure es=ds (scasb uses es) */
-
 
31
    mov di, dx     /* set di to string (for NULL matching) */
-
 
32
    mov cx, 0xffff /* preset cx to 65535 (-1) */
-
 
33
    cld            /* clear DF so scasb increments DI */
-
 
34
    repne scasb    /* cmp al, es:[di], inc di, dec cx until match found */
-
 
35
    /* CX contains (65535 - strlen(s)) now */
-
 
36
    not cx         /* reverse all bits so I get (strlen(s) + 1) */
-
 
37
    dec cx         /* this is CX length */
-
 
38
    jz WRITEDONE   /* do nothing for empty strings */
-
 
39
 
-
 
40
    /* output by writing to stdout */
-
 
41
    /* mov ah, 0x40 */  /* DOS 2+ -- write to file via handle */
-
 
42
    xor bh, bh
-
 
43
    mov bl, 1 /* set handle (1=stdout 2=stderr) */
-
 
44
    /* mov cx, xxx */ /* write CX bytes */
-
 
45
    /* mov dx, s   */ /* DS:DX is the source of bytes to "write" */
-
 
46
    int 0x21
-
 
47
    WRITEDONE:
-
 
48
    pop es
-
 
49
    pop ds
-
 
50
  }
-
 
51
}
-
 
52
 
-
 
53
 
20
/* change all / to \ in a string */
54
/* change all / to \ in a string */
21
void slash2backslash(char *str) {
55
void slash2backslash(char *str) {
22
  int x;
56
  int x;
23
  for (x = 0; str[x] != 0; x++) {
57
  for (x = 0; str[x] != 0; x++) {
24
    if (str[x] == '/') str[x] = '\\';
58
    if (str[x] == '/') str[x] = '\\';