🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc
Article #15766

Re: TURBO PASCAL with MASM

#15766
From: mmm
Date: Fri, 16 Jan 1987 17:28
59 lines
2366 bytes
Turbo and masm are not the easiest things to use together but it
can be done if you know a few tricks.  The first and perhaps most
important one is how to debug under turbo pascal.

first you must load turbo under a debugger (i'll use symdeb as an
example)
symdeb turbo.com

after the debugger loads, type 'g' to get turbo started.  when you
want to hit a breakpoint, just compile you code with an inline($cc);
statement in your code (and int 3) which will cause the debugger to
become active.  set the ip to the next instruction (ip := ip+1) in
order to continue.

MASM:
the biggest problem is finding your data.  you can use the 'external xx.bin;'
syntax to include you own assembly code in a binary format but the code
must be totaly relocatable.  this means you cannot access any direct offsets.
for example 'mov ax,cs:x' would not work because masm assumes a starting
address of 0.  parameters in the mov instruction are absolute references
(unlike jumps and calls).  

to work around this problem you will need to use a base register to
access your data.  All references will have to be based off this register.
here is an example of how to write a routine:

code segment para public 'CODE'
assume cs:code, ds:nothing		;forces all references to be cs:

	jmp	start
data	label	word
xx	dw	?
yy	dw	?

start:	push	bp
	mov	bp,sp			;save the stack
	call	next			;get our instruction pointer
next:	pop	bx			;in bx
	sub	bx,offset next		;make bx point to the start of
					;this piece of code.

;to reference data, you need to always use the bx register
	mov	ax,word ptr xx[bx]        

;to get the address of a variable
	lea	si,xx[bx]

code	ends
	end

hope this helps, 

lloyd w. tabb
nbi engineering
3450 mitchell lane
boulder, colorado 80301

{hao|ucbvax|allegra}!nbires!mmm
	
Technical Details
Message-ID: <965@nbires.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!ames!ucbcad!ucbvax!hplabs!hao!nbires!mmm
References: <932@ihlpf.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!ames!ucbcad!ucbvax!hplabs!hao!nbires!mmm
From: mmm@nbires.UUCP
Newsgroups: comp.sys.ibm.pc
Subject: Re: TURBO PASCAL with MASM
Message-ID: <965@nbires.UUCP>
Date: Fri, 16-Jan-87 12:28:03 EST
Article-I.D.: nbires.965
Posted: Fri Jan 16 12:28:03 1987
Date-Received: Sat, 17-Jan-87 18:45:37 EST
References: <932@ihlpf.UUCP>
Reply-To: mmm@nbires.UUCP (Lloyd W. Tabb)
Distribution: world
Organization: NBI Inc, Boulder CO
Lines: 59