Author Topic: Assembler for 8088  (Read 1056 times)

0 Members and 1 Guest are viewing this topic.

Offline admiralk

  • Regular Contributor
  • *
  • Posts: 106
  • Country: us
Assembler for 8088
« on: September 13, 2019, 11:31:59 pm »
I am a bit confused on what to use to program the ROM in my computer build that is based on an 8088 processor. If I understand right, I can use NASM with ith format. Assuming that is correct, does anyone know if the file is created in text or binary. I assume it is text based. I have never been that good at reading files, so it would save a lot of trial and error if I started with the right assembler and the right format.

Much of this project involves building my own tools, as it is not based on any particular computer. At this point I am looking to develop an EEPROM programmer and it would help a lot if I knew what kind of format I need to read. To start I just want to be able to open the assembled file, display it, and send it to whatever hardware I build to do the actual programming. Eventually I hope to have a functioning IDE.
 

Online Ampera

  • Super Contributor
  • ***
  • Posts: 2566
  • Country: us
    • Ampera's Forums
Re: Assembler for 8088
« Reply #1 on: September 14, 2019, 09:47:30 pm »
Assemblers are program that take assembly language and compile it into machine code *binaries*.

NASM is totally capable of generating 8088 compatible binaries, just ensure you've set it to 16-bit mode. GCC's assembler is, afaik, not capable of this, and the Intel, Borland, and AT&T assemblers are I believe capable of this. NASM, however, is the most simple and common option.
Professional complainer-in-chief criticizing other people's code
Programmer and bumbling Unix fool
Op @ EEVBlog IRC: irc.austnet.irc #eevblog
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 15020
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Assembler for 8088
« Reply #2 on: September 15, 2019, 12:27:53 am »
Microsoft Macro Assembler (MASM), possibly an early version if you want to run it on contemporary hardware rather than effectively cross coding (somewhere around, I guess, version 4-6, the executable (not the output) went 386+ only, I think?).

I've not actually used NASM but if it offers macros then that's nice.  There are several others that claim compatibility with MASM so I guess also support macros.

Macros aren't at all needed, but they're definitely handy.  You'll find repetitive patterns all the time, and it's nice to have standard formats to work with them.

There's something to be said for using C as well, just because you get the C preprocessor -- a more powerful macro system than most assemblers have (I think?).

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 5211
  • Country: fr
Re: Assembler for 8088
« Reply #3 on: September 15, 2019, 02:37:12 pm »
I second NASM, it has a powerful preprocessor and even a pseudo-language, and supports pretty much all x86 variants. It's still actively maintained (latest release end of 2018).

https://www.nasm.us/xdoc/2.14.02/html/nasmdoc0.html
 

Offline admiralk

  • Regular Contributor
  • *
  • Posts: 106
  • Country: us
Re: Assembler for 8088
« Reply #4 on: September 15, 2019, 03:16:05 pm »
I have used NASM before, but it has been several years and for a more modern processor. It sounds like I am good there.

I have been experimenting with a .hex file from Atmel Studio. That appears to be a text file as I have no problem getting it to print the ASCII on the screen, but have been unable to get it converted hex, so far. I guess I should try writing a small file with NASM and see if that works any better.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 5211
  • Country: fr
Re: Assembler for 8088
« Reply #5 on: September 15, 2019, 03:53:18 pm »
Many EEPROM programmers support pure binary files, which NASM can generate, additionally to .hex files.
If yours doesn't, you can use some "bin2hex" utility. There are many out there.
See this for instance: http://srecord.sourceforge.net/
srec_cat will allow you to convert files and do much more.
 

Offline admiralk

  • Regular Contributor
  • *
  • Posts: 106
  • Country: us
Re: Assembler for 8088
« Reply #6 on: September 15, 2019, 10:29:17 pm »
Now I ran into another problem. It appears there is a bit of syntax difference between NASM and MASM. The sample code I have is MASM and I am not familiar enough with assembly to translate it. I can assemble the code to an .obj, but that is as far as I can go as the 16-bit linker is long gone. I can only find dead links to it. I did find an old version of VC++, but an not too sure that it will run on Widows7 or that it has the right link.exe to begin with. Maybe I can get NASM to do the last part?
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 15020
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Assembler for 8088
« Reply #7 on: September 16, 2019, 01:31:21 am »
This any help?
https://www.seventransistorlabs.com/masm6_1.zip
MASM 6.11 compatibility, ML 6.15, LINK 5.60, all win32 executables, should be able to do everything?

Note that EXE is relocatable and contains headers; you want, I think, either COM (.org 100h though?) or the right switches or directives to generate binary output.  This should be helpful:
http://www.sxlist.com/techref/language/masm/toc.htm

If you need LINK to run on 8086, probably the OBJ file format is compatible(?!!) and any contemporary version will do; I know it came with QuickBasic, and probably the other too?
https://winworldpc.com/product/macro-assembler/1x

Note: these are probably not illegal links; I don't know about my hosted file specifically, but WinWorld at least has been around for a very long time, MS is aware of their existence, and they continue to take no action against them with regards to old products like this.

Tim
« Last Edit: September 16, 2019, 01:36:35 am by T3sl4co1l »
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline admiralk

  • Regular Contributor
  • *
  • Posts: 106
  • Country: us
Re: Assembler for 8088
« Reply #8 on: September 16, 2019, 11:37:21 pm »
Thanks, I found a link to all the old MASMs, but as far as I could tell, they all required DOS. I will give the win32 exes a shot when I get some time.

