Help with my asm code

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
KieranFoot

Help with my asm code

Post by KieranFoot »

I understand asm a little but i dont understand how to do if statements, so i want to know how to convert the following qb code into asm ???

Code: Select all

IF (B AND &HE0) = &H0 THEN
  IF (C AND &HE0) = &HC0 THEN
    Success = -1
  END IF
END IF
Thanx ;D
Tim

Re:Help with my asm code

Post by Tim »

Here's my first stab at it:

Code: Select all

mov bl, [b]
mov cl, [c]

; BL & 0E0h...
test bl, 0E0h
; ... = 0, then continue
jnz rest_of_the_program

; CL & 0E0h...
and cl, 0E0h
; ... = 0C0h...
cmp cl, 0C0h
; ...then continue
jne rest_of_the_program

; success: assign -1 to variable Success
mov dword [Success], -1

rest_of_the_program:
; do whatever was underneath the IF statement
Imagine you're coding BASIC, but the only control statement you have is GOTO (equivalent to JMP, etc. in assembly).

Erm, do you know any languages besides BASIC? Any C, perhaps, or Pascal?
KieranFoot

Re:Help with my asm code

Post by KieranFoot »

I know a bit of c++ but thats about it.

I wanted that code converting because I'm adding interrupt functions to handle SBlaster cards such as SBDetect and SBWriteReg. I think its a good idea to have sound routines built into the very foundations of the system...

Thanx ;D
Post Reply