| | |
Need help in LC# code
![]() |
you should probably get the recommended book Introduction to Computing Systems: From Bits and Gates to C and Beyond and read it. I don't know the first thing about it, so can't help you.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
You're just in luck. I just finished writing a similar subroutine for my assembly class (uses the same textbook as mentioned above) to ask if someone wants to play again (we've made the game pong breakout). The following code is documented well enough for you to understand it clearly.
Assembly Syntax (Toggle Plain Text)
; ; Prompts the user for something. ; ; Preconditions: ; ; TRAP x42 must be implemented in the OS in a way that it does not wait ; for a key to be pressed. It should only check if a key's pressed once. ; ; Must use the following declarations. ; ; PROMPT .STRINGZ "Would you like to do something (y/n)? " ; HEX_Y1 .FILL x79 ; hex for 'y' ; HEX_Y2 .FILL x59 ; hex for 'Y' ; HEX_N1 .FILL x6E ; hex for 'n' ; HEX_N2 .FILL x4E ; hex for 'N' ; ; Postconditions: ; ; If yes, return 1 in R0. ; If no, return 0 in R0. ; PROMPT_SR LEA R0, PROMPT ; Load PROMPT to R0 be a string. TRAP x22 ; Print the string in R0. POLL TRAP x42 ; Get the key press. (This code assumes that ; TRAP x42 does not wait for a key to be pressed. LD R4, HEX_Y1 ; Load the hex value for 'y'. NOT R4, R4; ; Get the 2's compliment ADD R4, R4, #1 ; ADD R4, R5, R4 ; R4 = R5 - R4 BRz YES ; If R5 is zero, then 'y' was pressed. LD R4, HEX_Y2 ; Load the hex value for 'Y'. NOT R4, R4; ; Get the 2's compliment ADD R4, R4, #1 ; ADD R4, R5, R4 ; R4 = R5 - R4 BRz YES ; If R5 is zero, then 'Y' was pressed. LD R4, HEX_N1 ; Load the hex value for 'n'. NOT R4, R4; ; Get the 2's compliment ADD R4, R4, #1 ; ADD R4, R5, R4 ; R4 = R5 - R4 BRz NO ; If R5 is zero, then 'n' was pressed. LD R4, HEX_N2 ; Load the hex value for 'N'. NOT R4, R4; ; Get the 2's compliment ADD R4, R4, #1 ; ADD R4, R5, R4 ; R4 = R5 - R4 BRz NO ; If R5 is zero, then 'N' was pressed. BRnzp POLL ; y/Y or n/N has not bee pressed, so poll again. YES: AND R0, R0, #0 ; Clear R0. ADD R0, R0, #1 ; Add one to R0. RET NO: AND R0, R0, #0 ; Clear R0. RET
Last edited by c0dex; Dec 4th, 2008 at 11:29 pm.
![]() |
Similar Threads
- Code 19 Registry Error (Windows NT / 2000 / XP)
- Why won't this code work? (VB.NET)
- Need help with DirectX code (C)
- Tutorials & Code Submissions - Questions? (DaniWeb Community Feedback)
- Some Basic Code Hopefully (Help Needed) (HTML and CSS)
Other Threads in the Assembly Forum
- Previous Thread: rs232 and assembly
- Next Thread: I need help with matrix color
| Thread Tools | Search this Thread |






