Hi!

- code cleanup/optimization, comments added.
--- Begin Message ---
diff -ruNp old/kernel/intr.asm new/kernel/intr.asm
--- old/kernel/intr.asm 2004-05-24 17:29:46.000000000 +0000
+++ new/kernel/intr.asm 2004-05-24 17:39:06.000000000 +0000
@@ -108,9 +108,8 @@ 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
 
 ;
@@ -125,9 +124,8 @@ 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
@@ -167,8 +165,8 @@ DETECTXMSDRIVER:
 
         cmp al, 80h
         je detected
-        xor ax, ax
-        xor dx, dx
+       xor     ax,ax
+       cwd
         ret
 
 detected:
@@ -207,9 +205,9 @@ 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
 
 ;
@@ -274,9 +272,8 @@ 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
 
 ;
@@ -310,8 +307,8 @@ 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
                         
 ;

--- End Message ---


Reply via email to