I am working on a lab for school that i need some help on.
The requirements are:
write a program that will continously input any 8-bit number 0-99 from a group of switches designated as port 1 and connected to the isa bus of the pc. (at school they have the boards hooked up so i just need to do the code)
Each time the PC inputs an 8-bit bcd from port 1 it should output the 8-bit inputted number to a group of 8 leds designates as port also connected to isa bus. The displayed BCD should flash at a 1-second rate on the led's. In addition the system should display the bcd number in the center of the pc screen as a decimal number and flash at a 4 second On, 4 second off rate.
must be white characters on a red background. also the message "the bcd number is equal to" must be on the screen as well in black characters not blinking. only the number flashes.
Well started but ran into some trouble as far as the screen color. It works if i make it all one color but once i put the second set of attributes in it causes problems. I basically used one sr to set the attributes and then had two seperate values for splitting the screen where the message ends and the decimal number starts for now i just have my name there.
I know the color is off and the actual row and column number is too i have just been playing around with it for a while now.
Also i am not sure how to put in a counter in the delay sr so after 4 flashes it will display a different message
Once that works instead of flashing a message 4 times i will just output the bcd to the leds then after the forth flash the decimal number will flash on the screen.
I will paste the code below if anyone feels like giving me a hand i would appreciate it
Thanks
PAGE 60,132
STSEG SEGMENT STACK 'STACK'
DB 64 DUP(?)
STSEG ENDS
DTSEG SEGMENT 'DATA'
MESSAGE DB 'THE BCD NUMBER IS EQUAL TO ','$'
MESSAGE1 DB 'PETE','$'
CLEAR DW 0000H ;CLEAR SCREEN STARTING AT ROW COL
CLEARE DW 3854H ;CLEAR SCREEN TO ROW COL
COLOR DB 71H ;COLOR 0=BLACK BACKGROUND 1=BLUE LETTERS
CURSOR DW 1313H ;CURSOR POSITION ROW COL
DELAY DB 08H
CLEAR2 DW 0024H
CLEARE2 DW 3854H
COLOR2 DB 77H
DTSEG ENDS
CDSEG SEGMENT 'CODE'
MAIN PROC FAR
ASSUME CS: CDSEG, DS:DTSEG, SS:STSEG
MOV AX, DTSEG
MOV DS, AX
;-----------------------------
BACK: MOV BH, COLOR
MOV CX, CLEAR
MOV DX, CLEARE
CALL CLEAR_SR
MOV DX, CURSOR
CALL CURSOR_SR
MOV DX, OFFSET MESSAGE
CALL DIS_SR
; MOV BH, COLOR2
; MOV CX, CLEAR2
; MOV DX, CLEARE2
; CALL CLEAR_SR
;MOV DX, CURSOR2
;CALL CURSOR_SR
MOV DX, OFFSET MESSAGE1
CALL DIS_SR ;DIPLAY MESSAGE
MOV BL, DELAY ;SETUP DELAY TIME
CALL DELAY_SR ;DELAY THE DISPLAYED MESSAGE
MOV BH, COLOR2
MOV CX, CLEAR
MOV DX, CLEARE
CALL CLEAR_SR ;TURN OFF THE SCREEN
MOV BL, DELAY
CALL DELAY_SR ;DELAY THE BLANK CLEARED SCREEN
MOV AX,0H
MOV BL,1BH
CALL ESC_SR
JMP BACK
MAIN ENDP
;----------------
CLEAR_SR PROC
PUSH AX
MOV AX, 0600H
INT 10H
POP AX
RET
CLEAR_SR ENDP
;----------------
CURSOR_SR PROC
PUSH AX
PUSH BX
MOV AH, 02
MOV BH, 00
INT 10H
POP BX
POP AX
RET
CURSOR_SR ENDP
;------------------
DIS_SR PROC
PUSH AX
MOV AH,09
INT 21H
POP AX
RET
DIS_SR ENDP
;-------------
ESC_SR PROC
MOV AH, 01
INT 16H
CMP AL,BL
JNE RETURN
INT 03H
RETURN: RET
ESC_SR ENDP
;---------------
DELAY_SR PROC
PUSH AX
BACK: MOV CX, 33144 ;1/2 SECOND DELAY
WAITF1:
IN AL,61H
AND AL,10H
CMP AL,AH
JE WAITF1
MOV AH,AL
LOOP WAITF1
DEC BL
JNZ BACK
POP AX
RET
DELAY_SR ENDP
;--------------
CDSEG ENDS
END MAIN
The screen defaults to 80x25, so the bottom row is 24 and the right-most column is 79. The value 3854H for CLEARE is specifying 38h = 56 for the bottom row, and 54h = 84 for the right-most column. It would be easier to avoid these sorts of errors if you would load the byte registers individually with decimal values:
mov dh, 24
mov dl, 79
The same goes for the cursor position.
For the default 16-color alphanumeric modes the attribute byte layout is:
blinking red green blue intensity red green blue
| background | | foreground |
The blinking bit controls foreground blinking, but this is probably not useful for what your are doing. For a white foreground on a red background, the attribute byte should be 47h, or 4Fh for a hi-intensity white foreground on a red background. Since the white characters must flash I would clear the screen using this attribute. You could erase the white characters by changing the attribute bytes in the area to 44h (red on red). Because the characters would not be disturbed, you could restore them by setting the attribute back to 47h (or 4Fh). To write the black characters to the screen you could use the BIOS to clear that area of the screen to 40h (black on red), and then write the characters to the screen. If I were doing this I would use the BIOS Write Teletype (ah = 0Eh) function to write characters to the screen (note that the foreground attribute parameter applies only for graphics modes).
I think a good way to handle the timing would be to use the BIOS Even Wait function (Interrupt 15h, function 83h). You could do everything from two nested loops. The outer loop would program the Event Wait function for a one-second delay. The inner loop would poll for and handle any keyboard or input port activity, and poll the Even Wait output byte. Each time the Even Wait function timed out:
The one-second update would be performed.
The four-second counter would be incremented, and when it reached a value of four the four-second update would be performed and the counter reset to zero.
The loop would then exit and execution would continue at the start of the outer loop, starting a new one-second delay and entering the inner loop.
I'm not sure what you are doing with the Int 3 in the ESC_SR procedure. If you want the program to terminate there you should call Interrupt 21h function 4Ch.
Thanks for your input
I will play around keeping your advice in mind and get back to u.
About the delay we have not done anything with int 15h or int 83h so will probally stay away from that route.
Can you give me any help with working with the delay that i am using now?
Thanks Again
The delay code you are currently using is counting refresh toggles. AFAIK the system BIOS uses this method to implement accurate short delays. The BIOS programs PIT timer 1 for mode 2 (rate generator) and binary count, with an initial count of 12h = 18. With an input frequency of 1193282Hz there are 1193182 / 18 / 2 = 33144 toggles per half second, so your loop count value is correct. Your code has a potential problem in that it checks only one state of the toggle, so depending on the duration of the toggle 'on' state, the speed of the CPU, bus delays, etc, the code could potentially count a single toggle more than once. For reliability I would use two loops, one to wait for the bit to be set, and one to wait for it to be cleared. Another problem is that when running under Windows NT/2000/XP the toggle does not run at the 'normal' rate. On my Windows 2000 system a half-second delay requires a loop count of ~46500.