-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssembly_code.asm
More file actions
127 lines (113 loc) · 2.62 KB
/
Copy pathAssembly_code.asm
File metadata and controls
127 lines (113 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
;====================================================================
; Main.asm file generated by New Project wizard
;
; Created: Sat Jan 11 2025
; Processor: 8086
; Compiler: MASM32
;
; Before starting simulation set Internal Memory Size
; in the 8086 model properties to 0x10000
;====================================================================
CODE SEGMENT PUBLIC 'CODE'
ASSUME CS:CODE
porta EQU 68h ; Address of Port A 68 & F8 ==68
portb EQU 6Ah ; Address of Port B
portc EQU 6Ch ; Address of Port C
controlport EQU 6Eh ; Address of Control Port
START:
main:
mov al,88h ; set values for control port (100: for mode a 0 ,0 :A port is output, 1: c upper is input,0:b mode0, 0 :b port is output,0: c lowerpart dont care set as 0 )
out controlport,al
SCANNING_KEYBOARDS:
;FIRSTCOLUMN
; sending for first column
mov al,00000100b
out portb, al
; receiving for first column
in al, portc
and al,0fh ; check if any data was sent on this column
jnz column1 ; key stroke detected, jump to figure the row (exact key)
;SECOUND COLUMN
; sending for second column
mov al,00000010b
out portb, al
; receiving for second column
in al, portc
and al,0fh ; check if any data was sent on this column
jnz column2 ; key stroke detected, jump to figure the row (exact key)
;THIRD COLUMN
; sending for third column
mov al,00000001b
out portb, al
; receiving for third column
in al, portc
and al,0fh ; check if any data was sent on this column
jnz column3 ; key stroke detected, jump to figure the row (exact key)
jmp SCANNING_KEYBOARDS
column1:
;num1
cmp al,0001b
jnz num4
mov al,110b
out porta, al
jmp SCANNING_KEYBOARDS
num4:
cmp al,0010b
jnz num7
mov al,1100110b
out porta, al
jmp SCANNING_KEYBOARDS
num7:
cmp al,0100b
jnz SCANNING_KEYBOARDS
mov al,0000111b
out porta, al
jmp SCANNING_KEYBOARDS
column2:
;num2
cmp al,0001b
jnz num5
mov al,1011011b
out porta, al
jmp SCANNING_KEYBOARDS
num5:
cmp al,0010b
jnz num8
mov al,1101101b
out porta, al
jmp SCANNING_KEYBOARDS
num8:
cmp al,0100b
jnz num0
mov al,1111111b
out porta, al
jmp SCANNING_KEYBOARDS
num0:
cmp al,1000b
jnz SCANNING_KEYBOARDS
mov al,0111111b
out porta, al
jmp SCANNING_KEYBOARDS
column3:
;num3
cmp al,0001b
jnz num6
mov al,1001111b
out porta, al
jmp SCANNING_KEYBOARDS
num6:
cmp al,0010b
jnz num9
mov al,1111101b
out porta, al
jmp SCANNING_KEYBOARDS
num9:
cmp al,0100b
jnz SCANNING_KEYBOARDS
mov al,1101111b
out porta, al
jmp SCANNING_KEYBOARDS
ENDLESS:
JMP ENDLESS
CODE ENDS
END START