Skip to content

Commit

Permalink
Merge pull request #50 from idcrook/code-listings-fixes
Browse files Browse the repository at this point in the history
Code listings fixes
  • Loading branch information
jagregory authored Feb 25, 2022
2 parents fbf2dd1 + 8975f42 commit fe37d28
Show file tree
Hide file tree
Showing 31 changed files with 1,186 additions and 1,177 deletions.
28 changes: 14 additions & 14 deletions src/chapter-07.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,21 +246,21 @@ the whole point.)
.data
; Sample string to search through.
SampleString label byte
db This is a sample string of a long enough length '
db so that raw searching speed can outweigh any '
db extra set-up time that may be required.',0
db 'This is a sample string of a long enough length '
db 'so that raw searching speed can outweigh any '
db 'extra set-up time that may be required.',0
SAMPLE_STRING_LENGTH equ $-SampleString
; User prompt.
Prompt db Enter character to search for:$'
Prompt db 'Enter character to search for:$'
; Result status messages.
ByteFoundMsg db 0dh,0ah
db Specified byte found.',0dh,0ah,$'
db 'Specified byte found.',0dh,0ah,'$'
ZeroByteFoundMsg db 0dh, 0ah
db Zero byte encountered.',0dh,0ah,$'
db 'Zero byte encountered.',0dh,0ah,'$'
NoByteFoundMsg db 0dh,0ah
db Buffer exhausted with no match.', 0dh, 0ah, $'
db 'Buffer exhausted with no match.', 0dh, 0ah, '$'
.code
Start proc near
Expand Down Expand Up @@ -351,21 +351,21 @@ all the difference.
.data
; Sample string to search through.
SampleString label byte
db This is a sample string of a long enough length '
db so that raw searching speed can outweigh any '
db extra set-up time that may be required.',0
db 'This is a sample string of a long enough length '
db 'so that raw searching speed can outweigh any '
db 'extra set-up time that may be required.',0
SAMPLE_STRING_LENGTH equ $-SampleString
; User prompt.
Prompt db Enter character to search for:$'
Prompt db 'Enter character to search for:$'
; Result status messages.
ByteFoundMsg db 0dh,0ah
db Specified byte found.',0dh,0ah,$'
db 'Specified byte found.',0dh,0ah,'$'
ZeroByteFoundMsg db 0dh,0ah
db Zero byte encountered.', 0dh, 0ah, $'
db 'Zero byte encountered.', 0dh, 0ah, '$'
NoByteFoundMsg db 0dh,0ah
db Buffer exhausted with no match.', 0dh, 0ah, $'
db 'Buffer exhausted with no match.', 0dh, 0ah, '$'
; Table of initial, possibly partial loop entry points for
; SearchMaxLength.
Expand Down
24 changes: 12 additions & 12 deletions src/chapter-16.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ timed from a RAM disk on a 20 MHz 386.
Ch = *BufferPtr++ & 0x7F; /* strip high bit, which some
word processors set as an
internal flag */
CharFlag = ((Ch >= a') && (Ch <= z')) ||
((Ch >= A') && (Ch <= Z')) ||
((Ch >= 0') && (Ch <= 9')) ||
(Ch == \'');
CharFlag = ((Ch >= 'a') && (Ch <= 'z')) ||
((Ch >= 'A') && (Ch <= 'Z')) ||
((Ch >= '0') && (Ch <= '9')) ||
(Ch == '\'');
if ((!CharFlag) && PredCharFlag) {
WordCo u nt++;
}
Expand Down Expand Up @@ -291,19 +291,19 @@ ScanLoop:
and al,7fh ;strip high bit for word processors
; that set it as an internal flag
mov bl,1 ;assume this is a char; CharFlag = 1;
cmp al,a' ;it is a char if between a and z
cmp al,'a' ;it is a char if between a and z
jb CheckAZ
cmp al,z'
cmp al,'z'
jna IsAChar
CheckAZ:
cmp al,A' ;it is a char if between A and Z
cmp al,'A' ;it is a char if between A and Z
jb Check09
cmp al,Z'
cmp al,'Z'
jna IsAChar
Check09:
cmp al,0' ;it is a char if between 0 and 9
cmp al,'0' ;it is a char if between 0 and 9
jb CheckApostrophe
cmp al,9'
cmp al,'9'
jna IsAChar
CheckApostrophe:
cmp al,27h ;it is a char if an apostrophe
Expand Down Expand Up @@ -745,7 +745,7 @@ jumping.
mov di,[bp+CharFlag]
mov bh,[di] ;bh = old CharFlag
mov bl,[si] ;bl = character
add bh,A'-1 ;make bh into character
add bh,'A'-1 ;make bh into character
add bx,bx ;prepare to index
mov al,es:[bx]
cbw ;get hi bit in ah (then bh)
Expand Down Expand Up @@ -1155,7 +1155,7 @@ report a "location counter overflow" warning; ignore it.)
#include <stdio.h>
#include <ctype.h>

