Intel 8085 microprocessor

Thread Starter

vincent19-mas

Joined Dec 27, 2012
83
Hey there, I would like to ask if anyone here know about Intel 8085 chip and the assembly language ?

Need some help here.

Thanks !
 

Thread Starter

vincent19-mas

Joined Dec 27, 2012
83
Well, it is about the programming assembly code. I am not used to it :(
Rich (BB code):
CPU"8085.TBL¡±
PORTA: EQU 80H
PORTB: EQU 81H
PORTC: EQU 82H
CTRLPORT:EQU 83H

ORG 2000H
LXI SP,3FF0H
MVI A, 10000000B
OUT CTRLPORT
REPEAT: MVI A, 11111110B
         OUT PORT C
         CALL DELAY
         MVI A, 11111111B
         OUT PORT C
         CALL DELAY
         JMP REPEAT

DELAY: MVI C,255
LOOP1: MVI B,255
LOOP: DCR B
    JNZ LOOP
    DCR C
    JNZ LOOP1
    RET
    END
For this coding, I dont get the difference between the two bolded part. From what my leturer told me, the first bolded one is the configuration bits while the second one is the bit sent to the PORTA ><.

Hope anyone can help. I am totally new to this programming :)
 

MrChips

Joined Oct 2, 2009
21,682
The two instructions are similar.
What makes the difference is the next instruction following the one shown in bold.
 

JohnInTX

Joined Jun 26, 2012
4,237
What if any peripheral chip(s) are you using? Your addresses look like its an 8255? If so the code looks like it should work assuming the processor is up.

The first bolded part configures the 8255 for ports A,B,and C to be regular output ports. The 8255 has several operating modes and you have to configure the ports at power up. This is one of the MODE 0 (standard IO) modes with all lines output. You only have to configure it once.

After configuring, you just write to the ports at their IO addresses 80h-82h for ports A-C respectively.

Since you are using the OUT instruction, the ports must be IO mapped in the hardware. The 8085 bus allows various ways to map IO but most systems use the IO space that is accessed using the IN and OUT instructions. IN and OUT set the IO-M/ pin on the processor to '1' when reading and writing. This pin is decoded by external logic to interpret the address bus as an IO (not memory address).

So after configuring, the program toggles the LSbit of PORTC not PORTA. The MVI A,xx loads the accumulator which in turn is what gets written to the port by the OUT instruction.

BTW: the processor starts executing at 0000h and your code starts at 2000h. If you are using some firmware monitor/loader that resides down there and you jump to the code at 2000h via the monitor, OK. If not, you should ORG the code to 0000h.

absf, good call. It took me an episode of 'West Wing' to remember the 8255.. gettin' old.
 
Last edited:

absf

Joined Dec 29, 2010
1,947
I think the 8085 is interfacing to an 8255 PPI.

Writing 10000000B to the control register is to set Ports A, B and C to output direction and bit 7=1 means control register is in I/O mode. See datasheets attached.
 

Attachments

Last edited:

takao21203

Joined Apr 28, 2012
3,695
Learning assembler, you have to examine the instruction set and read what each instruction is doing.

Assembler is based on putting together several instructions to do something.
 

Thread Starter

vincent19-mas

Joined Dec 27, 2012
83
What if any peripheral chip(s) are you using? Your addresses look like its an 8255? If so the code looks like it should work assuming the processor is up.

The first bolded part configures the 8255 for ports A,B,and C to be regular output ports. The 8255 has several operating modes and you have to configure the ports at power up. This is one of the MODE 0 (standard IO) modes with all lines output. You only have to configure it once.

After configuring, you just write to the ports at their IO addresses 80h-82h for ports A-C respectively.

Since you are using the OUT instruction, the ports must be IO mapped in the hardware. The 8085 bus allows various ways to map IO but most systems use the IO space that is accessed using the IN and OUT instructions. IN and OUT set the IO-M/ pin on the processor to '1' when reading and writing. This pin is decoded by external logic to interpret the address bus as an IO (not memory address).

So after configuring, the program toggles the LSbit of PORTC not PORTA. The MVI A,xx loads the accumulator which in turn is what gets written to the port by the OUT instruction.

