Write a program which collects in data samples, Computer Engineering

Assignment Help:

Write a program which collects in data samples from a port at 1 ms interval. The upper 4 bits collected data same as mastered and stored in an array in successive locations.

; REGISTERS: Uses CS, SS, DS, AX, BX, CX, DX, SI, SP

; PROCEDURES: Uses WAIT

DATA_SEG       SEGMENT

            PRESSURE DW 100 DUP (0); Set up array of 100 words

NBR_OF_SAMPLES EQU 100    

            PRESSURE_PORT EQU 0FFF8h     ; hypothetical input port

DATA_SEG       ENDS

STACK_SEG SEGMENT STACK

            DW 40    DUP (0)    ; set stack of 40 words

STACK_TOP   LABEL WORD

STACK_SEG   ENDS

 

CODE_SEG SEGMENT

            ASSUME CS: CODE_SEG, DS: DATA_SEG, SS: STACK_SEG

START:           MOV   AX, DATA_SEG; Initialise data segment register

MOV DS, AX  

MOV AX, STACK_SEG   ; Initialise stack segment register

MOV SS, AX  

MOV SP, OFFSET STACK - TOP    ; initialise stack pointer top of 

                                                ; stack

LEA SI, PRESSURE; SI points to start of array 

     ; PRESSURE

MOV BX, NBR_OF_SAMPLES   ; Load BX with number

                        ; Of samples

MOV DX, PRESSURE_PORT   ; Point DX at input port

                                                ; It can be any A/D converter or 

                                                ; Data port.

READ_NEXT: IN AX, DX   ; Read data from port

            ; Please note use of IN instruction

            AND AX, 0FFFH; Mask upper 4 bits of AX

            MOV [SI], AX   ; Store data word in array

            CALL WAIT   ; call procedures wait for delay  

INC SI; Increment SI by two as dealing with 

INC SI; 16 bit words and not bytes

DEC BX; Decrement sample counter

JNZ READ_NEXT   ; Repeat till 100

      ; Samples are collected

STOP: NOP    

WAIT   PROC NEAR  

            MOV CX, 2000H   ; Load delay value

                                     ; Into CX

HERE:   LOOP HERE   ; Loop until CX = 0

            RET    

WAIT   ENDP    

CODE_SEG ENDS    

END    

Discussion:

Please consider that CALL to the procedure as above doesn't specify whether the call is to a FAR procedure or a NEAR procedure. This distinction is made at the time of defining the procedure. 

 

The procedure above can be converted in a FAR procedure by changing the definition of procedure as below:

WAIT              PROC FAR

 .

 .

WAIT             ENDS

The procedure can now be statedin another segment if the need to be, in same assembly language file.


Related Discussions:- Write a program which collects in data samples

Write a pseudo code to find sum of two functions, Q. Write a pseudo code to...

Q. Write a pseudo code to find sum of two functions? Let's write a pseudo code to find sum of two functions f(A) + f(B). In first algorithm we will not use locking. Process

What are condition codes, What are condition codes? In many processors,...

What are condition codes? In many processors, the condition code flags are kept in the processor status register. They are either set are cleared by lots of instructions, so th

Explain macro definition and call, Explain Macro definition and call. ...

Explain Macro definition and call. Macro: The assembly language programming frequently finds this necessary to repeat certain piece of code several times during the course of

Describe ergonomic keyboards, Q. Describe Ergonomic Keyboards? Ergonomi...

Q. Describe Ergonomic Keyboards? Ergonomics is the study of environment, conditions as well as efficiency of workers. Ergonomics proposes that keyboard wasn't designed with hum

Recombination - canonical genetic algorithm, Recombination: Therefore...

Recombination: Therefore during the selection and mating process then the GA repeatedly lines up pairs of individuals for reproduction. Hence the next question is how to gener

Send a report to the printer, How to send a report to the printer instead o...

How to send a report to the printer instead of displaying it on the screen? We can send a report to the printer instead of displaying it on the screen.  To do this, use the key

Concept of multithreading, Concept of Multithreading: This problem ris...

Concept of Multithreading: This problem rises in design of large scale multiprocessors like MPP. So a solution for optimizing this latency must be acquired at. The idea of Mul

Explain the process of inter-register signalling, Explain the process of in...

Explain the process of inter-register signalling. Registers are utilized in common control exchanges to store and analyze routing data. They are given on a common basis is a

Higher order predicate logic - artificial intelligence, Higher Order Predic...

Higher Order Predicate Logic: In first order predicate logic, we are allowed to quantify over objects only. If we let  ourselves  to  quantify  over  predicate  or  function  s

Operation of micro controller, Consider the hardware design as shown. Withi...

Consider the hardware design as shown. Within the target system the EPROM would contain the hex data as shown below   Address  Assembly code   8000             86   8001

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd