Author Topic: NASM inserts an unwanted WAIT byte, why?  (Read 9330 times)

Offline RuudB

  • Jr. Member
  • *
  • Posts: 40
  • Country: nl
    • Ruud's Commodore Site
NASM inserts an unwanted WAIT byte, why?
« on: October 09, 2019, 07:00:52 AM »
Hello,

I'm busy disassembling a XT BIOS. I started disassembling it some where in the '90s using Sourcer. In 2014 I converted the source code to NASM. Then the board died... :(
Last month I got the same board with, seemingly, the same ROM (both say V2.30) but quite some bytes were different. In this case I used my own disassembler. If I assemble the one generated by my tool, NASM inserts an extra 09Bh byte before the only FINIT instruction in this BIOS. I have no idea why. Please have a look, maybe you see something.

The listing of the original source that compiles fine:
Code: [Select]
   600 0000036F 093E1000                or [Equipment],di
   601 00000373 B201                    mov dl,001h
   602 00000375 EC                      in al,dx
   603 00000376 240F                    and al,00Fh
   604 00000378 7505                    jne B_E37F
   605                                 
   606 0000037A 800E110010              or byte [M_0011],010h
   607                                  B_E37F: ; [E37F]
   608 0000037F DBE3                    fninit
   609 00000381 C606910000              mov byte [M_0091],000h
   610 00000386 D93E9000                fnstcw word [M_0090]
   611 0000038A 8A269100                mov ah,[M_0091]
   612 0000038E 80FC03                  cmp ah,003h
   613 00000391 7505                    jne B_E398
   614                                 
   615 00000393 800E100002              or byte [Equipment],002h
   616                                  B_E398: ; [E398]
   617 00000398 BAF703                  mov dx,003F7h
 

There is an EQU of course for all "M_xxxx" variables like:
Code: [Select]
    15                                  M_0011 equ 00011h

The listing of the new source that adds the WAIT at line 586:
Code: [Select]
   578 0000036F 093E1000                or [Equipment],di
   579 00000373 B201                    mov dl,01h
   580 00000375 EC                      in al,dx
   581 00000376 240F                    and al,0Fh
   582 00000378 7505                    jne B_E37F ; [E37F]
   583                                 
   584 0000037A 800E110010              or byte [0011h],10h
   585                                  B_E37F: ; [E37F]
   586 0000037F 9BDBE3                  finit
   587 00000382 C606910000              mov byte [0091h],00h
   588 00000387 D93E9000                fnstcw word [0090h]
   589 0000038B 8A269100                mov ah,[0091h]
   590 0000038F 80FC03                  cmp ah,03h
   591 00000392 7505                    jne B_E398 ; [E398]
   592                                 
   593 00000394 800E100002              or byte [Equipment],02h
   594                                  B_E398: ; [E398]
   595 00000399 BAF703                  mov dx,03F7h
I don't see why it could influence the behavior of NASM but just to be sure I replaced the used [xxxxh] variables here above by their M_ equivalents: it didn't change things.

Any info or help is welcome. Thanks in advance!

Kind regards, Ruud Baltissen
With kind regards / met vriendelijke groet, Ruud Baltissen

Offline RuudB

  • Jr. Member
  • *
  • Posts: 40
  • Country: nl
    • Ruud's Commodore Site
Re: NASM inserts an unwanted WAIT byte, why?
« Reply #1 on: October 09, 2019, 07:58:40 AM »
Just FYI:

I replaced the FINIT instruction by "db 0DBh, 0E3h" and the code is assembled fine now. The actual difference with the original BIOS is just one byte: the length of the keyboard buffer has been shortened. The other differences are most probably caused by using another assembler: if I disassemble the original BIOS I get the same source code, except this one byte.
With kind regards / met vriendelijke groet, Ruud Baltissen

Offline RuudB

  • Jr. Member
  • *
  • Posts: 40
  • Country: nl
    • Ruud's Commodore Site
Re: NASM inserts an unwanted WAIT byte, why?
« Reply #2 on: October 09, 2019, 10:04:01 AM »
I found the error: FINIT is something else than FNINIT.
I'm sorry for waisting you time.
With kind regards / met vriendelijke groet, Ruud Baltissen