Making std asm code into Turbo Asm code? 
Author Message
 Making std asm code into Turbo Asm code?

Hello,

Could someone please tell me what has to be done to the following code so that
I may compile it as part of a Turbo Pascal 7.0 program? (using Turbo Assembler)
The author has given permission to use the code as long as he is given credit,
which he will be if I can use it.

I will need to call this from my main program with a filename as the only
parameter.

Thank you!

Karla

******************************************************************************
IDEAL
;Constants

LINEWIDTH       EQU 80          ;Length of string storage for line
SCREENLENGTH    EQU 24          ;Number of rows in display window
MAXLINES        EQU 8096        ;Size of arrays of line pointers
BUFFERLENGTH    EQU 1200h       ;Length of file buffer
STACKSIZE       EQU 50h         ;Length of stack
BELL            EQU 7           ;Some non-printing chars
BS              EQU 8
HT              EQU 9
LF              EQU 10
CR              EQU 13
CRLF            EQU 0A0Dh
CTRL_Z          EQU 26
ESCAPE          EQU 27
DEL             EQU 127
PROGLENGTH = EndOfProgram - Orig + 100h  ;Length of .COM file

;Create a named string
MACRO String Name, Text
        LOCAL LL
Name    db LL-Name-1, Text
LL:
ENDM

;Make <Name> a byte ptr to <Length> bytes of storage after end of code.
;Like a .DATA? segment for .COM file, so uninitialized data doesn't take up
;room in the .COM file.
MACRO B? Name, Length
        LOCAL where
        where = EndOfProgram + BuffersCount
Name    EQU BYTE PTR where
        BuffersCount = BuffersCount + Length
ENDM

;Like B? but for word storage
MACRO W? Name, Length
        LOCAL where
        where = EndOfProgram + BuffersCount
Name    EQU WORD PTR where
        BuffersCount = BuffersCount + Length + Length
ENDM

BuffersCount = 0

MODEL TINY
CODESEG
ORG 100h
Orig:
jmp Start

String copyRight 'E 1.3.  Copyright (C) David Nye, 1991.  All rights reserved.'

;Some defaults, use ECONFIG to change

attribNl        db 1Fh          ;Default text attributes
attribInv       db 70h          ;Default status line attributes
tabSize         db 4            ;Tab increment
inserting?      db 0            ;True if in insert mode
autoIndent?     db -1           ;True if in autoindent mode
startInText?    db 0            ;Set to true to start up in text mode
zLMargin        db 8            ;Left margin setting for Alt Z
zRMargin        db LINEWIDTH-8  ;Right margin setting for Alt Z

;Strings

String cantOpenMsg,     "Can't open file."
String rdErrorMsg,      'Error reading file.'
String fileErrorMsg,    "Can't save file."
String diskFullMsg,     'Disk full.'
String noRoomMsg,       'Out of memory.'
String sysErrMsg,       'System error.'
String notMarkingMsg,   'Not marking.'
String setLabelMsg,     'Label (0-9): '
String setTabsMsg,      'Tab width: '
String newFileMsg,      'File name: '
String gotoMsg          'Jump to what line? '
String editingMsg       <'Help F1',186,'Editing: '>
String findMsg          'Find: '
String replaceMsg       'Replace with: '
String notFoundMsg      'No more matching strings found.'
String anyKeyMsg        'Press any key to continue.'
String ctrlCMsg         '*Break*'
String cancelledMsg     'Cancelled.'
BAK                     db  '.BAK', 0
comspec$                db  'COMSPEC='
helpMsg                 db 'CURSOR left           left arrow, ^S    '
                        db 'BLOCK begin                 ^B          '
                        db '  right               right arrow, ^D   '

                        db '  word left           ^left arrow, ^A   '

                        db '  word right          ^right arrow, ^F  '

                        db '  tab right, left     Tab, Shift Tab    '

                        db '  start, end of line  Home, End         '

                        db '  line up             up arrow, ^E      '

                        db '  line down           down arrow, ^X    '

                        db '  page up             PgUp, ^R          '

                        db '  page down           PgDn, ^C          '

                        db '  start of file       ^PgUp             '

                        db '  end of file         ^PgDn             '

                        db 'DELETE                Del               '

                        db '  backspace           Backspace         '

                        db '  delete word left    ^[                '

                        db '  delete word right   ^], ^T            '
                        db 'MARGIN set L, R             ^Home, ^End '
                        db '  delete rest of line ^\                '

                        db '  delete line         ^-, ^Y            '

                        db '  undelete line       ^^                '

                        db 'INSERT mode toggle    Ins               '


                        db 'SHELL to DOS, run EFn.BAT   F2, F3-F6 * '
                        db 80 dup (' ')

                        db 'hifted, + = use last string if shifted. '
                        db 'Status line flags:  Insert  Overwrite  C'
                        db 'hanged  AutoIndent  [ LMargin  ] RMargin'

;EXEC function parameter block

EXECParams      dw 0
EXECCmdLineOff  dw 0
ProgramSegment  dw 0, -1, -1 , -1 , -1
EXECBAT         db 0, '/c EF'
EXECFnumber     db 'x.BAT '
EXECFileName    db 20 dup (0)

;Variables

newFile?        db 0            ;True if new file
marking?        db 0            ;True if marking text
changed?        db 0            ;True if original file has been changed
isBAKed?        db 0            ;True if .BAK file already written
needCopies?     db -1           ;True unless lines in buffer were just deleted
autoReplace?    db 0            ;-1 if auto-replace with shift, 1 without shift
noEscape?       db 0            ;True if prompt demands response
labelTable      dw 10 dup (0)   ;Table of line pointers assigned to labels

;These variables and buffers are allocated space following .COM file
W? sstack, STACKSIZE            ;Stack goes here
STACKTOP = EndOfProgram + BuffersCount
W? cursorShape, 1               ;Line cursor parameters for color or mono
B? fName?, 1                    ;True if file name given on command line
B? justFound?, 1                ;True if no other commands since last Find
B? swapped?, 1                  ;True if edited file swapped out during EXEC
W? lMargin, 1                   ;Current margins
W? rMargin, 1
W? fHandle, 1                   ;File handle
W? lastLine, 1                  ;Index of last line in file
W? blockPtrsLast, 1             ;Index of last line in block buffer
W? top, 1                       ;Index of first line on screen
W? bottom, 1                    ;Index of last line on screen
W? mark, 1                      ;Start of marking for block command
W? here, 1                      ;Temporaries
W? spTemp, 1
W? comspecPtrOff, 1             ;Pointer to COMSPEC value: offset, segment
W? comspecPtrSeg, 1
W? bufferPtr, 1                 ;Multipurpose buffer pointer
W? hereCol, 1
W? topSegPtr, 1
W? topSeg, 1
W? topIndex, 1
W? videoSegment, 1              ;Segment of system's video memory
W? heapStart, 1                 ;Segment of start of heap
W? heapPtr, 1                   ;Segment pointer to next free paragraph in heap
B? fName, 50                    ;File name in ASCIIZ format
B? otherFName, 50               ;Name of second file
W? otherLine, 1                 ;Line of cursor in second file
ESSENTIALS = BuffersCount       ;Buffers above here not saved with shell + swap
W? temp, 1                      ;Temporary storage
B? fNameBAK, LINEWIDTH          ;Current file with .BAK extension added
B? fNameTemp, LINEWIDTH         ;File name for block read/writes, shell
B? pad, LINEWIDTH               ;Scratch buffer
B? findString, LINEWIDTH        ;Search string for Find command
B? replaceString, LINEWIDTH     ;New string for Replace command
W? linePtrs, MAXLINES           ;List of line pointers
W? blockPtrs, MAXLINES          ;Line pointers for block or line deletes
B? buffer, BUFFERLENGTH         ;File buffer
ENDFBUFFER = BuffersCount


ctrlTable       dw na           ;Undefined
                dw WordLeft     ;^A
                dw BeginBlock   ;^B
                dw PageDown     ;^C
                dw Right        ;^D
                dw Up           ;^E
                dw WordRight    ;^F
                dw na           ;^G or BEL
                dw BackSpace    ;^H or BS
                dw Tab          ;^I or HT
                dw na           ;^J or LF
                dw na           ;^K or VT
                dw na        
...

read more »



Tue, 25 Nov 1997 03:00:00 GMT  
 Making std asm code into Turbo Asm code?


Quote:
>>Hello,

