Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -22,7 +22,7 @@ linnum = $14
; kernel routines
linstr = $bdcd ; C64 ROM : convert a 16-bit value to string and print on current device (default screen)
chrout = $ffd2 ; C64 ROM kernel: output a character to current device, default screen
; use $fded for Apple 2
; use $fded for Apple 2
;
; ----------------------------------------------
;

View file

@ -1,68 +1,68 @@
org 100h
mvi a,32 ; Start with space
mvi d,16 ; 16 lines
dochar: mov c,a ; Print number
call putnum
mov a,c
lxi h,spc ; Is it space?
cpi 32
jz print
lxi h,del
cpi 127 ; Is it del?
jz print
lxi h,chr ; Character
mov m,a
print: call puts
adi 16 ; Next column
jp dochar ; Done with this line?
lxi h,nl
call puts
sui 95 ; Next line
dcr d
jnz dochar
ret
;;; Print number in A. C, D preserved.
putnum: lxi h,num ; Set number string to spaces
push h
mvi b,' '
mov m,b
inx h
mov m,b
inx h
mov m,b
dgts: mvi b,-1
divmod: sui 10 ; B = A/10, A = (A mod 10)-10
inr b
jnc divmod
adi 58 ; Make digit
mov m,a ; Store digit
dcx h
mov a,b ; Next digit
ana a
jnz dgts
pop h ; Print number
;;; Print zero-terminated (...ish) string
puts: mov e,m
call putch
inx h
dcr e
jp puts
ret
;;; Output character in E using CP/M call,
;;; preserving registers
putch: push psw
push b
push d
push h
mvi c,2
call 5
pop h
pop d
pop b
pop psw
ret
nl: db 13,10,0 ; Newline
num: db ' : ',0 ; Placeholder for number string
spc: db 'Spc ',0 ; Space
del: db 'Del ',0 ; Del
chr: db '* ',0 ; Placeholder for character
org 100h
mvi a,32 ; Start with space
mvi d,16 ; 16 lines
dochar: mov c,a ; Print number
call putnum
mov a,c
lxi h,spc ; Is it space?
cpi 32
jz print
lxi h,del
cpi 127 ; Is it del?
jz print
lxi h,chr ; Character
mov m,a
print: call puts
adi 16 ; Next column
jp dochar ; Done with this line?
lxi h,nl
call puts
sui 95 ; Next line
dcr d
jnz dochar
ret
;;; Print number in A. C, D preserved.
putnum: lxi h,num ; Set number string to spaces
push h
mvi b,' '
mov m,b
inx h
mov m,b
inx h
mov m,b
dgts: mvi b,-1
divmod: sui 10 ; B = A/10, A = (A mod 10)-10
inr b
jnc divmod
adi 58 ; Make digit
mov m,a ; Store digit
dcx h
mov a,b ; Next digit
ana a
jnz dgts
pop h ; Print number
;;; Print zero-terminated (...ish) string
puts: mov e,m
call putch
inx h
dcr e
jp puts
ret
;;; Output character in E using CP/M call,
;;; preserving registers
putch: push psw
push b
push d
push h
mvi c,2
call 5
pop h
pop d
pop b
pop psw
ret
nl: db 13,10,0 ; Newline
num: db ' : ',0 ; Placeholder for number string
spc: db 'Spc ',0 ; Space
del: db 'Del ',0 ; Del
chr: db '* ',0 ; Placeholder for character

View file

@ -1,58 +1,58 @@
cpu 8086
bits 16
putch: equ 2h
section .text
org 100h
mov cx,16 ; 16 lines
mov bh,32 ; Start at 32
dochar: mov al,bh ; Print number
call putnum
cmp bh,32 ; Space?
je .spc
cmp bh,127 ; Del?
je .del
mov [chr],bh ; Otherwise, print character
mov di,chr
jmp .out
.spc: mov di,spc
jmp .out
.del: mov di,del
.out: call putstr
add bh,16 ; Next column
cmp bh,128 ; Done with this line?
jb dochar
mov di,nl ; Print newline
call putstr
sub bh,95 ; Do next line
loop dochar
ret
;;; Print number in AL as ASCII, right-aligned in 3 characters
putnum: mov dx,2020h ; Put spaces in number
mov di,num ; Two spaces
mov [di],dx
inc di
inc di
mov [di],dh ; Third space
mov bl,10 ; Divisor
.div: xor ah,ah ; Write digits
div bl
add ah,'0'
mov [di],ah
dec di
test al,al
jnz .div
mov di,num ; Print number
putstr: mov ah,putch ; Use zero-terminated strings
.loop: mov dl,[di]
test dl,dl
jz .done
int 21h
inc di
jmp .loop
.done: ret
section .data
num: db ' : ',0 ; Placeholder for number string
nl: db 13,10,0 ; Newline
spc: db 'Spc ',0 ; Space
del: db 'Del ',0 ; Del
chr: db '* ',0 ; Placeholder for character
cpu 8086
bits 16
putch: equ 2h
section .text
org 100h
mov cx,16 ; 16 lines
mov bh,32 ; Start at 32
dochar: mov al,bh ; Print number
call putnum
cmp bh,32 ; Space?
je .spc
cmp bh,127 ; Del?
je .del
mov [chr],bh ; Otherwise, print character
mov di,chr
jmp .out
.spc: mov di,spc
jmp .out
.del: mov di,del
.out: call putstr
add bh,16 ; Next column
cmp bh,128 ; Done with this line?
jb dochar
mov di,nl ; Print newline
call putstr
sub bh,95 ; Do next line
loop dochar
ret
;;; Print number in AL as ASCII, right-aligned in 3 characters
putnum: mov dx,2020h ; Put spaces in number
mov di,num ; Two spaces
mov [di],dx
inc di
inc di
mov [di],dh ; Third space
mov bl,10 ; Divisor
.div: xor ah,ah ; Write digits
div bl
add ah,'0'
mov [di],ah
dec di
test al,al
jnz .div
mov di,num ; Print number
putstr: mov ah,putch ; Use zero-terminated strings
.loop: mov dl,[di]
test dl,dl
jz .done
int 21h
inc di
jmp .loop
.done: ret
section .data
num: db ' : ',0 ; Placeholder for number string
nl: db 13,10,0 ; Newline
spc: db 'Spc ',0 ; Space
del: db 'Del ',0 ; Del
chr: db '* ',0 ; Placeholder for character

