Assembler for 8088 - Page 1
Forum section: electronics / general

author: admiralk
author_rank: Regular Contributor
timestamp: September 13, 2019, 11:31:59 pm
content: 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.

author: Ampera
author_rank: Super Contributor
timestamp: September 14, 2019, 09:47:30 pm
content: 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.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: September 15, 2019, 12:27:53 am
content: 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

author: SiliconWizard
author_rank: Super Contributor
timestamp: September 15, 2019, 02:37:12 pm
content: 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

author: admiralk
author_rank: Regular Contributor
timestamp: September 15, 2019, 03:16:05 pm
content: 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.

author: SiliconWizard
author_rank: Super Contributor
timestamp: September 15, 2019, 03:53:18 pm
content: 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.

author: admiralk
author_rank: Regular Contributor
timestamp: September 15, 2019, 10:29:17 pm
content: 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?

author: T3sl4co1l
author_rank: Super Contributor
timestamp: September 16, 2019, 01:31:21 am
content: This any help?https://www.seventransistorlabs.com/masm6_1.zipMASM 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.htmIf 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/1xNote: 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

author: admiralk
author_rank: Regular Contributor
timestamp: September 16, 2019, 11:37:21 pm
content: 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.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: September 17, 2019, 12:20:47 am
content: 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, 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

author: admiralk
author_rank: Regular Contributor
timestamp: September 17, 2019, 12:55:04 am
content: Nope, that seems to be the problem.Code:SEGMENTBOB;Define the code segmentASSUMECS:BOB,DS:BOB,SS:BOB;Set all segment registersto;the same locationORG7F0h;The 2716 location for the 8088;powerup instruction of FFFF0hSTART:MOVAL,00000001b;This will light the zero light;on the 373's outputAGAIN:OUT10h,AL;Since the 373 is enabled by;IO/M directly, it will respond;to any port referenceJMPAGAIN;Go light the LED againBOBENDS;Tell assembler this is the end;of code for this segmentENDSTART;Tell assembler this is the endToo tired to fix the formatting, but it starts on line 2.Code:Matrix.asm:3: error: parser: instruction expectedMatrix.asm:15: error: parser: instruction expectedMatrix.asm:17: error: parser: instruction expectedIt 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

author: SiliconWizard
author_rank: Super Contributor
timestamp: September 17, 2019, 02:11:05 pm
content: Quote from: T3sl4co1l on September 17, 2019, 12:20:47 amNope. See there:https://www.nasm.us/doc/nasmdoc2.htmlQuote

author: admiralk
author_rank: Regular Contributor
timestamp: September 19, 2019, 10:04:21 pm
content: After a bit of experimenting, I almost found a solution.Using MASM with original example file; ml > link > com2hex gives meCode:3A 30 30 30 30 30 30 30 31 46 46 0D 0AUsing NASM with all the ASSUME parts removed and ith format gives meCode:3A 30 36 30 37 46 30 30 30 42 30 30 31 45 36 3130 45 42 46 43 37 35 0D 0A 3A 30 30 30 30 30 3030 31 46 46 0D 0AUsing NASM with all the ASSUME parts removed and no file type option gives meCode: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 ofCode:00000000 B0 01 E6 10 EB FCI needCode: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 00000007F0 B0 01 E6 10 EB FC

author: T3sl4co1l
author_rank: Super Contributor
timestamp: September 20, 2019, 07:22:29 am
content: Put this at the top of the code:.org 7e0Tim

author: admiralk
author_rank: Regular Contributor
timestamp: September 20, 2019, 07:25:45 pm
content: Thanks, but it does not like thatCode:error: parser: instruction expectedI already had ORG in it to begin with also. This is it cleaned up some.Code:ORG7F0h;The 2716 location for the 8088;powerup instruction of FFFF0hSTART:MOVAL,00000001b;This will light the zero light;on the 373's outputAGAIN:OUT10h,AL;Since the 373 is enabled by;IO/M directly, it will respond;to any port referenceJMPAGAIN;Go light the LED againYou would think something this simple would just work.

author: admiralk
author_rank: Regular Contributor
timestamp: September 24, 2019, 11:08:14 pm
content: OK RTFMIt 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 isCode:ORG 0TIMES 7F0h-($-$$) DB 0;ORG7F0h;The 2716 location for the 8088;powerup instruction of FFFF0hSTART:MOVAL,00000001b;This will light the zero light;on the 373's outputAGAIN:OUT10h,AL;Since the 373 is enabled by;IO/M directly, it will respond;to any port referenceJMPAGAIN;Go light the LED againThanks for all the suggestions.