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

@ -0,0 +1,131 @@
bdos equ 5
getch equ 1
putch equ 2
puts equ 9
cr equ 13
lf equ 10
wboot equ 0
;
org 100h
lxi sp,stack ; set our own stack
;
; obtain two numbers from the console
;
lxi d,pmt1st
mvi c,puts
call bdos
call getdec
shld first
call crlf
lxi d,pmt2nd
mvi c,puts
call bdos
call getdec
shld second
call crlf
;
; compare them (1st in HL, 2nd in DE)
;
lhld second
xchg
lhld first
call cmp16
cz isequal
call cmp16
cc isless
call cmp16
jz $+6
cnc isgreater
jmp done
isequal:
push d
push h
lxi d,eqmsg
mvi c,puts
call 5
pop h
pop d
ret
isless: push d
push h
lxi d,ltmsg
mvi c,puts
call 5
pop h
pop d
ret
isgreater:
push d
push h
lxi d,gtmsg
mvi c,puts
call 5
pop h
pop d
ret
done: jmp wboot
;----------------------------------------------------
; unsigned comparison of HL and DE
; return with zero flag set if HL=DE
; return with carry set if HL < DE (NC if HL >= DE)
;----------------------------------------------------
cmp16: mov a,h
cmp d
rnz
mov a,l
cmp e
ret
;-------------------------------------------------------
; read decimal number from keyboard and return with
; unsigned binary equivalent in HL
;-------------------------------------------------------
getdec: lxi h,0
newdig: push h
mvi c,getch
call bdos
pop h
sui 30h ; convert from ASCII to binary
rm ; return if less than 0
cpi 10
rp ; return if greater than 9
; multiply HL by 10 then add new digit
push h
pop d
dad h ; double HL (= HL*2)
dad h ; double it again (= HL*4)
dad d ; add starting value (= HL*5)
dad h ; then double it (= HL*10)
mvi d,0
mov e,a
dad d ; add new digit to number
jmp newdig
;-----------------------------------------------------
; write CRLF to console
;-----------------------------------------------------
crlf: push b
push d
push h
mvi e,cr
mvi c,putch
call bdos
mvi e,lf
mvi c,putch
call bdos
pop h
pop d
pop b
ret
;-----------------------------------------------------
; data and stack
;-----------------------------------------------------
first: dw 0
second: dw 0
pmt1st: db 'First number : $'
pmt2nd: db 'Second number: $'
eqmsg: db 'The two numbers are equal',cr,lf,'$'
gtmsg: db 'The first number is greater than the second'
db cr,lf,'$'
ltmsg: db 'The first number is less than the second'
db cr,lf,'$'
stack equ $+128
end

View file

@ -0,0 +1,13 @@
begin
integer a, b;
outstring(1,"First number : ");
ininteger(0, a);
outstring(1,"Second number: ");
ininteger(0,b);
if a = b then outstring(1,"The two numbers are equal");
if a < b then outstring(1,"The first number is less than the second");
if a > b then outstring(1,"The first number is greater than the second");
end

View file

@ -0,0 +1,13 @@
begin
integer a, b;
write("First number :" );
read(a);
write("Second number: ");
read(b);
if a = b then write("The two numbers are equal");
if a < b then write("The first number is less than the second");
if a > b then write("The first number is greater than the second");
end

View file

@ -0,0 +1,16 @@
begin
integer a, b;
write("First number:" );
read(a);
write("Second number: ");
read(b);
if a = b then
write("The two numbers are equal")
else if a < b then
write("The first number is less than the second")
else % a must be greater than b %
write("The first number is greater than the second");
end

View file

@ -0,0 +1,24 @@
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_Io;
procedure Compare_Ints is
A, B : Integer;
begin
Get(Item => A);
Get(Item => B);
-- Test for equality
if A = B then
Put_Line("A equals B");
end if;
-- Test For Less Than
if A < B then
Put_Line("A is less than B");
end if;
-- Test For Greater Than
if A > B then
Put_Line("A is greater than B");
end if;
end Compare_Ints;

