sorry for the double post. but who could help me up with this code? :( it wont run on a86 but runs perfectly on 8086. please help me.


JMP BEGIN
MES:DB 'ASCII CHARACTERS'
MES3 DB 'PASSWORD INCORRECT!DENIED ACCESS!$'
MES2 db 'PASSWORD: $'
MES1 db 'RETRY: $'
MSG: DB 'Please enter the fan number: $'
MSG1: DB 'Fan No. 1 has been successfully turned on$'
MSG2: DB 'Fan No. 2 has been successfully turned on$'
MSG3: DB 'Fan No. 3 has been successfully turned on$'
MSG4: DB 'Fan No. 4 has been successfully turned on$'
MSG1A: DB 'Fan No. 1 is not working, contact the electrician immediately$'
MSG2A: DB 'Fan No. 2 is not working, contact the electrician immediately$'
MSG3A: DB 'Fan No. 3 is not working, contact the electrician immediately$'
MSG4A: DB 'Fan No. 4 is not working, contact the electrician immediately$'
MSG1B: DB 'Fan No. 1 has been successfully shut down$'
MSG2B: DB 'Fan No. 2 has been successfully shut down$'
MSG3B: DB 'Fan No. 3 has been successfully shut down$'
MSG4B: DB 'Fan No. 4 has been successfully shut down$'
MSG1C: DB 'Fan No. 1 is still on$'
MSG2C: DB 'Fan No. 2 is still on$'
MSG3C: DB 'Fan No. 3 is still on$'
MSG4C: DB 'Fan No. 4 is still on$'
MSG5: DB 'Do you still want to continue?(y/n): $'
MSG6: DB 'Thank you for using the program...  :) bye!$'
MSG7: DB 'Do you want to turn on or off a fan?<o/f>: $'
MSG8: DB 'You entered a wrong answer! Please follow the instructions $'
MSG10: DB 'Press 1 to turn on all the fans OR 2 to turn it on one at a time $'
MSG12: DB 'Press 1 to turn off all the fans OR 2 to turn it off one at a time $'
MSG9A: DB 'Fan Nos. 1 2 3 & 4 has been successfully turned on$'
MSG11A: DB 'Fan Nos. 1 2 3 & 4 has been successfully shut down$'
MSG9: DB 'Are you sure you dont want to continue?(y/n): $'


ASTERISK:
       MOV AH,09H
       LEA DX,ASK
       INT 21H
       RET
ASK: DB '#$'


SPACE:                          ;ENDLINE SUBROUTINE
       MOV AH,02
       MOV DX,00AH
       INT 21H
       MOV DX,00DH
       INT 21H
       RET
CLEAR:                ;CLEAR SCREEN SUBROUTINE
       MOV AX,03
       INT 10H
       RET
CENTER:                         ;CENTER ALIGNMENT OF CURSOS SUBROUTINE
       MOV AH,02
       MOV BH,00
       MOV DH,12
       MOV DL,20
       INT 10H
       RET
       
ORIGIN:
       MOV AH,02
       MOV BH,00
       MOV DH,00
       MOV DL,00
       INT 10H
       INT 21H
       RET
     
WRONG1:                         ;IF THE SYNTAX ENTERED IS WRONG IT WILL GO HERE
       CALL CLEAR
       CALL CENTER
       MOV AH,09
       LEA DX,MSG8
       INT 21H
       CALL SPACE
       MOV AH,02
       MOV BH,00
       MOV DH,13
       MOV DL,20
       INT 10H        
       MOV AH,09
       LEA DX,MSG5
       INT 21H
       MOV AH,01
       INT 21H
       CMP AL,06EH
       JE NO

       CMP AL,04EH
       JE NO

       CMP AL,059H
       JE YES1

       CMP AL,079H
       JE YES1
       
       CALL WRONG1
       CALL CLEAR
       MOV AH,02
       MOV BH,00
       MOV DH,00
       MOV DL,00
       INT 10H
       INT 21H
           
       YES1:
       
           RET


BEGIN:


CALL CLEAR ;clear the screen
CALL CENTER
MOV AH,09H ;display string
LEA DX,MES2 ;prints Enter password
INT 21H
MOV BL,3
AGAIN:
       MOV AH,07 ;direct keyboard input
       INT 21H
       MOV BH,AL ;move the input al to bh
       CMP BH,0DH
       JE  AGAIN
       CALL ASTERISK
       CMP BH,'e'
       JE AGAIN1 ;if equal jump to again
       JNE WRONG ;if not to wrong
AGAIN1:
       MOV AH,07
       INT 21H
       MOV BH,AL
       CMP BH,0DH
       JE INVALID9
       CALL ASTERISK
       CMP BH,08H
       JE AGAIN
       CMP BH,'d'
       JE AGAIN2
       JNE WRONG
AGAIN2:
       MOV AH,07
       INT 21H
       MOV BH,AL
       CALL ASTERISK
       CMP BH,'r'
       JE AGAIN3
       JNE WRONG
INVALID9:
        CALL INVALID8
AGAIN3:
       MOV AH,07
       INT 21H
       MOV BH,AL
       CALL ASTERISK
       CMP BH,'i'
       JE AGAIN4
       JNE WRONG
AGAIN4:
       MOV AH,07
       INT 21h
       MOV BH,AL
       CALL ASTERISK
       CMP BH,'a'
       JE AGAIN5
       JNE WRONG
AGAIN5:
       MOV AH,07
       INT 21h
       MOV BH,AL
       CALL ASTERISK
       CMP BH,'n'
       JE AGAIN6
       JNE WRONG
AGAIN6:
       MOV AH,07
       INT 21h
       MOV BH,AL
       CALL ASTERISK
       CMP BH,'7'
       JE AGAIN7
       JNE WRONG
INVALID8:
       CALL INVALID
AGAIN7:
       MOV AH,07
       INT 21H
       MOV BH,AL
       CMP BH,0DH ;compare the input with the enter key
       JE EXIT
       JNE WRONG
WRONG:
       MOV AH,07
       INT 21H
       MOV BH,AL
       CALL ASTERISK
       CMP BH,0DH ;compare the input with the enter key
       JE INVALID
       JNE WRONG
INVALID:
       CALL CLEAR
       CALL CENTER
       MOV AH,09
       LEA DX,MES1 ;prints retry password
       INT 21H
       DEC BL ;decrements bl until 3 attempts
       CMP BL,0
       JE INVALID2
       JMP AGAIN
INVALID2:
       CALL CLEAR
       CALL CENTER
       MOV AH,09 ;print password failed!!!
       LEA DX,MES3
       INT 21H
       INT 20H
EXIT:
       CALL CLEAR
       MOV AH,02
       MOV BH,00
       MOV DH,00
       MOV DL,00
       INT 10H

;START OF THE MAIN PROGRAM

START:
CALL SPACE                          ;START OF MAIN PROGRAM
MOV AH,09                       ;1ST QUESTION
LEA DX,MSG7                    
INT 21H

MOV AH,01
INT 21H

CMP AL,04FH                     ;COMPARING OF CHARACTER
JE TURNON

CMP AL,06FH                     ;COMPARING OF CHARACTER
JE TURNON

CMP AL,046H                     ;COMPARING OF CHARACTER
JE TURNOFF

CMP AL,066H                     ;COMPARING OF CHARACTER
JE TURNOFF



CALL WRONG1                     ;CATCH CHARACTERS THAT ARE NOT VALID
CALL CLEAR
CALL ORIGIN
JMP START:
                               ;IF YOU WANT TO TURN ON A FAN
TURNON:
CALL SPACE
MOV AH,09
LEA DX,MSG10
INT 21H

MOV AH,08
INT 21H

CMP AL,031h                     ;IF YOU WANT TO TURN ON ALL THE FANS
JE FANALL

CMP AL,032h                     ;IF YOU WANT TO TURN ON THE FAN ONE AT A TIME
JE FAN1X1

CALL WRONG1                     ;MAKE IT A SUBROUTINE
CALL CLEAR
CALL ORIGIN
JMP TURNON

FANALL:                         ;IF FAN ALL IS CHOSEN
MOV AL,0001
MOV DX,378h
OUT DX,AL

MOV AL,0001
MOV DX,379h
IN  AL,DX

CMP AL,01
JE ON1A
JNE OFF1A

HERE1:                          

MOV AL,0010
MOV DX,378h
OUT DX,AL

MOV AL,0010
MOV DX,379h
IN  AL,DX

CMP AL,01
JE ON2A
JNE OFF2A

HERE2:

MOV AL,0011
MOV DX,378h
OUT DX,AL

MOV AL,0011
MOV DX,379h
IN  AL,DX

CMP AL,01
JE ON3A
JNE OFF3A

HERE3:

MOV AL,0100
MOV DX,378h
OUT DX,AL

MOV AL,0100
MOV DX,379h
IN  AL,DX

CMP AL,01
JE ON4A
JNE OFF4A

ON1A:
CALL SPACE
MOV AH,09
LEA DX,MSG1
INT 21H

JMP HERE1

OFF1A:
CALL SPACE
MOV AH,09
LEA DX,MSG1A
INT 21H

JMP HERE1

ON2A:
CALL SPACE
MOV AH,09
LEA DX,MSG2
INT 21H

JMP HERE2

OFF2A:
CALL SPACE
MOV AH,09
LEA DX,MSG2A
INT 21H

JMP HERE2

ON3A:
CALL SPACE
MOV AH,09
LEA DX,MSG3
INT 21H

JMP HERE3

OFF3A:
CALL SPACE
MOV AH,09
LEA DX,MSG3A
INT 21H

JMP HERE3

ON4A:
CALL SPACE
MOV AH,09
LEA DX,MSG4
INT 21H

JMP NEXT

OFF4A:
CALL SPACE
MOV AH,09
LEA DX,MSG4A
INT 21H

JMP NEXT


FAN1X1:
CALL SPACE                         ;IF YOU CHOSE TO TURN ON THE FAN 1BY1
MOV AH,09
LEA DX,MSG
INT 21H

MOV AH,01
INT 21H

CMP AL,031h
JE FAN1

CMP AL,032h
JE FAN2

CMP AL,033h
JE FAN3

CMP AL,034h
JE FAN4


CALL WRONG1
CALL CLEAR
CALL ORIGIN
JMP  TURNON

FAN1:
MOV AL,0001
MOV DX,378h
OUT DX,AL

MOV AL,0001
MOV DX,379h
IN  AL,DX

CMP AL,01
JE ON1
JNE OFF1

ON1:
CALL SPACE
MOV AH,09
LEA DX,MSG1
INT 21H

JMP NEXT

OFF1:
CALL SPACE
MOV AH,09
LEA DX,MSG1A
INT 21H

JMP NEXT
 
 
FAN2:
MOV AL,0010
MOV DX,378h
OUT DX,AL

MOV AL,0010
MOV DX,379h
IN  AL,DX

CMP AL,02
JE ON2
JNE OFF2

ON2:
CALL SPACE
MOV AH,09
LEA DX,MSG2
INT 21H

JMP NEXT

OFF2:
CALL SPACE
MOV AH,09
LEA DX,MSG2A
INT 21H

JMP NEXT

FAN3:
MOV AL,0011
MOV DX,378h
OUT DX,AL

MOV AL,0011
MOV DX,379h
IN  AL,DX

CMP AL,03
JE ON3
JNE OFF3

ON3:
CALL SPACE
MOV AH,09
LEA DX,MSG3
INT 21H

JMP NEXT

OFF3:
CALL SPACE
MOV AH,09
LEA DX,MSG3A
INT 21H

JMP NEXT


FAN4:
MOV AL,0100
MOV DX,378h
OUT DX,AL


MOV AL,0100
MOV DX,379h
IN  AL,DX

CMP AL,04
JE ON4
JNE OFF4

ON4:
CALL SPACE
MOV AH,09
LEA DX,MSG4
INT 21H

JMP NEXT

OFF4:
CALL SPACE
MOV AH,09
LEA DX,MSG4A
INT 21H

NEXT:                           ;ASK THE USER IF HE/SHE WANTS TO CONTINUE
CALL SPACE

MOV AH,09
LEA DX,MSG5
INT 21H

MOV AH,01
INT 21H

CMP AL,06EH
JE NO

CMP AL,04EH
JE NO

CMP AL,059H
JE YES

CMP AL,079H
JE YES


CALL WRONG1
CALL CLEAR
CALL ORIGIN
JMP NEXT


NO:                             ;IF THE ASWER IS NO
MOV AH,02
MOV BH,00
MOV DH,13
MOV DL,20
INT 10H                                                      
JMP END

YES:                            ;IF THE ANSWER IS YES
CALL CLEAR
CALL ORIGIN
JMP START:

                               ;IF THE USER CHOSE TO TURN OFF THE FANS
TURNOFF:
CALL SPACE
MOV AH,09
LEA DX,MSG12
INT 21H

MOV AH,08
INT 21H

CMP AL,031h
JE FANALLO

CMP AL,032h
JE FAN1X1O

CALL WRONG1
CALL CLEAR
CALL ORIGIN
JMP  TURNOFF

FANALLO:                        ;IF THE USER CHOSE TO TURN OF ALL THE FANS
MOV AL,0000
MOV DX,378h
OUT DX,AL

MOV AL,0000
MOV DX,379h
IN  AL,DX

CMP AL,00
JE OFF1B
JNE ON1B

HERE1O:

MOV AL,0000
MOV DX,378h
OUT DX,AL

MOV AL,0000
MOV DX,379h
IN  AL,DX

CMP AL,00
JE OFF2B
JNE ON2B

HERE2O:

MOV AL,0000
MOV DX,378h
OUT DX,AL

MOV AL,0000
MOV DX,379h
IN  AL,DX

CMP AL,00
JE OFF3B
JNE ON3B

HERE3O:

MOV AL,0000
MOV DX,378h
OUT DX,AL

MOV AL,0000
MOV DX,379h
IN  AL,DX

CMP AL,00
JE OFF4B
JNE ON4B

ON1B:
CALL SPACE
MOV AH,09
LEA DX,MSG1C
INT 21H

JMP HERE1O

OFF1B:
CALL SPACE
MOV AH,09
LEA DX,MSG1B
INT 21H

JMP HERE1O

ON2B:
CALL SPACE
MOV AH,09
LEA DX,MSG2C
INT 21H

JMP HERE2O

OFF2B:
CALL SPACE
MOV AH,09
LEA DX,MSG2B
INT 21H

JMP HERE2O

ON3B:
CALL SPACE
MOV AH,09
LEA DX,MSG3C
INT 21H

JMP HERE3O

OFF3B:
CALL SPACE
MOV AH,09
LEA DX,MSG3B
INT 21H

JMP HERE3O

ON4B:
CALL SPACE
MOV AH,09
LEA DX,MSG4C
INT 21H

JMP NEXT

OFF4B:
CALL SPACE
MOV AH,09
LEA DX,MSG4B
INT 21H

JMP NEXT


FAN1X1O:                        ;IF THE USER CHOSE TO TURN OF THE FAN 1BY1                
CALL SPACE
MOV AH,09
LEA DX,MSG
INT 21H

MOV AH,01
INT 21H

CMP AL,031h
JE FANO1

CMP AL,032h
JE FANO2

CMP AL,033h
JE FANO3

CMP AL,034h
JE FANO4

CALL WRONG1
CALL CLEAR
CALL ORIGIN
JMP TURNOFF


FANO1:
MOV AL,0000
MOV DX,378h
OUT DX,AL

MOV AL,0000
MOV DX,379h
IN  AL,DX

CMP AL,00
JE  OFFO1
JNE ONO1

ONO1:
CALL SPACE
MOV AH,09
LEA DX,MSG1C
INT 21H

JMP NEXT

OFFO1:
CALL SPACE
MOV AH,09
LEA DX,MSG1B
INT 21H

JMP NEXT

FANO2:
MOV AL,0000
MOV DX,378h
OUT DX,AL

MOV AL,0000
MOV DX,379h
IN  AL,DX

CMP AL,00
JE  OFFO2
JNE ONO2

ONO2:
CALL SPACE
MOV AH,09
LEA DX,MSG2C
INT 21H

JMP NEXT

OFFO2:
CALL SPACE
MOV AH,09
LEA DX,MSG2B
INT 21H

JMP NEXT  

FANO3:
MOV AL,0000
MOV DX,378h
OUT DX,AL

MOV AL,0000
MOV DX,379h
IN  AL,DX

CMP AL,00
JE  OFFO3
JNE ONO3

ONO3:
CALL SPACE
MOV AH,09
LEA DX,MSG3C
INT 21H

JMP NEXT

OFFO3:
CALL SPACE
MOV AH,09
LEA DX,MSG3B
INT 21H

JMP NEXT  

FANO4:
MOV AL,0000
MOV DX,378h
OUT DX,AL

MOV AL,0000
MOV DX,379h
IN  AL,DX

CMP AL,00
JE  OFFO4
JNE ONO4

ONO4:
CALL SPACE
MOV AH,09
LEA DX,MSG4C
INT 21H

JMP NEXT

OFFO4:
CALL SPACE
MOV AH,09
LEA DX,MSG4B
INT 21H

JMP NEXT
 

END:
MOV AH,09
LEA DX,MSG9
INT 21H

MOV AH,01
INT 21H

CMP AL,06EH
JE START

CMP AL,04EH
JE START

CMP AL,059H
JE YEAHMEN!

CMP AL,079H
JE YEAHMEN!

CALL WRONG1
CALL CLEAR
CALL ORIGIN
CALL SPACE
JMP END:

YEAHMEN!:
CALL CLEAR
CALL CENTER
MOV AH,09
LEA DX,MSG6
INT 21H          
INT 20H


Posted on 2010-10-07 11:47:43 by redprintz
What happens with a86? "won't run" isn't much to go on.

Best,
Frank

Posted on 2010-10-07 13:00:04 by fbkotler
redprintz,

Why it should compile? mov al, 0100 is a no-no in A86 land, for example.
Posted on 2010-10-07 14:06:27 by baldr
ikr!. :(
but can my teacher said that we would run the program using a86. as you can see the program is all about turning on a fan and off using assembly language and parallel ports. any hints on what can i do with the mov al,0100? is mov al,02h? please help me out. and there's also a problem saying "jump <128>" on some labels and call functions. please help. it's already due tomorrow and i need to fix the program.
Posted on 2010-10-08 00:35:59 by redprintz
I missed the "mov al, 0100" problem - good catch, baldr! The reason it won't assemble is that a86 treats any number beginning with a '0' as hex! If it were 100 decimal, it would fit (you understand that, I hope!). But 100 decimal doesn't make much sense. Judging from the "pattern", it looks to me as if those numbers are supposed to be binary. According to the manual (a86 has a nice manual!) a86 indicates binary as "100xB", for example. What's 8086 (I ASSume you mean the emulator, not the CPU) think "0100" means? If they're supposed to be binary, you could also represent them as 0, 1, 2, 4 (0100 would be 4, not 2 - you almost got that right). This applies to the numbers that you're "out"ing to the port, and comparison to the the numbers the port is "in"ing to al - not all the numbers in your program! ("in" overwrites al, so there's no point in loading something into it first - as you do repeatedly - but it won't hurt)

There is no "jump <128>". Unconditional "jmp" comes in two sizes. So do conditional jumps - apparently a86 doesn't know about the three-byte size - they weren't available before 80386, I'm surprised "8086" lets you do it. Isaacson recommends "IF cond JMP". Read chapter 8, at least!

The usual way, if a conditional jump exceeds 128 bytes, and "near" jumps aren't available, is:


; je foo - out of range
jne lillypad
jmp foo
lillypad:
; ...


This is what "IF cond JMP" would generate.

Tomorrow, eh? Good luck.

Best,
Frank

Posted on 2010-10-08 02:24:46 by fbkotler
Thanks for the advice guys. but does anyone of you know how to make GUI on a 80x25 windows? for example an outline of a box or something. :) i just need the finishing touches. do you think it'll work on my circuit?
Posted on 2010-10-08 08:19:12 by redprintz
I dunno, post the schematic! :)

Seriously, if it works, it works. That doesn't mean it's "right" - code that "works" but has bugs in it is easy!

Drawing the outline of a box isn't difficult...

http://en.wikipedia.org/wiki/Box-drawing_characters

A "GUI" really ought to be mouse-enabled... or at least handle arrow-keys, etc. You haven't got time to do a decent job with it. The trick to getting "extended" keys is that the "get char" interrupt (int 21h/1, int 21h/7, int 21h/8) returns zero - do it again to find out which key you've got. Alternately, use the bios int 16h/0 - if al is zero, look in ah to find out which key... Mouse is on int 33h, as I recall.

Here's an example that draws a box (and some other "fancy" text). This code is so old that I started it in a86, then discovered Nasm ( http://www.nasm.us ). The a86 version didn't get as far as the box, so I'll attach the Nasm version. I'll zip it up with the assembled .com file so you don't have to deal with still a third assembler. (But when you finish this class, get yourself a real assembler! Masm/Tasm/Nasm/Fasm/Jwasm... or register a86 and get a386 - a86 is a toy!) It writes "direct to screen memory", so probably won't work in a "windowed" dox-box (alt-enter to go to full-screen mode, as I recall). Might not work at all any more... you can try it, and look at the code anyway...

Best,
Frank

Attachments:
Posted on 2010-10-08 14:09:13 by fbkotler
redprintz,

