URGENT String Passing Procedure

[b][red]This message was edited by HaVeMercy at 2004-3-23 0:36:38[/red][/b][hr]
[b][red]This message was edited by HaVeMercy at 2004-3-22 22:25:34[/red][/b][hr]
I am trying to write a procedure that passes a string to a procedure, and the user imputs characters in the string. I am unsure as to how to do this. The textbook I have uses values as an example. Sample code, link to tutorials, any hints would be appreciated. Hopefully after I get this basic method down, I will be able to apply it to the other things I need to do in this project. The procedure needs to be written using conventional segment directives.

This is urgent because the project needs to be completed by Wednesday night.

Thanks for the input dwccgc and AsmGuru62. I'm trying to use the OFFSET command to pass the strings but am getting the error "Immediate Operand not allowed." I've also tried
MOV DX, OFFSET [STRING1]
but then I get the error message that it cannot resolve externals.

I've hit a wall. Any ideas?

The code is below:

.MODEL SMALL
.STACK 64
INCLUDE Cis21ja.inc

EXTRN READSTRING:FAR
EXTRN CHECKSTRING:FAR

CR EQU 13
LF EQU 10

STACK SEGMENT PARA 'Stack'
DW 64 DUP(?)
STACK ENDS
;=============================================================
DATASEG SEGMENT PARA 'Data'

PROMPT1 DB 'Enter First String', 13, 10
PROMPT2 DB 'Enter Second String', 13, 10
SUP_FOUN DB 'SUBSTRING FOUND', 13, 10
STRING1 DW 80 DUP(' ')
STRING2 DW 80 DUP(' ')
NEWLINE DW CR, LF
COUNT1 DW 0000
COUNT2 DW 0000

DATASEG ENDS
;=============================================================

CODESEG SEGMENT PARA 'Code'
BEGIN PROC FAR
ASSUME SS:STACK, DS:DATASEG, CS:CODESEG
MOV AX, DATASEG
MOV DS, AX
MOV ES, AX

@STDOUT PROMPT1
PUSH OFFSET [STRING1]
PUSH OFFSET [STRING2]
PUSH OFFSET [COUNT1]
PUSH OFFSET [COUNT2]
CALL READSTRING

;@STDOUT STRING2
;@STDOUT STRING1

MOV AX, 4C00H
INT 21H

BEGIN ENDP ;End procedure
CODESEG ENDS
END BEGIN

;=============================================================

TITLE READSTRING Called subprogram
CODESEG SEGMENT PARA PUBLIC 'Code'
READSTRING PROC NEAR

PUSH BP
MOV BP, SP
MOV SI, [BP + 10]
@STDIN [SI]
MOV [BP + 6]
RETF 4

READSTRING ENDP
CODESEG ENDS
END



Thanks in advance.




Comments

  • Search google with the following string "Assembler x86 tutorial"
    Here is one link that I found.
    http://burks.brighton.ac.uk/burks/language/asm/asmtut/asm1.htm

    : I am trying to write a procedure that passes a string to a procedure, and the user imputs characters in the string. I am unsure as to how to do this. The textbook I have uses values as an example. Sample code, link to tutorials, any hints would be appreciated. Hopefully after I get this basic method down, I will be able to apply it to the other things I need to do in this project. The procedure needs to be written using conventional segment directives.
    :
    : This is urgent because the project needs to be completed by Wednesday night.
    :
    : Thanks in advance.
    :

  • : Search google with the following string "Assembler x86 tutorial"
    : Here is one link that I found.
    : http://burks.brighton.ac.uk/burks/language/asm/asmtut/asm1.htm
    :
    : : I am trying to write a procedure that passes a string to a procedure, and the user imputs characters in the string. I am unsure as to how to do this. The textbook I have uses values as an example. Sample code, link to tutorials, any hints would be appreciated. Hopefully after I get this basic method down, I will be able to apply it to the other things I need to do in this project. The procedure needs to be written using conventional segment directives.
    : :
    : : This is urgent because the project needs to be completed by Wednesday night.
    : :
    : : Thanks in advance.
    : :
    :
    :
    [blue]Usually, when you pass parameters and a parameter does not fit into a register - you need to pass an address of the parameter. That convention is easily applied to strings, because, string can be any length - 260 symbols for a path and a few Kbytes if you want to pass a whole text file to another function.

    So, in your case - you need to pass a pointer to a buffer where the information should be entered by user. You can allocate that buffer by any means - stack, heap or .DATA section, no matter, but when you need to pass it to others - simply load the address of the buffer into some register and call the function.

    Theoretically, you can pass the whole string on stack, but it is very convoluted way to do things - the stack is always changing, and if you need to keep your large objects intact - you have to always copy them back from stack to their original memory storage, so your code eventually gets slower than even C/C++ code.[/blue]
  • Please see my post. I have editied it....I have added the code I have so far. Alas, I still have questions. As always thank you for your help.

    : : Search google with the following string "Assembler x86 tutorial"
    : : Here is one link that I found.
    : : http://burks.brighton.ac.uk/burks/language/asm/asmtut/asm1.htm
    : :
    : : : I am trying to write a procedure that passes a string to a procedure, and the user imputs characters in the string. I am unsure as to how to do this. The textbook I have uses values as an example. Sample code, link to tutorials, any hints would be appreciated. Hopefully after I get this basic method down, I will be able to apply it to the other things I need to do in this project. The procedure needs to be written using conventional segment directives.
    : : :
    : : : This is urgent because the project needs to be completed by Wednesday night.
    : : :
    : : : Thanks in advance.
    : : :
    : :
    : :
    : [blue]Usually, when you pass parameters and a parameter does not fit into a register - you need to pass an address of the parameter. That convention is easily applied to strings, because, string can be any length - 260 symbols for a path and a few Kbytes if you want to pass a whole text file to another function.
    :
    : So, in your case - you need to pass a pointer to a buffer where the information should be entered by user. You can allocate that buffer by any means - stack, heap or .DATA section, no matter, but when you need to pass it to others - simply load the address of the buffer into some register and call the function.
    :
    : Theoretically, you can pass the whole string on stack, but it is very convoluted way to do things - the stack is always changing, and if you need to keep your large objects intact - you have to always copy them back from stack to their original memory storage, so your code eventually gets slower than even C/C++ code.[/blue]
    :

  • : [b][red]This message was edited by HaVeMercy at 2004-3-23 0:36:38[/red][/b][hr]
    : [b][red]This message was edited by HaVeMercy at 2004-3-22 22:25:34[/red][/b][hr]
    : I am trying to write a procedure that passes a string to a procedure, and the user imputs characters in the string. I am unsure as to how to do this. The textbook I have uses values as an example. Sample code, link to tutorials, any hints would be appreciated. Hopefully after I get this basic method down, I will be able to apply it to the other things I need to do in this project. The procedure needs to be written using conventional segment directives.
    :
    : This is urgent because the project needs to be completed by Wednesday night.
    :
    : Thanks for the input dwccgc and AsmGuru62. I'm trying to use the OFFSET command to pass the strings but am getting the error "Immediate Operand not allowed." I've also tried
    : MOV DX, OFFSET [STRING1]
    : but then I get the error message that it cannot resolve externals.
    :
    : I've hit a wall. Any ideas?
    :
    : The code is below:
    :
    : .MODEL SMALL
    : .STACK 64
    : INCLUDE Cis21ja.inc
    :
    : EXTRN READSTRING:FAR
    : EXTRN CHECKSTRING:FAR
    :
    : CR EQU 13
    : LF EQU 10
    :
    : STACK SEGMENT PARA 'Stack'
    : DW 64 DUP(?)
    : STACK ENDS
    : ;=============================================================
    : DATASEG SEGMENT PARA 'Data'
    :
    : PROMPT1 DB 'Enter First String', 13, 10
    : PROMPT2 DB 'Enter Second String', 13, 10
    : SUP_FOUN DB 'SUBSTRING FOUND', 13, 10
    : STRING1 DW 80 DUP(' ')
    : STRING2 DW 80 DUP(' ')
    : NEWLINE DW CR, LF
    : COUNT1 DW 0000
    : COUNT2 DW 0000
    :
    : DATASEG ENDS
    : ;=============================================================
    :
    : CODESEG SEGMENT PARA 'Code'
    : BEGIN PROC FAR
    : ASSUME SS:STACK, DS:DATASEG, CS:CODESEG
    : MOV AX, DATASEG
    : MOV DS, AX
    : MOV ES, AX
    :
    : @STDOUT PROMPT1
    : PUSH OFFSET [STRING1]
    : PUSH OFFSET [STRING2]
    : PUSH OFFSET [COUNT1]
    : PUSH OFFSET [COUNT2]
    : CALL READSTRING
    :
    : ;@STDOUT STRING2
    : ;@STDOUT STRING1
    :
    : MOV AX, 4C00H
    : INT 21H
    :
    : BEGIN ENDP ;End procedure
    : CODESEG ENDS
    : END BEGIN
    :
    : ;=============================================================
    :
    : TITLE READSTRING Called subprogram
    : CODESEG SEGMENT PARA PUBLIC 'Code'
    : READSTRING PROC NEAR
    :
    : PUSH BP
    : MOV BP, SP
    : MOV SI, [BP + 10]
    : @STDIN [SI]
    : MOV [BP + 6]
    : RETF 4
    :
    : READSTRING ENDP
    : CODESEG ENDS
    : END
    :
    :
    :
    : Thanks in advance.
    :
    :
    [blue]In order to use PUSH OFFSET ... - you have to specify the .386 directive and since you did not - the Assembler complains. It can be resolved by the pair of instructions, like so:
    [code]
    MOV AX, OFFSET [...]
    PUSH AX
    [/code]
    Or, simply specify .386, but this can cause 32-bit segments, like it does in TASM, so maybe, just replace every PUSH OFFSET [...] with the above instructions and try again.[/blue]
  • Still having problems. :-(

    I modified the code and I'm still getting 'READSTRING': UNRESOLVED EXTERNAL'

    I modified it so:

    MOV AX, OFFSET [STRING1]
    PUSH AX
    MOV AX, OFFSET [STRING2]
    PUSH AX
    MOV AX, OFFSET [COUNT1]
    PUSH AX
    MOV AX, OFFSET [COUNT2]
    PUSH AX
    CALL READSTRING

    When I comment out the @stdout error, I get the error. When I include the @stdout calls in the build, I get a length parameter missing @stdout error. I've also experimented with different Models, but the same problem.

    Again, thank you for your efforts.

    : : [b][red]This message was edited by HaVeMercy at 2004-3-23 0:36:38[/red][/b][hr]
    : : [b][red]This message was edited by HaVeMercy at 2004-3-22 22:25:34[/red][/b][hr]
    : : I am trying to write a procedure that passes a string to a procedure, and the user imputs characters in the string. I am unsure as to how to do this. The textbook I have uses values as an example. Sample code, link to tutorials, any hints would be appreciated. Hopefully after I get this basic method down, I will be able to apply it to the other things I need to do in this project. The procedure needs to be written using conventional segment directives.
    : :
    : : This is urgent because the project needs to be completed by Wednesday night.
    : :
    : : Thanks for the input dwccgc and AsmGuru62. I'm trying to use the OFFSET command to pass the strings but am getting the error "Immediate Operand not allowed." I've also tried
    : : MOV DX, OFFSET [STRING1]
    : : but then I get the error message that it cannot resolve externals.
    : :
    : : I've hit a wall. Any ideas?
    : :
    : : The code is below:
    : :
    : : .MODEL SMALL
    : : .STACK 64
    : : INCLUDE Cis21ja.inc
    : :
    : : EXTRN READSTRING:FAR
    : : EXTRN CHECKSTRING:FAR
    : :
    : : CR EQU 13
    : : LF EQU 10
    : :
    : : STACK SEGMENT PARA 'Stack'
    : : DW 64 DUP(?)
    : : STACK ENDS
    : : ;=============================================================
    : : DATASEG SEGMENT PARA 'Data'
    : :
    : : PROMPT1 DB 'Enter First String', 13, 10
    : : PROMPT2 DB 'Enter Second String', 13, 10
    : : SUP_FOUN DB 'SUBSTRING FOUND', 13, 10
    : : STRING1 DW 80 DUP(' ')
    : : STRING2 DW 80 DUP(' ')
    : : NEWLINE DW CR, LF
    : : COUNT1 DW 0000
    : : COUNT2 DW 0000
    : :
    : : DATASEG ENDS
    : : ;=============================================================
    : :
    : : CODESEG SEGMENT PARA 'Code'
    : : BEGIN PROC FAR
    : : ASSUME SS:STACK, DS:DATASEG, CS:CODESEG
    : : MOV AX, DATASEG
    : : MOV DS, AX
    : : MOV ES, AX
    : :
    : : @STDOUT PROMPT1
    : : PUSH OFFSET [STRING1]
    : : PUSH OFFSET [STRING2]
    : : PUSH OFFSET [COUNT1]
    : : PUSH OFFSET [COUNT2]
    : : CALL READSTRING
    : :
    : : ;@STDOUT STRING2
    : : ;@STDOUT STRING1
    : :
    : : MOV AX, 4C00H
    : : INT 21H
    : :
    : : BEGIN ENDP ;End procedure
    : : CODESEG ENDS
    : : END BEGIN
    : :
    : : ;=============================================================
    : :
    : : TITLE READSTRING Called subprogram
    : : CODESEG SEGMENT PARA PUBLIC 'Code'
    : : READSTRING PROC NEAR
    : :
    : : PUSH BP
    : : MOV BP, SP
    : : MOV SI, [BP + 10]
    : : @STDIN [SI]
    : : MOV [BP + 6]
    : : RETF 4
    : :
    : : READSTRING ENDP
    : : CODESEG ENDS
    : : END
    : :
    : :
    : :
    : : Thanks in advance.
    : :
    : :
    : [blue]In order to use PUSH OFFSET ... - you have to specify the .386 directive and since you did not - the Assembler complains. It can be resolved by the pair of instructions, like so:
    : [code]
    : MOV AX, OFFSET [...]
    : PUSH AX
    : [/code]
    : Or, simply specify .386, but this can cause 32-bit segments, like it does in TASM, so maybe, just replace every PUSH OFFSET [...] with the above instructions and try again.[/blue]
    :

  • : Still having problems. :-(
    :
    : I modified the code and I'm still getting 'READSTRING': UNRESOLVED EXTERNAL'
    :
    : I modified it so:
    :
    : MOV AX, OFFSET [STRING1]
    : PUSH AX
    : MOV AX, OFFSET [STRING2]
    : PUSH AX
    : MOV AX, OFFSET [COUNT1]
    : PUSH AX
    : MOV AX, OFFSET [COUNT2]
    : PUSH AX
    : CALL READSTRING
    :
    : When I comment out the @stdout error, I get the error. When I include the @stdout calls in the build, I get a length parameter missing @stdout error. I've also experimented with different Models, but the same problem.
    :
    : Again, thank you for your efforts.

    [blue]In addition to:
    [code]
    EXTRN READSTRING:FAR
    [/code]
    You need to include actual library with that function into your build. How did you do it? Also, is it TASM or MASM?[/blue]

    :
    : : : [b][red]This message was edited by HaVeMercy at 2004-3-23 0:36:38[/red][/b][hr]
    : : : [b][red]This message was edited by HaVeMercy at 2004-3-22 22:25:34[/red][/b][hr]
    : : : I am trying to write a procedure that passes a string to a procedure, and the user imputs characters in the string. I am unsure as to how to do this. The textbook I have uses values as an example. Sample code, link to tutorials, any hints would be appreciated. Hopefully after I get this basic method down, I will be able to apply it to the other things I need to do in this project. The procedure needs to be written using conventional segment directives.
    : : :
    : : : This is urgent because the project needs to be completed by Wednesday night.
    : : :
    : : : Thanks for the input dwccgc and AsmGuru62. I'm trying to use the OFFSET command to pass the strings but am getting the error "Immediate Operand not allowed." I've also tried
    : : : MOV DX, OFFSET [STRING1]
    : : : but then I get the error message that it cannot resolve externals.
    : : :
    : : : I've hit a wall. Any ideas?
    : : :
    : : : The code is below:
    : : :
    : : : .MODEL SMALL
    : : : .STACK 64
    : : : INCLUDE Cis21ja.inc
    : : :
    : : : EXTRN READSTRING:FAR
    : : : EXTRN CHECKSTRING:FAR
    : : :
    : : : CR EQU 13
    : : : LF EQU 10
    : : :
    : : : STACK SEGMENT PARA 'Stack'
    : : : DW 64 DUP(?)
    : : : STACK ENDS
    : : : ;=============================================================
    : : : DATASEG SEGMENT PARA 'Data'
    : : :
    : : : PROMPT1 DB 'Enter First String', 13, 10
    : : : PROMPT2 DB 'Enter Second String', 13, 10
    : : : SUP_FOUN DB 'SUBSTRING FOUND', 13, 10
    : : : STRING1 DW 80 DUP(' ')
    : : : STRING2 DW 80 DUP(' ')
    : : : NEWLINE DW CR, LF
    : : : COUNT1 DW 0000
    : : : COUNT2 DW 0000
    : : :
    : : : DATASEG ENDS
    : : : ;=============================================================
    : : :
    : : : CODESEG SEGMENT PARA 'Code'
    : : : BEGIN PROC FAR
    : : : ASSUME SS:STACK, DS:DATASEG, CS:CODESEG
    : : : MOV AX, DATASEG
    : : : MOV DS, AX
    : : : MOV ES, AX
    : : :
    : : : @STDOUT PROMPT1
    : : : PUSH OFFSET [STRING1]
    : : : PUSH OFFSET [STRING2]
    : : : PUSH OFFSET [COUNT1]
    : : : PUSH OFFSET [COUNT2]
    : : : CALL READSTRING
    : : :
    : : : ;@STDOUT STRING2
    : : : ;@STDOUT STRING1
    : : :
    : : : MOV AX, 4C00H
    : : : INT 21H
    : : :
    : : : BEGIN ENDP ;End procedure
    : : : CODESEG ENDS
    : : : END BEGIN
    : : :
    : : : ;=============================================================
    : : :
    : : : TITLE READSTRING Called subprogram
    : : : CODESEG SEGMENT PARA PUBLIC 'Code'
    : : : READSTRING PROC NEAR
    : : :
    : : : PUSH BP
    : : : MOV BP, SP
    : : : MOV SI, [BP + 10]
    : : : @STDIN [SI]
    : : : MOV [BP + 6]
    : : : RETF 4
    : : :
    : : : READSTRING ENDP
    : : : CODESEG ENDS
    : : : END
    : : :
    : : :
    : : :
    : : : Thanks in advance.
    : : :
    : : :
    : : [blue]In order to use PUSH OFFSET ... - you have to specify the .386 directive and since you did not - the Assembler complains. It can be resolved by the pair of instructions, like so:
    : : [code]
    : : MOV AX, OFFSET [...]
    : : PUSH AX
    : : [/code]
    : : Or, simply specify .386, but this can cause 32-bit segments, like it does in TASM, so maybe, just replace every PUSH OFFSET [...] with the above instructions and try again.[/blue]
    : :
    :
    :

  • [b][red]This message was edited by HaVeMercy at 2004-3-23 15:7:22[/red][/b][hr]
    I did declare "EXTRN READSTRING:FAR"

    The declaration, as I have it, goes like this:
    MODEL SMALL
    .STACK 64

    EXTRN READSTRING:FAR

    CR EQU 13
    LF EQU 10

    STACK SEGMENT PARA 'Stack'
    ORG 100H
    STACK ENDS

    DATASEG SEGMENT PARA 'Data'
    .
    .
    .
    DATASEG ENDS

    CODESEG SEGMENT PARA 'Code'
    BEGIN PROC FAR
    ASSUME SS:STACK DS:DATASEG CS:CODESEG

    ETC...ETC...

    Did I make a mistake here???

    I'm using MASM 6.15.

    : : Still having problems. :-(
    : :
    : : I modified the code and I'm still getting 'READSTRING': UNRESOLVED EXTERNAL'
    : :
    : : I modified it so:
    : :
    : : MOV AX, OFFSET [STRING1]
    : : PUSH AX
    : : MOV AX, OFFSET [STRING2]
    : : PUSH AX
    : : MOV AX, OFFSET [COUNT1]
    : : PUSH AX
    : : MOV AX, OFFSET [COUNT2]
    : : PUSH AX
    : : CALL READSTRING
    : :
    : : When I comment out the @stdout error, I get the error. When I include the @stdout calls in the build, I get a length parameter missing @stdout error. I've also experimented with different Models, but the same problem.
    : :
    : : Again, thank you for your efforts.
    :
    : [blue]In addition to:
    : [code]
    : EXTRN READSTRING:FAR
    : [/code]
    : You need to include actual library with that function into your build. How did you do it? Also, is it TASM or MASM?[/blue]
    :
    : :
    : : : : [b][red]This message was edited by HaVeMercy at 2004-3-23 0:36:38[/red][/b][hr]
    : : : : [b][red]This message was edited by HaVeMercy at 2004-3-22 22:25:34[/red][/b][hr]
    : : : : I am trying to write a procedure that passes a string to a procedure, and the user imputs characters in the string. I am unsure as to how to do this. The textbook I have uses values as an example. Sample code, link to tutorials, any hints would be appreciated. Hopefully after I get this basic method down, I will be able to apply it to the other things I need to do in this project. The procedure needs to be written using conventional segment directives.
    : : : :
    : : : : This is urgent because the project needs to be completed by Wednesday night.
    : : : :
    : : : : Thanks for the input dwccgc and AsmGuru62. I'm trying to use the OFFSET command to pass the strings but am getting the error "Immediate Operand not allowed." I've also tried
    : : : : MOV DX, OFFSET [STRING1]
    : : : : but then I get the error message that it cannot resolve externals.
    : : : :
    : : : : I've hit a wall. Any ideas?
    : : : :
    : : : : The code is below:
    : : : :
    : : : : .MODEL SMALL
    : : : : .STACK 64
    : : : : INCLUDE Cis21ja.inc
    : : : :
    : : : : EXTRN READSTRING:FAR
    : : : : EXTRN CHECKSTRING:FAR
    : : : :
    : : : : CR EQU 13
    : : : : LF EQU 10
    : : : :
    : : : : STACK SEGMENT PARA 'Stack'
    : : : : DW 64 DUP(?)
    : : : : STACK ENDS
    : : : : ;=============================================================
    : : : : DATASEG SEGMENT PARA 'Data'
    : : : :
    : : : : PROMPT1 DB 'Enter First String', 13, 10
    : : : : PROMPT2 DB 'Enter Second String', 13, 10
    : : : : SUP_FOUN DB 'SUBSTRING FOUND', 13, 10
    : : : : STRING1 DW 80 DUP(' ')
    : : : : STRING2 DW 80 DUP(' ')
    : : : : NEWLINE DW CR, LF
    : : : : COUNT1 DW 0000
    : : : : COUNT2 DW 0000
    : : : :
    : : : : DATASEG ENDS
    : : : : ;=============================================================
    : : : :
    : : : : CODESEG SEGMENT PARA 'Code'
    : : : : BEGIN PROC FAR
    : : : : ASSUME SS:STACK, DS:DATASEG, CS:CODESEG
    : : : : MOV AX, DATASEG
    : : : : MOV DS, AX
    : : : : MOV ES, AX
    : : : :
    : : : : @STDOUT PROMPT1
    : : : : PUSH OFFSET [STRING1]
    : : : : PUSH OFFSET [STRING2]
    : : : : PUSH OFFSET [COUNT1]
    : : : : PUSH OFFSET [COUNT2]
    : : : : CALL READSTRING
    : : : :
    : : : : ;@STDOUT STRING2
    : : : : ;@STDOUT STRING1
    : : : :
    : : : : MOV AX, 4C00H
    : : : : INT 21H
    : : : :
    : : : : BEGIN ENDP ;End procedure
    : : : : CODESEG ENDS
    : : : : END BEGIN
    : : : :
    : : : : ;=============================================================
    : : : :
    : : : : TITLE READSTRING Called subprogram
    : : : : CODESEG SEGMENT PARA PUBLIC 'Code'
    : : : : READSTRING PROC NEAR
    : : : :
    : : : : PUSH BP
    : : : : MOV BP, SP
    : : : : MOV SI, [BP + 10]
    : : : : @STDIN [SI]
    : : : : MOV [BP + 6]
    : : : : RETF 4
    : : : :
    : : : : READSTRING ENDP
    : : : : CODESEG ENDS
    : : : : END
    : : : :
    : : : :
    : : : :
    : : : : Thanks in advance.
    : : : :
    : : : :
    : : : [blue]In order to use PUSH OFFSET ... - you have to specify the .386 directive and since you did not - the Assembler complains. It can be resolved by the pair of instructions, like so:
    : : : [code]
    : : : MOV AX, OFFSET [...]
    : : : PUSH AX
    : : : [/code]
    : : : Or, simply specify .386, but this can cause 32-bit segments, like it does in TASM, so maybe, just replace every PUSH OFFSET [...] with the above instructions and try again.[/blue]
    : : :
    : :
    : :
    :
    :



  • : [b][red]This message was edited by HaVeMercy at 2004-3-23 15:7:22[/red][/b][hr]
    : I did declare "EXTRN READSTRING:FAR"

    [blue]You did not get my point - I said: "in ADDITION to declaration
    as EXTRN" - you need to link a library with that function.[/blue]

    :
    : The declaration, as I have it, goes like this:
    : MODEL SMALL
    : .STACK 64
    :
    : EXTRN READSTRING:FAR
    :
    : CR EQU 13
    : LF EQU 10
    :
    : STACK SEGMENT PARA 'Stack'
    : ORG 100H
    : STACK ENDS
    :
    : DATASEG SEGMENT PARA 'Data'
    : .
    : .
    : .
    : DATASEG ENDS
    :
    : CODESEG SEGMENT PARA 'Code'
    : BEGIN PROC FAR
    : ASSUME SS:STACK DS:DATASEG CS:CODESEG
    :
    : ETC...ETC...
    :
    : Did I make a mistake here???
    :
    : I'm using MASM 6.15.
    :
    : : : Still having problems. :-(
    : : :
    : : : I modified the code and I'm still getting 'READSTRING': UNRESOLVED EXTERNAL'
    : : :
    : : : I modified it so:
    : : :
    : : : MOV AX, OFFSET [STRING1]
    : : : PUSH AX
    : : : MOV AX, OFFSET [STRING2]
    : : : PUSH AX
    : : : MOV AX, OFFSET [COUNT1]
    : : : PUSH AX
    : : : MOV AX, OFFSET [COUNT2]
    : : : PUSH AX
    : : : CALL READSTRING
    : : :
    : : : When I comment out the @stdout error, I get the error. When I include the @stdout calls in the build, I get a length parameter missing @stdout error. I've also experimented with different Models, but the same problem.
    : : :
    : : : Again, thank you for your efforts.
    : :
    : : [blue]In addition to:
    : : [code]
    : : EXTRN READSTRING:FAR
    : : [/code]
    : : You need to include actual library with that function into your build. How did you do it? Also, is it TASM or MASM?[/blue]
    : :
    : : :
    : : : : : [b][red]This message was edited by HaVeMercy at 2004-3-23 0:36:38[/red][/b][hr]
    : : : : : [b][red]This message was edited by HaVeMercy at 2004-3-22 22:25:34[/red][/b][hr]
    : : : : : I am trying to write a procedure that passes a string to a procedure, and the user imputs characters in the string. I am unsure as to how to do this. The textbook I have uses values as an example. Sample code, link to tutorials, any hints would be appreciated. Hopefully after I get this basic method down, I will be able to apply it to the other things I need to do in this project. The procedure needs to be written using conventional segment directives.
    : : : : :
    : : : : : This is urgent because the project needs to be completed by Wednesday night.
    : : : : :
    : : : : : Thanks for the input dwccgc and AsmGuru62. I'm trying to use the OFFSET command to pass the strings but am getting the error "Immediate Operand not allowed." I've also tried
    : : : : : MOV DX, OFFSET [STRING1]
    : : : : : but then I get the error message that it cannot resolve externals.
    : : : : :
    : : : : : I've hit a wall. Any ideas?
    : : : : :
    : : : : : The code is below:
    : : : : :
    : : : : : .MODEL SMALL
    : : : : : .STACK 64
    : : : : : INCLUDE Cis21ja.inc
    : : : : :
    : : : : : EXTRN READSTRING:FAR
    : : : : : EXTRN CHECKSTRING:FAR
    : : : : :
    : : : : : CR EQU 13
    : : : : : LF EQU 10
    : : : : :
    : : : : : STACK SEGMENT PARA 'Stack'
    : : : : : DW 64 DUP(?)
    : : : : : STACK ENDS
    : : : : : ;=============================================================
    : : : : : DATASEG SEGMENT PARA 'Data'
    : : : : :
    : : : : : PROMPT1 DB 'Enter First String', 13, 10
    : : : : : PROMPT2 DB 'Enter Second String', 13, 10
    : : : : : SUP_FOUN DB 'SUBSTRING FOUND', 13, 10
    : : : : : STRING1 DW 80 DUP(' ')
    : : : : : STRING2 DW 80 DUP(' ')
    : : : : : NEWLINE DW CR, LF
    : : : : : COUNT1 DW 0000
    : : : : : COUNT2 DW 0000
    : : : : :
    : : : : : DATASEG ENDS
    : : : : : ;=============================================================
    : : : : :
    : : : : : CODESEG SEGMENT PARA 'Code'
    : : : : : BEGIN PROC FAR
    : : : : : ASSUME SS:STACK, DS:DATASEG, CS:CODESEG
    : : : : : MOV AX, DATASEG
    : : : : : MOV DS, AX
    : : : : : MOV ES, AX
    : : : : :
    : : : : : @STDOUT PROMPT1
    : : : : : PUSH OFFSET [STRING1]
    : : : : : PUSH OFFSET [STRING2]
    : : : : : PUSH OFFSET [COUNT1]
    : : : : : PUSH OFFSET [COUNT2]
    : : : : : CALL READSTRING
    : : : : :
    : : : : : ;@STDOUT STRING2
    : : : : : ;@STDOUT STRING1
    : : : : :
    : : : : : MOV AX, 4C00H
    : : : : : INT 21H
    : : : : :
    : : : : : BEGIN ENDP ;End procedure
    : : : : : CODESEG ENDS
    : : : : : END BEGIN
    : : : : :
    : : : : : ;=============================================================
    : : : : :
    : : : : : TITLE READSTRING Called subprogram
    : : : : : CODESEG SEGMENT PARA PUBLIC 'Code'
    : : : : : READSTRING PROC NEAR
    : : : : :
    : : : : : PUSH BP
    : : : : : MOV BP, SP
    : : : : : MOV SI, [BP + 10]
    : : : : : @STDIN [SI]
    : : : : : MOV [BP + 6]
    : : : : : RETF 4
    : : : : :
    : : : : : READSTRING ENDP
    : : : : : CODESEG ENDS
    : : : : : END
    : : : : :
    : : : : :
    : : : : :
    : : : : : Thanks in advance.
    : : : : :
    : : : : :
    : : : : [blue]In order to use PUSH OFFSET ... - you have to specify the .386 directive and since you did not - the Assembler complains. It can be resolved by the pair of instructions, like so:
    : : : : [code]
    : : : : MOV AX, OFFSET [...]
    : : : : PUSH AX
    : : : : [/code]
    : : : : Or, simply specify .386, but this can cause 32-bit segments, like it does in TASM, so maybe, just replace every PUSH OFFSET [...] with the above instructions and try again.[/blue]
    : : : :
    : : :
    : : :
    : :
    : :
    :
    :
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories