-
Notifications
You must be signed in to change notification settings - Fork 0
/
far_call_advanced.asm
56 lines (44 loc) · 1.06 KB
/
far_call_advanced.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name "faradv"
org 100h ; set location counter to 100h
jmp start
adr_a dw offset a
seg_a dw ?
adr_c dw offset c
seg_c dw ?
; set segments, requred because we don't know where
; the program will be loaded by the operating system
start:
mov ax, cs
mov seg_a, ax
mov seg_c, ax
call far adr_a
call b
call far adr_c
mov ax, offset d
call ax
ret ; return to os.
;--------------------------------------------------
a proc
mov ax, 1
retf ; far return, pop ip and cs.
a endp
;--------------------------------------------------
b proc
add ax, 2
ret ; return, pop ip only.
b endp
;-------------------------------------------------
c proc
add ax, 3
retf ; far return, pop ip and cs.
c endp
;-------------------------------------------------
d proc
add ax, 4
ret ; return, pop ip only.
d endp
;-------------------------------------------------
; note: assembler automatically replaces ret (C3) with retf (CB)
; if proc has far label, for example:
; c proc far
; ....