#define ChType( c ) (((c) & 0x7f) == \'' || isalnum((c) & 0x7f))
#define ChType( c ) (((c) & 0x7f) == '\'' || isalnum((c) & 0x7f))

int NoCarry[ 4 ] = { 0, 0x80, 1, 0x80 };
int Carry[ 4 ] = { 1, 0x81, 1, 0x80 };
Expand Down
4 changes: 2 additions & 2 deletions src/chapter-17.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void main()
x = random(cellmap_width);
y = random(cellmap_height);
next_map.set_cell(x, y);
} while (init_length);
} while (--init_length);
current_map.copy_cells(next_map); // put init map in current_map

enter_display_mode();
Expand Down Expand Up @@ -1207,7 +1207,7 @@ void cellmap::init()
if (cell_state(x, y) == 0) {
set_cell(x, y);
}
} while (init_length);
} while (--init_length);
}
```
Expand Down
10 changes: 5 additions & 5 deletions src/chapter-18.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void BuildMaps( void )
{
unsigned short i, j, Size, x = 0, y, N1, N2, N3, C1, C2, C3;

printf( "_DATA segment DATA'\nalign 2\n" );
printf( "_DATA segment 'DATA'\nalign 2\n" );
printf( "public _CellMap\n" );
printf( "_CellMap label word\n" );

Expand Down Expand Up @@ -284,7 +284,7 @@ void BuildMaps( void )
printf( "Change1 dw offset _CHANGE:_ChangeList1\n" );
printf( "Change2 dw offset _CHANGE:_ChangeList2\n" );
printf( "ends\n\n" );
printf( "_CHANGE segment para public FAR_DATA'\n" );
printf( "_CHANGE segment para public 'FAR_DATA'\n" );
}
else
{
Expand All @@ -300,7 +300,7 @@ void BuildMaps( void )
printf( "dw %d dup (offset DGROUP:ChangeCell)\n", Size );
printf( "ends\n\n" );

printf( "_LDMAP segment para public FAR_DATA'\n" );
printf( "_LDMAP segment para public 'FAR_DATA'\n" );

do
{
Expand Down Expand Up @@ -536,7 +536,7 @@ void Fix( char *Offset, char *Str, int JumpBack )
printf( "mov bh,[bx]\n" );
printf( "mov [bp+%s],bx\n", Offset );

if( *Offset != 0' ) printf( "lea ax,[bp+%s]\n", Offset );
if( *Offset != '0' ) printf( "lea ax,[bp+%s]\n", Offset );
else printf( "mov ax,bp\n" );

printf( "stosw\n" );
Expand Down Expand Up @@ -654,7 +654,7 @@ void main( void )
BuildMaps();

printf( "DGROUP group _DATA\n" );
printf( "LIFE segment CODE'\n" );
printf( "LIFE segment 'CODE'\n" );
printf( "assume cs:LIFE,ds:DGROUP,ss:DGROUP,es:NOTHING\n" );
printf( ".386C\n" "public _NextGen\n\n" );

Expand Down
16 changes: 8 additions & 8 deletions src/chapter-24.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ only the enabled planes would be affected by each operation.
; the images with the background.
; By Michael Abrash.
;
stack segment para stack STACK'
stack segment para stack 'STACK'
db 512 dup(?)
stack ends
;
Expand All @@ -149,23 +149,23 @@ GC_ROTATE equ 3 ;GC data rotate/logical function
; register index
GC_MODE equ 5 ;GC mode register index
;
dseg segment para common DATA'
dseg segment para common 'DATA'
;
; String used to label logical functions.
;
LabelString label byte
db UNMODIFIED AND OR XOR '
db 'UNMODIFIED AND OR XOR '
LABEL_STRING_LENGTH equ $-LabelString
;
; Strings used to label fill patterns.
;
FillPatternFF db Fill Pattern: 0FFh'
FillPatternFF db 'Fill Pattern: 0FFh'
FILL_PATTERN_FF_LENGTH equ $ - FillPatternFF
FillPattern00 db Fill Pattern: 000h'
FillPattern00 db 'Fill Pattern: 000h'
FILL_PATTERN_00_LENGTH equ $ - FillPattern00
FillPatternVert db Fill Pattern: Vertical Bar'
FillPatternVert db 'Fill Pattern: Vertical Bar'
FILL_PATTERN_VERT_LENGTH equ $ - FillPatternVert
FillPatternHorz db Fill Pattern: Horizontal Bar'
FillPatternHorz db 'Fill Pattern: Horizontal Bar'
FILL_PATTERN_HORZ_LENGTH equ $ - FillPatternHorz
;
dseg ends
Expand All @@ -192,7 +192,7 @@ TEXT_UP macro TEXT_STRING, TEXT_LENGTH, ROW, COLUMN
int 10h
endm
;
cseg segment para public CODE'
cseg segment para public 'CODE'
assume cs:cseg, ds:dseg
start proc near
mov ax,dseg
Expand Down
24 changes: 12 additions & 12 deletions src/chapter-25.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ BIOS, as well).
; for use with modes 0Dh, 0Eh, 0Fh, 10h, and 12h.
; By Michael Abrash.
;
stack segment para stack STACK'
stack segment para stack 'STACK'
db 512 dup(?)
stack ends
;
Expand All @@ -127,13 +127,13 @@ GC_ROTATE equ 3 ;GC data rotate/logical function
; register index
GC_BIT_MASK equ 8 ;GC bit mask register index
;
dseg segment para common DATA'
dseg segment para common 'DATA'
TEST_TEXT_ROW equ 69 ;row to display test text at
TEST_TEXT_COL equ 17 ;column to display test text at
TEST_TEXT_WIDTH equ 8 ;width of a character in pixels
TestString label byte
db Hello, world!',0 ;test string to print.
db 'Hello, world!',0 ;test string to print.
FontPointer dd ? ;font offset
dseg ends
;
Expand All @@ -145,7 +145,7 @@ SETGC macro INDEX, SETTING
out dx,ax
endm
;
cseg segment para public CODE'
cseg segment para public 'CODE'
assume cs:cseg, ds:dseg
start proc near
mov ax,dseg
Expand Down Expand Up @@ -452,7 +452,7 @@ set the Map Mask register to 01H and fill with blue.
; to memory that already contains data.
; By Michael Abrash.
;
stack segment para stack STACK'
stack segment para stack 'STACK'
db 512 dup(?)
stack ends
;
Expand All @@ -475,7 +475,7 @@ SETSC macro INDEX, SETTING
dec dx
endm
;
cseg segment para public CODE#146;
cseg segment para public 'CODE'
assume cs:cseg
start proc near
;
Expand Down Expand Up @@ -575,7 +575,7 @@ off as well as 0FFH-bytes to planes that must be on.
; setting of memory that already contains data.
; By Michael Abrash.
;
stack segment para stack STACK#146;
stack segment para stack 'STACK'
db 512 dup(?)
stack ends
;
Expand Down Expand Up @@ -613,7 +613,7 @@ SETGC macro INDEX, SETTING
dec dx
endm
;
cseg segment para public CODE#146;
cseg segment para public 'CODE'
assume cs:cseg
start proc near
;
Expand All @@ -639,8 +639,8 @@ HorzBarLoop:
dec bp
jnz HorzBarLoop
;
; Fill screen with blue, using set/reset to force plane 0 to 1#146;s and all
; other plane to 0#146;s.
; Fill screen with blue, using set/reset to force plane 0 to 1's and all
; other plane to 0's.
;
SETSC SC_MAP_MASK,0fh ;must set map mask to enable all
; planes, so set/reset values can
Expand Down Expand Up @@ -707,7 +707,7 @@ be used to control individual pixels.
; with CPU data to modify setting of memory that already contains data.
; By Michael Abrash.
;
stack segment para stack STACK#146;
stack segment para stack 'STACK'
db 512 dup(?)
stack ends
;
Expand Down Expand Up @@ -745,7 +745,7 @@ SETGC macro INDEX, SETTING
dec dx
endm
;
cseg segment para public CODE#146;
cseg segment para public 'CODE'
assume cs:cseg
start proc near
;
Expand Down
16 changes: 8 additions & 8 deletions src/chapter-26.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ characters can be drawn in any of the 16 available colors.
; Assembled with MASM
; By Michael Abrash
;
stack segment para stack STACK'
stack segment para stack 'STACK'
db 512 dup(?)
stack ends
;
Expand All @@ -111,16 +111,16 @@ GC_ROTATE equ 3 ;GC data rotate/logical function
GC_MODE equ 5 ;GC Mode register
GC_BIT_MASK equ 8 ;GC bit mask register index
;
dseg segment para common DATA'
dseg segment para common 'DATA'
TEST_TEXT_ROW equ 69 ;row to display test text at
TEST_TEXT_COL equ 17 ;column to display test text at
TEST_TEXT_WIDTH equ 8 ;width of a character in pixels
TestString label byte
db Hello, world!',0 ;test string to print.
db 'Hello, world!',0 ;test string to print.
FontPointer dd ? ;font offset
dseg ends
;
cseg segment para public CODE'
cseg segment para public 'CODE'
assume cs:cseg, ds:dseg
start proc near
mov ax,dseg
Expand Down Expand Up @@ -458,7 +458,7 @@ along with the tables used to alter the 8x14 and 8x16 ROM fonts into
; Assembled with MASM
; By Michael Abrash
;
stack segment para stack STACK'
stack segment para stack 'STACK'
db 512 dup(?)
stack ends
;
Expand All @@ -478,16 +478,16 @@ GC_ROTATE equ 3 ;GC data rotate/logical function
GC_MODE equ 5 ;GC Mode register
GC_BIT_MASK equ 8 ;GC bit mask register index
;
dseg segment para common DATA'
dseg segment para common 'DATA'
TEST_TEXT_ROW equ 69 ;row to display test text at
TEST_TEXT_COL equ 17 ;column to display test text at
TEST_TEXT_COLOR equ 0fh ;high intensity white
TestString label byte
db Hello, world!',0 ;test string to print.
db 'Hello, world!',0 ;test string to print.
FontPointer dd ? ;font offset
dseg ends
;
cseg segment para public CODE'
cseg segment para public 'CODE'
assume cs:cseg, ds:dseg
start proc near
mov ax,dseg
Expand Down
Loading

0 comments on commit fe37d28

Please sign in to comment.