;#pragma once ; CIS - 261 ; IO.H -- header file for I / O macros ; 32 - bit version for flat memory model .NOLIST; turn off listing .386 EXTRN itoaproc : near32, atoiproc : near32 EXTRN dtoaproc : near32, atodproc : near32 EXTRN inproc : near32, outproc : near32 EXTRN szlenproc : near32 itoa MACRO dest, source, xtra;; convert integer to ASCII string IFB .ERR EXITM ENDIF IFNB .ERR EXITM ENDIF push ebx;; save EBX mov bx, source push bx;; source parameter lea ebx, dest;; destination address push ebx;; destination parameter call itoaproc;; call itoaproc(source, dest) pop ebx;; restore EBX ENDM atoi MACRO source, xtra;; convert ASCII string to integer in AX ;; offset of terminating character in ESI IFB .ERR EXITM ENDIF IFNB .ERR EXITM ENDIF push ebx;; save EBX lea ebx, source;; source address to EBX push ebx;; source parameter on stack call atoiproc;; call atoiproc(source) pop ebx;; parameter removed by ret ENDM dtoa MACRO dest, source, xtra;; convert double to ASCII string IFB .ERR EXITM ENDIF IFNB .ERR EXITM ENDIF push ebx;; save EBX mov ebx, source push ebx;; source parameter lea ebx, dest;; destination address push ebx;; destination parameter call dtoaproc;; call dtoaproc(source, dest) pop ebx;; restore EBX ENDM atod MACRO source, xtra;; convert ASCII string to integer in EAX ;; offset of terminating character in ESI IFB .ERR EXITM ENDIF IFNB .ERR EXITM ENDIF lea eax, source;; source address to EAX push eax;; source parameter on stack call atodproc;; call atodproc(source) ;; parameter removed by ret ENDM output MACRO string, xtra;; display string IFB .ERR EXITM ENDIF IFNB .ERR EXITM ENDIF push eax;; save EAX lea eax, string;; string address push eax;; string parameter on stack call outproc;; call outproc(string) pop eax;; restore EAX ENDM input MACRO dest, length, xtra;; read string from keyboard IFB .ERR EXITM ENDIF IFNB .ERR EXITM ENDIF push ebx;; save EBX lea ebx, dest;; destination address push ebx;; dest parameter on stack mov ebx, length;; length of buffer push ebx;; length parameter on stack call inproc;; call inproc(dest, length) pop ebx;; restore EBX ENDM szlen MACRO string, xtra;; get string length IFB .ERR EXITM ENDIF IFNB .ERR EXITM ENDIF lea eax, string;; string address push eax;; string parameter on stack call szlenproc;; call szlenproc(string) ENDM .NOLISTMACRO; suppress macro expansion listings .LIST; begin listing
This is not my code! this is from http://www.c-jump.com/bcc/c261c/CIS261syllabus.html
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.