Subversion Repositories SvarDOS

Rev

Rev 437 | Rev 530 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 437 Rev 445
Line 65... Line 65...
65
  return(0);
65
  return(0);
66
}
66
}
67
 
67
 
68
 
68
 
69
/* outputs a NULL-terminated string to stdout */
69
/* outputs a NULL-terminated string to stdout */
70
void output_internal(const char *s, unsigned short nl) {
70
void output_internal(const char *s, unsigned char nl) {
-
 
71
  const static unsigned char *crlf = "\r\n$";
71
  _asm {
72
  _asm {
-
 
73
    push ds
72
    mov ah, 0x02 /* AH=9 - write character in DL to stdout */
74
    pop es         /* make sure es=ds (scasb uses es) */
73
    mov si, s
75
    /* get length of s into CX */
-
 
76
    mov ax, 0x4000 /* ah=DOS "write to file" and AL=0 for NULL matching */
-
 
77
    mov dx, s      /* set dx to string (required for later) */
-
 
78
    mov di, dx     /* set di to string (for NULL matching) */
-
 
79
    mov cx, 0xffff /* preset cx to 65535 (-1) */
74
    cld          /* clear DF so lodsb increments SI */
80
    cld            /* clear DF so scasb increments DI */
-
 
81
    repne scasb    /* cmp al, es:[di], inc di, dec cx until match found */
75
    NEXTBYTE:
82
    /* CX contains (65535 - strlen(s)) now */
-
 
83
    not cx         /* reverse all bits so I get (strlen(s) + 1) */
76
    lodsb /* load byte from DS:SI into AL, SI++ */
84
    dec cx         /* this is CX length */
-
 
85
    jz WRITEDONE   /* do nothing for empty strings */
-
 
86
 
77
    mov dl, al
87
    /* output by writing to stdout */
-
 
88
    /* mov ah, 0x40 */  /* DOS 2+ -- write to file via handle */
78
    or al, 0  /* is al == 0? */
89
    mov bx, 1      /* handle 1 is always stdout */
79
    jz DONE
90
    /* mov cx, xxx */ /* write CX bytes */
-
 
91
    /* mov dx, s   */ /* DS:DX is the source of bytes to "write" */
80
    int 0x21
92
    int 0x21
81
    jmp NEXTBYTE
-
 
82
    DONE:
93
    WRITEDONE:
83
    or nl, 0
94
 
84
    jz FINITO
-
 
85
    /* print out a CR/LF trailer if nl set */
95
    /* print out a CR/LF trailer if nl set */
86
    mov dl, 0x0D /* CR */
96
    or byte ptr [nl], 0
87
    int 0x21
97
    jz FINITO
88
    mov dl, 0x0A /* LF */
98
    mov ah, 0x09
-
 
99
    mov dx, crlf
89
    int 0x21
100
    int 0x21
90
    FINITO:
101
    FINITO:
91
  }
102
  }
92
}
103
}
93
 
104
 
94
 
105
 
95
void nls_output_internal(unsigned short id, unsigned short nl) {
106
void nls_output_internal(unsigned short id, unsigned char nl) {
96
  const char *ptr = langblock + 4; /* first 4 bytes are lang id and lang len */
107
  const char *ptr = langblock + 4; /* first 4 bytes are lang id and lang len */
97
  const char *NOTFOUND = "NLS_STRING_NOT_FOUND";
108
  const char *NOTFOUND = "NLS_STRING_NOT_FOUND";
98
  /* find the string id in langblock memory */
109
  /* find the string id in langblock memory */
99
  for (;;) {
110
  for (;;) {
100
    if (((unsigned short *)ptr)[0] == id) {
111
    if (((unsigned short *)ptr)[0] == id) {