简体   繁体   中英

numerical base conversion on Intel 8086

I'm working on a numerical base conversion program and I've stumbled upon a problem in one part of the code:

    mov ax,36864
    mov bx,ax
    mov dx,0
    sub bx,4096
    jns ustawGr
    mov al,48
    int 29h
    jmp konwerter16

It works fine for numbers up to 36863, but for some reason it is not going into ustawGr and prints 0 for any higher number even though the register should be able to contain it.

36864 - 4096 is 0x9000 - 0x1000 == 0x8000 . In two's complement representation 0x8000 is the greatest negative 16-bit number ( -32768 ). And since the value is negative, your jns won't be taken.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM