This paper describes a global compaction algorithm which can produce efficient microprograms with respect to both space and time. The algorithm depends upon a generalized data dependency graph (GDDG), which can integratedly express the concurrency of microorders and their mobility past the boundaries of basic blocks, as well as the control flow for a microprogram. In the algorithm an initial GDDG is first built up from a source microprogram consisting of a sequence of microorders, and this is transformed by repeated application of a set of microscopic transformation rules to the graph's edges until all of them have been examined. Then microorders are packed into microinstruction fields so that the more frequently executed basic blocks may contain as few microinstructions as possible. The intrinsic nature of the control flow's joins and forks allows determination of which basic block should accommodate those microorders that can be placed in more than one basic block.