Microprocessor Simulator 0 Help


Example - 01first.asm - Arithmetic



Download 1.18 Mb.
Page31/82
Date18.03.2021
Size1.18 Mb.
#56105
1   ...   27   28   29   30   31   32   33   34   ...   82
sms32v50 (3)
sms32v50 (3), sms32v50 (6)

Example - 01first.asm - Arithmetic


Contents

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.

Example - 01first.asm


; ===== 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.


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.


Download 1.18 Mb.

Share with your friends:
1   ...   27   28   29   30   31   32   33   34   ...   82




The database is protected by copyright ©ininet.org 2024
send message

    Main page