8086 assembly parameter passing question

本帖最後由 luckiejacky 於 2010-8-11 17:49 編輯

Hello,
The following code is copied from a book.....
  1. FontInfo proc FAR C PUBLIC USES DS SI, buf:FAR PTR, choice:byte
  2. ;;;;;;;;;;;;;;;;;;;;
複製代碼
FAR, C, PUBLIC seem to be macros.
How do I pass parameters to the subroutine using the name 'buf'?
I don't want to use global variables. What should I do?
The book is very incomplete
Thanks

TOP

回復 2# gilbertluis

Thanks for your help. But I am using turbo assembler wo...     

TOP

你個 FontInfo 係咪接受一個 buffer 呀?
咁你個 buf 係一個 memory address, 咁你 call FontInfo 咪 pass 一個 address 入去:
(以下係 Microsoft assembler syntax, 你轉返去 Borland syntax).
mov  di, OFFSET buffer       ;  設 ds = 想 FontInfo 用的 memory address
mov   al, 1                                ;  我求其當 choice = 1
INVOKE  FontInfo,  di, al      ;  call FontInfo

TOP

你個 FontInfo 係咪接受一個 buffer 呀?
咁你個 buf 係一個 memory address, 咁你 call FontInfo 咪 pass  ...
ccwork 發表於 2010-8-22 01:13


Hello ching,
Sorry for late reply. I wonder how to write the subroutine declaration in the first place.
Because Turbo Assembler doesn't like the way the book writes the subroutine header just like I've shown in the first post.
Thanks

TOP

Hello ching,
Sorry for late reply. I wonder how to write the subroutine declaration in the first p ...
luckiejacky 發表於 2010-8-26 17:26

我嘗試解讀你個 example

FontInfo proc FAR C PUBLIC USES DS SI, buf:FAR PTR, choice:byte
FontInfo  <==== function name
proc         <==== 應該係 assembler keyword
FAR          <==== 另一個 code segment ?  我唔記得左啦
C              <====  C 的 calling convention
PUBLIC     <====  唔知, 可能係指多個 compilation unit  可使用
USES DS, SI    <==== assembler 幫你做 push 同 pop DS, SI register

我係 Microsoft assembler 時係咁樣 declare
funcA        proc            a:byte, b:byte

(因係我係一開始就用標準 macro 去設定
       .model tiny
       .dos
唔洗個個 function 搞)

TOP

我嘗試解讀你個 example

FontInfo proc FAR C PUBLIC USES DS SI, buf:FAR PTR, choice:byte
FontInfo   ...
ccwork 發表於 2010-8-26 23:39


好吧,我試試,多謝你。

TOP