BTW: the processor starts executing at 0000h and your code starts at 2000h. If you are using some firmware monitor/loader that resides down there and you jump to the code at 2000h via the monitor, OK. If not, you should ORG the code to 0000h.

absf, good call. It took me an episode of 'West Wing' to remember the 8255.. gettin' old.
How do you know that I am using 8255 chip ? Well, so
MVI A,10000000B <-- configuration bit for 8255 ?
MVI A, 00000001B <--- load this value of '1' and '0' at each pins of Port A ?

 

JohnInTX

Joined Jun 26, 2012
4,237
How do you know that I am using 8255 chip ?
Are you?

Based on the addresses of the ports and the value written to the config register its a good guess? I thought it might be an 8155 at first but came to think the 8255 about the same time as absf did, although I was wrong first. So I win.

MVI A, 00000001B <--- load this value of '1' and '0' at each pins of Port A ?
MVI A,<data> doesn't do anything to the ports until you do the OUT instruction. If you read the instruction set, you'll see that OUT n copies the value of A (the accumulator) to the output port n. With IO mapped systems, all IO goes through A. (IN reads the port and the value shows up in A).

If you are NOT using an 8255, most of this does not apply.
 
Last edited:

Thread Starter

vincent19-mas

Joined Dec 27, 2012
83
Are you?

Based on the addresses of the ports and the value written to the config register its a good guess? I thought it might be an 8155 at first but came to think the 8255 about the same time as absf did, although I was wrong first. So I win.

MVI A,<data> doesn't do anything to the ports until you do the OUT instruction. If you read the instruction set, you'll see that OUT n copies the value of A (the accumulator) to the output port n. With IO mapped systems, all IO goes through A. (IN reads the port and the value shows up in A).

If you are NOT using an 8255, most of this does not apply.
Yay! I am using 8255. Oh yea, I missed that. MVI A, <data> is just loading the data at accumulator to be waited to be OUTPUT to a specific PORT right ? So at first MVI A,10000000B is loading 10000000 at accumulator. Then, OUT CTRLPORT means I am configuring the 8255 ?

Thanks !
 

JohnInTX

Joined Jun 26, 2012
4,237
Then, OUT CTRLPORT means I am configuring the 8255 ?
Yup! Like modern microcontrollers, the peripheral chips of the day (8155, 8255, 8256 etc) tried to be as flexible as possible so each one has one or more configuration registers. The programmer has to look at how the hardware is hooked up (Inputs/Outputs etc) and during the system initialization, write to all of the various config registers to set up the chips for the specific application. Its usually done once after reset and before doing anything else.

If you look carefully at the 8255 datasheet, you'll see that the port/config addresses are specified by A1-A0 and 00=PORTA, 01=PORTB, 10=PORTC, 11=ControlWord (config). When wired up the upper bits of the address are provided by some logic (gates, PAL, GPLD etc) and when 1000 00xx is sent, this logic asserts CE/ on the 8255 but the last two bits are directly connected to the processor's IO address and are decoded by the 8255 internally so when you write to 83h (10000 11) the first 6 bits are fixed by the hardware, the last two are determined specified by the OUT instruction, in this case, the config register.

Your config is about a simple as it gets, all outputs. If you need inputs from the SAME 8255, you'll have to change the value written to the config register to make one of the ports an input. The 8255 is a bit crude here, ports A and B have to be all the same way. Port C is split into 4 bit groups. Its incumbent on the designer not to mix I and O on the same port/group.

Question for you - what are you using to assemble/load/debug the code?
 
Last edited:

absf

Joined Dec 29, 2010
1,947
absf, good call. It took me an episode of 'West Wing' to remember the 8255.. gettin' old.
I knew the 8155 well as I have a bundle of them from OKI teletype machines. The 8155 has 256 bytes of RAM and a timer inside. And I had a hard time interfacing them to my 8085 SBC. It was transfered from breadboard to a stripboard recently...

I only has a few (2 or 3) 8255 from old PC XT and I have made an interface board to the PC parallel port that's why I can still remember it.

Allen
 

JohnInTX

Joined Jun 26, 2012
4,237
interfacing them to my 8085 SBC. It was transfered from breadboard to a stripboard recently...
There was a time when I could roll an 8085 kernel out without looking at a datasheet. But that was with a full CAE package. You, sir, are a stud.

Have a great weekend.
 

Thread Starter

vincent19-mas

Joined Dec 27, 2012
83
Yup! Like modern microcontrollers, the peripheral chips of the day (8155, 8255, 8256 etc) tried to be as flexible as possible so each one has one or more configuration registers. The programmer has to look at how the hardware is hooked up (Inputs/Outputs etc) and during the system initialization, write to all of the various config registers to set up the chips for the specific application. Its usually done once after reset and before doing anything else.

If you look carefully at the 8255 datasheet, you'll see that the port/config addresses are specified by A1-A0 and 00=PORTA, 01=PORTB, 10=PORTC, 11=ControlWord (config). When wired up the upper bits of the address are provided by some logic (gates, PAL, GPLD etc) and when 1000 00xx is sent, this logic asserts CE/ on the 8255 but the last two bits are directly connected to the processor's IO address and are decoded by the 8255 internally so when you write to 83h (10000 11) the first 6 bits are fixed by the hardware, the last two are determined specified by the OUT instruction, in this case, the config register.

Your config is about a simple as it gets, all outputs. If you need inputs from the SAME 8255, you'll have to change the value written to the config register to make one of the ports an input. The 8255 is a bit crude here, ports A and B have to be all the same way. Port C is split into 4 bit groups. Its incumbent on the designer not to mix I and O on the same port/group.

Question for you - what are you using to assemble/load/debug the code?
Well, another question. What is the function on ANI 00000001B at read function there ? I am using hyper terminal in my lab..you know where can I download the simulator ?
 

JohnInTX

Joined Jun 26, 2012
4,237
IIRC ANI is And Immediate with the accumulator i.e. AND the literal operand with the (A)ccumulator. The result is left in the accumulator. In the IO context, its most useful for stripping off unused bits after an IO read e.g.

Rich (BB code):
IN PORTC ; get 8 bit port C. Value is in accumulator
 ANI 01h   ; strip all but LSbit, result in accumulator. Status flags set.
 JZ   LS_BIT_WAS_0  ; Jump on accumulator==0 i.e. LSbit of portC was 0
 ; continue when LSbit was 1
 ; do something..
 JMP done

LS_BIT_WAS_0:
  execute code for when bit was 0

done:
Writing is done similarly but since you only can write bytes, you have to do some logic by reading the current value modifying it then writing it back i.e.

Rich (BB code):
IN PORTC ; get current value to Accumulator
 ORI 80h   ; set MSbit
 ANI FEh   ; clear LSbit
 OUT PORT C ; write result - MSbit set, LSbit cleared, others unchanged
This works OK but if you are serious, you should maintain a copy of the output port value in RAM, modify that then write the RAM byte to the port.

As far as a simulator, nope. We did all of the 8085 stuff on a FutureData AMDS with a handrolled firmware monitor/debugger that talked to a terminal (like Hyperterminal)
 
Last edited:

Thread Starter

vincent19-mas

Joined Dec 27, 2012
83
There was a time when I could roll an 8085 kernel out without looking at a datasheet. But that was with a full CAE package. You, sir, are a stud.

Have a great weekend.
Rich (BB code):
CPU"8085.TBL"
PORTA: EQU 80H
PORTB: EQU 81H
PORTC: EQU 82H
CTRLPORT: EQU 83H

ORG 2000H
LXI SP,3FF0H
MVI A, 10010000B
OUT CTRLPORT

READ: IN PORTA
       ANI 00000001B
       JZ REPEAT
       JMP NOREPEAT


REPEAT: MVI A, 11111100B
         OUT PORTC
         CALL DELAY
         MVI A, 11111111B
         OUT PORTC
         CALL DELAY
           JMP READ
         
NOREPEAT: MVI A, 11111110B
         OUT PORTC
         CALL DELAY
         MVI A, 11111101B
         OUT PORTC
         CALL DELAY
         JMP READ

DELAY: MVI C,255
LOOP1: MVI B,255
LOOP: DCR B
    JNZ LOOP
    DCR C
    JNZ LOOP1
    RET
    END
Ok, by seeing to this code, whats the function of ANI 00000001B there ? and when IN PORTA, then what value will it read if a siwtch is connected to PORTA0 and the switch is closed ? What will be the value of others pins of PORTA ? Floating ?

Thanks !
 

absf

Joined Dec 29, 2010
1,947
Rich (BB code):
CPU"8085.TBL"
PORTA: EQU 80H
PORTB: EQU 81H
PORTC: EQU 82H
CTRLPORT: EQU 83H

ORG 2000H
LXI SP,3FF0H
MVI A, 10010000B
OUT CTRLPORT

;assuming switch on PA0 is active low pulled high with 10K

READ: IN PORTA			;read port A
       ANI 00000001B		;mask off bit 1 to bit 7
       JZ REPEAT		;switch is closed, goto repeat		
       JMP NOREPEAT		;else goto norepeat

; assuming Green LED on PB0 & red LED on PB1
; LED lighted when logic 0 is applied

REPEAT: MVI A, 11111100B	;switch on both G & R LED	
         OUT PORTC
         CALL DELAY		;for a while 
         MVI A, 11111111B	;switch off both LED	
         OUT PORTC
         CALL DELAY		;wait for a while		
           JMP READ		;loop back to read key
         
NOREPEAT: MVI A, 11111110B	;G LED ON and R LED off
         OUT PORTC
         CALL DELAY		;for a while
         MVI A, 11111101B	;G LED off and R LED on
         OUT PORTC
         CALL DELAY		;for a while 
         JMP READ		;loop back to read key

DELAY: MVI C,255
LOOP1: MVI B,255
LOOP: DCR B
    JNZ LOOP
    DCR C
    JNZ LOOP1
    RET
    END
With comments in the program, does things look clearer now?

What the value read when a switch is closed is totally up to the way you wire the switch. It can be active low with pullup resistor or active high with pulldown R.

Allen
 

Thread Starter

vincent19-mas

Joined Dec 27, 2012
83
Rich (BB code):
CPU"8085.TBL"
PORTA: EQU 80H
PORTB: EQU 81H
PORTC: EQU 82H
CTRLPORT: EQU 83H

ORG 2000H
LXI SP,3FF0H
MVI A, 10010000B
OUT CTRLPORT

;assuming switch on PA0 is active low pulled high with 10K

READ: IN PORTA            ;read port A
       ANI 00000001B        ;mask off bit 1 to bit 7
       JZ REPEAT        ;switch is closed, goto repeat        
       JMP NOREPEAT        ;else goto norepeat

; assuming Green LED on PB0 & red LED on PB1
; LED lighted when logic 0 is applied

REPEAT: MVI A, 11111100B    ;switch on both G & R LED    
         OUT PORTC
         CALL DELAY        ;for a while 
         MVI A, 11111111B    ;switch off both LED    
         OUT PORTC
         CALL DELAY        ;wait for a while        
           JMP READ        ;loop back to read key
         
NOREPEAT: MVI A, 11111110B    ;G LED ON and R LED off
         OUT PORTC
         CALL DELAY        ;for a while
         MVI A, 11111101B    ;G LED off and R LED on
         OUT PORTC
         CALL DELAY        ;for a while 
         JMP READ        ;loop back to read key

DELAY: MVI C,255
LOOP1: MVI B,255
LOOP: DCR B
    JNZ LOOP
    DCR C
    JNZ LOOP1
    RET
    END
With comments in the program, does things look clearer now?

What the value read when a switch is closed is totally up to the way you wire the switch. It can be active low with pullup resistor or active high with pulldown R.

Allen
Okay, I get that. However, if I only connect one swtich to PORT A0, then pin A0 will have a value set either to 1 or 0. How about the others pin like A1 A2 A3...A7 ?will it HIGH, LOW or floating ?

Thanks !
 
Top