]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/modex/demos/c/c_utils.asm
IT WORKS!!!! cannot multipage yet!
[16.git] / src / lib / modex / demos / c / c_utils.asm
index 429253b12a49353e4ad71deaffa6b99b6bf7c28a..011820134d532a9d394870f84b4c4a2427ce1a11 100755 (executable)
 \r
        ; macros to PUSH and POP multiple registers\r
 \r
-PUSHx MACRO R1, R2, R3, R4, R5, R6, R7, R8\r
-       IFNB <R1>\r
-               push    R1                              ; Save R1\r
-               PUSHx   R2, R3, R4, R5, R6, R7, R8\r
-       ENDIF\r
-ENDM\r
-\r
-POPx MACRO R1, R2, R3, R4, R5, R6, R7, R8\r
-       IFNB <R1>\r
-               pop             R1                              ; Restore R1\r
-               POPx    R2, R3, R4, R5, R6, R7, R8\r
-       ENDIF\r
-ENDM\r
+; PUSHx MACRO R1, R2, R3, R4;, R5, R6, R7, R8\r
+;      IFNB <R1>\r
+;              push    R1                              ; Save R1\r
+;              PUSHx   R2, R3, R4;, R5, R6, R7, R8\r
+;      ENDIF\r
+ENDM\r
+;\r
+; POPx MACRO R1, R2, R3, R4;, R5, R6, R7, R8\r
+;      IFNB <R1>\r
+;              pop             R1                              ; Restore R1\r
+;              POPx    R2, R3, R4;, R5, R6, R7, R8\r
+;      ENDIF\r
+ENDM\r
 \r
        ; Macro to Clear a Register to 0\r
 \r
@@ -58,6 +58,8 @@ ENDM
        s               EQU     SHORT\r
        ?x4             EQU <?,?,?,?>\r
        ?x3             EQU <?,?,?>\r
+       ?x2             EQU <?,?>\r
+       ?x1             EQU <?>\r
 \r
 \r
        .Data\r
@@ -82,7 +84,10 @@ CR_LF                DB      13, 10                  ; the CRLF data
        PUBLIC  DOS_PRINT\r
 \r
 DP_Stack       STRUC\r
-                               DW      ?x2     ; DI, SI, DS, BP\r
+                               DW      ?x1     ; DI, SI, DS, BP\r
+                               DW      ?x1     ; DI, SI, DS, BP\r
+                               DW      ?x1     ; DI, SI, DS, BP\r
+                               DW      ?x1     ; DI, SI, DS, BP\r
                                DD      ?       ; Caller\r
        DP_Text         DD      ?       ; Far Address of Text to print\r
 DP_Stack       ENDS\r
@@ -90,7 +95,11 @@ DP_Stack     ENDS
 \r
 DOS_PRINT       PROC    FAR\r
 \r
-       PUSHx   BP, DS, SI, DI          ; Preserve Important Registers\r
+       ;PUSHx  BP, DS, SI, DI          ; Preserve Important Registers\r
+       push bp\r
+       push ds\r
+       push si\r
+       push di\r
        mov             BP, SP                          ; Set up Stack Frame\r
 \r
        lds     DX, [BP].DP_Text        ; Get Addr of Text$ descriptor\r
@@ -129,7 +138,11 @@ DOS_PRINT   PROC    FAR
        int             21h                                     ; Call DOS to do it\r
 \r
        cld                                                     ; Reset Direction Flag\r
-       POPx    DI, SI, DS, BP          ; Restore Saved Registers\r
+       ;POPx   DI, SI, DS, BP          ; Restore Saved Registers\r
+       pop di\r
+       pop si\r
+       pop ds\r
+       pop bp\r
        ret             4                                       ; Exit & Clean Up Stack\r
 \r
 DOS_PRINT       ENDP\r
@@ -147,7 +160,11 @@ DOS_PRINT   ENDP
 \r
 DOS_PRINTS      PROC    FAR\r
 \r
-       PUSHx   BP, DS, SI, DI          ; Preserve Important Registers\r
+       ;PUSHx  BP, DS, SI, DI          ; Preserve Important Registers\r
+       push bp\r
+       push ds\r
+       push si\r
+       push di\r
        mov             BP, SP                          ; Set up Stack Frame\r
 \r
        lds     DX, [BP].DP_Text        ; Get Addr of Text$ descriptor\r
@@ -176,7 +193,11 @@ DOS_PRINTS  PROC    FAR
 \r
 @DPS_Exit:\r
        cld                                                     ; Reset Direction Flag\r
-       POPx    DI, SI, DS, BP          ; Restore Saved Registers\r
+       ;POPx   DI, SI, DS, BP          ; Restore Saved Registers\r
+       pop di\r
+       pop si\r
+       pop ds\r
+       pop bp\r
        ret             2                                       ; Exit & Clean Up Stack\r
 \r
 DOS_PRINTS      ENDP\r
