4 Replies - 972 Views - Last Post: 11 October 2016 - 04:40 AM

#1 ChrisHex1   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 10-October 16

Basic ASM Question

Posted 10 October 2016 - 05:33 AM

Hi All,

I am struggling greatly with a practice problem I found online.

This is taken from the SMS32V50 Program Website:

; --------------------------------------------------------------
;  Input key presses from the keyboard until Enter is pressed.
; --------------------------------------------------------------
	CLO		; Close unwanted windows.
Rep:
	IN	00	; Wait for key press - Store it in AL.
	CMP	AL,0D	; Was it the Enter key? (ASCII 0D)
	JNZ	Rep	; No - jump back.  Yes - end.



END
; --------------------------------------------------------------

TASK
Harder! Store all the text you type in RAM when you type it in.
When you press Enter, display the stored text on the VDU display.


I have put the the section I need help with in bold. Below is what I have so far, and I am not having any luck. What is happening is when I go to type in letters, upon hitting enter the first character I entered increases until the alphabet is finished.. What I need to have happen is to type in a message, hit enter and then have the display produce it.

My Code:

;===============================================================
         CLO            ; Close unwanted windows.
         MOV BL, A0     ; Move value to top left
Rep:
         
         IN 00          ; Wait for key press - Store in AL.
         MOV [BL], AL   ; Move value held in BL memory location into display
         INC BL         ; Increment BL
         CMP AL, 0D     ; Compare -- was it the Enter key? (ASCII 0D)
         JNZ Rep        ; No - Jump back.   Yes - end.
         MOV CL, C0
         MOV DL, [A0]

Rep01:   MOV [CL], DL
         INC BL
         INC CL
         INC DL 
         CMP CL, 00
         JNZ Rep01
         END
;===============================================================




Is This A Good Question/Topic? 0
  • +

Replies To: Basic ASM Question

#2 turboscrew   User is offline

  • D.I.C Lover
  • member icon

Reputation: 172
  • View blog
  • Posts: 1,114
  • Joined: 03-April 12

Re: Basic ASM Question

Posted 10 October 2016 - 09:44 AM

Never come across this simulator before, but:
The 'Rep'-loop looks fine.
Then you get the beginning of VDU in CL and the first stored character in DL.

In the 'Rep01'-loop you put the character in DL onto the VDU.
Then you increment the BL (Why? You don't use it.), VDU location and the CHARACTER in DL and check if you've done the whole VDU. If not, you loop the next round.

You don't fetch another of your saved characters.
Instead of incrementing DL you should fetch another character into DL.

This post has been edited by turboscrew: 10 October 2016 - 09:45 AM

Was This Post Helpful? 1
  • +
  • -

#3 ChrisHex1   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 10-October 16

Re: Basic ASM Question

Posted 10 October 2016 - 10:47 AM

View Postturboscrew, on 10 October 2016 - 09:44 AM, said:

Never come across this simulator before, but:
The 'Rep'-loop looks fine.
Then you get the beginning of VDU in CL and the first stored character in DL.

In the 'Rep01'-loop you put the character in DL onto the VDU.
Then you increment the BL (Why? You don't use it.), VDU location and the CHARACTER in DL and check if you've done the whole VDU. If not, you loop the next round.

You don't fetch another of your saved characters.
Instead of incrementing DL you should fetch another character into DL.


Thank you for the reply!
I don't mean to be a pain in the butt, but I still can't seem to get it.
I made a few changes, such as removing the Rep01 INC of BL, and attempting to move a new character into the VDU, but heres what I get as an example:

Lets say I enter "Chris" into the program. I hit enter, and all it says is "C C C C C C C C C C C C...". I feel as if I am getting hung up on something rather obvious.
Was This Post Helpful? 0
  • +
  • -

#4 turboscrew   User is offline

  • D.I.C Lover
  • member icon

Reputation: 172
  • View blog
  • Posts: 1,114
  • Joined: 03-April 12

Re: Basic ASM Question

Posted 10 October 2016 - 01:16 PM

Did you increment the stored character location pointer?

Something like:

   ...
         MOV CL, C0      ; start of VDU
         MOV AL, A0      ; stored character pointer to AL

Rep01:   MOV DL, [AL]    ; get stored character
         MOV [CL], DL    ; put on VDU
         INC CL          ; next char. on VDU
         INC AL          ; next stored character
         CMP CL, 00      ; end of VDU memory?
         JNZ Rep01       ; no, loop
         END


Was This Post Helpful? 1
  • +
  • -

#5 ChrisHex1   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 10-October 16

Re: Basic ASM Question

Posted 11 October 2016 - 04:40 AM

View Postturboscrew, on 10 October 2016 - 01:16 PM, said:

Did you increment the stored character location pointer?

Something like:

   ...
         MOV CL, C0      ; start of VDU
         MOV AL, A0      ; stored character pointer to AL

Rep01:   MOV DL, [AL]    ; get stored character
         MOV [CL], DL    ; put on VDU
         INC CL          ; next char. on VDU
         INC AL          ; next stored character
         CMP CL, 00      ; end of VDU memory?
         JNZ Rep01       ; no, loop
         END




Thank you so much for the help.
After doing what you mentioned (directly above) it works.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1