Hi!

intr.asm
- wrong prototypes fixed and syncronized with *.h headers.
- small code cleanup (removed jumps) and optimizations, more comments.

--- Begin Message ---
diff -ruNp old/kernel/intr.asm new/kernel/intr.asm
--- old/kernel/intr.asm 2004-05-23 13:02:00.000000000 +0000
+++ new/kernel/intr.asm 2004-06-01 22:57:06.000000000 +0000
@@ -94,7 +94,9 @@
 
 segment        HMA_TEXT
 
-;; COUNT ASMPASCAL res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp)
+;
+; int ASMPASCAL res_DosExec(int mode, exec_blk * ep, const char * lp);
+;
     global RES_DOSEXEC
 RES_DOSEXEC:
         pop es                  ; ret address
@@ -106,12 +108,13 @@ RES_DOSEXEC:
         push ds                 
         pop es                  ; es = ds
         int 21h
-        jc short no_exec_error
-        xor ax, ax
-no_exec_error:
+       sbb     dx,dx           ; CF=0?
+       and     ax,dx           ;  then ax=0, else ax=error code
         ret
 
-;; UCOUNT ASMPASCAL res_read(int fd, void *buf, UCOUNT count); 
+;
+; unsigned ASMPASCAL res_read(int fd, void *buf, unsigned count);
+;
     global RES_READ
 RES_READ:
         pop ax         ; ret address
@@ -121,23 +124,20 @@ RES_READ:
         push ax        ; ret address
         mov ah, 3fh
         int 21h
-        jnc no_read_error
-        mov ax, -1
-no_read_error:
+       sbb     dx,dx           ; CF=1?
+       or      ax,dx           ;  then ax=-1, else ax=bytes read
         ret
 
 segment        INIT_TEXT
 ;
-;       void init_call_intr(nr, rp)
-;       REG int nr
-;       REG struct REGPACK *rp
+; unsigned ASMPASCAL init_call_intr(int nr, iregs * rp);
 ;
                global  INIT_CALL_INTR
 INIT_CALL_INTR:
                INTR
 
 ;
-; int init_call_XMScall( (WORD FAR * driverAddress)(), WORD AX, WORD DX)
+; int ASMPASCAL init_call_XMScall(void FAR * driverAddress, UWORD ax, UWORD dx);
 ;
 ; this calls HIMEM.SYS 
 ;
@@ -154,8 +154,10 @@ INIT_CALL_XMSCALL:
             push es         ; driver address ("jmp es:cx")
             push cx
             retf
-            
-; void FAR *DetectXMSDriver(VOID)
+
+;
+; void FAR * ASMPASCAL DetectXMSDriver(VOID);            
+;
 global DETECTXMSDRIVER
 DETECTXMSDRIVER:
         mov ax, 4300h
@@ -163,8 +165,8 @@ DETECTXMSDRIVER:
 
         cmp al, 80h
         je detected
-        xor ax, ax
-        xor dx, dx
+       xor     ax,ax
+       cwd
         ret
 
 detected:
@@ -179,13 +181,18 @@ detected:
         pop es
         ret        
 
+;
+; void ASMPASCAL keycheck(void);
+;
 global KEYCHECK
 KEYCHECK:
         mov ah, 1
         int 16h
         ret                
 
-;; int open(const char *pathname, int flags); 
+;
+; int ASMPASCAL open(const char *pathname, int flags); 
+;
     global INIT_DOSOPEN
 INIT_DOSOPEN: 
         ;; init calling DOS through ints:
@@ -198,12 +205,14 @@ INIT_DOSOPEN: 
 
 common_int21:
         int 21h
-        jnc common_no_error
-        mov ax, -1
-common_no_error:
+       jnc     common_ret      ; CF=1?
+       sbb     ax,ax           ;  then ax=-1, else ax unchanged
+common_ret:
         ret
 
-;; int close(int fd);
+;
+; int ASMPASCAL close(int fd);
+;
     global CLOSE
 CLOSE:         
         pop ax         ; ret address
@@ -212,7 +221,9 @@ CLOSE:         
         mov ah, 3eh
         jmp short common_int21
 
-;; UCOUNT read(int fd, void *buf, UCOUNT count); 
+;
+; unsigned ASMPASCAL read(int fd, void *buf, unsigned count);
+;
     global READ
 READ: 
         pop ax         ; ret address
@@ -223,7 +234,9 @@ READ: 
         mov ah, 3fh
         jmp short common_int21
 
-;; int dup2(int oldfd, int newfd); 
+;
+; int ASMPASCAL dup2(int oldfd, int newfd);
+;
     global DUP2
 DUP2:
         pop ax         ; ret address
@@ -233,7 +246,9 @@ DUP2:
         mov ah, 46h
         jmp short common_int21
         
-;; VOID init_PSPSet(seg psp_seg)
+;
+; void ASMPASCAL init_PSPSet(seg psp_seg);
+;
     global INIT_PSPSET
 INIT_PSPSET:
         pop ax         ; ret address
@@ -243,7 +258,9 @@ INIT_PSPSET:
         int 21h
         ret
 
-;; COUNT init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp)
+;
+; int ASMPASCAL init_DosExec(int mode, exec_blk * ep, const char * lp);
+;
     global INIT_DOSEXEC
 INIT_DOSEXEC:
         pop es                  ; ret address
@@ -255,12 +272,13 @@ INIT_DOSEXEC:
         push ds                 
         pop es                  ; es = ds
         int 21h
-        jc short exec_no_error
-        xor ax, ax
-exec_no_error:
+       sbb     dx,dx           ; CF=0?
+       and     ax,dx           ;  then ax=0, else ax=error code
         ret
 
-;; int init_setdrive(int drive)
+;
+; int ASMPASCAL init_setdrive(int drive);
+;
    global INIT_SETDRIVE
 INIT_SETDRIVE:
        mov ah, 0x0e
@@ -271,7 +289,9 @@ common_dl_int21:
         int 21h
         ret
 
-;; int init_switchar(int char)
+;
+; int ASMPASCAL init_switchar(int chr);
+;
    global INIT_SWITCHAR
 INIT_SWITCHAR:
        mov ax, 0x3701
@@ -287,11 +307,13 @@ ALLOCMEM:
         push ax          ; ret address
         mov ah, 48h
         int 21h
-        sbb bx, bx       ; carry=1 -> ax=-1
-        or  ax, bx       ; segment
+       sbb     bx,bx           ; CF=1?
+       or      ax,bx           ;  then ax=-1, else ax=segment
         ret
                         
-;; void set_DTA(void far *dta)        
+;
+; void ASMPASCAL set_DTA(void far *dta);
+;
     global SET_DTA
 SET_DTA:
         pop ax           ; ret address

--- End Message ---

Reply via email to