Those who know x86 assembly and real mode, what'd I do wrong here?

mov cx,0000
mov ax,e823
mov bx,1
add cx,1
int 15 ; supposed to be undocumented CMOS raw write on my mobo if bx!=0,ax=e823
test cx,00ff
jne .loop

The JNE doesn't ever trigger, so I end up always returning no matter what cx is. I'm testing if the undocumented writes actually work, and cl is supposed to be 00-FF as it's the address to write bx to in CMOS. I'm running in real mode, if it matters.

  • 7
    This code doesn’t do what you think it does.

    TEST does not compre the the two numbers; it does a bit wise and then sets flags.

    JNE does a conditional jump based on whether the zero flag is set.

    So first time through your code:

    CX <- 0
    CX <- CX + 1
    TEST CX, 0xff -> bitwise and of 0x1 and 0xff -> 0x1, is not zero, ZF <- 0
    JNE .loop: ZF is not set, do not take jump.

    Use CMP instead of test and JZ instead of JNE

    JNE is named because CMP works on op1 - op2 so it’s zero when they’re equal.
  • 5
    Also, don’t use undocumented BIOS Irqs, the documented ones are shoddy enough
  • 1
    Uh, shouldnt test be a cmp operation instead?
  • 4
    Please, for your sanity, use the standard interrupts. You'll thank me later.
  • 2
    @FrodoSwaggins @Ranchu i'll have to see if that works, thanks. (Seems it's not as different from GBz80ASM as I thought!)
    @PrivateGER what's the fun in that? It's a junker PC i'm not afraid to trash if need be, and it's good ASM practice. Plus, I just like to break shit sometimes. (Also if Compaq didn't want us using it they wouldnt've patented it.)
  • 1
    @Parzi You'll have to start over completely if you ever change motherboards though...
  • 0
    @PrivateGER it supposedly works on all COMPAQ boards after 2011, but y'know, HP. Mine's after that date but actually COMPAQ.
  • 1
    *Standard USE SO comment*
  • 1
    @Gregozor2121 "this is stupid, use this library for C, alsoo this is a duplicate of this unrelated question about the library. Too many false dupe claims? Good, here's an ask ban. Edit your questions or you can't ask another, but these questions must then get responses that you accept. How would they get new responses? I dunno, you figure it out."

    Fuck SO.
Add Comment