@@ -192,7 +213,10 @@ DOS_PRINTS  ENDP
        PUBLIC  SET_VIDEO_MODE\r
 \r
 SVM_Stack      STRUC\r
-                               DW      ?x2     ; DI, SI, DS, BP\r
+                               DW      ?x1     ; DI, SI, DS, BP\r
+                               DW      ?x1     ; DI, SI, DS, BP\r
+                               DW      ?x1     ; DI, SI, DS, BP\r
+                               DW      ?x1     ; DI, SI, DS, BP\r
                                DD      ?       ; Caller\r
        SVM_Mode        DB      ?,? ; Desired Video Mode\r
 SVM_Stack      ENDS\r
@@ -200,7 +224,11 @@ SVM_Stack  ENDS
 \r
 SET_VIDEO_MODE PROC    FAR\r
 \r
-       PUSHx   BP, DS, SI, DI          ; Preserve Important Registers\r
+       ;PUSHx  BP, DS, SI, DI          ; Preserve Important Registers\r
+       push bp\r
+       push ds\r
+       push si\r
+       push di\r
        mov             BP, SP                          ; Set up Stack Frame\r
 \r
        CLR             AH                                      ; Function 0\r
@@ -209,7 +237,11 @@ SET_VIDEO_MODE     PROC    FAR
        int             10H                                     ; Change Video Modes\r
 \r
 @SVM_Exit:\r
-       POPx    DI, SI, DS, BP          ; Restore Saved Registers\r
+       ;POPx   DI, SI, DS, BP          ; Restore Saved Registers\r
+       pop di\r
+       pop si\r
+       pop ds\r
+       pop bp\r
        ret             2                                       ; Exit & Clean Up Stack\r
 \r
 SET_VIDEO_MODE ENDP\r
@@ -226,7 +258,11 @@ SET_VIDEO_MODE     ENDP
 \r
 SCAN_KEYBOARD  PROC    FAR\r
 \r
-       PUSHx   BP, DS, SI, DI          ; Preserve Important Registers\r
+       ;PUSHx  BP, DS, SI, DI          ; Preserve Important Registers\r
+       push bp\r
+       push ds\r
+       push si\r
+       push di\r
 \r
        mov             AH, 01H                         ; Function #1\r
        INT             16H                                     ; Call Keyboard Driver\r
@@ -246,7 +282,11 @@ SCAN_KEYBOARD      PROC    FAR
 \r
 @SK_Exit:\r
        cld                                                     ; Reset Direction Flag\r
-       POPx    DI, SI, DS, BP          ; Restore Saved Registers\r
+       ;POPx   DI, SI, DS, BP          ; Restore Saved Registers\r
+       pop di\r
+       pop si\r
+       pop ds\r
+       pop bp\r
        ret                                                     ; Exit & Clean Up Stack\r
 \r
 SCAN_KEYBOARD  ENDP\r
@@ -345,7 +385,9 @@ ISQ_Stack   ENDS
 \r
 INT_SQR                PROC    FAR\r
 \r
-    PUSHx   BP, DI                             ; Save BP\r
+    ;PUSHx   BP, DI                            ; Save BP\r
+       push bp\r
+       push di\r
     mov     BP, SP                             ; Set up Stack Frame\r
 \r
        xor     AX, AX                          ; {xor eax,eax}\r
@@ -375,9 +417,18 @@ INT_SQR            PROC    FAR
 \r
        add     ax, [BP].ISQ_Round      ; {add eax,$00008000}\r
                                                                ; {*round* result in hi word: ie. +0.5}\r
-       shr     ax, 8                           ; {shr eax,16}  {to ax (result)}\r
-\r
-       POPx    DI, BP                          ; Restore Registers\r
+       shr     ax, 1                           ; {shr eax,16}  {to ax (result)}\r
+       shr     ax, 1                           ; {shr eax,16}  {to ax (result)}\r
+       shr     ax, 1                           ; {shr eax,16}  {to ax (result)}\r
+       shr     ax, 1                           ; {shr eax,16}  {to ax (result)}\r
+       shr     ax, 1                           ; {shr eax,16}  {to ax (result)}\r
+       shr     ax, 1                           ; {shr eax,16}  {to ax (result)}\r
+       shr     ax, 1                           ; {shr eax,16}  {to ax (result)}\r
+       shr     ax, 1                           ; {shr eax,16}  {to ax (result)}\r
+\r
+       ;POPx   DI, BP                          ; Restore Registers\r
+       pop di\r
+       pop bp\r
        ret             4                                       ; Exit\r
 \r
 INT_SQR                ENDP\r