Name: __________________
Section:_______________
http://www.cs.wpi.edu/~jburge/courses/c01/cs2011/tasm_instructions.html
enter, assemble, and link the following program. Save your program on diskette (the A: drive) so you'll have it for future reference.
TITLE Program subtracts two integers and checks the result .model small ;start all programs you will write .stack 100h ;for CS2011 with these directives .data ;the program's variables go here vara dw 5 varb dw 11 res dw ? .code ;the code starts here .startup ;TASM directive that sets up stack ;segment and data segment mov ax,vara ;variable a loaded into AX mov res, 0 ;clear result nop ;SET THE FIRST BREAKPOINT HERE sub a, varb mov res, ax ;res = vara – varb cmp res, -1 ;SET THE SECOND BREAKPOINT HERE je done ; if the result of the subtraction is zero - jump to the end! mov res, 0 ;SET THE THIRD BREAKPOINT HERE
done: nop ;SET THE FOURTH BREAKPOINT HERE ;NOP - no operation - it's just a placeholder .exit ;a TASM directive that returns ;control to the calling program. ;Meant to be used in conjunction ;with .startup end ;end of source code
You should get an error the first time you try to build the program. What was it?
_____________________________________________________
This is because you can't subtract directly from a memory location. Change the sub vara, varb to sub ax, varb (the value in memory location vara has already been loaded into ax).
Fix the error and build the program again. Once you have successfully built the program, bring up the turbo debugger. Then,
You will need to know how to use the Turbo Assembler tools for Homework 3, so make sure you ask the TA for help if you come across something you do not understand. You will need to hand in this handout at the end of your lab session to receive credit for the lab.