GUI does mean graphic mode, doesn't it?
Posted on 2010-10-08 15:13:57 by baldr
True. I suspect that what Redprintz is looking for is a "Pitiful Text User Interface". PTUI! :)

Best,
Frank

Posted on 2010-10-08 15:44:29 by fbkotler
redprintz,

If you're trying to design windowing system in 80x25, take heed: no overlapped windows. Split this scarce visible space as you want, but don't aim for useless concept (derived from desktop paradigm): why in the name of seventh hell someone would need window if all that he/she can see is its border?
Posted on 2010-10-08 17:09:00 by baldr
We actually tried interfacing it with the circuit. I don't have the schematics but the circuit is just easy. But it seems that we can't actually "turn it on/off" the fans. :( forget the GUI part. lol, what i need now is just to run the program. anyone that has free time willing to help me debug my code? Pretty please? :)
It's our exam week already and the project was extended 1 week. So basically we need it to run this until friday. I think I'm going crazy now. Are the codes good? I mean the inputs and outputs. I can't do this on my own.  :sad:

Btw, I am running this program under vista. LOL
I know that it's wrong but I'm desperate. I have this other computer that is WinXP but FFS it doesn't have any parallel ports installed. :(
Posted on 2010-10-12 23:52:09 by redprintz
You like old folk music? You know "Barbara Allen"?


