Hey there, I would like to ask if anyone here know about Intel 8085 chip and the assembly language ?
Need some help here.
Thanks !
Need some help here.
Thanks !
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
How do you know that I am using 8255 chip ? Well, soWhat 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.
Are you?How do you know that I am using 8255 chip ?
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).MVI A, 00000001B <--- load this value of '1' and '0' at each pins of Port A ?
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 ?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.
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.Then, OUT CTRLPORT means I am configuring the 8255 ?
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...absf, good call. It took me an episode of 'West Wing' to remember the 8255.. gettin' old.
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.interfacing them to my 8085 SBC. It was transfered from breadboard to a stripboard recently...
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 ?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?
Oops, will post the code later..another codeWell, 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 ?
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:
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
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.
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
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
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 ?With comments in the program, does things look clearer now?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
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 | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Address decoding - Intel 8085 | Digital Design | 10 | ||
V | Intel 8085 microprocessor | Programming & Languages | 36 | |
R | intel 8085 microprocessor and 8155 PIA | Homework Help | 3 | |
Intel 8085 project, a few questions. | Microcontrollers | 22 | ||
S | Intel Microprocessors 8085 & 8086 | Homework Help | 1 |