>>Could someone please tell me what has to be done to the following code so that
>>I may compile it as part of a Turbo Pascal 7.0 program? (using Turbo Assembler)
>>The author has given permission to use the code as long as he is given credit,
>>which he will be if I can use it.

>>I will need to call this from my main program with a filename as the only
>>parameter.

>>Thank you!

>>Karla

>>******************************************************************************
>>IDEAL

[Large snip of code]

I don't want to sound like im telling you off but the author gave you
permission to use it, not the entire 80 thousand or so (I beleve) readers
of comp.lang.pascal!

Thought of that before you sent it?

Also, you could have just mailed to comp.lang.pascal saying that you would
like some help and then just emailed to code to those intrested.  Besides
which it takes time to download the message on a 14400 modem and a *very*
long time for anyone on a 2400 baud modem!

P.S. What does it do anyway?

*************************************************************************

** To error is human, but to really foul things up requires a computer **
*************************************************************************



Tue, 25 Nov 1997 03:00:00 GMT  
 Making std asm code into Turbo Asm code?

Quote:

> [Large snip of code]

> I don't want to sound like im telling you off but the author gave you
> permission to use it, not the entire 80 thousand or so (I beleve) readers
> of comp.lang.pascal!

> Thought of that before you sent it?

Hmmmm....well, it DOES sound like you're telling me off.:)
Actually, the code is available at just about every ftp site that keeps source
code such as this...and the permission is granted in the docs....so anyone else
who might like to use it is welcome to although they should probably get the
entire zip file (e14a.zip) for the rest of the documentation.

Quote:

> Also, you could have just mailed to comp.lang.pascal saying that you would
> like some help and then just emailed to code to those intrested.  Besides
> which it takes time to download the message on a 14400 modem and a *very*
> long time for anyone on a 2400 baud modem!

You're absolutely right! :) My judgement was clouded by desperation and I
should have done it differently. I didn't quite realize how long the code was
until after I had posted it and noted that it was 2000+ lines *wince*.

BTW It took me approx. 10 min. to upload it and my connection is 2400. To me
that isn't terribly long but I suppose these things are relative...

Quote:

> P.S. What does it do anyway?

It's an editor, and a pretty nice one too.

Quote:
> ** To error is human, but to really foul things up requires a computer **
> *************************************************************************

And then do you yell at it, too!? :) (just kidding!)

Anyway, my apologies...now, can you help me or not!?

Karla



Wed, 26 Nov 1997 03:00:00 GMT  
 Making std asm code into Turbo Asm code?

Quote:

>Could someone please tell me what has to be done to the following code so that
>I may compile it as part of a Turbo Pascal 7.0 program? (using Turbo Assembler)

Hello, Karla

I'm afraid it isn't easy work: the code seems to use its own memory
management and it can overwrite TP code; you must really carefully
examine every line of the code and make sure to understand what it
does. It is much too complicated for such an approach.

Why not to use it as separate program and invoke it by EXEC?
Simplest. Note program can easily get name of file it was loaded
from, and the program to load may have similar name (not necessary
executable-like, in this case its name can differ from name of the
pascal program by extension only).

Or simulate it is invoked by EXEC (the code image may be linked into
program, but to execute it you must allocate memory from DOS, create
PSP in it (a lot of problems: this DOS call assumes CS=PSP!), move
the code there, set current PSP = the new PSP, set command line and
transfer control to the code; do not forget to set INT 22h before
create PSP to point to location where control is to be transferred
when the program finishes execution).

Other alternative is: swap your program out of memory (or allocate
some memory at highest possible address and move it there; need of
course restore interrupt vectors changed by Turbo Pascal, seems
there is a library function which can do it), then move the asm
program code to PSP:100h, and transfer control to it.
It requires changing the program's exit code to transfer control
back to pascal code, or the pascal program will be terminated...



Sat, 29 Nov 1997 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Std Deviation in ASM code

2. ASM compiler in asm-code

3. Linking asm code to C++ code

4. ASM code public/private key cryptography source code

5. Linking asm code into C++ code

6. x86 ASM code -> z80 asm code??

7. asm source code examples ?

8. Asm code for DA file access?

9. the beginnig of asm code

10. 32bit ASM-Code under DOS

11. Error in ASM Code

12. Using inline asm in c/c++ code

 

 
Powered by phpBB® Forum Software