; LABELS.ASM ; ; Purpose: ; - Show the difference in syntax between two types of labels: ; Labels on CODE require a colon after the label (code=colon). ; Labels on DATA must not be followed by a colon (data=don't). ; - Demonstrate a common error in coding loop algorithms. ; ; Algorithm PseudoCode: ; ; initialize counter from MAXL ; do { ; output an asterisk ; decrease counter by value in DOWN ; } while ( counter is not zero ) ; exit with zero return code ; ; Note1: This code has a bug - the loop never terminates. Why? ; ; Note2: ; Many comments in this file are intended to teach students about the ; meaning of various assembler instructions. They are NOT suitable ; for students documenting their own code, since they do not refer to ; any process or problem being solved. ; ; Students: Do NOT copy the teacher-style comments into your own code. ; ; -IAN! idallen@ncf.ca July 2000 ;---------------------------------------------------------------------- Labels segment assume CS:Labels,DS:Labels ; .COM format uses only one segment org 100h ; .COM format executable starts at 100h ;---------------------------------------------------------------------- START: MOV BX,MAXL ; initialize BX to start the loop DOLOOP: MOV DL,CHAR ; output this CHAR on the screen... MOV AH,02h ; using DOS service 02h and... INT 21h ; interrupt number 21h (remember the 'h'!) SUB BX,DOWN ; decrease BX and loop back up if not zero JNZ DOLOOP ; this is a conditional "jump if not zero" MOV AH,4Ch ; code to terminate this LABELS program MOV AL,0h ; set a zero return status from LABELS INT 21h ; call the DOS service routine to do the job MAXL DW 0FFh ; max loop start value DOWN DW 2h ; go down by this much each time CHAR DB '*' ; output this character ;---------------------------------------------------------------------- Labels ends end start ; "start" is the label on the first instruction