Category : Files from Magazines
Archive   : VOL8N22.ZIP
Filename : SETJMP.ASM

 
Output of file : SETJMP.ASM contained in archive : VOL8N22.ZIP




CODE SEGMENT BYTE PUBLIC
ASSUME CS:CODE
PUBLIC SetJmp, LongJmp

SetJmp PROC FAR
PUSH BP
MOV BP, SP
LES DI, 6[BP] ; Get address of JumpBuffer
CLD
LEA AX, 6[BP] ; Save SP
ADD AX, 4
STOSW
MOV AX, SS
STOSW ; Save SS
MOV AX, 4[BP]
STOSW ; Save CS
MOV AX, 2[BP]
STOSW ; Save IP
MOV AX, [BP]
STOSW ; Save BP
MOV AX, DS
STOSW ; Save DS
XOR AX, AX ; Return a value of 0 from SetJmp
POP BP ; Restore previous frame pointer
RET 4 ; Clean up stack and return
SetJmp ENDP

LongJmp PROC FAR
PUSH BP
MOV BP, SP
MOV BX, 6[BP] ; Get the return code
CMP BX, 1 ; If it is zero then return a value of 1
ADC BX, 0 ; so that LongJmp never returns 0
LDS SI, 8[BP] ; DS:SI points to JumpBuffer
CLD
LODSW ;Restore SS
MOV SS, [SI]
MOV SP, AX ;Restore SP
LODSW
LODSW
PUSH AX ;Push CS and IP onto the stack
LODSW
PUSH AX
LODSW
MOV BP, AX ;Restore BP
LODSW
MOV DS, AX ;Restore DS
MOV AX, BX ;RetValue in AX
RET ;Return with CS:IP from JumpBuffer
LongJmp ENDP
CODE ENDS
END






  3 Responses to “Category : Files from Magazines
Archive   : VOL8N22.ZIP
Filename : SETJMP.ASM

  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/