And slowly, slowly she drew up
And slowly she drew nigh him
And the only words to him did say
Young man, I think you're dyin'.


If you can't do it on your own, I think you're gonna flunk the course! But I suppose we can try to help you debug it. Once again, "what happens?" Does the program appear to run, but the fans don't turn on and off? Or does the program crash when you attempt to "out" a byte to a port? ("this program has performed an illegal operation and will be shut down"?) Are you trying to step through it with d86 (or other debugger) to see what's happening? We started off here with something that "runs perfectly in 8086". How true is that? Did it actually turn fans on and off?

"Are the codes good? I mean the inputs and outputs."

Dunno, let's take a look...


FANALL:                        ;IF FAN ALL IS CHOSEN
MOV AL,0001
MOV DX,378h
OUT DX,AL

MOV AL,0001 ; useless!
MOV DX,379h
IN  AL,DX

CMP AL,01
JE ON1A
JNE OFF1A


I'm ASSuming that those numbers are expressed in binary, "0001xB" for a86, etc.

I rather doubt if that is correct. I hope I remember this as being more complicated than it is... I think what you need to do is:  poll the "busy" bit in the status port until it goes off, put your byte on the data port, set the "strobe" bit in the control port for at least 5 microseconds, turn it back off and repeat. In order to read anything from the data port (other than the last thing written to it), you may need to enable bidirectional port (bit 5 in the control port), and probably poll the status port some more. None of this may apply to your circuit... if you're lucky.

