The following code assembles flawless with TASM 4:
.486p
; Publics for PB
public CopyString
; Externals
extrn Get$Loc: FAR ; internal PB functions
extrn Get$Alloc: FAR
DATA segment word use16 public 'DATA'
str db "Text from the Assembly Language Data Segment."
slen equ $ - str ; string length
DATA ends
code16 segment para public use16
assume cs:code16, ds:DATA
; FUNCTION CopyString
; Purpose: Copy a string into a PB string.
; Input: None
; Output: ax = string handle ===> success
; ax = 0 ===> failed
CopyString proc far
push bp
mov bp, sp
sub sp, 2 ; temporary storage
push ds
push es
push di
push si
mov ax, slen ; get string length
push ax ; length onto stack
call Get$Alloc ; allocate string space
or ax, ax ; space available?
jz CopyString3 ; no: jump
mov [bp-2], ax ; save new handle
push ax ; handle at stack
call Get$Loc ; determine string address
; dx:ax = string address
; cx = string length
mov es, dx
mov di, ax ; es:di -> destinaton
mov si, offset str ; ds:si -> source
CopyString1:
mov al, ds:[si] ; read 1 byte
mov byte ptr es:[di], al ; write 1 byte
inc di ; update pointers and counter
inc si
dec cx
jnz CopyString1
mov ax, [bp-2] ; load string handle
CopyString2:
pop si
pop di
pop es
pop ds
mov sp, bp
pop bp
ret
CopyString3:
xor ax, ax ; indicate error
jmp short CopyString2
CopyString endp
code16 ends
end
There's nothing special. But the DOS version of jWasm produces the following error protocol:
ASMTEST.ASM(15) : Error A2218: Syntax error: db
ASMTEST.ASM(38) : Error A2066: Operand is expected
ASMTEST.ASM(50) : Error A2066: Operand is expected
What happens here? I've included the complete source and the running EXE into the archive ASMTEST.ZIP.
Gunther