PDA

View Full Version : 8080 assembler



Terry Yager
December 28th, 2003, 03:53 PM
Anybody here speak/remember any 8080 assembly language? I'm having some problems with buggy code and could use a little help.

--T

Erik
December 28th, 2003, 04:53 PM
Post the code or the question and I'll see what I can remember. I should know more then I do considering the number of 8080s in the house but even if I can't I'm sure someone can help you out.

Erik

Terry Yager
December 28th, 2003, 05:56 PM
OK, for starters, can you tell me what's wrong with this subroutine? It's s'posed to read the (ASCII) character in the A register and print it out to the screen, using the CP/M system call 2h "Console out", after which it should return control to the calling program, but instead of returning to CP/M, it just gets lost and hangs the machine.
;
bdos equ 5h
conout equ 2h
;
;subroutine to print character in a-reg out on screen
;
pchar push h ;save hl (conout uses it)
mov e,a ;print hex digit
mvi c,conout
call bdos
pop h ;get hl back
ret
;
end
;

I have used DDT's "T"(race) command to single step thru this prog and the point where it loses control is where it calls the subroutine "pchar".

Is this snippet enough to work with, or do you need the entire program?

--T

(Sorry if the listing looks funny, your editor doesn't seem to recognize tabs or spaces.)

Allison
April 2nd, 2005, 06:46 PM
>>> ;
bdos equ 5h
conout equ 2h
;
;subroutine to print character in a-reg out on screen
;
pchar push h ;save hl (conout uses it)
mov e,a ;print hex digit
mvi c,conout
call bdos
pop h ;get hl back
ret
;
end
;

I have used DDT's "T"(race) command to single step thru this prog and the point where it loses control is where it calls the subroutine "pchar".
<<<
The code looks right for the example.

My guess is that your stack is blown. Did you set up a stack and is it large enough?

Allison

Terry Yager
April 2nd, 2005, 08:48 PM
Gee, it's been awhile, but as I recall, I wasn't using any stack other than the Z80's own stack space. The code came from the book Soul of CP/M, and is just one of several serious errors I found in the book. Even with it's faults, I did learn more A/L programming from that book than I have from any other source, so it's still a keeper.

--T

Allison
April 10th, 2005, 07:19 AM
Gee, it's been awhile, but as I recall, I wasn't using any stack other than the Z80's own stack space. The code came from the book Soul of CP/M, and is just one of several serious errors I found in the book. Even with it's faults, I did learn more A/L programming from that book than I have from any other source, so it's still a keeper.

--T

Know the book. There is an assumption that you did create a stack that's valid. Most of those examples are code segments and are unadorned
with "setup" code to initialize things.

If you using DDT to Trace the execution you can show the registers first
and set a value in the stack. You may be surprized whree the stack points
in uninitialized. Because it's uninitialized it may be stepped on or worse
crush the system stack.

First rule of programming, anything uninitialized will be in the worst place and the wrong size.

Personally, the best book for CP/M programming is The Programmers CP/M Handbook by Andy Johnson-laird (Osborne/McGraw-hill). There
are other 8080/z80 programming books as well by Osborne and The Blacksburg Group.


Allison

Terry Yager
April 10th, 2005, 04:00 PM
Know the book.

I did actually debug a couple of the errors, but then, I gave up trying.


Personally, the best book for CP/M programming is The Programmers CP/M Handbook by Andy Johnson-laird (Osborne/McGraw-hill). There
are other 8080/z80 programming books as well by Osborne and The Blacksburg Group.


Allison

Yes, I have that book too, but it's way over my head at this point. I'm working my way up to it. Right now, I'm using the Kathy Spraklen book, and after that (during, actually) there's Mastering CP/M by Allan Miller. I like this one because it's all macro-based. If all else fails to get thru my thick skull, I still have the Zaks book to fall back on. (I wouldn't mind having a copy of the Lance Levinthal book, if ya have an extra kicking around).

--T

Allison
April 11th, 2005, 07:16 AM
>>>fall back on. (I wouldn't mind having a copy of the Lance Levinthal book, if ya have an extra kicking around).<<<


Sorry I don't. In order to store all this in available space copies and dups
are rid of asap whenever I get something with books or manuals. I have an extensive library somethere in the region of 80 linear feet of shelf space.

The most difficult part of 8080 assembler is that the instruction set is both
odd in format and in many cases there is a instruction to do something but
an reciprical instruction does not exist or worse has a different name form. The best example is you can load the spackpointer with a constant [LXI SP,1234] yet there is no instruction to save the stack pointer. Though the Z80 has a larger instruction set it's regularity both in form and available instructions is why many claim it's easier to learn.

Myself the first assembler was PDP-8 back in '69 and it's instruction set is best described as starkly minimalist. It's small size made it somewhat friendly and easy to understand. Learning to program with it made you think as you were very close to the machine as a result. I still enjoy it.

Keep posting your examples that behave oddly, hopefully we can help.

Allison

patscc
April 14th, 2005, 10:05 AM
OK, for starters, can you tell me what's wrong with this subroutine? It's s'posed to read the (ASCII) character in the A register and print it out to the screen, using the CP/M system call 2h "Console out", after which it should return control to the calling program, but instead of returning to CP/M, it just gets lost and hangs the machine.
;
bdos equ 5h
conout equ 2h
;
;subroutine to print character in a-reg out on screen
;
pchar push h ;save hl (conout uses it)
mov e,a ;print hex digit
mvi c,conout
call bdos
pop h ;get hl back
ret
;
end
;

I have used DDT's "T"(race) command to single step thru this prog and the point where it loses control is where it calls the subroutine "pchar".

Is this snippet enough to work with, or do you need the entire program?

--T

(Sorry if the listing looks funny, your editor doesn't seem to recognize tabs or spaces.)

Is the snippet line

pchar push h ;save hl (conout uses it)

equiv to defiinition and entry to subroutine pchar ?
(I'm used to
pchar: ;blah
push h ;save blah
...)

If this is what I'm looking at, try push/pop h,b,d instead of just h
I'd try it myself, but most of my hardware is packed.
patscc

Terry Yager
April 14th, 2005, 01:43 PM
I've completely lost track of the original code, but I see what you're saying. There is a missing colon in the label, but I can't tell if it was a typo from when I typed it here or not. Oh well, I've moved on...

--T