Day 5




Subroutines


	Subroutines, almost just like C or BASIC...

Labels

We've seen labels before when we saw variables, except these labels that mark a location in code have a color (':') after them, such as: outputA: mov ah,2 mov dl,'A' int 21h These labels can be accessed like variables also, and that's how self-modifying code works.

The CALL and RET Instructions

The CALL instruction calls a function specified by a label and a RET instruction returns to the main program, such as the following: mov dl,'G' call outputLetter mov dl,'o' call outputLetter call ExitProgram outputLetter: mov ah,2 int 21h ret ; returns to instruction after the CALL ExitProgram: mov ah,4ch int 21h ; note that since the program will exit, there's no need for a RET. The above program will output Go in DOS.

This Day In Review

With what you know now, you can write a program to output the alphabet. It'll be (very) long, but you can do it! Tomorrow, Functions in assembly! Happy coding!, -Mike H
Intro - Day 6

Patater GBAGuy Mirror
Contact