R
R
Ruslan Isaev2016-01-24 15:23:52
Programming
Ruslan Isaev, 2016-01-24 15:23:52

How to make complex conditions in assembler?

in C, this would look like this:

if(cmd=="a")
  getHelp();
else if(cmd=="b")
  openTextEditor();
else if(cmd=="c")
  reboot();

And how can I write on the assembler? (PS I use FASM)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Armenian Radio, 2016-01-24
@Omnigamer

cmp ax, 1
je :action1
cmp ax, 2
je :action2

;тут ребут

:action1:
тут вызов справки
jmp :done

:action2:
тут вызов редактора
jmp :done

:done
тут конец

N
none7, 2016-01-27
@none7

If exactly a, b, c, and do not save every byte, then

cmp ax, 'a'
setb cl
cmp ax, 'c'
seta ch
or ch, cl
jne default
call [ax + jump_table - 'a']
default:
ret
jump_table dd getHelp, openTextEditor, reboot

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question