Assembly Language: a simple shop/store program

A small program I made a year ago in Turbo Assembler.

tasm shop assembly language

It’s a shop displaying four items, each item having 9 stocks. The user is first prompted for which item he/she wishes to buy, for the quantity of the purchase, and if he wants to buy again. The program closes once the shop runs out of stock.

.model small
.code
org 100h
s: jmp main
;—-Coded by Catzie of http://catzie.net
;—- VARIABLES —-

m01 db “ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»”,10,13,”$”
m02 db “º M Y S T O R E º”,10,13,”$”
m03 db “º º”,10,13,”$”
m04 db “º ÚÄÄÄ¿ ÚÄÄÄ¿ ÚÄÄÄ¿ ÚÄÄÄ¿ º”,10,13,”$”
m05 db “º ³ ³ ³ ³ ³ ³ ³ ³ º”,10,13,”$”
m06 db “º ÀÄÄÄÙ ÀÄÄÄÙ ÀÄÄÄÙ ÀÄÄÄÙ º”,10,13,”$”
m07 db “º A B C D º”,10,13,”$”
m08 db “º º”,10,13,”$”
m09 db “ºÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĺ”,10,13,”$”
m10 db “º º”,10,13,”$”
m11 db “º º”,10,13,”$”
m12 db “º Buy:( ) Qty:( ) Try Again?[Y/N]:( ) º”,10,13,”$”
m13 db “º º”,10,13,”$”
m14 db “º º”,10,13,”$”
m15 db “º º”,10,13,”$”
m16 db “ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ”,10,13,”$”

A db 39H,”$”
B db 39H,”$”
C db 39H,”$”
D db 39H,”$”

spacer1 db ” $”

vBelowZERO db “Not enough items to sell.$”
vClose db “All items sold out! Thank you.$”

main proc near
mov ax,03
int 10h

cls1: cmp A,”0″
je cls2
jne clsNOT
cls2: cmp B,”0″
je cls3
jne clsNOT
cls3: cmp C,”0″
je cls4
jne clsNOT
cls4: cmp D,”0″
je cls5
jne clsNOT

cls5: call closeProg
call exit

clsNOT:
call dispMenu

call qtyA
call qtyB
call qtyC
call qtyD

call clrError

call buyCursor
call input ;input for Buy
cmp al,”A”
je inA
cmp al,”B”
je inB
cmp al,”C”
je in_C
cmp al,”D”
je inD

inA:call inputA
call tryAgain

inB:call inputB
call tryAgain

in_C:call inputC
call tryAgain

inD:call inputD
call tryAgain

call exit

;—-Coded by Catzie Keng of http://catzie.net
;——- inputA, inputB, inputC, inputD ——-
inputA proc
call qtyCursor
call input ;input for Qty
add A,30h
sub A,al
call qtyA
call tryAgain
inputA endp

inputB proc
call qtyCursor
call input ;input for Qty
add B,30h
sub B,al
call qtyB
call tryAgain
inputB endp

inputC proc
call qtyCursor
call input ;input for Qty
add C,30h
sub C,al
call qtyC
call tryAgain
inputC endp

inputD proc
call qtyCursor
call input ;input for Qty
add D,30h
sub D,al
call qtyD
call tryAgain
inputD endp

;————————————-

closeProg proc
mov ah,2
mov bh,0
mov dl,4
mov dh,13
int 10h
mov ah,9
lea dx,vClose
int 21h
ret
closeProg endp

tryAgain proc
call tryAgainCursor
call input
cmp al,”N”
je exit1
cmp al,”Y”
je again
again: call main
exit1:call exit
ret
tryAgain endp

;——- qtyA, qtyB, qtyC, qtyD ——-
qtyA proc
mov cl, al
mov ah,2
mov bh,0
mov dl,6
mov dh,4
int 10h
cmp A,30h ;30h is 0
jb belowZEROA

mov ah,9
lea dx,A
int 21h
ret
belowZEROA: call pBelowZERO
add A,cl
sub A, 30h
ret
qtyA endp

qtyB proc
mov cl, al
mov ah,2
mov bh,0
mov dl,17
mov dh,4
int 10h
cmp B,30h ;30h is 0
jb belowZEROB

mov ah,9
lea dx,B
int 21h
ret
belowZEROB: call pBelowZERO
add B,cl
sub B, 30h
ret
qtyB endp

qtyC proc
mov cl, al
mov ah,2
mov bh,0
mov dl,28
mov dh,4
int 10h
cmp C,30h ;30h is 0
jb belowZEROC

mov ah,9
lea dx,C
int 21h
ret
belowZEROC: call pBelowZERO
add C,cl
sub C, 30h
ret
qtyC endp

qtyD proc
mov cl, al
mov ah,2
mov bh,0
mov dl,38
mov dh,4
int 10h
cmp D,30h ;30h is 0
jb belowZEROD

mov ah,9
lea dx,D
int 21h
ret
belowZEROD: call pBelowZERO
add D,cl
sub D,30h
ret
qtyD endp

;—————————————-
pBelowZERO proc
mov ah,2
mov bh,0
mov dl,4
mov dh,13
int 10h
mov ah,9
lea dx,vBelowZERO
int 21h
ret
pBelowZERO endp

clrError proc
mov ah,2
mov bh,0
mov dl,1
mov dh,13
int 10h
mov ah,9
lea dx, spacer1
int 21h
ret
clrError endp

tryAgainCursor proc
mov ah,2
mov bh,0
mov dl,39
mov dh,11
int 10h
ret
tryAgainCursor endp

qtyCursor proc
mov ah,2
mov bh,0
mov dl,17
mov dh,11
int 10h
ret
qtyCursor endp

input proc
mov ah,1
int 21h
ret
input endp

buyCursor proc
mov ah,2
mov bh,0
mov dl,7
mov dh,11
int 10h
ret
buyCursor endp

dispMenu proc
mov ah,9
lea dx,m01
int 21h
lea dx,m02
int 21h
lea dx,m03
int 21h
lea dx,m04
int 21h
lea dx,m05
int 21h
lea dx,m06
int 21h
lea dx,m07
int 21h
lea dx,m08
int 21h
lea dx,m09
int 21h
lea dx,m10
int 21h
lea dx,m11
int 21h
lea dx,m12
int 21h
lea dx,m13
int 21h
lea dx,m14
int 21h
lea dx,m15
int 21h
lea dx,m16
int 21h
ret
dispMenu endp

exit:
;—-Coded by Catzie Keng of http://catzie.net
int 20h
main endp
end s

Related Posts:

Posts that may be related to "Assembly Language: a simple shop/store program":

Catzie

A Filipino programmer with a variety of interests such as baking, singing, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert flavors, obsessing about finding out how some things works, board games, anime, video games, and forgetting things that usually go in her long list of interests. Running small-time online dessert shops Cookies PH and Catzie's Cakery.

5 comments on “Assembly Language: a simple shop/store program

 

  1. hi.. i try to run your program but an error occur.. error says

    –>. unexpected end of file encountered.. how can i fix it?? thanks alot.. 🙂

  2. thanks a lot for this,,we had a project in programming about making a store program wherein buyer can ofcourse buy and can also add items to the stock, there are also 4 candies and up to 99 maximum items, this really helped a lot ,, btw for those interested I edited the above program to meet my project requirements

  3. i have encountered the same problem with eac..

    how do you solve it..

    thanks a lot for this by the way..

    😀

  4. I am trying to make a program that will multiply the first and the second number and subtract it from the 3rd number>> n3-(n1+n2).. but I don’t know how… please help this computation is needed in my project….

Leave a Reply

Your email address will not be published. Required fields are marked *