Select Page

##### Objective:

Entry and Disassembly of Simple Programs.

#### Using Arithmetic Instructions e.g. ADD, SUB, MUL, DIV, etc.

Here are all the learning tasks grouped together with pointers to the example programs and explanatory notes.

Simple Arithmetic

Example – 01first.asm – Arithmetic

1. Write a program that subtracts using SUB
2. Write a program that multiplies using MUL
3. Write a program that divides using DIV
4. Write a program that divides by zero. Make a note to avoid doing this in real life.

#### Entry and Disassembly of Simple Programs.

Most of these examples include a learning task. Study the example and if you can complete the task/s, it is likely that your understanding is good.

 ; ===== WORK OUT 2 PLUS 2 ====================================== CLO                 ; Close unwanted windows. MOV AL,2      ; Copy a 2 into the AL register. MOV BL,2       ; Copy a 2 into the BL register. ADD AL,BL    ; Add AL to BL. Answer goes into AL. END                ; Program ends ; ===== Program Ends ===========================================   YOUR TASK ========= Use SUB, DIV and MUL to subtract, divide and multiply. What happens if you divide by zero? Make use of CL and DL as well as AL and BL.

By: Miss SABA WAHAB

Type this code into the simulator editor OR copy and paste the code OR load the example from disk.

Step through the program by pressing Alt+P repeatedly.

While you are stepping, watch the CPU registers. You should see a ‘2’ appear in the AL register followed by a ‘2’ in the BL register. AL should be added to BL and a ‘4’ should appear in AL. The altered registers are highlighted yellow.

Watch the register labelled IP (Instruction Pointer). This register keeps track of where the processor has got to in the program. If you look at the RAM display, one RAM location is labelled with a red blob. This corresponds to the Instruction Pointer. Note how the red blob (IP) moves when you step the program.

When doing the learning exercises, add to and modify your own copy of the example.

What you need to know

Use all the registers AL, BL, CL and DL and experiment with ADD, SUB, MUL and DIV.

Find out what happens if you try to divide by zero.

MUL COMMND

SUB COMMAND

MICROPROCESSOR PRACTICAL NOTE BOOK                                                              WRITER: MISS SABA WAHAB