What I would do, I think, is to set the "masterwork" aside for now, and write a bare minimum program that will turn *any* fan on - keep bashin' on it until it does! Then fit what you've learned back into the main program. Have you got any example code with your circuit - or in your textbook - that you can go by? A "spec sheet" that tells what the circuit is expecting to see, at least? Does your teacher - or grad students, perhaps - offer help sessions?

Ralf Brown's "ports.lst" has the "tables" for the bits under port 3BCh, if that helps you find it easier. They'll be the same for ports 378h, 379h, and 37Ah... if those are the right ports - I ASSume you got those numbers from somewhere.

If your OS won't let you touch the ports, of course, you'll need a new OS. Last time I ran Windows (win98), it was gettin' pissy about it - the IDE controller wouldn't work in a dos-box... I think the parallel port did... but you could boot to real dos then. I imagine it's gotten worse. If all else fails, you might be able to run from a live CD...

http://www.freedos.org/

What's the setup in the Lab - or the machine on which your teacher will evaluate your program? Shoot for as close as that as you can get. (I'm assuming you have this circuit at home/dorm. If you have to work in the lab... wow...)

Nobody around here is going to do your homework for you, but we'll help, if we can. But we haven't got the circuit... and most of us don't use a86... so you're really going to have to do the bulk of it on your own. Sleep next week. :)

Best,
Frank

Posted on 2010-10-13 03:56:20 by fbkotler
Thanks for this interesting information. Really helpful
Posted on 2010-10-13 08:43:37 by autoreg
Thank you frank. But unfortunately our professor didn't teach us anything about "poll the "busy" bit in the status port until it goes off, put your byte on the data port, set the "strobe" bit in the control port for at least 5 microseconds, turn it back off and repeat. In order to read anything from the data port (other than the last thing written to it), you may need to enable bidirectional port (bit 5 in the control port), and probably poll the status port some more." that. so basically i was a bit lost there. LOL. He only give us this syntax:
This for outputs

MOV DX, 300H ;I/O PORT ADDRESS IS 300h
MOV AL, 0FFH  ; OUTPUT DATA SENT IS FFh
OUT DX,AL      ;SEND FFh TO PORT 300h

And this for inputs

MOV DX, 310h ; I/O PORT ADDRESS IS 310h
IN    AL, DX    ; AL CONTAINS AN INPUT
                      ;DATA FROM PORT 310h


When I try it out on EMU8086 it works but unfortunately it's just an emulator. so the parallel port is not connected to any circuits. the program just works. when i tried it with a86 it still works but when i connect it to the fans it's like the program is not connected to the circuits at all. it's still the same w/ or w/o the parallel port. it just runs. like if i press "1" it says

Fan No. 1 is not working, contact the electrician immediately
Fan No. 2 is not working, contact the electrician immediately
Fan No. 3 is not working, contact the electrician immediately
Fan No. 4 is not working, contact the electrician immediately


So when i see this i tell myself "Oh, it's not yet connected to the circuit or the parallel port so maybe it doesn't detect any inputs from the circuit thus "
Fan No. 1 is not working, contact the electrician immediately" and so on. but when i connect it it's still the same.

No one is helping me. I'm just alone at this. Even my classmates don't share w/ each other. lol.
Thank you again sir. :)
Posted on 2010-10-13 09:08:11 by redprintz
No, classmates aren't supposed to help each other. That would be called "cheating". Personally, I'd call it "cooperating to solve a problem". But they're more interested in "rating" one student as "better" than another than in teaching you to cooperate to solve problems. (Do not get the grumpy old man started on the educational system!)

If your professor didn't explain anything about polling the status port (or give you something to read about it), maybe you don't have to do it, with your circuit. The syntax you show applies to any port, but what you need to "tell" it differs. You wouldn't expect to do the same thing with the keyboard controller port as you'd do with the Real Time Clock port, even though you'd use the same "in" and "out" instructions. If you don't "know" what your circuit expects, you'll have to try to figure it out. Figuring out ports by trial-and-error isn't easy, in my experience!

Start with something simple, just read the status port, and see what it says...


; org 100h - I don't think a86 needs this

mov dx, 379h
in al, dx

call show_al_bin

mov ah, 4Ch  ; exit subfunction
int 21h          ; call Good Ol' Dos
;------------------------------------------

show_al_bin:
push cx
push dx

mov cx, 8  ; 8 bits to print

show_al_bin_top:
rcl al, 1    ; rotate al and set/clear carry flag
mov dl, '0' ; start with '0'
adc dl, 0  ; "add with carry" - make it '1'... or not

push ax    ; save al, we're using it
mov ah, 2 ; print character in dl subfunction
int 21h    ; call Good Ol' Dos
pop ax      ; get al back

loop show_al_top ; do it 8 times

pop dx
pop cx
ret
; end - I don't think a86 needs this
;--------------------------------


That's untested, and may need some help to assemble with a86 (it was a long time ago I last used a86!), but you can probably get it going. Then try writing something to the data port...


...
call show_al_bin

mov dx, 378h
mov al, 1        ; we don't care if it's binary, hex, or decimal!
out dx, al

mov dx, 379h
in al, dx
call show_al_bin
...


... and read the status port again to see if anything has changed. Try reading the data port, too. I would expect it to show what you just wrote to it, but maybe not...

If the leftmost bit of the status port is a '1', that's the "busy" bit, and maybe you do have to wait for it. If the data port always reads the same thing even after you write something else to it - especially if it's always all '1's - that might be a sign that the OS is messin' with ya. As I recall, that's what happened when I tried to read the IDE controller port in a Windows "dos box", but in "real dos" the same code read the hard drive fine. I don't know what you can do if that's happening.

See if you can learn anything from it. I know time's getting short...

Best,
Frank

Posted on 2010-10-14 06:39:24 by fbkotler
Thank you for that sir. Now my problem is creating a flow chart. ughh. it doesn't get any better than this.
anyways. I've encountered visustin v6.0 but the problem is it's not cracked or you could say it's not for free.
does anyone here knows a source code to flowchart generator? damn it. tomorrow is the deadline and i'm gonna be toast!
Posted on 2010-10-14 09:09:42 by redprintz

does anyone here knows a source code to flowchart generator?


Perhaps Dia will help.
Posted on 2010-10-14 12:45:31 by SpooK