You are on page 1of 11

Include Irvine32.

inc
ExitProcess proto,dwExitCode:dword
.data
bill DWORD 0
string BYTE ' WELCOME TO STATIONERY SHOP OF FAHEEM AHMAD and
MUHAMMAD SHABAN',0dh,0ah,0
string1 BYTE ' Menu:',0dh,0ah
BYTE ' Enter 1 - Registers ',0dh,0ah
BYTE ' Enter 2 - Pencils ',0dh,0ah
BYTE ' Enter 3 - Geometry ',0dh,0ah
BYTE ' Enter 4 - Colours ',0dh,0ah
BYTE ' Enter 5 - Papers ',0dh,0ah
BYTE ' Enter 6 - Exit ',0dh,0ah,0

string2 BYTE ' Enter 1- To continue',0dh,0ah


BYTE ' Enter 2 - Exit ',0dh,0ah,0

string3 BYTE ' Enter 1 - Despatch Register = Rs 100',0dh,0ah


BYTE ' Enter 2 - Diary Register = Rs 150',0dh,0ah
BYTE ' Enter 3 - Exit ',0dh,0ah,0

buffer3 DWORD 100,150

string4 BYTE ' Enter 1 - Despatch Register = Rs 100',0dh,0ah


BYTE ' Enter 2 - Diary Register = Rs 150',0dh,0ah
BYTE ' Enter 3 - Index Register = Rs 175',0dh,0ah
BYTE ' Enter 4 - Attendance = Rs 225',0dh,0ah
BYTE ' Enter 5 - Exit ',0dh,0ah,0

buffer4 DWORD 100,150,175,225

string5 BYTE ' Enter 1 - Led Pencil = Rs 10 ',0dh,0ah


BYTE ' Enter 2 - Ink Pen = Rs 50',0dh,0ah
BYTE ' Enter 3 - Ball Points =Rs 10 ',0dh,0ah
BYTE ' Enter 4 - Marker = Rs 15 ',0dh,0ah
BYTE ' Enter 5 - Exit ',0dh,0ah,0

buffer5 DWORD 10,50,10,15

string6 BYTE ' Enter 1 - = Scale lenth(6 cm) = Rs 12 ',0dh,0ah


BYTE ' Enter 2 - = Scale lenth(12 cm) = Rs 24',0dh,0ah
BYTE ' Enter 3 - = Compass = Rs 75',0dh,0ah
BYTE ' Enter 4 - = Ruler = Rs 55',0dh,0ah
BYTE ' Enter 5 - Exit ',0dh,0ah,0

buffer6 DWORD 12,24,75,55

string7 BYTE ' Enter 1 - Led Colours 6(pieces) = Rs 90',0dh,0ah


BYTE ' Enter 1 - Led Colours 12(pieces) = Rs 150',0dh,0ah
BYTE ' Enter 3 - Permanent Light Colours = Rs 200',0dh,0ah
BYTE ' Enter 4 - Permanent Dark Colours = Rs 250',0dh,0ah
BYTE ' Enter 5 - Exit ',0dh,0ah,0

buffer7 DWORD 90,150,200,250

string8 BYTE ' Enter 1 - Cotton Paper = Rs 155',0dh,0ah


BYTE ' Enter 2 - Tag Paper = Rs 145',0dh,0ah
BYTE ' Enter 3 - Bond Paper = Rs 75',0dh,0ah
BYTE ' Enter 4 - Book Paper = Rs 60',0dh,0ah
BYTE ' Enter 5 - Exit ',0dh,0ah,0

buffer8 DWORD 155,145,75,60

spaces BYTE ' ',0

errorMsg BYTE ' Please follow instructions correctly ',0dh,0ah,0

Quantity BYTE ' Quantity: ',0

billing BYTE ' Total Bill: Rs ',0

.code
main proc
call Crlf
call Crlf
mov edx,OFFSET string
call WriteString
L1:
mov edx,OFFSET string1
call WriteString
mov edx,OFFSET spaces
call WriteString
call ReadDec
call Checkerror ; check whether user enter the number in given range

