Author Topic: Please help me!!!!!  (Read 18151 times)

Offline 委座

  • Jr. Member
  • *
  • Posts: 3
Please help me!!!!!
« on: July 23, 2010, 07:19:40 AM »
   Hello everyone,I have just studied ASM for a 6 days.I want to write a procedure?it can show "welcome"in  screen.Everything is OK when I linked it,but it could show "welcome"in the screen.Please tell me why!!
    Here is the code:
assume cs:code,ds:data
    data segment
      db "w","e","l","c","o","m","e"
    data ends
   code segment
start:mov ax,data
      mov ds,ax
      mov ax,0b800h
      mov ss,ax
      mov sp,0080h
      mov bx,0
      mov cx,7
    s:mov al,[bx]
      mov ah,0cah
      pop ax
      inc bx
      loop s
      mov ax,4c00H
      int 21H
     code ends
   end start

 :( :( :( :( :(

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Please help me!!!!!
« Reply #1 on: July 23, 2010, 08:43:05 AM »
I'd be glad to help you out. Which way did you come in? :)

Seriously, dude, you may be in the wrong place. Nasm won't assemble your code, and whatever you assembled it with, I'm surprised to hear that it linked without complaint. It makes no sense! You load ax with "some values", and then "pop ax" - which overwrites it. You *might* get some output if you "push ax" instead of "pop ax", but it would be the weirdest way to get a message on screen I've ever seen!

I would suggest you put your video regeneration buffer segment (0B800h) in es, not ss, zero di, and use "stosw" to write the character and attribute to the screen.

Whatever you've been using for a "study guide" the last six days, it does not appear to be for Nasm. And, to be honest, it doesn't seem to be helping you much.

Here's how I'd do something similar - not the same! - in Nasm... if I were still running dos:

Code: [Select]
;---------------------------------
; nasm -f bin -o hwnoint.com hwnoint.asm

org 100h

    push word 0B800h    ; segment of video memory
    pop es              ; (because stosw uses es:di)
    mov di, (10 * 80 + 30) * 2  ; offset into screen
        ; (row * width + column) * 2 bytes/character
    mov si, msg         ; offset of our string
    mov ah, 0B0h        ; color (blinking black on cyan)
top:
    lodsb               ; get byte from [ds:si] into al
                        ; and increment si for next one
    or al, al           ; this doesn't change al, but sets
    jz depart           ; the flags - if zero, we're done
    stosw               ; stores ax (char & color) to [es:si]
                        ; and add 2 to di for next one
    jmp short top       ; do more
depart:
    ret                 ; return to dos (or other caller)

msg db " Look, Ma! No ints! ",0  ; note 0, not '$', terminated
                                                  ; '$' is just for int 21h/9
;------------------------------------

Whatever you used to assemble your code, it probably won't assemble this, so it may not help you any... Good luck!

Best,
Frank





Offline c051n3

  • Jr. Member
  • *
  • Posts: 22
Re: Please help me!!!!!
« Reply #2 on: July 23, 2010, 01:57:30 PM »
It looks like dos masm code to me. He is apparently "trying" to write directly to the screen buffer. Frank's code should assemble and at the very least should show you how to do it properly.

This made me look at my old video routines libray and it brought back thoughts of xmode, snow protection, syncing, and all that fun stuff  ;)

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Please help me!!!!!
« Reply #3 on: July 23, 2010, 06:14:22 PM »
Ah, yes - "chained" vs "unchained" modes. Bank switching. Ah, those were the days! :)

Yeah, looks like Masm/Tasm code. I'll bet Japheth's "Jwasm" will do it, if he wants an open-source assembler:

http://www.japheth.de

Or... quite easy to "translate" that code to Nasm. Mostly deleting things Nasm doesn't need, and swap "code segment" to "segment code"...

I was thinking "maybe if he pushes ax", but... in Real Mode, hardware interrupts use "our" stack. While writing "direct to screen" is much faster than using dos/bios interrupts, reading from that area is quite slow. Probably best for a beginner not to touch ss at all...

He'll get it... or not...

Best,
Frank