Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assembly Language programming help. I need to finish writing a program for this

ID: 657611 • Letter: A

Question

Assembly Language programming help.

I need to finish writing a program for this assignment. Here's the problem:

Write a 32-bit assembly language that interacts with a User and processes a variety of transactions, acting like an inventory program. Your inventory program must be able to keep track of eight (8) different products that are stored at six (6) different warehouses.

Your program must welcome the User and describe any procedures for using your program. The User should then be prompted for a choice of actions from the following list:

      I - INITIALIZE the number of all of the products stored at all of the warehouses to zero (0).

      R - RECEIVE a quantity of a product at a warehouse.

      S - SHIP a quantity of a product from a warehouse.

      T - TRANSFER a quantity of a product from one warehouse to another.

      P - PUBLISH a report showing how many of each product is stored at each warehouse.

      F - FILE processing of a series of transaction codes and their associated parameters. See notes for the details of this file structure.

      X - EXIT choice.

Some of the actions selected by the User require no additonal input, while others require multiple interactions to identify the parameters of the transaction requested by the USER.

Explanation / Answer

mov ax, cs

mov ds, ax

mov ax, 0b800h

mov es, ax

mov bh, b[color]

call clrscr

mov b[row], 12

mov b[col], 34

call setCursor

lea dx, menu_main

call printStr

mov bh, 70h

mov si, (160*11)+(2*33)

mov w[xCoor], 10

mov w[yCoor], 7

call createFrame

mov si,(160*12)+(2*34)

mov bh, 7h

mov w[xCoor], 8

mov b[selectPosition], 0

mov b[lowerLimit], 4

call highlight

mov b[selectMode], 0

call select

int 20h

select: mov b[terminate], 0

ask3: call getChar

cmp ah, 48h

if e call upKey

cmp ah, 50h

if e call downKey

cmp al, 0dh

if e call enterKey

cmp b[terminate], 0

if ne ret

jmp ask3

;MOVE SELECTION UP

upKey: cmp b[selectPosition], 0

if e ret

mov bh, 70h

call highlight

sub si, 160

mov bh, 7h

call highlight

dec b[selectPosition]

ret

;MOVE SELECTION DOWN

downKey: mov bh, b[lowerLimit]

cmp b[selectPosition], bh

if e ret

mov bh, 70h

call highlight

add si, 160

mov bh, 7h

call highlight

inc b[selectPosition]

ret

;PROCESS ENTER KEY

enterKey: cmp b[selectMode], 0

if e call fromMainMenu

cmp b[selectMode], 1

if e call fromSearch1

cmp b[selectMode], 2

if e call fromSearch2

ret

;COMPARE selectPosition AND CALL CORRESPONDING FUNCTION

fromMainMenu: cmp b[selectPosition], 0

if e call funcAppend

cmp b[selectPosition], 1

if e call funcEdit

cmp b[selectPosition], 2

if e call funcSearch

cmp b[selectPosition], 3

if e call funcDelete

cmp b[selectPosition], 4

if e mov b[terminate], 1

mov b[terminate], 1

ret

getInput: mov bx,0

   lol:

  

call getChar

mov ah,2

mov dl,al   

int 21h

loop lol

ret

fromSearch1: mov b[terminate], 1

ret

fromSearch2: ret

;ADD FUNCTION

funcAppend: ret

;EDIT FUNCTION

funcEdit: ret

;SEARCH FUNCTION

funcSearch: call product_search

ret

;DELETE FUNCTION

funcDelete:

       mov bh, b[color]

call clrscr

mov si, (160*10)+(2*28)

mov bh, 70h

mov b[xCoor], 36

mov b[yCoor], 5

call createFrame

mov b[row], 11

mov b[col], 29

call setCursor

lea dx, menu_delete

call printStr

     

mov b[row], 11

mov b[col], 40

call setCursor

mov cx, 6

call getInput

lea si, buffer

   mov cx,6

     

cmp b[valid],0

je searchend

           

   lea di,buffer2

  

   searchend:

mov ah,0

int 16h

call idsearch

ret

;GETS A CHARACTER WITHOUT ECHO

getChar: mov ah, 0

int 16h

ret

;HIGHLIGHTS AN ITEM IN A MENU

;(SI - SET LOCATION, BH - ATTRIBUTE, xCoor - LENGTH TO BE HIGHLIGHTED)

highlight: push si

mov cx, w[xCoor]

change: mov b[es:si+1], bh

add si, 2

loop change

pop si

ret

;CREATES A FRAME

;SI - LOCATION OF THE UPPERLEFT CORNER OF FRAME

