flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > OS Construction > asm_setjmp

Author
Thread Post new topic Reply to topic
Mike Gonta



Joined: 26 Dec 2010
Posts: 186
asm_setjmp
asm_setjmp
8086 code.

Code:

asm_setjmp:
  pop WORD [env]
  push WORD [env; get and put back the return address
  push cx
  push dx
  push bx
  push bp
  push si
  push di ; push all registers except ax
  push WORD [env; return address stacked for asm_longjmp
  mov [env], sp ; save sp for asm_longjmp to restore
  add WORD [env], 2 ; adjust sp to point to di on the stack
                    ; which also clears the carry flag for
  ret               ; the initial return to asm_setjmp

asm_longjmp:
  push WORD [env]
  pop sp ; retore sp
  pop di
  pop si
  pop bp
  pop bx
  pop dx
  pop cx ; pop all registers except ax
  stc
  ret ; return to asm_setjmp with the carry flag set

env dw 0




Use the functions like this:

Code:

  call asm_setjmp
  jnc .1
; handle errors here, any error code in ax
; even use 0 for a no error exit for example
.1:

; ...

; handle errors here
  mov ax, -1 ; any error code in ax
  jmp asm_longjmp ; no need to "call ahead" since "you ain't comin' back"



_________________
Mike Gonta
look and see - many look but few see

http://mikegonta.com
Post 10 Jan 2017, 17:57
View user's profile Send private message Reply with quote
nop



Joined: 01 Sep 2008
Posts: 167
Location: right here left there
hi mike could you describe why you wrote this code
Post 10 Jan 2017, 22:24
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.