summaryrefslogtreecommitdiff
path: root/assembly/win95/win95.S
diff options
context:
space:
mode:
Diffstat (limited to 'assembly/win95/win95.S')
-rw-r--r--assembly/win95/win95.S202
1 files changed, 202 insertions, 0 deletions
diff --git a/assembly/win95/win95.S b/assembly/win95/win95.S
index 0ecd394..ace9008 100644
--- a/assembly/win95/win95.S
+++ b/assembly/win95/win95.S
@@ -1,5 +1,204 @@
_start:
+# Print menu
+li a7,4
+la a0,menumsg
+ecall
+
+# Read the user's input
+li a7,5
+ecall
+
+li t0,1
+beq a0,t0,retailkey
+li t0,2
+beq a0,t0,oemkey
+li t0,3
+beq a0,t0,upgradepassword
+j _start
+
+retailkey:
+
+# Clear the screen
+li a7,4
+la a0,clearscreenmsg
+ecall
+
+# Section 1: any 3 numbers, with some exceptions
+# Generate 3 random numbers, 0-9
+li a0,0
+li a1,9
+li a7,128
+ecall
+mv s0,a0
+li a0,0
+li a1,9
+li a7,128
+ecall
+mv s1,a0
+li a0,0
+li a1,9
+li a7,128
+ecall
+mv s2,a0
+
+# In the case of the first two being the same and NOT 0/1/2, the third must be different
+bne s0,s1,1f # digits 1/2 are not the same
+bne s1,s2,1f # digits 2/3 are not the same
+li t0,3
+blt s2,t0,1f # all are less than 3
+
+# Just decrement the 3rd digit so it's not the same, it's always at least 3 if we're
+# here, so this won't underflow
+addi s2,s2,-1
+
+1:
+# Print the digits
+li a7,1
+mv a0,s0
+ecall
+li a7,1
+mv a0,s1
+ecall
+li a7,1
+mv a0,s2
+ecall
+
+# Print a dash
+li a7,11
+li a0,'-'
+ecall
+
+# Section 2a: any 6 digits
+li s0,0
+li t0,6
+1:
+li a0,0
+li a1,9
+li a7,128
+ecall
+add s0,s0,a0
+li a7,1
+ecall
+addi t0,t0,-1
+bnez t0,1b
+
+# Section 2b: Check digit for section 2a
+li t0,7
+rem s0,s0,t0
+sub a0,t0,s0
+li a7,1
+ecall
+
+j anykey
+
+oemkey:
+
+# Clear the screen
+li a7,4
+la a0,clearscreenmsg
+ecall
+
+# Section 1a: Any 3-digit number 001-366
+li a0,1
+li a1,366
+li a7,128
+ecall
+mv s0,a0
+
+li t0,100
+div a0,s0,t0
+addi a0,a0,0x30
+li a7,11
+ecall
+
+li t0,10
+div a0,s0,t0
+li t0,10
+rem a0,a0,t0
+addi a0,a0,0x30
+li a7,11
+ecall
+
+li t0,10
+rem a0,s0,t0
+addi a0,a0,0x30
+li a7,11
+ecall
+
+# Section 1b: 2 digits, >=95 or <=03
+li a0,0
+li a1,8
+li a7,128
+ecall
+addi s0,a0,95
+li t0,100
+rem s0,s0,t0
+
+li t0,10
+div a0,s0,t0
+addi a0,a0,0x30
+li a7,11
+ecall
+
+li t0,10
+rem a0,s0,t0
+addi a0,a0,0x30
+li a7,11
+ecall
+
+# Section 2 and 3a: '-OEM-0'
+la a0,oemmsg
+li a7,4
+ecall
+
+# Section 3b: Any 5 digits
+li s0,0
+li t0,5
+1:
+li a0,0
+li a1,9
+li a7,128
+ecall
+add s0,s0,a0
+li a7,1
+ecall
+addi t0,t0,-1
+bnez t0,1b
+
+# Section 3c: Check digit for section 3b
+li t0,7
+rem s0,s0,t0
+sub a0,t0,s0
+li a7,1
+ecall
+
+# Another dash
+li a0,'-'
+li a7,11
+ecall
+
+# Section 4: Any 5 digits
+li t0,5
+1:
+li a0,0
+li a1,9
+li a7,128
+ecall
+li a7,1
+ecall
+addi t0,t0,-1
+bnez t0,1b
+
+j anykey
+
+upgradepassword:
+
+# Clear the screen
+la a0,clearscreenmsg
+li a7,4
+ecall
+
# Clear the input buffer
la t0,inputbuf
sd x0,0(t0)
@@ -132,6 +331,7 @@ addi a0,a0,0x30
li a7,11
ecall
+anykey:
# Wait for user to press any key before clearing the screen and restarting
li a7,4
la a0,anykeymsg
@@ -152,10 +352,12 @@ la a0,inputerrormsg
ecall
j _start
+menumsg: .asciz "1: Retail Key\n2: OEM Key\n3: Upgrade Password\n\nEnter your choice:\n"
keypromptmsg: .asciz "Enter key: "
passwordheadermsg: .asciz "Password: "
inputerrormsg: .asciz "Invalid entry\n\n"
anykeymsg: .asciz "\n\nPress any key..."
+oemmsg: .asciz "-OEM-\n0"
clearscreenmsg: .asciz "\n\n\n\n\n\n"
inputbuf: .skip 7
.globl _start