home *** CD-ROM | disk | FTP | other *** search
-
- ; Here you will find the original code used for an assembly
- ; language routine used for MicroSoft QuickBasic. Below, we
- ; have written the code the performs the same function for
- ; the TURBO BASIC procedure GETBLANK (found elsewhere in the
- ; file QB-TO-TB.BAS). We have provided both versions of this
- ; code so that users who are porting their QuickBasic programs
- ; over to TURBO BASIC may see the differences in the two methods
- ; side by side, and quickly see what must be altered.
- ;
-
-
- ; This is the assembly routine for QuickBasic:
-
- ;FRAME STRUC
- ; DW ?
- ; DD ?
- ;LAST_CHAR DW ?
- ;STRING DW ?
- ;FRAME ENDS
- ;
- ;CGROUP GROUP FINDBL
- ;FINDBL SEGMENT PARA PUBLIC 'CODE'
- ; ASSUME CS:CGROUP
- ;
- ;START PROC FAR
- ; PUBLIC TRAILINGBLANKS
- ;TRAILINGBLANKS:
- ; NOP
- ; PUSH BP
- ; MOV BP,SP
- ; MOV SI,[BP+STRING]
- ; MOV CH,0
- ; MOV CX,DS:[SI]
- ; MOV SI,DS:[SI+2]
- ; ADD SI,CX
- ; DEC SI
- ;
- ;LOOP_1: MOV AL,DS:[SI]
- ; CMP AL,020H
- ; JNE NOT_A_BLANK
- ; DEC SI
- ; DEC CX
- ; JNZ LOOP_1
- ;
- ;NOT_A_BLANK:
- ; MOV SI,[BP+LAST_CHAR]
- ; MOV DS:[SI],CX
- ; POP BP
- ; RET 4
- ;
- ;START ENDP
- ;FINDBL ENDS
- ; END
-
-
- ; Here is the routine that performs the same function for
- ; TURBO BASIC. Please note that you should read Appendix C
- ; of the Turbo Basic Reference Manual to understand what we
- ; are really doing here.
-
-
- program segment ; begin program segment
- assume cs:program
-
- push bp ; save bp
- mov bp, sp
- push es ; save es because we'll use it for pointer manipulation
- push ds ; ditto
-
- les di, [bp + 6h] ; load pointer to string descriptor into es:di
- mov dx, ds:[0] ; get the beginning of the string segment from ds:[0]
- push dx
- pop ds ; make ds point to string segment
- mov si, es:[di + 2] ; get offset into string segment from es:[di + 2]
-
- mov cx,es:[di] ;load the length of the string into cx
- and cx, 7fffh ;mask off the high bit of the length byte
- add si, cx ;add the length to the beginning address
- dec si ;subtract one from the length to adjust it
-
-
- LOOP_1:
- mov al,ds:[si] ;move the string character into al
- cmp al,020h ;compare it to a blank
- jne NOT_A_BLANK ;if equal to a blank, jump out of loop
- dec si ;decrement the string index
- dec cx ;decrement the count of the length
- jnz loop_1 ;skip out of the loop if the position is zero
- ;
- NOT_A_BLANK:
- lds di, [bp+0ah] ;get the address of the integer to return
- ;the result in
- mov ds:[di], cx ;move the result into the integer
- pop ds ;pop and restore all the registers
- pop es
- pop bp
-
- program ends ; end program segment
-
- end