MOV BL,1E ; Moves value ( 1E – 30SECS ) into BL
CALL 80 ; Call Subroutine 80 (delay routine)
; AMBER / RED
MOV AL,50 ; Copy 10100000 into the AL register.
OUT 01 ; Send AL to Port One (The traffic lights).
MOV BL,02 ; Moves value ( 2 ) into BL
CALL 80 ; Call Subroutine 80 (delay routine)
; RED / RED
MOV AL,90 ; Copy 01010000 into the AL register.
OUT 01 ; Send AL to Port One (The traffic lights).
MOV BL,01 ; Moves value ( 1 ) into BL
CALL 80 ; Call Subroutine 80 (delay routine)
; RED / RED AMBER
MOV AL,98 ; Copy 10011000 into the AL register.
OUT 01 ; Send AL to Port One (The traffic lights).
MOV BL,02 ; Moves value ( 2 ) into BL
CALL 80 ; Call Subroutine 80 (delay routine)
; RED / GREEN
MOV AL,84 ; Copy 10000100 into the AL register.
OUT 01 ; Send AL to Port One (The traffic lights).
MOV BL,F ; Moves value ( F – 15SECS ) into BL
CALL 80 ; Call Subroutine 80 (delay routine)
; RED / AMBER
MOV AL,88 ; Copy 10010000 into the AL register.
OUT 01 ; Send AL to Port One (The traffic lights).
MOV BL,02 ; Moves value ( 2 ) into BL
CALL 80 ; Call Subroutine 80 (delay routine)
JMP Start ; Jump back to the start.
ORG 80 ; Subroutine 80 ( Delay Routine )
flag:
CMP BL,0 ; Compare BL to ( 0 )
JNZ flag ; Jump if not ( 0 )
RET ; Return to where it was called from
ORG 90 ; Subroutine 90 ( Interrupt Routine )
DEC BL ; Decrement BL by ( 1)
IRET
END ; End Program
; Program Ends
3.0
Question A
Discuss the basic architecture and operation of the micro-simulator that you have been using in the practical work.
The simulator consists of a central processing unit, 256 bytes of random access memory and 16 input output ports. There is a hardware timer that triggers interrupt 02 at regular time intervals that can be pre-set using the configuration tab. All the calculations and decisions are made in the CPU. This has an arithmetic and logic unit where the processing is carried out. Data is taken from the registers then processed and the results are returned to the registers. Move commands are used to move data between RAM locations and the registers. There are many instructions, each with a specific purpose and is called the instruction set. The CPU has four general-purpose registers called AL, BL, CL and DL. These are eight bits or one byte wide. Registers can hold unsigned numbers in the range 0 to +255 and signed numbers in the range –128 to +127.
The special purpose registers in the CPU are called IP, SR and SP..
IP Is the instruction Pointer and this register contains the address of the instruction being carried out.
SR is the Status Register and contains flags that report the CPU status. These are;
The zero flag is set to one if a calculation has given a zero result.
The sign flag is set to one if a calculation has given a negative result.
The overflow flag is set if a result was too big to fit in a register.
The interrupt is set if interrupts are enabled.
Stack Pointer
Question 3.0 A continued
The stack is an area of memory that is organized using the last in first out rule and points to the next free stack location. The simulator stack starts at address BF just below the RAM used for the video display. The stack grows towards address zero. Data is pushed onto the stack to save it for later use. Data is dropped off the stack when required. The stack pointer keeps track of where to push or drop data.
Random Access Memory
The simulator has 256 bytes of ram. The addresses are from 0 to 255 in decimal numbers or from [00] to [FF] in hexadecimal
Busses
Busses are collections of wires used to carry signals around the computer. They are commonly printed as parallel tracks on circuit boards. Slots are sockets that enable cards to be connected to the system bus. An 8-bit computer typically has registers 8 bits wide and 8 wires in a bus. A 16-bit computer has 16 bit registers and 16 address and data wires.
Data Bus
The Data Bus is used to carry data between the CPU, RAM and IO ports. The simulator
has an 8-bit data bus.
Address Bus
The Address Bus is used to specify what RAM address or IO port should be used and has an 8-bit address bus.
Control Bus
Question 3.0 A continued
This determines whether to access RAM or IO ports. It also determines whether data is being read or written. The CPU reads data when it flows into
the CPU and writes data when it flows out of the CPU to RAM or the IO ports.
System Clock
The System clock carries regular pulses so that all the electronic components can
Function at the correct time and is referred to as the clock speed.
Hardware Interrupts
Hardware Interrupts require at least one wire and enable the CPU to respond to events that are triggered by hardware.
Question B
What are the advantages and disadvantages of programming a machine in Machine Code or Assembly language over using High-level languages such as java?
Machine code is run in the microprocessor using the fetch-execute sequence and everything that the CPU executes is machine code. When windows is being run the .EXE files are machine code.
Both Machine Code and High Level languages have there own advantages and disadvantages – Compiled programs can be distributed without the source code (for security and copyright reasons). They are also more efficient (as the translation process is done during development time). Interpreted languages are easier to write and debug, but are generally slower as the compilation process occurs every time (and during) the execution process. Hybrid combinations are possible (such as Visual Basic), which compiles into an intermediary language called p-code and requires an interpreter to run. For very efficient code, (such as program that have limited resources), programs can be written directly in machine code. An example would be a hard disk device driver, which must be small and very efficient.
Because of the nature of high level languages a program must firstly be compiled and an object file is produced, this is then assembled and an executable file is produced. The result of this is Machine code – but this produced code would normally be far larger than code written directly in a low level language.