View file

@ -1,193 +1,193 @@
.equ CursorX,0x02000000
.equ CursorY,0x02000001
ProgramStart:
mov sp,#0x03000000 ;Init Stack Pointer
mov r4,#0x04000000 ;DISPCNT -LCD Control
mov r2,#0x403 ;4= Layer 2 on / 3= ScreenMode 3
str r2,[r4] ;now the screen is visible
bl ResetTextCursors ;set text cursors to top left of screen
mov r2,#32
mov r3,#32+20 ;screen height is 20 chars
mov r5,#0 ;column spacer
mov r6,#5
;R0 = Character to print (working copy)
;R2 = real copy
;R3 = compare factor
mov sp,#0x03000000 ;Init Stack Pointer
mov r4,#0x04000000 ;DISPCNT -LCD Control
mov r2,#0x403 ;4= Layer 2 on / 3= ScreenMode 3
str r2,[r4] ;now the screen is visible
bl ResetTextCursors ;set text cursors to top left of screen
mov r2,#32
mov r3,#32+20 ;screen height is 20 chars
mov r5,#0 ;column spacer
mov r6,#5
;R0 = Character to print (working copy)
;R2 = real copy
;R3 = compare factor
loop_printAscii:
mov r0,r2
bl ShowHex
mov r0,#32
bl PrintChar
mov r0,r2
bl PrintChar
bl CustomNewLine
add r2,r2,#1
cmp r2,#128
beq forever ;exit early
cmp r2,r3
bne loop_printAscii
add r3,r3,#20 ;next section
;inc to next column
add r5,r5,#5
mov r0,r5
mov r1,#0
bl SetTextCursors
subs r6,r6,#1
bne loop_printAscii
mov r0,r2
bl ShowHex
mov r0,#32
bl PrintChar
mov r0,r2
bl PrintChar
bl CustomNewLine
add r2,r2,#1
cmp r2,#128
beq forever ;exit early
cmp r2,r3
bne loop_printAscii
add r3,r3,#20 ;next section
;inc to next column
add r5,r5,#5
mov r0,r5
mov r1,#0
bl SetTextCursors
subs r6,r6,#1
bne loop_printAscii
forever:
b forever
b forever
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;; INPUT/OUTPUT SUBROUTINES - CREATED BY KEITH OF CHIBIAKUMAS.COM
;;;;; INPUT/OUTPUT SUBROUTINES - CREATED BY KEITH OF CHIBIAKUMAS.COM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintString: ;Print 255 terminated string
STMFD sp!,{r0-r12, lr}
PrintString: ;Print 255 terminated string
STMFD sp!,{r0-r12, lr}
PrintStringAgain:
ldrB r0,[r1],#1
cmp r0,#255
beq PrintStringDone ;Repeat until 255
bl printchar ;Print Char
b PrintStringAgain
ldrB r0,[r1],#1
cmp r0,#255
beq PrintStringDone ;Repeat until 255
bl printchar ;Print Char
b PrintStringAgain
PrintStringDone:
LDMFD sp!,{r0-r12, pc}
LDMFD sp!,{r0-r12, pc}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintChar:
STMFD sp!,{r0-r12, lr}
mov r4,#0
mov r5,#0
mov r3,#CursorX
ldrB r4,[r3] ;X pos
mov r3,#CursorY
ldrB r5,[r3] ;Y pos
mov r3,#0x06000000 ;VRAM base
mov r6,#8*2 ;Xpos, 2 bytes per pixel, 8 bytes per char
mul r2,r4,r6
add r3,r3,r2
mov r4,#240*8*2 ;Ypos, 240 pixels per line,
mul r2,r5,r4 ;2 bytes per pixel, 8 lines per char
add r3,r3,r2
adr r4,BitmapFont ;Font source
sub r0,r0,#32 ;First Char is 32 (space)
add r4,r4,r0,asl #3 ;8 bytes per char
mov r1,#8 ;8 lines
STMFD sp!,{r0-r12, lr}
mov r4,#0
mov r5,#0
mov r3,#CursorX
ldrB r4,[r3] ;X pos
mov r3,#CursorY
ldrB r5,[r3] ;Y pos
mov r3,#0x06000000 ;VRAM base
mov r6,#8*2 ;Xpos, 2 bytes per pixel, 8 bytes per char
mul r2,r4,r6
add r3,r3,r2
mov r4,#240*8*2 ;Ypos, 240 pixels per line,
mul r2,r5,r4 ;2 bytes per pixel, 8 lines per char
add r3,r3,r2
adr r4,BitmapFont ;Font source
sub r0,r0,#32 ;First Char is 32 (space)
add r4,r4,r0,asl #3 ;8 bytes per char
mov r1,#8 ;8 lines
DrawLine:
mov r7,#8 ;8 pixels per line
ldrb r8,[r4],#1 ;Load Letter
mov r9,#0b100000000 ;Mask
mov r2, #0b1111111101000000; Color: ABBBBBGGGGGRRRRR A=Alpha
mov r7,#8 ;8 pixels per line
ldrb r8,[r4],#1 ;Load Letter
mov r9,#0b100000000 ;Mask
mov r2, #0b1111111101000000; Color: ABBBBBGGGGGRRRRR A=Alpha
DrawPixel:
tst r8,r9 ;Is bit 1?
strneh r2,[r3] ;Yes? then fill pixel (HalfWord)
add r3,r3,#2
mov r9,r9,ror #1 ;Bitshift Mask
subs r7,r7,#1
bne DrawPixel ;Next Hpixel
add r3,r3,#480-16 ;Move Down a line (240 pixels *2 bytes)
subs r1,r1,#1 ;-1 char (16 px)
bne DrawLine ;Next Vline
LineDone:
mov r3,#CursorX
ldrB r0,[r3]
add r0,r0,#1 ;Move across screen
strB r0,[r3]
mov r10,#30
cmp r0,r10
bleq NewLine
LDMFD sp!,{r0-r12, pc}
tst r8,r9 ;Is bit 1?
strneh r2,[r3] ;Yes? then fill pixel (HalfWord)
add r3,r3,#2
mov r9,r9,ror #1 ;Bitshift Mask
subs r7,r7,#1
bne DrawPixel ;Next Hpixel
add r3,r3,#480-16 ;Move Down a line (240 pixels *2 bytes)
subs r1,r1,#1 ;-1 char (16 px)
bne DrawLine ;Next Vline
LineDone:
mov r3,#CursorX
ldrB r0,[r3]
add r0,r0,#1 ;Move across screen
strB r0,[r3]
mov r10,#30
cmp r0,r10
bleq NewLine
LDMFD sp!,{r0-r12, pc}
NewLine:
STMFD sp!,{r0-r12, lr}
mov r3,#CursorX
mov r0,#0
strB r0,[r3]
mov r4,#CursorY
ldrB r0,[r4]
add r0,r0,#1
strB r0,[r4]
LDMFD sp!,{r0-r12, pc}
STMFD sp!,{r0-r12, lr}
mov r3,#CursorX
mov r0,#0
strB r0,[r3]
mov r4,#CursorY
ldrB r0,[r4]
add r0,r0,#1
strB r0,[r4]
LDMFD sp!,{r0-r12, pc}
CustomNewLine:
STMFD sp!,{r0-r12, lr}
mov r3,#CursorX
mov r0,r5
strB r0,[r3]
mov r4,#CursorY
ldrB r0,[r4]
add r0,r0,#1
strB r0,[r4]
LDMFD sp!,{r0-r12, pc}
STMFD sp!,{r0-r12, lr}
mov r3,#CursorX
mov r0,r5
strB r0,[r3]
mov r4,#CursorY
ldrB r0,[r4]
add r0,r0,#1
strB r0,[r4]
LDMFD sp!,{r0-r12, pc}
ResetTextCursors:
STMFD sp!,{r4-r6,lr}
mov r4,#0
mov r5,#CursorX
mov r6,#CursorY
strB r4,[r5]
strB r4,[r6]
LDMFD sp!,{r4-r6,lr}
bx lr
STMFD sp!,{r4-r6,lr}
mov r4,#0
mov r5,#CursorX
mov r6,#CursorY
strB r4,[r5]
strB r4,[r6]
LDMFD sp!,{r4-r6,lr}
bx lr
SetTextCursors:
;input: R0 = new X
; R1 = new Y
STMFD sp!,{r5-r6}
mov r5,#CursorX
mov r6,#CursorY
strB r0,[r5]
strB r1,[r6]
LDMFD sp!,{r5-r6}
bx lr
;input: R0 = new X
; R1 = new Y
STMFD sp!,{r5-r6}
mov r5,#CursorX
mov r6,#CursorY
strB r0,[r5]
strB r1,[r6]
LDMFD sp!,{r5-r6}
bx lr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ShowHex:
STMFD sp!,{r0-r12, lr}
mov r2,r0,ror #4
bl ShowHexChar
mov r2,r0
bl ShowHexChar
LDMFD sp!,{r0-r12, pc}
STMFD sp!,{r0-r12, lr}
mov r2,r0,ror #4
bl ShowHexChar
mov r2,r0
bl ShowHexChar
LDMFD sp!,{r0-r12, pc}
ShowHexChar:
STMFD sp!,{r0-r12, lr}
;mov r3,
and r0,r2,#0x0F ; r3
cmp r0,#10
addge r0,r0,#7 ;if 10 or greater convert to alphabet letters a-f
add r0,r0,#48
bl PrintChar
LDMFD sp!,{r0-r12, pc}
STMFD sp!,{r0-r12, lr}
;mov r3,
and r0,r2,#0x0F ; r3
cmp r0,#10
addge r0,r0,#7 ;if 10 or greater convert to alphabet letters a-f
add r0,r0,#48
bl PrintChar
LDMFD sp!,{r0-r12, pc}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BitmapFont:
;each byte represents a row of 8 pixels. This is a 1BPP font that is converted to the GBA's 16bpp screen format at runtime
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; 20
@ -286,4 +286,4 @@ BitmapFont:
.byte 0x08,0x04,0x04,0x02,0x02,0x04,0x04,0x08 ; 7D }
.byte 0x00,0x00,0x00,0x20,0x52,0x0C,0x00,0x00 ; 7E ~
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ; 7F
.byte 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ; 80
.byte 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF ; 80

