;; Kira Swab ;; Macros for Project 4 ;; April 2001 ;;________________________________________________________________________________ .nolist nin macro symbolname ;;macro takes single argument pusha ;;push registers if (type symbolname) EQ 1 ;;checking for byte, word, dw call readint mov symbolname, al ;;stores parameter endif if (type symbolname) EQ 2 ;;checks for word call readint mov symbolname, ax endif if (type symbolname) EQ 4 ;;checks for dw call readlong mov symbolname, eax endif if (type symbolname) GT 4 ;;checks for error echo Error in number input .err .exitm endif popa ;;restores registers endm ;;___________________________________________________________________________________ nout macro symbolname ;;number out macro pushad if (type symbolname) EQ 1 ;;check for byte mov ah, 0 mov al, symbolname mov bx, 10 call writeint ;;writes byte endif if (type symbolname) EQ 2 ;;check for word mov ax, symbolname mov bx, 10 call writeint ;;writes word endif if (type symbolname) EQ 4 ;;check for dw mov eax, symbolname mov bx, 10 call writelong ;;write dw endif if (type symbolname) GT 4 ;;checks for error echo Error in number input .err .exitm popad endif .data .code endm ;;_______________________________________________________________________________________ cin macro cinchar,symbolname,numchars ;;reads char .code pusha ifidni <'c'>,<'&cinchar&'> ;; compares cinchar with c call Readkey mov symbolname, al endif ifidni <'s'>,<'&cinchar&'> ;;compares cinchar with s mov dx, offset symbolname ;;gets string mov cx, numchars call readstring endif popa endm ;;______________________________________________________________________________________ cout macro charac,symbolname ;;displays char or string local lit .code pusha ifidni <'c'>,<'&charac&'> ;;if c, holds character mov ah, 2 mov dl, &symbolname& ;;moves symbolname for output int 21h mov symbolname, al endif ifidni <'s'>,<'&charac&'> ;;if s, holds string mov dx, offset symbolname ;;writes string call writestring endif ifidni <'l'>,<'&charac&'> ;;if l, holds literal mov dx, offset lit call writestring ;;writes literal endif popa .data lit db "&symbolname", 0 .code endm .list ;;gets list file .listmacroall ;;shows macros