flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > negative value bug?

Author
Thread Post new topic Reply to topic
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 22 Nov 2011, 12:16
I was playing around with some code i posted in main
and decided to throw some negative values at it for fun.
Tested on versions 1.69.14 and 1.69.35 with same result:
Code:
org 0x0100
use16

  mov bx,-1                     ;bug?
  call display_bin16

  mov bx,1                      ;bug?
  neg bx
  call display_bin16

  mov bx,0
  mov bh,-1                     ;bug?
  call display_bin16

  mov bx,0
  mov bl,-1                     ;bug?
  call display_bin16

  mov bx,0x81                   ;ok
  call display_bin16

  mov bx,129                    ;ok
  call display_bin16

  mov bx,10000001b              ;ok
  call display_bin16

  mov bx,not 0x7ffe             ;ok
  call display_bin16

  mov bx,0x8001                 ;ok
  call display_bin16

  mov bx,32769                  ;ok
  call display_bin16

  mov bx,1000000000000001b      ;ok
  call display_bin16

  xor ah,ah
  int 0x16
  ret

display_bin16:
  mov cx,16
  mov ah,0x02
display_bin16_loop:
  xor dx,dx
  shl bx,1
  adc dl,'0'
  int 0x21
  loop display_bin16_loop
  mov dl,0x0d
  int 0x21
  mov dl,0x0a
  int 0x21
  ret
    

_________________
Coding a 3D game engine with fasm is like trying to eat an elephant,
you just have to keep focused and take it one 'byte' at a time.
Post 22 Nov 2011, 12:16
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 22 Nov 2011, 13:35
I get This:
Code:
1111111111111111
1111111111111111
1111111100000000
0000000011111111
0000000010000001
0000000010000001
0000000010000001
1000000000000001
1000000000000001
1000000000000001
1000000000000001
    


Where is the bug ?

_________________
Nil Volentibus Arduum Razz
Post 22 Nov 2011, 13:35
View user's profile Send private message Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 557
smiddy 22 Nov 2011, 18:54
DJ Mauretto wrote:
I get This:
Code:
1111111111111111
1111111111111111
1111111100000000
0000000011111111
0000000010000001
0000000010000001
0000000010000001
1000000000000001
1000000000000001
1000000000000001
1000000000000001
    


Where is the bug ?


I tried it also this morning and I received the same results as you, I just didn't have time to post.
Post 22 Nov 2011, 18:54
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 22 Nov 2011, 21:12
Ok, i found the problem...
It turns out i was not thinking in 2's compliment (duh)
I have rewired my brain to remember this...
How stupid do i feel now?
Post 22 Nov 2011, 21:12
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 22 Nov 2011, 21:40
Quote:
How stupid do i feel now?
relax, it can happen to anyone! Razz

http://board.flatassembler.net/topic.php?p=137196#137196
(last post)

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 22 Nov 2011, 21:40
View user's profile Send private message Send e-mail Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 517
Location: Munich
shutdownall 22 Nov 2011, 22:20
ouadji wrote:
[color=green][size=14]
Quote:
How stupid do i feel now?
relax, it can happen to anyone! Razz


But not to a bitshifter
He should know the difference between COMP and NEG why else did he use this nickname ? Razz
Post 22 Nov 2011, 22:20
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.