home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / tools / qb2tb / qb2tb.asm next >
Assembly Source File  |  1987-04-22  |  3KB  |  102 lines

  1.  
  2. ; Here you will find the original code used for an assembly
  3. ; language routine used for MicroSoft QuickBasic.  Below, we
  4. ; have written the code the performs the same function for
  5. ; the TURBO BASIC procedure GETBLANK (found elsewhere in the
  6. ; file QB-TO-TB.BAS).  We have provided both versions of this
  7. ; code so that users who are porting their QuickBasic programs
  8. ; over to TURBO BASIC may see the differences in the two methods
  9. ; side by side, and quickly see what must be altered.
  10. ;
  11.  
  12.  
  13. ;                    This is the assembly routine for QuickBasic:
  14.  
  15. ;FRAME     STRUC
  16. ;          DW        ?
  17. ;          DD        ?
  18. ;LAST_CHAR DW        ?
  19. ;STRING    DW        ?
  20. ;FRAME     ENDS
  21. ;
  22. ;CGROUP    GROUP     FINDBL
  23. ;FINDBL    SEGMENT   PARA PUBLIC 'CODE'
  24. ;          ASSUME    CS:CGROUP
  25. ;
  26. ;START     PROC      FAR
  27. ;          PUBLIC    TRAILINGBLANKS
  28. ;TRAILINGBLANKS:
  29. ;          NOP
  30. ;          PUSH      BP
  31. ;          MOV       BP,SP
  32. ;          MOV       SI,[BP+STRING]
  33. ;          MOV       CH,0
  34. ;          MOV       CX,DS:[SI]
  35. ;          MOV       SI,DS:[SI+2]
  36. ;          ADD       SI,CX
  37. ;          DEC       SI
  38. ;
  39. ;LOOP_1:   MOV       AL,DS:[SI]
  40. ;          CMP       AL,020H
  41. ;          JNE       NOT_A_BLANK
  42. ;          DEC       SI
  43. ;          DEC       CX
  44. ;          JNZ       LOOP_1
  45. ;
  46. ;NOT_A_BLANK:
  47. ;          MOV       SI,[BP+LAST_CHAR]
  48. ;          MOV       DS:[SI],CX
  49. ;          POP       BP
  50. ;          RET       4
  51. ;
  52. ;START     ENDP
  53. ;FINDBL    ENDS
  54. ;          END
  55.  
  56.  
  57. ;   Here is the routine that performs the same function for
  58. ;   TURBO BASIC.  Please note that you should read Appendix C
  59. ;   of the Turbo Basic Reference Manual to understand what we
  60. ;   are really doing here.
  61.  
  62.  
  63. program segment    ; begin program segment
  64.   assume cs:program
  65.  
  66.   push  bp         ; save bp
  67.   mov   bp, sp
  68.   push  es         ; save es because we'll use it for pointer manipulation
  69.   push  ds         ; ditto
  70.  
  71.   les   di, [bp + 6h]    ; load pointer to string descriptor into es:di
  72.   mov   dx, ds:[0]   ; get the beginning of the string segment from ds:[0]
  73.   push  dx
  74.   pop   ds           ; make ds point to string segment
  75.   mov   si, es:[di + 2] ; get offset into string segment from es:[di + 2]
  76.  
  77.   mov   cx,es:[di] ;load the length of the string into cx
  78.   and   cx, 7fffh  ;mask off the high bit of the length byte
  79.   add   si, cx     ;add the length to the beginning address
  80.   dec   si         ;subtract one from the length to adjust it
  81.  
  82.  
  83. LOOP_1:
  84.   mov   al,ds:[si]   ;move the string character into al
  85.   cmp   al,020h      ;compare it to a blank
  86.   jne   NOT_A_BLANK  ;if equal to a blank, jump out of loop
  87.   dec   si           ;decrement the string index
  88.   dec   cx           ;decrement the count of the length
  89.   jnz   loop_1       ;skip out of the loop if the position is zero
  90. ;
  91. NOT_A_BLANK:
  92.   lds   di, [bp+0ah] ;get the address of the integer to return
  93.                      ;the result in
  94.   mov   ds:[di], cx  ;move the result into the integer
  95.   pop   ds           ;pop and restore all the registers
  96.   pop   es
  97.   pop   bp
  98.  
  99. program ends         ; end program segment
  100.  
  101. end
  102.