View file

@ -0,0 +1,8 @@
(let a (toNumber (input "a> ")))
(let b (toNumber (input "b> ")))
(if (= a b)
(print "a = b")
(if (< a b)
(print "a < b")
(print "a > b")))

View file

@ -0,0 +1,21 @@
import ballerina/io;
public function main() returns error? {
int|error a;
int|error b;
while true {
a = int:fromString(io:readln("Enter value of a: "));
if a is error { break; }
b = int:fromString(io:readln("Enter value of b: "));
if b is error { break; }
if a < b {
io:println(`${a} < ${b}`);
}
if a == b {
io:println(`${a} == ${b}`);
}
if a > b {
io:println(`${a} > ${b}`);
}
}
}

View file

@ -0,0 +1,26 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. Int-Compare.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC 9(10).
01 B PIC 9(10).
PROCEDURE DIVISION.
DISPLAY "First number: " WITH NO ADVANCING
ACCEPT A
DISPLAY "Second number: " WITH NO ADVANCING
ACCEPT B
* *> Note: Longer verbal forms may be used instead of symbols
* *> e.g. 'IS GREATER THAN' instead '<'
IF A < B
DISPLAY A " is less than " B
ELSE IF A = B
DISPLAY A " is equal to " B
ELSE IF A > B
DISPLAY A " is larger than " B
END-IF.
GOBACK
.

View file

@ -0,0 +1,12 @@
print("Enter first number: ")
a = gets.not_nil!.to_i
print("Enter second number: ")
b = gets.not_nil!.to_i
puts "#{a} is " +
if a > b; "greater than"
elsif a < b; "less than"
elsif a == b; "equal to"
else "?"
end + " #{b}."

View file

@ -1,15 +1,15 @@
fun main = int by List args
fun main int by List args
int a, b
if args.length > 1
a = int!args[0]
b = int!args[1]
a int!args[0]
b int!args[1]
else
a = ask(int, "Enter the first integer ")
b = ask(int, "Enter the second integer ")
a ask(int, "Enter the first integer ")
b ask(int, "Enter the second integer ")
end
writeLine("=== a <> b is " + (a <> b) + " ===")
writeLine("[ a ◇ b is " + (a ◇ b) + " ]")
if a < b do writeLine(a + " < " + b) end
if a == b do writeLine(a + " == " + b) end
if a æ b do writeLine(a + " æ " + b) end
if a > b do writeLine(a + " > " + b) end
return 0
end

View file

@ -0,0 +1,7 @@
(defun integer-comparison (a b)
"Compare A to B and print the outcome in the message buffer."
(interactive "nFirst integer ⇒\nnSecond integer ⇒")
(cond
((< a b) (message "%d is less than %d." a b))
((> a b) (message "%d is greater than %d." a b))
((= a b) (message "%d is equal to %d." a b))))

View file

@ -0,0 +1,15 @@
include get.e
integer a,b
a = floor(prompt_number("a = ",{}))
b = floor(prompt_number("b = ",{}))
puts(1,"a is ")
if a < b then
puts(1,"less then")
elsif a = b then
puts(1,"equal to")
elsif a > b then
puts(1,"grater then")
end if
puts(1," b")

View file

@ -0,0 +1,20 @@
HAI 1.3
I HAS A X
I HAS A Y
VISIBLE "GIMMEH A NUMBR:"
GIMMEH X
X IS NOW A NUMBR
VISIBLE "GIMMEH ANOTHR NUMBR:"
GIMMEH Y
Y IS NOW A NUMBR
BOTH SAEM X AN Y, O RLY?
YA RLY, VISIBLE ":{X} IZ EQUAL TO :{Y}"
MEBBE DIFFRINT X AN SMALLR OF X AN Y
VISIBLE ":{X} IZ GREATR THN :{Y}"
MEBBE DIFFRINT X AN BIGGR OF X AN Y
VISIBLE ":{X} IZ LESS THN :{Y}"
OIC
KTHXBYE

View file

