Hallo, guten tag.
Ich habe 2 Programme für den TASM.
Wann wird FAR verwendet und wann nicht ?
Danke.
Code
.model medium, basic
.stack 200h
.386
.code
public AddFour
; Our stack:
; Number 6
; QB Seg 4
; QB Off 2
; BP 0
AddFour proc
push bp
mov bp, sp
mov ax, [bp+6]
add ax, 199
pop bp
ret 2
AddFour endp
end
Alles anzeigen
Code
.model medium,basic ;directive for the medium model
.code ;directive for code segment header
.286 ;directive to allow 286 opcodes
public Addition ;declares procedure Addition callable from QuickBASIC
;to use the function in QuickBASIC add this line to your program:
; DECLARE FUNCTION Addition% (firstvar%, secondvar%)
Addition PROC FAR ;all procedures (SUBS/FUNCTIONS) must be
;declared FAR, for the code segment could not
;be the same as the one you're calling your
;procedure from!
push bp ;save base pointer on stack
mov bp,sp ;use base pointer instead of stack pointer
mov ax,[bp+6] ;last variable (stack!)
mov bx,[bp+8] ;first variable (stack!)
pop bp ;restore base pointer from stack
add ax,bx ;add bx to ax without carry
RET 4 ;4 is the number of BYTES (2*INTEGER!) you
;used (got from the stack)
Addition ENDP ;if declared as FUNCTION, AX contains the
;result
END ;directive to stop the assembler
Alles anzeigen