; The name of our module. Typically it is placed at the absolute top of the ; file to make it easy to find. You'll be typing this a lot in pcdebug, ; so it is a good idea to keep it on the short side. NAME basic ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; basic_commented.asm ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Description: Contains a basic assembly file, with lots of commenting. ; ; This GROUP stuff makes our code work with Glen's .obj files. ; Only include the program elements (CODE, DATA, STACK) that your file uses. ; Just look at the other example files to clear this up. CGROUP GROUP CODE DGROUP GROUP DATA, STACK ; This, combined with the command string passed to the locator, determines ; where the compiled code is placed in memory. As you might have guessed, ; code goes in the following section. You *could* use 'potato' instead of ; 'code', but that wouldn't be very useful... CODE SEGMENT PUBLIC 'CODE' ASSUME CS: CGROUP, DS: DGROUP, SS: DGROUP ; This, combined with the "END main" at the bottom of the file, defines the ; entry point for your program. In other words, when you run pcdebug, it ; will know where to start executing code. main: CLI ; ensure interrupts are disabled ; We need to initialize our stack segment register and the stack pointer. ; They cannot start off "just anywhere" -- or we risk overwriting code ; and data! MOV AX, DGROUP MOV SS, AX MOV SP, OFFSET(DGROUP:TopOfStack) ; Likewise, we need to initialize the data segment register. MOV AX, DGROUP MOV DS, AX ; <-- your code goes here ; Loop infinitely. forever: JMP forever CODE ENDS DATA SEGMENT PUBLIC 'DATA' ; Here is where you will declare [memory] variables. DATA ENDS ; This is our stack. It is only required in the file with the entry point. ; Remember that the stack operates from "bottom up" -- so we reserve 256 ; words and make the stack point to the bottom of that block of memory. ; This means it can store 256 words before overflowing (a stack overflow ; is typically lethal to your program). 256 words should be plenty for ; EE51 programs. STACK SEGMENT PUBLIC 'STACK' DW 0100H DUP (?) ;256 words TopOfStack LABEL WORD STACK ENDS ; Always include the 'END' keyword at the end of every code file (not ; include files). Include the label used at the beginning of the file ; containing your program's entry point. END main