PDA

View Full Version : First program questions



Mike_Z
April 30th, 2015, 03:38 PM
Today, I tried my first CP/M assembler program. I didn't take long to find out how kunky ED is. Did I get confused. So I wrote the code in MS WORD and converted it to a text file and then up loaded the text file as a .ASM onto my 8" disk using 22DISK. Worked fine. I could use TYPE to see the file, everything looked good. I then did a ASM SYSGEN. The drives clicked and clunked and the .PRN and the .HEX files were made and A bunch of stuff was displayed on the console screen. After a while I figured the screen was displaying errors, a bunch of them, image that. One common one is that I placed a label and code on the same line. I can't do this? Here's what I had.


CRLF, MVI A,CR
CALL PUTCHAR
MVI A,LF
CALL PUTCHAR
RET


Does this have to be like this?



CRLF,
MVI A,CR
CALL PUTCHAR
MVI A,LF
CALL PUTCHAR
RET


When I looked at the .PRN file there was a 'S' in front of these types of lines. Mike

Mike_Z
April 30th, 2015, 04:15 PM
Looks like my mistake is with the label. I used a comma after the label. That is from a long time using another assembler that wanted comma's after a label. Looks like I need a Colon instead. So are these statements correct?


FIRST: MVI A,2

SECOND: EQU 8H

THIRD: DB 'TEXT'

FOURTH: DS 12


Mike

Chuck(G)
April 30th, 2015, 06:14 PM
Well, it'll work in DRI ASM, but really, you can leave the colon out in most cases.

As in:



FIRST MVI A,2

SECOND EQU 8H

THIRD DB 'TEXT'

FOURTH DS 12

Some x80 assemblers say that the colon should be used only when the label refers to the address of the current location. ASM doesn't care. I tend to use the convention that if a label is by itself on a line, use a colon; otherwise leave it out.

archeocomp
April 30th, 2015, 11:48 PM
BTW have you heard of XMODEM? I have never needed 22DISK(although it is very good) because I am using XMODEM, specifically XMODEM V5 tailored to my SBC.