View file

@ -0,0 +1,23 @@
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Ascii_Table is
N : Integer;
begin
for R in 0 .. 15 loop
for C in 0 .. 5 loop
N := 32 + 16 * C + R;
Put (N, 3);
Put (" : ");
case N is
when 32 =>
Put ("Spc ");
when 127 =>
Put ("Del ");
when others =>
Put (Character'Val (N) & " ");
end case;
end loop;
New_Line;
end loop;
end Ascii_Table;

View file

@ -1,3 +1,3 @@
LDA $41 ; ONERR A
EOR #$87 ; I READ
JMP $DB59 ; LY RND
LDA $41 ; ONERR A
EOR #$87 ; I READ
JMP $DB59 ; LY RND

View file

@ -6,25 +6,25 @@ ConvertedCharacter := ;Stores the currently converted ASCII code
RowLength := 0 ;Keeps track of the number of converted ASCII numbers in each row
Loop { ;Loops through each ASCII character and makes a list in MessageText
if CurrentASCII > 127 ;When the current ASCII number goes over 127, terminate the loop
Break
if (RowLength = 6) { ;Checks if the row is 6 converted characters long, and if so, inserts a line break (`n)
MessageText = %MessageText%`n
RowLength := 0
}
if (CurrentASCII = 32) {
ConvertedCharacter = SPC
} else {
if (CurrentASCII = 127) {
ConvertedCharacter = DEL
}
else {
ConvertedCharacter := Chr(CurrentASCII) ;Converts CurrentASCII number using Chr() and stores it in ConvertedCharacter
}
}
MessageText = %MessageText%%CurrentASCII%: %ConvertedCharacter%`t ;Adds converted ASCII to end of MessageText
CurrentASCII := CurrentASCII + 1
RowLength := RowLength + 1
if CurrentASCII > 127 ;When the current ASCII number goes over 127, terminate the loop
Break
if (RowLength = 6) { ;Checks if the row is 6 converted characters long, and if so, inserts a line break (`n)
MessageText = %MessageText%`n
RowLength := 0
}
if (CurrentASCII = 32) {
ConvertedCharacter = SPC
} else {
if (CurrentASCII = 127) {
ConvertedCharacter = DEL
}
else {
ConvertedCharacter := Chr(CurrentASCII) ;Converts CurrentASCII number using Chr() and stores it in ConvertedCharacter
}
}
MessageText = %MessageText%%CurrentASCII%: %ConvertedCharacter%`t ;Adds converted ASCII to end of MessageText
CurrentASCII := CurrentASCII + 1
RowLength := RowLength + 1
}
MsgBox, % MessageText ;Displays a message box with the ASCII conversion table, from the MessageText variable
return

View file

@ -1,14 +1,14 @@
for i = 32 to 47
for j = i to i + 80 step 16
begin case
case j = 32
s$ = "Spc"
case j = 127
s$ = "Del"
else
s$ = chr(j)
end case
print rjust(" "+string(j),5); ": "; ljust(s$,3);
next j
print
for j = i to i + 80 step 16
begin case
case j = 32
s$ = "Spc"
case j = 127
s$ = "Del"
else
s$ = chr(j)
end case
print rjust(" "+string(j),5); ": "; ljust(s$,3);
next j
print
next i

View file

@ -0,0 +1,22 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. CHARSET.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CHARCODE PIC 9(3) VALUE 32.
PROCEDURE DIVISION.
MAIN-PROCEDURE.
PERFORM UNTIL CHARCODE=128
DISPLAY FUNCTION CONCATENATE(
FUNCTION CONCATENATE(
CHARCODE,
" : "
),
FUNCTION CONCATENATE(
FUNCTION CHAR(CHARCODE),
" "
)
)
WITH NO ADVANCING
ADD 1 TO CHARCODE
END-PERFORM.
END PROGRAM CHARSET.

View file

@ -3,16 +3,16 @@
(setq cols 6)
(defun print-val (val) "Prints the value for that ascii number"
(cond
((= val 32) (format t " 32: SPC "))
((= val 127) (format t "127: DEL~%"))
((and (zerop (mod (- val startVal) cols)) (< val 100)) (format t "~% ~d: ~a " val (int-char val)))
((and (zerop (mod (- val startVal) cols)) (>= val 100)) (format t "~%~d: ~a " val (int-char val)))
((< val 100) (format t " ~d: ~a " val (int-char val)))
((>= val 100) (format t "~d: ~a " val (int-char val)))
(t nil)))
(cond
((= val 32) (format t " 32: SPC "))
((= val 127) (format t "127: DEL~%"))
((and (zerop (mod (- val startVal) cols)) (< val 100)) (format t "~% ~d: ~a " val (int-char val)))
((and (zerop (mod (- val startVal) cols)) (>= val 100)) (format t "~%~d: ~a " val (int-char val)))
((< val 100) (format t " ~d: ~a " val (int-char val)))
((>= val 100) (format t "~d: ~a " val (int-char val)))
(t nil)))
(defun get-range (lower upper) "Returns a list of range lower to upper"
(if (> lower upper) '() (cons lower (get-range (+ 1 lower) upper))))
(if (> lower upper) '() (cons lower (get-range (+ 1 lower) upper))))
(mapcar #'print-val (get-range startVal endVal))

View file

@ -3,60 +3,60 @@
program showAsciiTable(output);
const
columnsTotal = 6;
columnsTotal = 6;
type
// The hash indicates a char-data type.
asciiCharacter = #32..#127;
asciiCharacters = set of asciiCharacter;
// The hash indicates a char-data type.
asciiCharacter = #32..#127;
asciiCharacters = set of asciiCharacter;
var
character: asciiCharacter;
characters: asciiCharacters;
column, line: integer;
character: asciiCharacter;
characters: asciiCharacters;
column, line: integer;
begin
// characters needs to be initialized,
// because the next `include` below
// will _read_ the value `characters`.
// Reading _unintialized_ values, however,
// is considered bad practice in Pascal.
characters := [];
// `div` denotes integer division in Pascal,
// that means the result will be an _integer_-value.
line := (ord(high(asciiCharacter)) - ord(low(asciiCharacter)))
div columnsTotal + 1;
// Note: In Pascal for-loop limits are _inclusive_.
for column := 0 to columnsTotal do
begin
// This is equivalent to
// characters := characters + [];
// i.e. the union of two sets.
include(characters, chr(ord(low(asciiCharacter)) + column * line));
end;
for line := line downto 1 do
begin
// the for..in..do statement is an Extended Pascal extension
for character in characters do
begin
// `:6` specifies minimum width of argument
// [only works for write/writeLn/writeStr]
write(ord(character):6, ' : ', character);
end;
// emit proper newline character on `output`
writeLn;
// `characters` is evaluated prior entering the loop,
// not every time an iteration finished.
for character in characters do
begin
// These statements are equivalent to
// characters := characters + [character];
// characters := characters - [succ(character)];
// respectively, but shorter to write,
// i.e. less susceptible to spelling mistakes.
exclude(characters, character);
include(characters, succ(character));
end;
end;
// characters needs to be initialized,
// because the next `include` below
// will _read_ the value `characters`.
// Reading _unintialized_ values, however,
// is considered bad practice in Pascal.
characters := [];
// `div` denotes integer division in Pascal,
// that means the result will be an _integer_-value.
line := (ord(high(asciiCharacter)) - ord(low(asciiCharacter)))
div columnsTotal + 1;
// Note: In Pascal for-loop limits are _inclusive_.
for column := 0 to columnsTotal do
begin
// This is equivalent to
// characters := characters + [];
// i.e. the union of two sets.
include(characters, chr(ord(low(asciiCharacter)) + column * line));
end;
for line := line downto 1 do
begin
// the for..in..do statement is an Extended Pascal extension
for character in characters do
begin
// `:6` specifies minimum width of argument
// [only works for write/writeLn/writeStr]
write(ord(character):6, ' : ', character);
end;
// emit proper newline character on `output`
writeLn;
// `characters` is evaluated prior entering the loop,
// not every time an iteration finished.
for character in characters do
begin
// These statements are equivalent to
// characters := characters + [character];
// characters := characters - [succ(character)];
// respectively, but shorter to write,
// i.e. less susceptible to spelling mistakes.
exclude(characters, character);
include(characters, succ(character));
end;
end;
end.

View file

@ -1,19 +1,19 @@
$i
repeat($[i], 16) {
$j $= $i + 32
while($j < 128) {
if($j == 32) {
$val = SPC
}elif($j == 127) {
$val = DEL
}else {
$val = fn.char($j)
}
fn.printf(%4d : %-3s, $j, $val)
$j += 16
}
fn.println()
$j $= $i + 32
while($j < 128) {
if($j == 32) {
$val = SPC
}elif($j == 127) {
$val = DEL
}else {
$val = fn.char($j)
}
fn.printf(%4d : %-3s, $j, $val)
$j += 16
}
fn.println()
}

View file

@ -1,32 +1,32 @@
Function ProduceAscii$ {
Document Ascii$="\"
DelUnicode$=ChrCode$(0x2421)
j=0
Print Ascii$;
For i=0 to 15
Print Hex$(i, .5);
Ascii$=Hex$(i, .5)
Next
For i=0 to 32
If pos>16 then
Ascii$={
}+Hex$(j, .5)
Print : Print Hex$(j, .5);: j++
End if
Print Chrcode$(i+0x2400);
Ascii$=Chrcode$(i+0x2400)
Next
For i=33 to 126
If pos>16 then
Ascii$={
}+Hex$(j, .5)
Print : Print Hex$(j, .5);: j++
End if
Print Chr$(i);
Ascii$=Chr$(i)
Next
Print DelUnicode$
=Ascii$+DelUnicode$+{
}
Document Ascii$="\"
DelUnicode$=ChrCode$(0x2421)
j=0
Print Ascii$;
For i=0 to 15
Print Hex$(i, .5);
Ascii$=Hex$(i, .5)
Next
For i=0 to 32
If pos>16 then
Ascii$={
}+Hex$(j, .5)
Print : Print Hex$(j, .5);: j++
End if
Print Chrcode$(i+0x2400);
Ascii$=Chrcode$(i+0x2400)
Next
For i=33 to 126
If pos>16 then
Ascii$={
}+Hex$(j, .5)
Print : Print Hex$(j, .5);: j++
End if
Print Chr$(i);
Ascii$=Chr$(i)
Next
Print DelUnicode$
=Ascii$+DelUnicode$+{
}
}
Clipboard ProduceAscii$()

View file

@ -1,14 +1,14 @@
k = ""
for i in range(0, 15)
for j in range(32 + i, 127, 16)
if j = 32
k = "Spc"
else if j = 127
k = "Del"
else
k = chr(j)
end
print format("%3d : %-3s ", j, k)
end
println
for j in range(32 + i, 127, 16)
if j = 32
k = "Spc"
else if j = 127
k = "Del"
else
k = chr(j)
end
print format("%3d : %-3s ", j, k)
end
println
end

View file

@ -0,0 +1,20 @@
REM https://github.com/Eva-Broccoli/OPL-Rosetta-Code/blob/main/Asciitbl.opl
PROC main:
LOCAL i%,j%
i%=32
j%=1
WHILE i%<>48
WHILE j%<7
IF i%<100
PRINT " ";
ENDIF
PRINT i%,"-",CHR$(i%);" ";
i%=i%+16
j%=j%+1
ENDWH
PRINT
i%=i%-95
j%=1
ENDWH
GET
ENDP

View file

@ -0,0 +1,16 @@
local fmt = require "fmt"
for i = 0, 15 do
local j = 32 + i
while j < 128 do
local k = string.char(j)
if j == 32 then
k = "Spc"
elseif j == 127 then
k = "Del"
end
fmt.write("%3d : %-3s ", j, k)
j += 16
end
print()
end

View file

@ -5,12 +5,12 @@ chr <- function(n) {
idx <- 32
while (idx < 128) {
for (i in 0:5) {
num <- idx + i
if (num<100) cat(" ")
num <- idx + i
if (num<100) cat(" ")
cat(num,": ")
if (num == 32) { cat("Spc "); next }
if (num == 127) { cat("Del "); next }
cat(chr(num)," ")
if (num == 32) { cat("Spc "); next }
if (num == 127) { cat("Del "); next }
cat(chr(num)," ")
}
idx <- idx + 6
cat("\n")

View file

@ -0,0 +1,19 @@
Rebol [
title: "Rosetta code: Show ASCII table"
file: %Show_ASCII_table.r3
url: https://rosettacode.org/wiki/Show_ASCII_table
]
repeat i 16 [
repeat j 6 [
n: j - 1 * 16 + i + 31
prin ajoin [
pad n -3 ": "
pad any [
select [32 "Spc" 127 "Del"] n
to char! n
] 4
]
]
prin newline
]

View file

@ -0,0 +1,10 @@
\ publication syntax
main (p):+
for i =: from 32 upto 32+15
for j =: from 0 times 6 step 16
k =: i + j
c =: integer k code point as string
if c = ' ': c =: 'sp'
if k = 127: c =: 'del'
print format '%4; : %3; ' k, c nonl
print ''

View file

@ -4,19 +4,19 @@ VERSION "0.0000"
DECLARE FUNCTION Entry ()
FUNCTION Entry ()
FOR i = 32 TO 47
FOR j = i TO i + 80 STEP 16
SELECT CASE j
CASE 32
s$ = "Spc"
CASE 127
s$ = "Del"
CASE ELSE
s$ = CHR$(j)
END SELECT
PRINT RJUST$(" "+STRING(j),4); ": "; LJUST$(s$,3);
NEXT j
PRINT
NEXT i
FOR i = 32 TO 47
FOR j = i TO i + 80 STEP 16
SELECT CASE j
CASE 32
s$ = "Spc"
CASE 127
s$ = "Del"
CASE ELSE
s$ = CHR$(j)
END SELECT
PRINT RJUST$(" "+STRING(j),4); ": "; LJUST$(s$,3);
NEXT j
PRINT
NEXT i
END FUNCTION
END PROGRAM

View file

@ -1,9 +1,9 @@
for i = 32 to 47
for j = i to i + 80 step 16
s$ = chr$(j)
s$ = chr$(j)
if j = 32 s$ = "Spc"
if j = 127 s$ = "Del"
print str$(j, "#####"), ": ", s$;
print str$(j, "#####"), ": ", s$;
next j
print
next i

View file

@ -1,260 +1,260 @@
;
; Print ASCII table using Z80 assembly language
;
; Runs under CP/M 3.1 on YAZE-AG-2.51.2 Z80 emulator
; Assembled with zsm4 on same emulator/OS, uses macro capabilities of said assembler
; Created with vim under Windows
;
; Thanks to https://wikiti.brandonw.net for the idea for the conversion routine hl -> decimal ASCII
;
; 2023-04-04 Xorph
;
;
; Print ASCII table using Z80 assembly language
;
; Runs under CP/M 3.1 on YAZE-AG-2.51.2 Z80 emulator
; Assembled with zsm4 on same emulator/OS, uses macro capabilities of said assembler
; Created with vim under Windows
;
; Thanks to https://wikiti.brandonw.net for the idea for the conversion routine hl -> decimal ASCII
;
; 2023-04-04 Xorph
;
;
; Useful definitions
;
;
; Useful definitions
;
bdos equ 05h ; Call to CP/M BDOS function
strdel equ 6eh ; Set string delimiter
wrtstr equ 09h ; Write string to console
bdos equ 05h ; Call to CP/M BDOS function
strdel equ 6eh ; Set string delimiter
wrtstr equ 09h ; Write string to console
numrows equ 16d ; Number of rows for output
numcols equ 6d ; Number of columns for output
numrows equ 16d ; Number of rows for output
numcols equ 6d ; Number of columns for output
nul equ 00h ; ASCII control characters
esc equ 1bh
cr equ 0dh
lf equ 0ah
nul equ 00h ; ASCII control characters
esc equ 1bh
cr equ 0dh
lf equ 0ah
cnull equ '0' ; ASCII character constants
spc equ 20h
del equ 7fh
cnull equ '0' ; ASCII character constants
spc equ 20h
del equ 7fh
;
; Macros for BDOS calls
;
;
; Macros for BDOS calls
;
setdel macro char ; Set string delimiter to char
ld c,strdel
ld e,char
call bdos
endm
setdel macro char ; Set string delimiter to char
ld c,strdel
ld e,char
call bdos
endm
print macro msg ; Output string to console
ld c,wrtstr
ld de,msg
call bdos
endm
print macro msg ; Output string to console
ld c,wrtstr
ld de,msg
call bdos
endm
newline macro ; Print newline
ld c,wrtstr
ld de,crlf
call bdos
endm
newline macro ; Print newline
ld c,wrtstr
ld de,crlf
call bdos
endm
pushall macro ; Save all registers to stack
push af
push bc
push de
push hl
push ix
push iy
endm
pushall macro ; Save all registers to stack
push af
push bc
push de
push hl
push ix
push iy
endm
popall macro ; Recall all registers from stack
pop iy
pop ix
pop hl
pop de
pop bc
pop af
endm
popall macro ; Recall all registers from stack
pop iy
pop ix
pop hl
pop de
pop bc
pop af
endm
;
; =====================
; Start of main program
; =====================
;
;
; =====================
; Start of main program
; =====================
;
cseg
cseg
asciitab:
setdel nul ; Set string terminator to nul ('\0') - '$' is default in CP/M
setdel nul ; Set string terminator to nul ('\0') - '$' is default in CP/M
ld a,spc ; First ASCII code to print
ld a,spc ; First ASCII code to print
loop:
ld (char),a ; Put ASCII code in output placeholder
ld h,0 ; Register pair hl is used for printing the number, register h remains 0
ld l,a ; Put ASCII code in hl for decimal conversion
ld ix,buffer
call dispHL ; Create decimal representation
ld (char),a ; Put ASCII code in output placeholder
ld h,0 ; Register pair hl is used for printing the number, register h remains 0
ld l,a ; Put ASCII code in hl for decimal conversion
ld ix,buffer
call dispHL ; Create decimal representation
ld d,3d ; Pad decimal representation to 3 places with leading blanks
ld e,' ' ; Registers d and e are modified in macro, so assign each time
ld hl,buffer
ld bc,format
call padstrl
ld d,3d ; Pad decimal representation to 3 places with leading blanks
ld e,' ' ; Registers d and e are modified in macro, so assign each time
ld hl,buffer
ld bc,format
call padstrl
print format ; Print the whole thing
print colon
print format ; Print the whole thing
print colon
chkspc:
ld a,(char) ; Load again, register a was lost during BDOS calls
cp spc ; Check if Spc
jr nz,chkdel ; If not, check if Del
print txtspc ; If yes, print the text for Spc
jr nextcol ; ...and skip to the next column
ld a,(char) ; Load again, register a was lost during BDOS calls
cp spc ; Check if Spc
jr nz,chkdel ; If not, check if Del
print txtspc ; If yes, print the text for Spc
jr nextcol ; ...and skip to the next column
chkdel:
ld a,(char) ; Load again, register a was lost during BDOS calls
cp del ; Check if Del
jr nz,printc ; If not, print normal char
print txtdel ; If yes, print the text for Del
jr nextcol ; ...and skip to the next column
ld a,(char) ; Load again, register a was lost during BDOS calls
cp del ; Check if Del
jr nz,printc ; If not, print normal char
print txtdel ; If yes, print the text for Del
jr nextcol ; ...and skip to the next column
printc:
print char ; Normal char
print char ; Normal char
nextcol:
ld a,(curcol) ; Increase output column
inc a
cp numcols ; If last column, go to next row
jr z,nextrow
ld (curcol),a ; Save column counter
ld a,(char) ; Increase ASCII code by the number of rows for next column in same row
add a,numrows
jr loop ; Next code
ld a,(curcol) ; Increase output column
inc a
cp numcols ; If last column, go to next row
jr z,nextrow
ld (curcol),a ; Save column counter
ld a,(char) ; Increase ASCII code by the number of rows for next column in same row
add a,numrows
jr loop ; Next code
nextrow:
newline ; Display next row
xor a ; Set column counter back to 0
ld (curcol),a
ld a,(currow) ; Increase row counter
inc a
cp numrows ; When last row has been finished, we are done
jr z,exitprg
newline ; Display next row
xor a ; Set column counter back to 0
ld (curcol),a
ld a,(currow) ; Increase row counter
inc a
cp numrows ; When last row has been finished, we are done
jr z,exitprg
ld (currow),a ; Save row counter
ld a,(char) ; Set ASCII code back to starting code of next row
sub a,numrows * (numcols - 1d) - 1d
jp loop ; Use jp instead of jr because of jump distance!
ld (currow),a ; Save row counter
ld a,(char) ; Set ASCII code back to starting code of next row
sub a,numrows * (numcols - 1d) - 1d
jp loop ; Use jp instead of jr because of jump distance!
exitprg:
newline
ret ; Return to CP/M
newline
ret ; Return to CP/M
;
; ===================
; End of main program
; ===================
;
;
; ===================
; End of main program
; ===================
;
;
; Helper routines - notice that the Z80 does not have a divide instruction
; Notice further that CP/M does not have any support for pretty-printing
; formatted numbers and stuff like that. So we have to do all this by hand...
;
;
; Helper routines - notice that the Z80 does not have a divide instruction
; Notice further that CP/M does not have any support for pretty-printing
; formatted numbers and stuff like that. So we have to do all this by hand...
;
;
; Converts the value (unsigned int) in register hl to its decimal representation
; Register ix has memory address of target for converted value
; String is terminated with nul character (\0)
;
;
; Converts the value (unsigned int) in register hl to its decimal representation
; Register ix has memory address of target for converted value
; String is terminated with nul character (\0)
;
dispHL:
pushall
ld b,1 ; Flag for leading '0'
irp x,<-10000,-1000,-100,-10,-1>
ld de,x ; Subtract powers of 10 and determine digit
call calcdig
endm
pushall
ld b,1 ; Flag for leading '0'
irp x,<-10000,-1000,-100,-10,-1>
ld de,x ; Subtract powers of 10 and determine digit
call calcdig
endm
ld a,nul ; Terminate result string with nul
ld (ix+0),a
ld a,nul ; Terminate result string with nul
ld (ix+0),a
popall
ret ; End of conversion routine
popall
ret ; End of conversion routine
calcdig:
ld a,cnull-1 ; Determine the digit character
ld a,cnull-1 ; Determine the digit character
incrdig:
inc a ; Start with '0'
add hl,de ; As long as subtraction is possible, increment digit character
jr c,incrdig
inc a ; Start with '0'
add hl,de ; As long as subtraction is possible, increment digit character
jr c,incrdig
sbc hl,de ; If negative, undo last subtraction and continue with remainder
cp cnull ; Check for leading '0', these are ignored
jr nz,adddig
bit 0,b ; Use bit instruction for check if flag set, register a contains digit
ret nz ; If '0' found and flag set, it is a leading '0' and we return
sbc hl,de ; If negative, undo last subtraction and continue with remainder
cp cnull ; Check for leading '0', these are ignored
jr nz,adddig
bit 0,b ; Use bit instruction for check if flag set, register a contains digit
ret nz ; If '0' found and flag set, it is a leading '0' and we return
adddig:
ld b,0 ; Reset flag for leading '0', we are now outputting digits
ld (ix+0),a ; Store character in memory and set ix to next location
inc ix
ld b,0 ; Reset flag for leading '0', we are now outputting digits
ld (ix+0),a ; Store character in memory and set ix to next location
inc ix
ret ; End of conversion helper routine
ret ; End of conversion helper routine
;
; Formats a string to the specified minimum width with the specified filler character
; Register hl has memory address of nul-terminated string
; Register bc has memory address of target for padded string
; Register d has width
; Register e has filler character/byte
; Padding is on the left (function is intended for padding integer numbers)
;
;
; Formats a string to the specified minimum width with the specified filler character
; Register hl has memory address of nul-terminated string
; Register bc has memory address of target for padded string
; Register d has width
; Register e has filler character/byte
; Padding is on the left (function is intended for padding integer numbers)
;
padstrl:
pushall
push hl ; Save address of source for copy later on
ld a,d ; Check if width is 0, just copy string if so
cp 0
jr z,copysrc
ld a,nul ; Search for end of string. Each non-nul character decrements d
pushall
push hl ; Save address of source for copy later on
ld a,d ; Check if width is 0, just copy string if so
cp 0
jr z,copysrc
ld a,nul ; Search for end of string. Each non-nul character decrements d
findnul:
cp (hl)
jr z,nulfound ; Found end of string, d contains number of padding to add
dec d
jr z,copysrc
inc hl
jr findnul ; Repeat with next character
cp (hl)
jr z,nulfound ; Found end of string, d contains number of padding to add
dec d
jr z,copysrc
inc hl
jr findnul ; Repeat with next character
nulfound:
ld a,e ; Store as many padding characters to target as specified in register d
ld a,e ; Store as many padding characters to target as specified in register d
inspad:
ld (bc),a
inc bc ; Move to next memory address and decrease d
dec d
jr nz,inspad
ld (bc),a
inc bc ; Move to next memory address and decrease d
dec d
jr nz,inspad
copysrc:
pop hl ; Transfer source to target, bc points to first memory address after padding
pop hl ; Transfer source to target, bc points to first memory address after padding
movechar:
ld a,(hl)
ld (bc),a
inc hl
inc bc
cp nul ; Check if nul character copied
jr nz,movechar ; If no, repeat with next character
ld a,(hl)
ld (bc),a
inc hl
inc bc
cp nul ; Check if nul character copied
jr nz,movechar ; If no, repeat with next character
popall
ret ; End of padding routine
popall
ret ; End of padding routine
;
; ================
; Data definitions
; ================
;
;
; ================
; Data definitions
; ================
;
dseg
dseg
crlf: defb cr,lf,nul ; Generic newline
buffer: defs 10 ; Buffer for conversion of number to text
format: defs 10 ; Formatted number for output
colon: defz ' : ' ; Separator number/character, nul-terminated
char: defz ' ' ; Placeholder for ASCII character, nul-terminated
txtspc: defz 'Spc ' ; Space character 20h
txtdel: defz 'Del ' ; Del character 7fh
currow: defb 0d ; Current row
curcol: defb 0d ; Current column
crlf: defb cr,lf,nul ; Generic newline
buffer: defs 10 ; Buffer for conversion of number to text
format: defs 10 ; Formatted number for output
colon: defz ' : ' ; Separator number/character, nul-terminated
char: defz ' ' ; Placeholder for ASCII character, nul-terminated
txtspc: defz 'Spc ' ; Space character 20h
txtdel: defz 'Del ' ; Del character 7fh
currow: defb 0d ; Current row
curcol: defb 0d ; Current column