I need help with my hangman project in assembly language. I need to read words a
ID: 3572564 • Letter: I
Question
I need help with my hangman project in assembly language. I need to read words a text file to store a list and choose one using an LFSR pseudo-random number generator written in assembly language. No need of display of hangman/gallow.
For my project progress report, I need:
High level pseudocode and description to describe HOW you will implement your project code.
List of tasks you need to complete before submitting the project.
List of items you need (Hardware and software) in order to debug, demonstrate and submit your project.
Revised and updated schedule.
PLEASE HELP!!!
Explanation / Answer
.def rand16 ; get 16-bit random #
.def setrandSeed ; set random # seed
.def getrandSeed ; get current random # seed
.def MPYU ; r4 x r5 -> r6|r7
.def DIVU ; r4|r5 / r6 -> r5 R r4
SEED .equ 21845 ; Arbitrary seed value (65536/3)
MULT .equ 31821 ; Multiplier value (last 3 Digits are even21)
INC .equ 13849 ; 1 and 13849 have been tested
.bss randSeed,2 ; random seed
.text ; Program Section
setrandSeed:
mov.w r12,&randSeed ; set seed
ret
getrandSeed:
mov.w &randSeed,r12 ; return seed
ret
rand16:
push r4 ; save registers
push r5
push r6
push r7
mov.w &randSeed,r5 ; Prepare multiplication
mov.w #MULT,r4 ; Prepare multiplication
call #MPYU ; Call unsigned MPY (5.1.1)
add.w #INC,r7 ; Add INC to low word of product
mov.w r7,&randSeed ; Update randSeed
mov.w r7,r12 ; return in r12
swpb r12
and.w #0x7fff,r12 ; 0-32767
pop r7 ; restore registers
pop r6
pop r5
pop r4
ret
MPYU: clr.w r7 ; 0 -> LSBs RESULT
clr.w r6 ; 0 -> MSBs RESULT
MACU: push r8
clr.w r8 ; MSBs MULTIPLIER
L$01: bit.w #1,r4 ; TEST ACTUAL BIT 5-4
jz L$02 ; IF 0: DO NOTHING
add.w r5,r7 ; IF 1: ADD MULTIPLIER TO RESULT
addc.w r8,r6
L$02: rla.w r5 ; MULTIPLIER x 2
rlc.w r8 ;
rrc.w r4 ; NEXT BIT TO TEST
jnz L$01 ; IF BIT IN CARRY: FINISHED
L$03: pop r8
ret
DIVU: push r7
push r8
clr.w r7 ; clear result
mov.w #17,r8 ; initialize loop counter
D$01: cmp.w r6,r4 ; subtrahend < minuhend?
jlo D$02 ; n
sub.w r6,r4 ; y, subtract out
D$02: rlc.w r7 ; next bit, overflow?
jc D$04 ; y, result > 16 bits
dec.w r8 ; n, decrement loop counter, done?
jz D$03 ; y, terminate w/o error
rla.w r5 ; n,
rlc.w r4 ; adjust result, enter bit in result?
jnc D$01 ; n
sub.w r6,r4 ; y
setc
jmp D$02
D$03: clrc ; no error, c = 0
D$04: mov.w r7,r5 ; return r5 = r4|r5 / r6
pop r8
pop r7
ret ; error indication in c
.end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.