It's a
bad sign when
I can answer someone's ASM question...
phillid wrote:Well, I have found a function called 'cmpstr' which is meant to compare two strings but I don't have a way to tell it which label to jump to if the strings are equal, or not.
Code: Select all
; ...
mov si, equalmsg
; ...
mov si, notequalmsg
; ...
retn
These here are the two "outcomes" of the function, which obviously has been designed to point
si at some message depending on outcome. You want to "jump to label" instead. Obviously you have to modify the function.
Put two addresses (labels) into specific registers, and have the function return one of them depending on whether the strings are equal or not. After calling the function, jump to the "return" address.
Code: Select all
mov bx, label_if_equal
mov cx, label_if_not_equal
call cmpstr
jmp [ax]
cmpstr:
; ...
mov ax, bx ; instead of mov si, equalmsg
; ...
mov ax, cx ; instead of mov si, notequalmsg
; ...
retn
Which, of course and now that I think of it, is just a more complicated version of:
Code: Select all
mov bx, label_if_equal
mov cx, label_if_not_equal
jmp cmpstr
cmpstr:
; ...
jmp bx ; instead of mov si, equalmsg
; ...
jmp cx ; instead of mov si, notequalmsg
Does that help you?