@ -0,0 +1,10 @@
$a = [int] (Read-Host a)
$b = [int] (Read-Host b)
if ($a -lt $b) {
Write-Host $a is less than $b`.
} elseif ($a -eq $b) {
Write-Host $a is equal to $b`.
} elseif ($a -gt $b) {
Write-Host $a is greater than $b`.
}

View file

@ -0,0 +1,229 @@
# riscv assembly raspberry pico2 rp2350
# program compinteger.s
# connexion putty com3
/*********************************************/
/* CONSTANTES */
/********************************************/
/* for this file see risc-v task include a file */
.include "../../constantesRiscv.inc"
.equ BUFFERSIZE, 80
/*******************************************/
/* INITIALED DATAS */
/*******************************************/
.data
szMessStart: .asciz "Program riscv start.\r\n"
szMessEnd: .asciz "\nProgram end OK.\r\n"
szCariageReturn: .asciz "\r\n"
szMessNumber1: .asciz "Enter an integer : "
szMessNumber2: .asciz "Enter other integer : "
szMessErreurBuf: .asciz "Buffer too small !!"
szMessErrDep: .asciz "Number too large for 32 bits\r\n"
szMessEqual: .asciz "number 1 equal number 2."
szMessLower: .asciz "number 1 smaller number 2."
szMessGreater: .asciz "number 1 greater number 2."
.align 2
/*******************************************/
/* UNINITIALED DATA */
/*******************************************/
.bss
.align 2
sConvArea: .skip 24
sBuffer: .skip BUFFERSIZE
/**********************************************/
/* SECTION CODE */
/**********************************************/
.text
.global main
main:
call stdio_init_all # général init
1: # start loop connexion
li a0,0 # raz argument register
call tud_cdc_n_connected # waiting for USB connection
beqz a0,1b # return code = zero ?
la a0,szMessStart # message address
call writeString # display message
2:
la a0,szMessNumber1
call writeString # display message
la a0,sBuffer
li a1,BUFFERSIZE
call readString # read keyboard string
la a0,sBuffer
call conversionAtoD # conversion to decimal
mv s0,a0
call displayresult
la a0,szMessNumber2 # number 2
call writeString
la a0,sBuffer
li a1,BUFFERSIZE
call readString # read keyboard string
la a0,sBuffer
call conversionAtoD # conversion to decimal
mv s1,a0
call displayresult
blt s0,s1,4f # compare number 1 number 2
bgt s0,s1,3f
la a0,szMessEqual
call writeString
j 20f
3:
la a0,szMessGreater
call writeString
j 20f
4:
la a0,szMessLower
call writeString
20:
la a0,szCariageReturn
call writeString
j 2b # loop other compare number
la a0,szMessEnd
call writeString
call getchar
100: # final loop
j 100b
/***************************************************/
/* number display */
/***************************************************/
# a0 contains number
# a0 return length
displayresult:
addi sp, sp, -4 # reserve stack
sw ra, 0(sp) # save registers
la a1,sConvArea
call conversion10S # call decimal conversion
la a0,sConvArea # display result message
call writeString
la a0,szCariageReturn
call writeString
lw ra, 0(sp)
addi sp, sp, 4
ret
/**************************************************/
/* read keyboard string */
/**************************************************/
/* a0 buffer address */
/* a1 buffer size */
readString: # INFO: readString
addi sp, sp, -16
sw ra, 0(sp)
sw s0, 4(sp)
sw s1, 8(sp)
sw s2, 12(sp)
mv s0,a0 # buffer address
li s1,0
mv s2,a1
1:
li a0,100
call getchar # read a character
beqz a0,2f # end ?
li a1,0xD
beq a0,a1,2f # return char ?
add t1,s0,s1
sb a0,(t1) # store char in buffer
addi s1,s1,1 # next char
bge s1,s2,99f
call putchar # display char
j 1b # and loop
2:
add s1,s0,s1
sb x0,(s1) # zero final
li a0,0xA
call putchar
li a0,0xD
call putchar
mv a0,s1 # return counter character
j 100f
99: # error
la a0,szMessErreurBuf
call writeString
li a0,-1
100:
lw ra, 0(sp)
lw s0, 4(sp)
lw s1, 8(sp)
lw s2, 12(sp)
addi sp, sp, 16
ret
/******************************************************************/
/* String conversion numeric to register */
/******************************************************************/
.equ NUMMAXI, 1073741824
/* a0 string address */
/* a0 return value */
conversionAtoD: # INFO: conversionAtoD
addi sp, sp, -4 # save registres
sw ra, 0(sp)
li t2,10 # factor
li t3,0 # counter
mv t4,a0 # string address
li t1,0 # default positive sign
li a0,0 # init to 0
1: # loop removing leading spaces
add t0,t4,t3
lbu t5,(t0) # load a byte
beqz t5,100f # string end -> end
li t0,0x0A #
beq t5,t0,100f # string end -> end
li t0,' ' #
bne t5,t0,2f # no space ?
addi t3,t3,1 # yes --> loop next position
j 1b
2:
li t0,'-' # first byte is - ?
bne t5,t0,21f
li t1,1 # negative sign
j 4f # next position
21:
li t0,'+' # first byte is + ?
beq t5,t0,4f # yes -> next position
3: # debut de boucle de traitement des chiffres
li t0,'0'
blt t5,t0,4f # byte is not numeric
li t0,'9'
bgt t5,t0,4f # byte is not numeric
addi t5,t5,-48
li t0,NUMMAXI
bgt a0,t0,99f # number maxi ?
mul a0,t2,a0 # multiply by factor 10
add a0,a0,t5 # and add new byte
4:
addi t3,t3,1 # next position
add t0,t4,t3
lbu t5,(t0) # load byte
beq t5,x0,5f # string end -> end
li t0,0x0A
beq t5,t0,5f # string end -> end
j 3b # or loop
5:
beqz t1,100f # positive sign ?
neg a0,a0 # no
j 100f
99: # overflow error
la a0,szMessErrDep
call writeString
li a0,0 # on error return zero
100:
lw ra, 0(sp)
addi sp, sp, 4
ret
/************************************/
/* file include Fonctions */
/***********************************/
/* for this file see risc-v task include a file */
.include "../../includeFunctions.s"

View file

@ -0,0 +1,11 @@
let my_compare = (a, b) => {
if a < b { "A is less than B" } else
if a > b { "A is greater than B" } else
if a == b { "A equals B" }
else { "cannot compare NANs" }
}
let a = int_of_string(Sys.argv[2])
let b = int_of_string(Sys.argv[3])
Js.log(my_compare(a, b))

View file

@ -0,0 +1,13 @@
Rebol [
Title: "Comparing Two Integers"
URL: http://rosettacode.org/wiki/Comparing_two_integers
]
a: ask "First integer? " b: ask "Second integer? "
relation: [
a < b "less than"
a = b "equal to"
a > b "greater than"
]
print [a "is" case relation b]

View file

@ -0,0 +1,4 @@
a: integer input "Enter value of a"
b: integer input "Enter value of b"
cases a { { a < b } { print "Less than" } { a = b } { print "Equal to" } { a > b } { print "Greater than" } }

View file

@ -0,0 +1,27 @@
option explicit
function eef( b, r1, r2 )
if b then
eef = r1
else
eef = r2
end if
end function
dim a, b
wscript.stdout.write "First integer: "
a = cint(wscript.stdin.readline) 'force to integer
wscript.stdout.write "Second integer: "
b = cint(wscript.stdin.readline) 'force to integer
wscript.stdout.write "First integer is "
if a < b then wscript.stdout.write "less than "
if a = b then wscript.stdout.write "equal to "
if a > b then wscript.stdout.write "greater than "
wscript.echo "Second integer."
wscript.stdout.write "First integer is " & _
eef( a < b, "less than ", _
eef( a = b, "equal to ", _
eef( a > b, "greater than ", vbnullstring ) ) ) & "Second integer."