cmp eax,1 ; comparison b/w what user enter with each item of list
je L2
cmp eax,2
je L3
cmp eax,3
je L4
cmp eax,4
je L5
cmp eax,5
je L6
jmp last

L2: call Oriental ; calling procedures depends on what user enters


jmp L7
L3: call Registers
jmp L7
L4: call Pencils
jmp L7
L5: call Geometry
jmp L7
L6: call Colour
L7: mov edx,OFFSET string2
call WriteString
mov edx,OFFSET spaces
call WriteString
call ReadDec
call Checkerror1
cmp eax,1 ; if user want to continue then jump to L1
je L1
last:
call Crlf
call Crlf
mov edx,OFFSET billing
call WriteString
mov eax,bill
call WriteDec ; prints the bill
call Crlf ; next line
call Crlf
call WaitMsg
invoke ExitProcess,0
main endp

Oriental PROC

; print the oriental menu and add prices into bill according to which item of what
quantity user selects
; and call another func(NaanRoti) according to requirment
; Receives: string4, buffer4
; Returns: return updated bill
;-----------------------------------------------
mov edx,OFFSET string4
call WriteString
mov edx,OFFSET spaces
call WriteString
call ReadDec
call Crlf
call Checkerror3
cmp eax,1
je L1
cmp eax,2
je L2
cmp eax,3
je L3
cmp eax,4
je L4
cmp eax,5
jmp last
L1: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer4] ; buffer4 is array contains price of oriental foods
L11: ; quantity times a loop L11 runs
add bill,ebx ; add price into bill
loop L11
call naanroti
jmp last
L2: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer4 + 4]
L22:
add bill,ebx
loop L22
jmp last
L3: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer4 + 8]
L33:
add bill,ebx
loop L33
call NaanRoti
jmp last
L4: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer4 + 12]
L44:
add bill,ebx
loop L44

last:
ret
Oriental ENDP

NaanRoti PROC

; print the menu(naan,roti) and add prices into bill according to which item of
what quantity user selects
; Receives: string3, buffer3
; Returns: return updated bill
;-----------------------------------------------

mov edx,OFFSET string3


call WriteString
mov edx,OFFSET spaces
call WriteString
call ReadDec
call Checkerror2
cmp eax,1
je L1
cmp eax,2
je L2
jmp last
L1:
mov ebx,[buffer3] ; buuffer3 is array contains price of Naan and roti
mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
L11:
add bill,ebx
loop L11
jmp last
L2:
mov ebx,[buffer3 + 4]
mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
L22:
add bill,ebx
loop L22
last:
ret
NaanRoti ENDP

Registers PROC

; print the Registers menu and add prices into bill according to which item of what
quantity user selects
; Receives: string5, buffer5
; Returns: return updated bill
;-----------------------------------------------
mov edx,OFFSET string5
call WriteString
mov edx,OFFSET spaces
call WriteString
call ReadDec
call Crlf
call Checkerror3 ; check for error
cmp eax,1
je L1
cmp eax,2
je L2
cmp eax,3
je L3
cmp eax,4
je L4
cmp eax,5
jmp last

; price of 1st,2nd,.. item of Registers menu is on 1st,2nd.. index of buffer5


respectively
; same for all other menus

L1: mov edx,OFFSET Quantity


call WriteString
call ReadDec
mov ecx,eax
mov ebx,[buffer5]
L11:
add bill,ebx
loop L11
jmp last
L2: mov edx,OFFSET Quantity
call WriteString
call ReadDec
mov ecx,eax
mov ebx,[buffer5 + 4]
L22:
add bill,ebx
loop L22
jmp last
L3: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer5 + 8]
L33:
add bill,ebx
loop L33
jmp last
L4: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer5 + 12]
L44:
add bill,ebx
loop L44
last:

ret
Registers ENDP

Pencils PROC