Mike_Z
May 1st, 2015, 06:00 AM
I have heard of XMODEM, (By the way, I had to Google BTW to find out what that means, I'm an old fart [IAOF].) My intention is to get CP/M and my machine in good reliable shape before moving to another project. Recently, I picked up a paper back book, at a driveway flea market regarding KERMIT for DOS. Got it for a quarter. I was thinking, that when I have time, I'd try to get Kermit to replace one of my own programs that I wrote years ago, that communicates between my IBM XT and the 8080. I'm sure that KERMIT and/or XMODEM would work. It's a matter of time, first I want to enhance my CBIOS and incorporate it into my 8080 monitor program so I don't have to load it every time I start. I appreciate the suggestion. Thanks Mike

Mike_Z
May 1st, 2015, 07:56 AM
This morning I replaced all the label comma's and this reduced the amount of errors by a bunch. I found that the 'S' preceding the error stands for 'Syntax error'. Which is correct for the non recognition of the comma's. I ran the assembler again and this is what I got.


CP/M ASSEMBLER VER 2.0
U0202 320000 STA GDISK
E0358 DS STACKSIZE=2
0358
018H USE FACTOR
END OF ASSEMBLY


I can't find the 'U' error in my CP/M books, I'm guessing that it's for undefined operand. I'm betting that it can't find GDISK, because the 320000 seems to be code for STA but there is no address for GDISK. I must not have defined it. Is the 0202 that comes after the U the line number that the error occurred at?

The 'E' error is an expression error. I think I wanted that line to read DS STACKSIZE+2

Is the 0358 that is all by itself, the last line of the program? AND what is 018H USE FACTOR? is that how long the assembled program is?

One last question, if I add line numbers to my MS WORD document of the assembly program, what is the format for the line numbers? Is it just add the number and tab over to the label field? AND do these numbers start at zero or one?



0010 START: LXI SP,STACK ;Set stack space


Thanks Mike

deathshadow
May 1st, 2015, 08:10 AM
So I wrote the code in MS WORD and converted it to a text file and then up loaded the text file as a .ASM onto my 8" disk using 22DISK.
Word of warning, Word can do some auto-formatting stuff like styled quotes that take the document out of the ASCII7 character space; you might be better off using notepad or a programmers editor/notepad replacement like editplus, notepad++, win32pad, Text Wrangler, Sublime, Scite, etc, etc.

I like Flo's notepad2 (http://www.flos-freeware.ch/notepad2.html) as it has everything I like in an editor (long line rule, indentation guides, word-wrap guides, character counts for document and selection, regex search/replace, auto-indent, brace matching), lacks the things that just piss me off for being a step backwards in functionality (tabs, "project management")) and lets me turn off all the crap I don't like (illegibile acid trip known as syntax highlighting) or just pisses me off (autocomplete). Pretty much EVERY bit of code I've written the past five years was done from Notepad2, with Crimson Editor, Win32pad and just plain notepad before that going back a decade and a half.

You might also want to look into a local emulator to speed up your work process to test in the emulator for minor changes only going to the real hardware when you do something major. I've heard good things about ZEMU though I've not used it (yet).

Regardless of the platform -- Web, PC, C64, Apple II, Atari 800, CP/M -- and regardless of language -- C, Pascal, ASM, Java, HTML, CSS, JavaScript, PHP -- I do all of my coding and testing from a modern OS (typically windows, though I'm fairly platform agnostic -- they all suck in different ways) then test in an emulation like DosBox, Bochs, AppleWin, Kegs, VICE, etc, etc... Speeds up the workflow a lot and also is less headaches since at the ASM language level if you screw up, it's easier to reset an emulator or VM than it is the real hardware... More so when you have cross platform compilers like CC65 or ZMac that let you compile on modern OS for other targets.

It REALLY beats the tar out of trying to develop on the actual native hardware -- as you found out from the pathetic period authentic tools like ED. It also opens the door to creating your own local tools on a more robust platform for doing things you never would have thought of back in the day like sprite compilers, macro builders, encoders/encryption optimized to the data type instead of using a generic one, or even just making your own link-order builder. (I did this with CC65 for the C64 version of Paku Paku to deal with embedding static data without converting it to C or ASM code, just the raw binary). Also handy in the modern sense particularly with GNU compilers, given what utter and complete incomprehensible gibberish makefiles are.

Could be worse, I knew people who swore by writing code using edlin. :( Makes me wonder just what the **** is in the kool-aid of the people who still use Vi or emacs...Might as well go back to wordstar commands; Control-K THIS (holds up finger) mike-foxtrot!

archeocomp
May 1st, 2015, 08:12 AM
Here are the error codes explained, but U is not there
http://www.gaby.de/cpm/manuals/archive/cpm22htm/ch3.htm#Section_3.6

KC9UDX
May 1st, 2015, 08:51 AM
vi isn't bad if you use it everyday. I don't know what I'd do without Wordstar, or at least, Wordstar compatibility.

Mike_Z
May 1st, 2015, 09:15 AM
Shadow, most of that stuff you are talking about is a little over my head right now. Maybe as I get into this stuff, I can pick up on it. I suppose I could use NotePad etal. MS Word is something I know pretty well and I just convert the document to Plain Text and it seemed to work. I'll keep it in mind should I have trouble later. I also thought of trying MS EXCEL. This would keep the layout nice as a program sheet. Not sure how to save it. I know there are comma delimit methods, wonder if there is a TAB delimit. I'll have to give it a try.

I've never used WORDSTAR. Is it (or was it) available for CP/M? Maybe that program could be used to create source. There sure is a lot to think about. It really helps this old mind from slipping into dementia. Thanks Mike

Chuck(G)
May 1st, 2015, 09:26 AM
"U" is undefined symbol.

Wordstar is usually recognized as being primarily a CP/M product. The initial MS-DOS version was mostly an automated conversion of the 8080 code. I used to have a copy of version 0.9, but 3.3 is probably the best for a system with limited disk storage. 4.0 is better, but quite a bit larger. It's been around almost as long as CP/M.

The distinguishing characteristic of WS as a WYSIWYG is that it uses a "patch area" in memory to customize both printer and video output. You can use it on some of the dumbest terminals that have only a very rudimentary facitily for moving the cursor around. You can also use it for memory-mapped video. It's really very clever.

daver2
May 1st, 2015, 09:53 AM
Mike,

The 'U' error stands for "A label in an operand expression has not been defined prior to the current statement". Can be found at http://www.shaels.net/index.php/cpm80-22-documents/using-cpm/9-asm-utility. My guess is indeed that GDISK is unknown.

The 'E' error stands for "A required operand was not provided or operand expression can not be resolved" and I think you are correct that the '=' should be a '-'.

The "0358" is 'the next address to be assembled to'.

The 'USE FACTOR' is the '%' of the internal table size used. This is a bit of a strange number because 0 to 100% is scaled as 00 to FF hexadecimal!

If you want to incorporate line numbers - just put the line number as the very first thing on the line and leave a space between the line number and the remaining assembler source.

An excellent manual to download and read can be found at http://www.cpm.z80.de/randyfiles/DRI/ASM.pdf (although it is for ASM V1.0, so it is a bit out of date if you are using V2.0).

To echo the warning about WORD - I would definitely avoid it for entering good old plain ASCII text. Use NOTEPAD instead. I have also found the hard way that WORD does not necessarily give you (in the plain text it produces) what you think you typed in (especially if you have things like "smart quotes" and the like enabled in WORD - although you may not know it).

Dave

JonB
May 1st, 2015, 10:23 AM
The only problem with vi (which is my editor of choice by the way!) is that it can be a bit tricky to learn. Worth it, though. There doesn't appear to be a CP/M version... Yet. (Watch this space....!)

+1 for Notepad, or good old DOS EDIT.COM if you have it.

Chuck(G)
May 1st, 2015, 10:27 AM
The 'U' error stands for "A label in an operand expression has not been defined prior to the current statement". Can be found at http://www.shaels.net/index.php/cpm80-22-documents/using-cpm/9-asm-utility. My guess is indeed that GDISK is unknown.

That explanation is a little confusing. Forward label references are indeed allowed in ASM--otherwise it wouldn't be much of an assembler. "U" generally means that "I don't know what this is". Another error that can be confusing is the "P" error. For example:


0100 ORG 100H

Here:
P010C = This equ There+2
0100 0500 dw There+2
0003 = That equ This+3
0003 org This+3
There:

0003 END

Note that the forward reference to "There" in the DW statement assembles correctly, but the EQU statement with the same reference produces a "P" error. The reason for this should be obvious in the ORG statement a bit further on. You have a forward reference to a symbol whose value depends on the value of the forward reference.

What this is saying is that a forward reference EQU or SET is prohibited because of such a situation. Note also, that ASM doesn't tag all references to the suspicious EQU--it just assigns a value of 0 to the symbol.