;yCoor - HEIGHT OF FRAME (VERTICAL)

;xCoor - WIDTH OF FRAME (HORIZONTAL)

;BH - COLOR OF FRAME

createFrame: mov cx, w[yCoor]

ordinate:

push si

push cx

mov cx, w[xCoor]

abcissa:

mov b[es:si+1], bh

add si, 2

loop abcissa

pop cx

pop si

add si, 160

loop ordinate

ret

color db 17h

xCoor: dw ?

yCoor: dw ?

terminate: db ?

selectPosition: db ?

selectMode: db ?

lowerLimit: db ?

menu_main: db ' Append ', 0a, 8 dup(8),

db ' Edit ', 0a, 8 dup(8),

db ' Search ', 0a, 8 dup(8),

db ' Delete ', 0a, 8 dup(8),

db ' Exit ', '$'

menu_search1: db ' SEARCH BY PRODUCT ID ', 0a, 22 dup(8),

db ' SEARCH BY CATEGORY ', 0a, 22 dup(8),

db ' RETURN ', '$'

menu_search2: db ' SEARCH OPTICAL DRIVES ', 0a, 23 dup(8)

db ' SEARCH HARD DISKS ', 0a, 23 dup(8)

db ' SEARCH MOTHERBOARDS ', 0a, 23 dup(8)

db ' SEARCH PROCESSORS ', 0a, 23 dup(8)

db ' SEARCH VIDEO CARD ', 0a, 23 dup(8)

db ' SEARCH MEMORY ', 0a, 23 dup(8)

db ' SEARCH OTHERS ', 0a, 23 dup(8)

db ' RETURN ', '$'

menu_delete: db 'PRODUCT ID: ', 0a, 34 dup(8),

   db ' ', 0a, 34 dup(8),

db 'PRESS <ESC> TO RETURN TO MAIN MENU', '$'

;==============================================================

categorysearch:

  

              ;insert choices here

   cmp b[choice],1

if e call set2

cmp b[choice],2

if e call set3

   cmp b[choice],3

if e call set4

   cmp b[choice],4

if e call set5

    cmp b[choice],5

if e call set6

   cmp b[choice],6

if e call set7

   cmp b[choice],7

if e call set8

   lea di,buffer

   mov cx,6

   lea di,buffer

   call transfer

  

  

   mov dx, offset border3

call printStr

   call catsearch

   mov ah,0

   int 16h

              

ret

catsearch:

  

   mov w[datalen],34

mov cx,34

   lea dx, file1

   call openfile

   mov al, 2

   mov w[fp_COF], 0

   call MOVE_POINTER

   mov w[fp_EOF], ax

mov w[fp_SOF],0

   cmp ax,0

   if e ret

      

   mov b[row],3

   cprint:

   mov b[col],4

call CLEAR_BUFFER

   mov al, 0

mov bx, w[fp_SOF]

mov w[fp_COF], bx

call MOVE_POINTER

   mov cx,w[datalen]

  

   call readfile

   lea di,buffer2

   add di,6

   lea si,buffer

   mov cx,6

   call check3

   cmp b[valid],1

   JNE next1

     

   lea di,buffer2

   call printbuffer

   add b[row],1

next1:

   mov ax,w[datalen]

   add w[fp_SOF],ax

mov ax, w[fp_EOF]

cmp w[fp_SOF], ax

jne cprint

ret

set2:

lea si,file2

ret

set3:

lea si,file3

ret

set4:

lea si,file4

ret

set5:

lea si,file5

ret

set6:

lea si,file6

ret

set7:

lea si,file7

ret

set8:

lea si,file8

ret   

  

transfer:

  

   trans:

   mov al,b[si]

   mov b[di],al

   add di,1

   add si,1

   loop trans

ret

product_search:

call clrscr

mov b[row], 10

mov b[col], 28

call setCursor

mov dx, offset askid

call printStr

   lea si,buffer

   mov cx,6

   ask:

   mov ah,0

   int 16h

   cmp al,08h

if e call backspace

cmp al,'0'

   jl ask

   cmp al,'9'

   jg ask

   mov ah,2

   mov dl,al

   int 21h

   mov b[si],al

   add si,1

   loop ask

  

   call clrscr

mov dx, offset border3

   call printStr

   call idsearch

   cmp b[valid],0

je searchend1

           

   lea di,buffer2

   mov b[row],3

   mov b[col],4

call printbuffer

   searchend1:

mov ah,0

int 16h

ret

;============================Remove a string from Product Search=========================

