• Advertisement
Sign in to follow this  

TASM and passing by reference

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm attempting to start passing values in TASM 4.1 (and yes, that's what I have to use right now) and I'm obviously not doing something right in my translation from a MASM-centric book. My present code:
title
.model small
.stack 100h

extrn WriteString:proc          ; Takes zero-terminated string offset in dx
extrn CrLf:proc                 ; Prints Carriage Return/Line Feed
extrn WriteInt:proc             ; Takes number in ax, numeric base in bx

.data
arg2 db  1

.code
;--------------------------------------------------------------
_Test proc
ARG ARG1:PTR BYTE
;
; Testing pass by reference
;
; Last update: 10/22/04
;--------------------------------------------------------------
    mov BYTE PTR [ARG1],4
    mov ax,0
    mov al,BYTE PTR[arg1]
    Call WriteInt
    Call CrLf
    ret
_Test  endp

.code
main proc
    mov ax,@data
    mov ds,ax

.mainEntry:
    mov ax,0
    mov al,arg2
    mov bx,10
    Call WriteInt
    Call CrLf

    Call _Test C, Offset arg2
    mov ax,0
    mov al,arg2
    Call WriteInt
    Call CrLf

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;    CLEANUP AND EXIT     ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.mainExit:
    mov ax,4C00H                ; End program nicely
    int 21h
main endp
end main

And the present output is: 1 4 1 I see the code in my book using ADDR as opposed to offset when passing the pointer though that's erroring out in TASM for me. Any ideas? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Ok, I seem to have fixed it by using a word instead of byte btr.

I have a different issue now.

I'm using a function with an arg list:
X:WORD,Y:WORD,C:BYTE

Now, I have no issues with using macros, registers, dw's with the first two, but it seems as though I can only pass constants through the byte... The only exception being that I can pass words through with no errors... Is there some rule in dealing with bytes as opposed to the native word in 16bit asm? It would be annoying to have to use an offset or translate a byte through a word for every function that takes a byte.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement