'=========================================================================== ' Subject: ASSEMBLY AND BASIC Date: Unknown Date (00:00) ' Author: Matt Hart Code: ASM, QB, PDS ' Keys: ASSEMBLY,AND,BASIC Packet: ASMCODE.ABC '=========================================================================== ; ASCII.ASM by Matt Hart ; Returns the ASCII code of a string ; like ASC does BUT will return a -1 if ; the string is NULL rather than bombing out with ; an ILLEGAL FUNCTION CALL. ; .Model Medium, BASIC .Code ; Ascii PROC USES SI, Strg:Word MOV BX,Strg ; Pointer to descriptor MOV CX,[BX] ; Length CMP CX,0 ; Is the string null? JE NullString ; Yes - jump to NullString MOV SI,[BX+2] ; Address of the string into SI XOR AX,AX ; Clear AX to receive the character MOV AL,[SI] ; First character of the string JMP Ending ; Back to BASIC NullString: MOV AX,0FFFFh ; Return a -1 to the function Ending: RET ; Back to BASIC Ascii ENDP END C:\>masm ascii.asm or C:\>ml /c ascii.asm 'TEST.BAS DEFINT A-Z DECLARE FUNCTION Ascii(Strg$) PRINT Ascii(COMMAND$) C:\>bc test; C:\>link test+ascii,,,brun45; C:\>test A