backspace:

   cmp cx,6

if e ret

   mov ah,2

   mov dl,08h

   int 21h

   add cx,1

   push cx

   pop cx

   sub si,1

   mov ah,2

   mov dl,' '

   int 21h

   mov ah,2

   mov dl,08h

   int 21h

   ret

;===========================Display Characters to the screen============================

printStr:

mov ah, 9

int 21h

ret

clrscr:

mov ax, 3

int 10h

mov si, 1

mov cx, 2000

clear:

mov b[es:si], 17h

add si, 2

loop clear

ret

;==================================Product ID Search Program=============================

idsearch:

   lea dx, file1

   mov w[datalen],34

mov cx,34

   call scheck

ret

  

scheck: ;return 0 or 1

   mov b[valid],0

call openfile

   mov al, 2

   mov w[fp_COF], 0

   call MOVE_POINTER

   mov w[fp_EOF], ax

mov w[fp_SOF],0

cmp ax, 0

if e ret

   check:

call CLEAR_BUFFER

   mov al, 0

mov bx, w[fp_SOF]

mov w[fp_COF], bx

call MOVE_POINTER

   mov cx,w[datalen]

  

   call readfile

   lea di,buffer2

lea si,buffer

   mov cx,6

call check3

cmp b[valid],1

   JNE fend   

ret

   fend:

mov ax,w[datalen]

   add w[fp_SOF],ax

mov ax, w[fp_EOF]

cmp w[fp_SOF], ax

jne check

mov b[valid],0

ret

check3:

mov b[valid],0

compare:

   mov al,b[si]

   mov bl,b[di]

   cmp al,bl

   if ne ret

   add si,1

   add di,1

loop compare

mov b[valid],1

  

ret

;===============================Display The information Received from the Files open=================

printbuffer:

   call setcursor

mov cx, 6

call print2

add b[col],12

   call setcursor

mov cx, 6

call print2

   add b[col],12

   call setcursor

mov cx, 15

call print2

   add b[col],25

   call setcursor

mov cx, 3

call print2

   add b[col],15

   call setcursor

mov cx, 4

call print2

  

ret

print2:

mov dl,b[di]

mov ah,2

int 21h

add di,1

loop print2

ret

setCursor: ;accept dh,dl

mov ah, 2

mov bh, 0

   mov dh,b[row]

   mov dl,b[col]

int 10h

ret

openfile: ; accept dx as file

mov ah,3dh

mov al,2

int 21h

mov w[handle],ax

ret

readfile: ; accepts cx

mov ah,3fh

mov bx,w[handle]

lea dx,buffer2

int 21h

ret

MOVE_POINTER:

mov ah,42h

mov bx,w[handle] ;accept al,w[fp_COF]

mov cx,0

mov dx, w[fp_COF]

int 21h

ret

CLEAR_BUFFER:

mov al, ' '

lea si, buffer2

mov cx, 34

c1:

mov b[si], al

inc si

loop c1

ret

;=========================

fp_EOF dw ?

fp_COF dw ?

fp_SOF dw ?

datalen db '0$'   

valid db '0$'

askid db 'Enter Product #: $'

buffer db 6 dup(20h)

buffer2 db 34 dup(20h)

handle dw ?

file1 db 'record.txt', 00H

file2 db 'optdsk'

file3 db 'hardsk'

file4 db 'mboard'

file5 db 'prcssr'

file6 db 'vcards'

file7 db 'memory'

file8 db 'others'

mess1 db 'item #$'

mess2 db 'category$'

mess3 db 'product$'

mess4 db 'quantity$'

mess5 db 'price$'

row db ?

col db ?

choice db '0$'

;=========================Display The Table=============================

border3: db 201, 13 dup(205), 203, 10 dup(205), 203, 22 dup(205),203,12 dup(205), 203,16 dup(205), 187,0a, 79 dup(8),

db 186, 1 dup(' Product # '), 186, 1 dup(' Category '), 186, 1 dup(' Product '),186,1 dup(' Quantity '),186,1 dup(' Price '), 186,0a, 79 dup(8),

db 186, 13 dup(205), 206, 10 dup(205), 206, 22 dup(205),206,12 dup(205), 206,16 dup(205), 185,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 186, 13 dup(' '), 186, 10 dup(' '), 186, 22 dup(' '),186,12 dup(' '), 186,16 dup(' '), 186,0a, 79 dup(8),

db 200, 13 dup(205), 202, 10 dup(205), 202, 22 dup(205),202,12 dup(205), 202,16 dup(205), 188,'$'

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote