Skip to main content
GameDev.net gamedev.net
🔒 Locked

Assembly problems... pls help

Started by johnc82 Jul 30, 2003 at 2:44 PM 11 replies 2.6k views
Original Post
johnc82
johnc82
hi.... :-) code:
TITLE CSC320 PROJECT

INCLUDE mymac.mac
INCLUDE PM.MAC

SSEG SEGMENT PARA STACK ''STACK''
        DB 100 DUP(?)
SSEG ENDS

DSEG SEGMENT  

YAHOO   DB 100,?,100 DUP('' ''),''$''
TESTS   DB 100,?,100 DUP ('' ''),''$''
        ORG 10H
;F       DB 100 DUP ('' ''),''$''
        ORG 10H
YUP     DB ?

DSEG ENDS

CSEG SEGMENT 

MAIN PROC FAR

        ASSUME SS:SSEG, DS:DSEG, CS:CSEG

        MOV AX, DSEG
        MOV DS, AX
        MOV AX, 0000H
        MOV AH, 0AH
        MOV DX, OFFSET TESTS
        INT 21H
        MOV BX, OFFSET TESTS
        ;MOV AL, [TESTS]+2
        ;MOV YUP, AL
        ;COV_STRING TESTS, YUP
        ;TEST123 TESTS, YUP
        MOV AH, 00H
        MOV CH, 00H
        MOV CL, [BX]+1
CM:     MOV AL, [BX]+2
        CMP CH, CL
        JZ EXIT
        JNZ UP
UP:     MOV [YUP+AH], AL
        INC CH
        INC BX
        INC AH
        ;INC YUP
        JMP CM
EXIT:   STRING_OUTPUT YUP
        MOV AH, 4CH
        INT 21H

MAIN ENDP

CSEG ENDS
        END MAIN

Error: C:\TASM\BIN>TASM project.asm Turbo Assembler Version 4.1 Copyright (c) 1988, 1996 Borland International Assembling file: project.asm **Error** project.asm(45) Illegal indexing mode Error messages: 1 Warning messages: None Passes: 1 Remaining memory: 448k Can anyone pls help.... Thanks :-)
:-)
johnc82
johnc82
I remove it but the same error.........
:-)
DigitalDelusion
DigitalDelusion
The problem is the line:

MOV [YUP + AH], AL

you need to use the "whole" register you can't just use part of it. I would suggesting using:


MOV DI, YUP

;instead of
MOV AH, 00H

;then do
MOV [DI], AL
INC DI

;or
STOSB

;instead of not working
MOV [YUP + AH], AL
INC AH



[edited by - DigitalDelusion on July 31, 2003 4:25:29 AM]
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
johnc82
johnc82
y can''t i:

mov dl, [di+ah]

...... hmmmm
:-)
DigitalDelusion
DigitalDelusion
quote:
Original post by johnc82
y can''t i:

mov dl, [di+ah]

...... hmmmm


because the processor don''t support any addressing mode looking
like that, blame intel if you want it won''t change anything
you''ll have to reworke the code to use a proper indexing mode.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
johnc82
johnc82
thanks for the reply...


Btw, how can i get number of character, e.g.

code:

string db ''test test test'',''$''

there is 14 character in string..... but how can i get it....
any algorithms..... that help???

thanks
:-)
DigitalDelusion
DigitalDelusion
by far the easiest way is to let the assembler calculate it for you
just define a label or similar right after the string then you can
get the string length by doing:

mov cx, offset after_string - offset string

or you could use
repne scasb searching for ''$'' (or other terminating character) to find it runtime
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
johnc82
johnc82
hi again

code:

string1 DB ''test''
...........

mov cx, offset string1
mov ah, 02h
mov dl, cl
int 21h

result:
♦
the ''♦'' means 4 in hex........ how can i get the value of ''♦'' rather then '' ♦'', which is null.......

i''m damn close.......
:-)
johnc82
johnc82
nope it can''t......

output:

Illegal indexing mode
:-)
johnc82
johnc82
well....

anyone knwo how to get the string lenght of

data1 db ''abc''

without ''$''
:-)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.