-
Notifications
You must be signed in to change notification settings - Fork 15
/
garment_defect.asm
96 lines (77 loc) · 2.32 KB
/
garment_defect.asm
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
;Design and Emulate a smart automation system for a garment manufacturing unit with
;the following requirements:-
; To detect all possible defects.
; To remove the defective pieces.
; To provide comprehensive inventory report.
data segment
num1 db ?
num2 db ?
line DB 1h,2h,3h,4h,5h,6h,7h,8h,9h,0h;
MSG1 DB 10,13,"Threshold 1: $"
MSG2 DB 10,13,"Threshold 2: $"
MSG3 DB 10,13,"Defect detected $"
MSG4 DB 10,13,"Defect removed $"
MSG5 DB 10,13,"Good clothes: $"
MSG6 DB 10,13,"Bad clothes: $"
good db ?
bad db ?
data ends
code segment
assume cs:code, ds:data
start: mov ax, data
mov ds, ax
mov cx, 0bh ;set up loop counter
mov good,0Ah
mov bad,0000H
lea dx,msg1 ;load and display message 1
mov ah,9h
int 21h
mov ah,1h ;read character from console
int 21h
sub al,30h ;convert from ASCII to BCD
mov num1,al ;store number as num1
lea dx,msg2 ;load and display message 2
mov ah,9h
int 21h
mov ah,1h ;read character from console
int 21h
sub al,30h ;convert from ASCII to BCD
mov num2,al ;store number as num2
up: mov al,byte ptr[SI] ;compare next
cmp al,num1
jl dft
cmp al,num2
jl dft
jmp nxt
dft: lea dx,msg3 ;load and display message 3
mov ah,9h
int 21h
mov [si],0000H ;remove defect
inc bad
lea dx,msg4 ;load and display message 4
mov ah,9h
int 21h
jmp nxt
nxt: inc si ;point to next grade
dec cx
jnz up
lea dx,msg5 ;load and display message 5
mov ah,9h
int 21h
xor ax,ax
mov al,bad
sub good,al
add good,30h ;ASCII adjust before displaying
mov dl,good
mov ah,2h ;display it
int 21h
lea dx,msg6 ;load and display message 6
mov ah,9h
int 21h
add bad,30h ;ASCII adjust before displaying
mov dl,bad
mov ah,2h ;display it
int 21h
hlt
code ends
end start