REPE CMPSB problems

1.9k views Asked by At

i'm trying to use rep cmpsb as following:

    DSEG SEGMENT PARA PUBLIC 'DATA' 

    SOURCE DB 'ASDF'
    TARGET DB 'ASDF'

    SIZE EQU ($-TARGET)



DSEG ENDS

SSEG SEGMENT PARA STACK 'STACK'

SSEG ENDS    

CSEG SEGMENT PARA PUBLIC 'CODE'

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


MAIN:

    MOV AX,DSEG
    MOV DS,AX

    MOV SI,OFFSET SOURCE
    MOV DI,OFFSET TARGET

    CLD

    MOV CX,SIZE

    REPE CMPSB



    MOV AH,4CH
    INT 21H

CSEG ENDS
END MAIN

i'm using emu8086. tried rep and repe but nothing happens. rep should actually repeat until cx>0 either two strings are equal or not but it doesn't happen and it runs only one time (after program terminated,cx is 3) i also tried repe for two equal strings but nothing happened neither when running in these two modes,zero flag never changes,that i think it should be changed to repe work correctly so only repne works until cx=0 and doesn't give the correct result so what should i try?

---------solved--------------- works after initialize ES:

 DSEG SEGMENT PARA PUBLIC 'DATA' 

    SOURCE DB 'ASDF'
    TARGET DB 'ASDF'

    SIZE EQU ($-TARGET)



DSEG ENDS

SSEG SEGMENT PARA STACK 'STACK'

SSEG ENDS

ESEG SEGMENT PARA PUBLIC 'EXTRA'

ESEG ENDS    

CSEG SEGMENT PARA PUBLIC 'CODE'

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


MAIN:

    MOV AX,DSEG
    MOV DS,AX

    MOV ES, AX

    MOV SI,OFFSET SOURCE
    MOV DI,OFFSET TARGET

    CLD

    MOV CX,SIZE

    REPE CMPSB



    MOV AH,4CH
    INT 21H

CSEG ENDS
END MAIN
0

There are 0 answers