home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
rxfiles.zip
/
rx_frame.asm
< prev
next >
Wrap
Assembly Source File
|
1997-08-14
|
5KB
|
152 lines
;-----------------------------------------------------------------------
; xyzzy.ASM frame for xyzzy.RX by ML /AT /Fe xyzzy.RX xyzzy.ASM
;-----------------------------------------------------------------------
code segment para public 'CODE'
assume cs:code, ds:code, es:code, ss:code
RXSTR struct
RxLen dw ?
RxPtr dd ?
RXSTR ends
PRXSTR TYPEDEF far ptr RXSTR
SHVBLOCK struct
ShvNext dd ?
ShvNam RXSTR <>
ShvVal RXSTR <>
ShvNamL dw ?
ShvValL dw ?
ShvCode db ?
ShvRet db ?
SHVBLOCK ends
org 16h
RXpid dw ? ;_psp:0x16 parent (REXX) pid
org 2Ch
envseg dw ? ;_psp:0x2C environment segment
org 54h
DOSREXX4 dd ? ;_psp:0x54 'REXX' signature
SHVENTRY dd ? ;_psp:0x58 shared variable handler
org 82h
RXARGC dw ? ;_psp:0x82 number of arguments
RXARGV PRXSTR ? ;_psp:0x84 arg.s (length, pointer)
RXRESULT dd ? ;_psp:0x88 RESULT buffer (256 bytes)
_RXNAME db ? ;_psp:0x8C (undocumented)
org 100h ;COM entry point at CS:100
start: jmp stack ;set stack, release memory
;????? ????
;????? ????
argstr db ' <= argument',13,10,0
;-----------------------------------------------------------------------
main proc near ;enter after initialization
cmp word ptr DOSREXX4+2,'XX'
jne fail
mov cx,RXARGC ;example: number of arguments
les si,RXARGV
jcxz copyres
nextarg: push cx
push ds
mov cx,es:RXSTR.RxLen[si] ;example: argument length
lds dx,es:RXSTR.RxPtr[si] ;example: argument pointer
mov bx,2 ;stderr
mov ah,40h ;output DS:DX, length CX
int 21h
pop ds
mov dx,offset argstr
call message
add si,sizeof RXSTR
pop cx
loop nextarg
copyres: push ds
pop es
mov dx,offset _RXNAME
call strlen
les di,RXRESULT ;example: ES:DI = RESULT
mov si,dx ;example: DS:SI = _RXNAME
rep movsb ;copy _RXNAME (undocumented)
;????? ????
;????? ????
okay: xor al,al ;REXX function ended
jmp exit
fail: mov al,1 ;REXX function error
exit: mov ah,4Ch ;terminate with RC AL
int 21h
main endp
;-----------------------------------------------------------------------
;????? ????
;????? ????
;-----------------------------------------------------------------------
strlen proc near ;return length ASCIIZ string ES:DX
xchg di,dx ;modifies AX, CX
mov cx,di ;keep DX, DI, ES
not cx ;terminate search at segment limit
push di ;this will work for length < 64 KB
xor al,al
repne scasb ;search NUL
mov cx,di ;DI points behind NUL (or is NULL)
pop di ;restore DI
sub cx,di ;length inclusive NUL
dec cx ;length exclusive NUL
xchg dx,di ;restore DX
ret ;returns CX string length
strlen endp
;-----------------------------------------------------------------------
message proc near ;ASCIIZ string DS:DX to STDERR
push ax ;modifies BX, CX
push es ;keep AX, DX, DS, ES
push ds
pop es ;set ES = DS
call strlen ;CX = strlen( ES:DX )
pop es ;load old ES
mov bx,2 ;ASCIIZ string DS:DX to STDERR
mov ah,40h
int 21h
pop ax
ret
message endp
;-----------------------------------------------------------------------
align 16
stkparas equ 32 ;stack size 512 = 32 * 16
stack label near ;initialise *.com program
mov bx,offset stack + 16 * stkparas
mov sp,bx ;new stack 100h above init
mov cl,4
shr bx,cl ;used number of paragraphs:
mov ah,4ah ;modify allocated memory to
int 21h ;needed size i.e. free rest
jmp main ;current SP must be beyond
;-----------------------------------------------------------------------
code ends
end start ;program entry point