; print the Pencils menu and add prices into bill according to which item of what
quantity user selects
; Receives: string6, buffer6
; Returns: return updated bill
;-----------------------------------------------
mov edx,OFFSET string6
call WriteString
mov edx,OFFSET spaces
call WriteString
call ReadDec
call Crlf
call Checkerror3
cmp eax,1
je L1
cmp eax,2
je L2
cmp eax,3
je L3
cmp eax,4
je L4
cmp eax,5
jmp last
L1: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer6]
L11:
add bill,ebx
loop L11
jmp last
L2: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer6 + 4]
L22:
add bill,ebx
loop L22
jmp last
L3: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer6 + 8]
L33:
add bill,ebx
loop L33
jmp last
L4: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer6 + 12]
L44:
add bill,ebx
loop L44
last:
ret
Pencils ENDP

Geometry PROC

; print the Geometry menu and add prices into bill according to which item of what
quantity user selects
; Receives: string7, buffer7
; Returns: return updated bill
;-----------------------------------------------
mov edx,OFFSET string7
call WriteString
mov edx,OFFSET spaces
call WriteString
call ReadDec
call Crlf
call Checkerror3
cmp eax,1
je L1
cmp eax,2
je L2
cmp eax,3
je L3
cmp eax,4
je L4
cmp eax,5
jmp last
L1: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer7]
L11:
add bill,ebx
loop L11
jmp last
L2: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer7 + 4]
L22:
add bill,ebx
loop L22
jmp last
L3: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer7 + 8]
L33:
add bill,ebx
loop L33
jmp last
L4: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer7 + 12]
L44:
add bill,ebx
loop L44
last:
ret
Geometry ENDP

Colour PROC

; print the Colour menu and add prices into bill according to which item of what
quantity user selects
; Receives: string8, buffer8
; Returns: return updated bill
;-----------------------------------------------
mov edx,OFFSET string8
call WriteString
mov edx,OFFSET spaces
call WriteString
call ReadDec
call Crlf
call Checkerror3
cmp eax,1
je L1
cmp eax,2
je L2
cmp eax,3
je L3
cmp eax,4
je L4
cmp eax,5
jmp last
L1: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer8]
L11:
add bill,ebx
loop L11
jmp last
L2: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer8 + 4]
L22:
add bill,ebx
loop L22
jmp last
L3: mov edx,OFFSET Quantity
call WriteString
call ReadDec
mov ecx,eax
call Crlf
mov ebx,[buffer8 + 8]
L33:
add bill,ebx
loop L33
jmp last
L4: mov edx,OFFSET Quantity
call WriteString
call ReadDec
call Crlf
mov ecx,eax
mov ebx,[buffer8 + 12]
L44:
add bill,ebx
loop L44

last:
ret
Colour ENDP

Checkerror PROC

; check whether eax contains value in range 1-6


; Receives: eax
; Returns: eax contains value in range 1-6 according to user's choice
;-----------------------------------------------
L1:
cmp eax,1
jl L2
cmp eax,6
jg L2
jmp last

L2:
mov edx, OFFSET errorMsg
call WriteString
call ReadDec
jmp L1
last:
ret
Checkerror ENDP

Checkerror1 PROC

; check whether eax contains value either 1 or 2


; Receives: eax
; Returns: eax contains value either 1 or 2 according to user's choice
;-----------------------------------------------
L1:
cmp eax,1
jl L2
cmp eax,2
jg L2
jmp last

L2:
mov edx, OFFSET errorMsg
call WriteString
call ReadDec
jmp L1
last:
ret
Checkerror1 ENDP

Checkerror2 PROC

; check whether eax contains value in range 1-3


; Receives: eax
; Returns: eax contains value in range 1-3 according to user's choice
;-----------------------------------------------
L1:
cmp eax,1
jl L2
cmp eax,3
jg L2
jmp last

L2:
mov edx, OFFSET errorMsg
call WriteString
call ReadDec
jmp L1
last:
ret
Checkerror2 ENDP

Checkerror3 PROC
; check whether eax contains value in range 1-5
; Receives: eax
; Returns: eax contains value in range 1-6 according to user's choice
;-----------------------------------------------
L1:
cmp eax,1
jl L2
cmp eax,5
jg L2
jmp last

L2:
mov edx, OFFSET errorMsg
call WriteString
call ReadDec
jmp L1
last:
ret
Checkerror3 ENDP

end main

You might also like