Category : Modula II Source Code
Archive   : STRINGS.ZIP
Filename : STRASM.A

 
Output of file : STRASM.A contained in archive : STRINGS.ZIP
module StrAsm

section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE

public StrAsm$BackArray: sLen = 18; sSeg = 16; sOfs = 14;
dLen = 12; dSeg = 10; dOfs = 8; eLen = 6;

push bp; mov bp,sp
push ds; push es; push si; push di
lds si,[bp][sOfs]
push ss
pop es (* point es to stack *)
mov cx,[bp][eLen] (* for movsb *)
sub sp,cx (* make room for string *)
mov di,sp (* and point di to string *)
rep
movsb (* copy string to stack *)
push ss
pop ds (* point ds to stack segment *)
mov si,sp (* and si to string *)
les di,[bp][dOfs]
mov cx,[bp][eLen] (* recall length *)
add di,cx (* and point to end of string *)
dec di (* where string start = 0 *)
jmp bcopy
bcopy:
lodsb
mov es:[di],al
dec di
loop bcopy
ret:
add sp,[bp][eLen] (* pop off string *)
pop di; pop si; pop es; pop ds
pop bp; ret far 14

section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE

extrn AsmLib$Length

extrn StrAsm$BackArray

public StrAsm$Reverse: sLen = 16; sSeg = 14; sOfs = 12;
dLen = 10; dSeg = 8; dOfs = 6;
push bp; mov bp,sp
push ds; push es; push si; push di
push [bp][sLen]
push [bp][sSeg]
push [bp][sOfs]
les di,[bp][dOfs]
call far AsmLib$Length
cmp ax,0 (* is string empty? *)
jne continue
mov es:[di],al (* then return empty string *)
jmp ret
continue:
cmp ax,[bp][dLen] (* is source length >= destination size *)
jl less
je equal
mov ax,[bp][dLen] (* if greater, truncate *)
jmp equal
less:
add di,ax (* if less point to end of string *)
mov byte es:[di],0 (* and terminate string *)
equal:
push [bp][sLen]

push [bp][sSeg]
push [bp][sOfs]
push [bp][dLen]
push [bp][dSeg]
push [bp][dOfs]
push ax
call far StrAsm$BackArray
ret:
pop di; pop si; pop es; pop ds
pop bp; ret far 12

end



  3 Responses to “Category : Modula II Source Code
Archive   : STRINGS.ZIP
Filename : STRASM.A

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/