I was thinking maybe I could just take out the ASUME macro, and what it references, and see if NASM would work. As near as I can tell that is where the errors are coming from and I saw a couple references to doing that, or that is all it looked like they did anyway.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 15020
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Assembler for 8088
« Reply #9 on: September 17, 2019, 12:20:47 am »
NASM doesn't use ASSUME directive?

You may need to change or add segment prefixes on the applicable references.  Below an ASSUME <segreg> = <segname>, make sure that every reference to a label in that segment, that's not using the default segment (DS), has <segreg> prefixed.

Actually, I forget offhand if ASSUME actually does anything with code generation (i.e., ASSUME ES=MySeg, and MyLabel is in MySeg, a MOV AX,[MyLabel] should automatically prefix ES: on it?) or if it's just for checking (if you didn't set ES above, it's probably a warning?).  Hmm no, the latter wouldn't even make sense.... Well anyway, it's in the docs, I should look it up rather than ramble here.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline admiralk

  • Regular Contributor
  • *
  • Posts: 106
  • Country: us
Re: Assembler for 8088
« Reply #10 on: September 17, 2019, 12:55:04 am »
Nope, that seems to be the problem.

Code: [Select]
SEGMENT BOB ;Define the code segment
ASSUME CS:BOB,DS:BOB,SS:BOB ;Set all segment registersto
;the same location

ORG 7F0h ;The 2716 location for the 8088
;powerup instruction of FFFF0h
START: MOV AL,00000001b ;This will light the zero light
;on the 373's output
AGAIN: OUT 10h,AL ;Since the 373 is enabled by
;IO/M directly, it will respond
;to any port reference
JMP AGAIN ;Go light the LED again

BOB ENDS ;Tell assembler this is the end
;of code for this segment
END START ;Tell assembler this is the end

Too tired to fix the formatting, but it starts on line 2.

Code: [Select]
Matrix.asm:3: error: parser: instruction expected
Matrix.asm:15: error: parser: instruction expected
Matrix.asm:17: error: parser: instruction expected

It originally had BOB before SEGMENT and was thinking BOB was a label. I am not sure of the last error, I thought it was not supposed to read past END. Anyway, that is for another day.

I did find the place I got the MASM files from. It also has a bunch of tools that might come in handy.
http://www.nj7p.info/Computers/Software/Tools.html
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 5211
  • Country: fr
Re: Assembler for 8088
« Reply #11 on: September 17, 2019, 02:11:05 pm »
NASM doesn't use ASSUME directive?

Nope. See there: https://www.nasm.us/doc/nasmdoc2.html
Quote
As part of NASM's drive for simplicity, it also does not support the ASSUME directive. NASM will not keep track of what values you choose to put in your segment registers, and will never automatically generate a segment override prefix.
 

Offline admiralk

  • Regular Contributor
  • *
  • Posts: 106
  • Country: us
Re: Assembler for 8088
« Reply #12 on: September 19, 2019, 10:04:21 pm »
After a bit of experimenting, I almost found a solution.

Using MASM with original example file; ml > link > com2hex gives me
Code: [Select]
3A 30 30 30 30 30 30 30 31 46 46 0D 0AUsing NASM with all the ASSUME parts removed and ith format gives me
Code: [Select]
3A 30 36 30 37 46 30 30 30 42 30 30 31 45 36 31
30 45 42 46 43 37 35 0D 0A 3A 30 30 30 30 30 30
30 31 46 46 0D 0A
Using NASM with all the ASSUME parts removed and no file type option gives me
Code: [Select]
B0 01 E6 10 EB FCWhich is correct, except for the lack of an offset. I checked the com file and it turns out it was the same.

So it looks like I can just remove the stuff NASM does not like and use it. The only problem is how to get it to pad the start with all the 0s. In other words, instead of
Code: [Select]
00000000    B0 01 E6 10 EB FCI need
Code: [Select]
00000000    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
...
000007E0    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
000007F0    B0 01 E6 10 EB FC
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 15020
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Assembler for 8088
« Reply #13 on: September 20, 2019, 07:22:29 am »
Put this at the top of the code:

.org 7e0

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline admiralk

  • Regular Contributor
  • *
  • Posts: 106
  • Country: us
Re: Assembler for 8088
« Reply #14 on: September 20, 2019, 07:25:45 pm »
Thanks, but it does not like that
Code: [Select]
error: parser: instruction expected
I already had ORG in it to begin with also. This is it cleaned up some.
Code: [Select]
ORG 7F0h ;The 2716 location for the 8088
;powerup instruction of FFFF0h
START: MOV AL,00000001b         ;This will light the zero light
;on the 373's output
AGAIN: OUT 10h,AL ;Since the 373 is enabled by
;IO/M directly, it will respond
;to any port reference
JMP AGAIN ;Go light the LED again

You would think something this simple would just work.
 

Offline admiralk

  • Regular Contributor
  • *
  • Posts: 106
  • Country: us
Re: Assembler for 8088
« Reply #15 on: September 24, 2019, 11:08:14 pm »
OK RTFM  |O

It looks like NASM uses ORG different than other assemblers. I think I remember something like this, now, but it has been about 15 years. The correct answer is
Code: [Select]
ORG 0

                TIMES 7F0h-($-$$) DB 0
;ORG 7F0h ;The 2716 location for the 8088
;powerup instruction of FFFF0h
START:          MOV AL,00000001b ;This will light the zero light
;on the 373's output
AGAIN:          OUT 10h,AL ;Since the 373 is enabled by
;IO/M directly, it will respond
;to any port reference
JMP AGAIN ;Go light the LED again

Thanks for all the suggestions.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf