Author Topic: Starter questions from a NASM noob.  (Read 10300 times)

Offline migry

  • New Member
  • Posts: 1
Starter questions from a NASM noob.
« on: October 19, 2021, 12:30:47 PM »
I am new to NASM and new to 8086 assembly too (but I am familiar with the instruction set). I am no noob to assembly, having worked on 10+ CPUs over the years.

I have recently built some hardware, a 8088 "PC"-lite clone. I have been able to run the Tandy1000 BIOS and confirm it got through the BIOS start-up. It gets stuck at the floppy access code, which is not surprise, as I haven't yet built the floppy disk controller PCB! I found on Github a disassembly, which used IDA Pro, for the Tandy1000 BIOS. This has been helpful in getting my hardware to work.

I decided to use NASM since it is modern and well supported.

I would like to re-code the BIOS, just taking the parts I am interested in, and changing parts as necessary. I can use the disassembled code and then "knock" it into shape for NASM.

I have been using the XT IDe Universal BIOS (which uses NASM) as a reference, but it is very complicated.

Although I am new to 8086 assembly, perhaps this is no drawback, because the NASM syntax is different to other assemblers I am aware of (TASM, MASM, Watcom, etc).

My first question concerns accessing data at a fixed location. I want to access the BIOS variables at 0x400 and a temporary data structure at 0xbbee0 (memory in the GFX card).

The disassembled code looks like this example ...

Code: [Select]
F000:E05B                 mov     ax, 40h ; '@'
F000:E05E                 mov     ds, ax                              ; ds = 0x40
F000:E060                 mov     ax, 0BBE8h
F000:E063                 mov     es, ax                              ; es = 0xbbe8
F000:E065                 xor     ax, ax
F000:E067                 cmp     word ptr ds:p400.POST_reset_flag, 1234h ; soft reset?
F000:E06D                 jnz     short l0                            ; no, jump
F000:E06F                 mov     ax, ds:p400.keyb_status_flags_1
F000:E072                 and     ax, 6060h                           ; filter out insert / caps
F000:E075
F000:E075 l0:                                                         
F000:E075                 mov     es:pbbe80.shadow_keyb_status_flags_1, ax
F000:E079                 mov     ax, ds:p400.POST_reset_flag
F000:E07C                 mov     es:pbbe80.shadow_POST_reset_flag, ax

Now I have taken the BIOS variables struct from the XT IDE Universal BIOS, and I also see how these are accessed. What is not clear is how to code the segment part. Is there a recommended way? Can I do a "%define BIOS 0x400" and then for the "mov ax,40h" (above) with some more readable code e.g. "mov ax SEG BIOS(???)". I think I know how to code the reads of these locations e.g. "mov ax, [ds:BIOS.POST_reset_flag]. I am happy that the offset part gets calculated from the struct. I could leave the hard coded segment values in, but this looks tacky to me.

BTW I have read the PDF documents, but of course I am on a steep learning curve. I tried searching for NASM examples, but many are for apps for modern processors, not for embedded ROM code.