flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > fasmg - wrong output with octal literals

Author
Thread Post new topic Reply to topic
yaros



Joined: 07 Jan 2024
Posts: 3
yaros 07 Jan 2024, 19:32
Hey, I got blocked by a nasty bug Sad

Code:
dw 454o
dw 300
    


This simple code should assemble as 4 bytes 0x12C, but when using octal it drops the high bit...

Code:
$hexdump bug
0000000 002c 012c                              
    
Post 07 Jan 2024, 19:32
View user's profile Send private message Reply with quote
yaros



Joined: 07 Jan 2024
Posts: 3
yaros 07 Jan 2024, 20:25
So I did fix it, I think. I'm not good at x86 assembly, but I'm going to leave the patch here, just because I'm not sure how often fasmg gets released.

I'm surprised (and not, at the same time) that this was never noticed Smile But the only reason I'm using octal, is because I'm working with old Unix code, otherwise I'd just stick to hexadecimal.

Code:
*** fasmg/source/expressions_orig.inc   2023-06-22 13:55:48.000000000 -0600
--- fasmg/source/expressions.inc        2024-01-07 13:15:00.365383243 -0700
***************
*** 281,287 ****
        shl     eax,cl
        or      [edi],al
        sub     ebx,1
!       jc      number_converted
        add     cl,3
        cmp     cl,8
        jb      octal_digit
--- 281,287 ----
        shl     eax,cl
        or      [edi],al
        sub     ebx,1
!       jc      finish_octal
        add     cl,3
        cmp     cl,8
        jb      octal_digit
***************
*** 290,295 ****
--- 290,302 ----
        mov     [edi],ah
        xor     eax,eax
        jmp     octal_digit
+       finish_octal:
+       add     cl,3
+       cmp     cl,8
+       jb      number_converted
+       inc     edi
+       mov     [edi],ah
+       jmp number_converted
        skip_octal_digit:
        sub     ebx,1
        jnc     octal_digit
    
Post 07 Jan 2024, 20:25
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8344
Location: Kraków, Poland
Tomasz Grysztar 07 Jan 2024, 20:29
Confirmed, the bug was causing this very simple test to fail:
Code:
assert 454o = 0454o    

It's fixed in kaqg.
Post 07 Jan 2024, 20:29
View user's profile Send private message Visit poster's website Reply with quote
yaros



Joined: 07 Jan 2024
Posts: 3
yaros 08 Jan 2024, 03:55
That was fast. Thanks!
Post 08 Jan 2024, 03:55
View user's profile Send private message 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.